GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 30, 2014 10:22 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: showing urls in text view
PostPosted: Mon Nov 20, 2006 7:03 am 
Offline
GTK+ Geek

Joined: Fri Oct 06, 2006 6:37 am
Posts: 57
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 20, 2006 4:54 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
You will want to check out a piece of source from the GTK+ demo application at http://cvs.gnome.org/viewcvs/gtk%2B/dem ... iew=markup

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject: thank u
PostPosted: Tue Nov 21, 2006 5:18 am 
Offline
GTK+ Geek

Joined: Fri Oct 06, 2006 6:37 am
Posts: 57
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);

}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 21, 2006 3:51 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
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().

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 8:41 am 
Offline
Familiar Face

Joined: Wed Oct 11, 2006 9:49 am
Posts: 10
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 9:55 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
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.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group