GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

showing urls in text view

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
cnu_sree
GTK+ Geek


Joined: 06 Oct 2006
Posts: 57

PostPosted: Mon Nov 20, 2006 7:03 am    Post subject: showing urls in text view Reply with quote

actually my program is related to im
in that if we enter text on one text view and press enter then the data will be added on another text view.
if enter a url address in text view.
then it wills show like a text link in the textview
how we can get the click event for that
how it is possible
thank u in advance
sree
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 387
Location: Fairfax, Virginia

PostPosted: Mon Nov 20, 2006 4:54 pm    Post subject: Reply with quote

You will want to check out a piece of source from the GTK+ demo application at http://cvs.gnome.org/viewcvs/gtk%2B/demos/gtk-demo/hypertext.c?rev=1.6&view=markup
Back to top
cnu_sree
GTK+ Geek


Joined: 06 Oct 2006
Posts: 57

PostPosted: Tue Nov 21, 2006 5:18 am    Post subject: thank u Reply with quote

thank u very much
it is very useful to me
but a small problem is
when i move the cursor on to hypertext.the cursor will not changing to the hand symbol
that's y iam unable click there.
i found that iiam not using the below function properly

g_object_set_data (G_OBJECT (tag), "page", GINT_TO_POINTER (page));.
this is the line from the code ur given.
how can i handle thid line in my code.
my code is
void
on_button1_clicked (GtkButton *button,
gpointer user_data)
{

gtk_text_buffer_get_end_iter( buffer1, &end );
gtk_text_buffer_place_cursor (buffer1, &end);

GtkTextTag *tag;

tag = gtk_text_buffer_create_tag (buffer1, NULL,
"foreground", "blue",
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
g_object_set_data (G_OBJECT (tag), "page", GINT_TO_POINTER (page));
gtk_text_buffer_insert_with_tags (buffer1,&end, "www.google.com", -1, tag, NULL);

}
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 387
Location: Fairfax, Virginia

PostPosted: Tue Nov 21, 2006 3:51 pm    Post subject: Reply with quote

You need to check out the do_hypertext() function for changing the cursor. You have to create a new cursor with gdk_cursor_new(). Also, you're skipping a lot of steps it seems. I would recommend going through the whole demo and make sure you understand what is going on before you start coding yourself.

All the line you asked about is doing is converting an integer into a pointer so it can be stored on the object's data table. You see, every object can store pairs of strings and pointers. However, since an integer is not easily converted into a pointer, GLib provides a function for this. You can convert it back with GPOINTER_TO_INT().
Back to top
raj4u
Familiar Face


Joined: 11 Oct 2006
Posts: 10

PostPosted: Wed Nov 22, 2006 8:41 am    Post subject: Reply with quote

thank u its's working fine
but i ahve a small problem.
in my textview if i enter
sreewww.google.com http://google.com
how can i verify both www and http at a time
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 387
Location: Fairfax, Virginia

PostPosted: Wed Nov 22, 2006 9:55 pm    Post subject: Reply with quote

you're probably just going to want to search through the buffer for both patterns. Things like http://, https://, file://, etc should force a url and www should be an afterthought.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP