After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 525576 - URL in contact's status are not clickable
URL in contact's status are not clickable
Status: RESOLVED FIXED
Product: empathy
Classification: Core
Component: Contact List
unspecified
Other Linux
: Normal normal
: ---
Assigned To: empathy-maint
Depends on: 599640
Blocks:
 
 
Reported: 2008-04-01 16:15 UTC by Guillaume Desmottes
Modified: 2010-03-08 14:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
url_in_label.patch (4.32 KB, patch)
2009-07-20 11:24 UTC, Nicolò Chieffo
none Details | Review
url_in_label commit (4.42 KB, patch)
2009-07-20 11:39 UTC, Nicolò Chieffo
none Details | Review
url_in_label commit 2 (5.78 KB, patch)
2009-07-20 12:12 UTC, Nicolò Chieffo
none Details | Review
url_in_label.patch (5.45 KB, patch)
2009-07-20 12:28 UTC, Nicolò Chieffo
none Details | Review
url_in_label.patch (4.15 KB, patch)
2009-07-20 12:30 UTC, Nicolò Chieffo
none Details | Review
url_in_label.patch (10.11 KB, patch)
2009-07-21 21:49 UTC, Nicolò Chieffo
none Details | Review
url_in_label.patch (10.60 KB, patch)
2009-07-22 08:38 UTC, Nicolò Chieffo
none Details | Review
url_in_label.patch (9.84 KB, patch)
2009-07-22 09:16 UTC, Nicolò Chieffo
none Details | Review
bump_gtk_2_18.patch (342 bytes, patch)
2009-09-23 22:08 UTC, Nicolò Chieffo
none Details | Review
url.patch (10.10 KB, patch)
2009-09-25 13:10 UTC, Nicolò Chieffo
none Details | Review
new patch (8.12 KB, patch)
2009-10-26 17:16 UTC, Nicolò Chieffo
rejected Details | Review
backtrace (21.02 KB, text/plain)
2009-10-26 18:54 UTC, Nicolò Chieffo
  Details
diff (22.64 KB, patch)
2010-03-03 15:35 UTC, Guillaume Desmottes
reviewed Details | Review

Description Guillaume Desmottes 2008-04-01 16:15:13 UTC
Often some of my contacts put an URL in their status message. These URL are not clickable in the "contact info dialog" so I have to manually copy/paste it to be able to visit the web page. These URL's should be clickable.
Comment 1 Guillaume Desmottes 2008-04-10 09:44:57 UTC
This is not as trivial as I though. Maybe GTK+ could offer us more facilities to do that?
Comment 2 Nicolò Chieffo 2009-07-20 10:19:32 UTC
I have the code to add markup to a string. Do I have to attach it so you can use it?
Comment 3 Nicolò Chieffo 2009-07-20 10:54:04 UTC
I'm patching it now. it works with channel topics, I still need to find the label of contact information
Comment 4 Nicolò Chieffo 2009-07-20 11:16:15 UTC
No way, it works only for simple links, but if you have a "&" or another strange char it complains that you have to escape it.
Unfortunately if I escape it, also the :// are escaped, so I need a smarter way to append markup.
Help appreciated
Comment 5 Nicolò Chieffo 2009-07-20 11:24:47 UTC
Created attachment 138803 [details] [review]
url_in_label.patch

this is the patch. I don't know if I can do better, I don't know well how link handling works in GtkLabel. for instance this does not work with youtube videos
Comment 6 Nicolò Chieffo 2009-07-20 11:39:19 UTC
Created attachment 138809 [details] [review]
url_in_label commit

I think I managed to do this! (I borrowed the XML function g_markup_escape_text).
Please check this
Comment 7 Nicolò Chieffo 2009-07-20 12:12:55 UTC
Created attachment 138810 [details] [review]
url_in_label commit 2

there was an indentation problem, sorry
Comment 8 Jonny Lamb 2009-07-20 12:24:09 UTC
You should squash the two patches together.
Comment 9 Nicolò Chieffo 2009-07-20 12:28:07 UTC
Created attachment 138812 [details] [review]
url_in_label.patch

single patch (but no commitdiff).
I added other checks
Comment 10 Nicolò Chieffo 2009-07-20 12:30:42 UTC
Created attachment 138814 [details] [review]
url_in_label.patch

that was git diff --color, sorry
Comment 11 Frederic Peters 2009-07-20 12:31:42 UTC
I quickly tested the patch and at first it didn't recognize the URL (it was
between parenthesis), I think it should probably use the same regex as for
detecting URLs in chat views (see empathy-ui-utils.c,
empathy_uri_regex_dup_singleton).

Also it's not useful to have the URL clickable in the contact tooltip, as it's
not possible to click on it.

And last, it didn't make the URL clickable in the contact list (but that is
certainly harder and it was not requested in this bug report).
Comment 12 Nicolò Chieffo 2009-07-20 12:39:08 UTC
thanks for pointing out the url regex (I need to learn how to use it)

the contact tooltip uses the same label as the one shown in the contact information dialog, that's why it is shows as a link.

I'll have a look and if I can find where is the status label in the contact list I will try to expand the patch
Comment 13 Frederic Peters 2009-07-21 13:46:36 UTC
Nicolò, I experienced a segfault today, while running with your patch applied; this is because empathy_add_markup() got called with a NULL parameter, probably because empathy_contact_get_status() returned that.  (it was in the context of a subscription request).

To know if you are creating a widget for the tooltip, you can check against (information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP).
Comment 14 Nicolò Chieffo 2009-07-21 18:33:42 UTC
I've got the correct patch now, but I will attach it as soon as I manage to see if the label in the contact list can be markupped too

Is it really a problem if the label in the tooltip has a link inside?
Comment 15 Nicolò Chieffo 2009-07-21 21:49:38 UTC
Created attachment 138945 [details] [review]
url_in_label.patch

This works for me.
It does not add the feature directly in the contact list yet, because I don't know how to work wit GtkTreeView. Sorry
Comment 16 Nicolò Chieffo 2009-07-22 08:38:38 UTC
Created attachment 138971 [details] [review]
url_in_label.patch

I removed the link in the tooltip using the suggested condition.
Comment 17 Nicolò Chieffo 2009-07-22 09:06:36 UTC
I'm stupid, I mixed up 2 branches, sorry...
There are some lines belonging to another branch
Comment 18 Nicolò Chieffo 2009-07-22 09:16:05 UTC
Created attachment 138973 [details] [review]
url_in_label.patch

this should be ok
Comment 19 Nicolò Chieffo 2009-07-27 09:41:46 UTC
Can someone review it?
Comment 20 Xavier Claessens 2009-07-30 12:56:48 UTC
GTK 2.18 is required for this markup. I think it's better to wait for Empathy 2.29 to commit this patch, or at least GTK 2.18 stable release.
Comment 21 Nicolò Chieffo 2009-07-30 13:03:42 UTC
Yes, you are right, I forgot to say it, sorry.
Let's not forget about this bug.
Comment 22 Frederic Peters 2009-07-30 13:26:14 UTC
FWIW GNOME 2.28 is planned to go out with GTK+ 2.18, and it is perfectly okay for the release team to depend on unstable GTK+ 2.17.

Perhaps you could check for the GTK+ version and only call gtk_label_set_markup when available?
Comment 23 Will Thompson 2009-08-03 09:56:22 UTC
(In reply to comment #11)
> And last, it didn't make the URL clickable in the contact list (but that is
> certainly harder and it was not requested in this bug report).

...and is a terrible idea. I'd be incredibly annoyed if I single-clicked the contact list to foreground it and a browser popped up in my face, just as I am when I single-click the contact list and a call window pops up in my face.
Comment 24 Jonny Lamb 2009-08-03 10:41:40 UTC
(In reply to comment #23)
> ...and is a terrible idea. I'd be incredibly annoyed if I single-clicked the
> contact list to foreground it and a browser popped up in my face, just as I am
> when I single-click the contact list and a call window pops up in my face.

For the record, I also think more items to click on in the contact list is a terribly poor idea.
Comment 25 Nicolò Chieffo 2009-09-23 19:17:08 UTC
hi again, not gtk 2.18 has been released, so you can push this patch to git
Comment 26 Xavier Claessens 2009-09-23 19:56:55 UTC
indeed. my first comment is that the path should bump required version of gtk.
Comment 27 Nicolò Chieffo 2009-09-23 22:08:40 UTC
Created attachment 143846 [details] [review]
bump_gtk_2_18.patch
Comment 28 Nicolò Chieffo 2009-09-23 22:08:57 UTC
Is this enough? (I'm not expert)
Comment 29 Xavier Claessens 2009-09-24 07:02:37 UTC
Seems pretty good. Some comments:

 - Coding style, blocks are indented like that:

if (foo)
  {
    baaaaaaaaar (looooon thing more than 80char,
        arg2);
  }
else
  {
    bar ();
  }

Note that it is only for files tha are already in that coding style. Some are still using imendio coding style which is indented using 1 tab.

 - empathy_replace_with_br() is static, we usually name private function without the empathy_ prefix. Should be theme_adium_replace_with_br() to be consistent. Same for empathy_add_smiley_markup().

 - An optimisation I made in theme_adium_parse_body() is to not dup the string if there is no URL match or smiley is not used or there is no '\n'. I think empathy_add_*_markup() and empathy_replace_with_br() should return NULL if the string is unchanged.

 - Please add gtkdoc for empathy_add_link_markup(). I know most functions don't have doc, but we are trying to add that sloooowly :)

The rest looks fine to me. Thanks!
Comment 30 Nicolò Chieffo 2009-09-25 09:19:05 UTC
- coding style: in the example I can't understand if I have to use tabs or not, and I didn't understand the amounts of tabs I have to use. Since in my previous patch I used to put the wrapped argument exactly below the '( ' I now put it before, to respect the 80 char wrap. (also because it depends on the amount of spaces in which the editor expands the tab).

- I renamed those 2 static functions.

- the now theme_adium_add_smiley_markup always dups the string during the parse of images. I have no time to rethink the logic (also because it was not written by me). Anyway I prepared the logic when using the function as if it could return NULL, so the only thing you have to do is fix the function body itself.

- simple gtkdoc done

*NOT TESTED IT YET, SO NOT ATTACHING IT*
Comment 31 Nicolò Chieffo 2009-09-25 13:10:02 UTC
Created attachment 143987 [details] [review]
url.patch

this patch has a nasty infinite loop bug when someone puts links starting with '('

I don't know how to debug this, can you help?
Comment 32 Sumana Harihareswara 2009-10-24 23:36:14 UTC
URLs in a contact's status are still not clickable in 2.27.92 (I've tested) so I'd like to up the version number on this bug.
Comment 33 Xavier Claessens 2009-10-25 12:12:13 UTC
This won't be fixed in 2.28.x, it is for 2.29
Comment 34 Nicolò Chieffo 2009-10-26 11:03:39 UTC
Also as long as the patch has problems, it won't be committed...
Comment 35 Nicolò Chieffo 2009-10-26 17:03:12 UTC
I'm now working for a new patch. I hope I'll be able to fix this!
Comment 36 Nicolò Chieffo 2009-10-26 17:16:49 UTC
Created attachment 146278 [details] [review]
new patch

This patch works better, and also lets having both an URL and a SMILEY on the same text.

Unfortunately there seems to be a bug in the gtk function I'm trying to use:
gtk_label_set_markup (label, markup_text);

everything works if markup text is for example
<a href="www.gnome.org>www.gnome.org</a>

but if I add ( and ) around, the GUI locks and the cpu starts to spin up.
The problem is not in my code, I'm sure because it works correctly in adium themes.

can you tell me how can I execute gdb to debug this problem?
Comment 37 Xavier Claessens 2009-10-26 17:20:01 UTC
Note that I made a branch that fix parsing of string in adium:

http://git.collabora.co.uk/?p=user/xclaesse/empathy.git;a=shortlog;h=refs/heads/escape

I think you should rebase your patch on top of that. Hopefully that will get into master soon. See bug #599640
Comment 38 Nicolò Chieffo 2009-10-26 17:26:59 UTC
Ok, but I'll do it when you commit to master, so I don't have to rebase my patch lots of times.
Please tell me when!
Comment 39 Nicolò Chieffo 2009-10-26 18:54:08 UTC
Created attachment 146286 [details]
backtrace

I caught the backtrace hitting ctrl-c after having attacheced gdb.

do you understad where is the infinite loop?
Comment 40 Guillaume Desmottes 2009-10-27 10:49:37 UTC
As Xavier said, let's fix bug #599640 first.
Comment 41 Guillaume Desmottes 2009-11-18 18:01:01 UTC
Review of attachment 146278 [details] [review]:

Reject the patch for now
Comment 42 Xavier Claessens 2010-03-03 15:20:35 UTC
I made a branch using new API:

http://git.collabora.co.uk/?p=user/xclaesse/empathy.git;a=shortlog;h=refs/heads/clickable-link
Comment 43 Guillaume Desmottes 2010-03-03 15:35:25 UTC
Created attachment 155143 [details] [review]
diff

Attaching diff for easier review
Comment 44 Guillaume Desmottes 2010-03-03 15:52:20 UTC
Review of attachment 155143 [details] [review]:

Looks pretty good to me. Only few details:

::: libempathy-gtk/empathy-contact-widget.c
@@ +953,3 @@
+
+  status = empathy_contact_get_status (information->contact);
+  if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))

What happen if you display the link in tooltips as well? They won't be clickable but maybe it's worth doing it if only to easily spot the URL.

::: libempathy-gtk/empathy-string-parser.c
@@ +193,3 @@
+
+gchar *
+empathy_add_link_markup (const gchar *text)

Please add a small comment documenting this function.

@@ +195,3 @@
+empathy_add_link_markup (const gchar *text)
+{
+	static EmpathyStringParser parsers[] = {

Why having it static?
Comment 45 Xavier Claessens 2010-03-04 15:38:46 UTC
Fixed and pushed. Thanks :)
Comment 46 Xavier Claessens 2010-03-08 12:21:09 UTC
reopening, this is causing a serious regression. That's a GTK issue, see bug #612066.

I reverted the changes until it gets fixed in GTK.
Comment 47 Xavier Claessens 2010-03-08 12:21:54 UTC
Note: To re-enable, simply revert the revert commit efb42513359f4db545e3312e3c583d07c6306418 :D
Comment 48 Xavier Claessens 2010-03-08 14:04:20 UTC
Set this bug back to resolved, Guillaume opened a new bug to enable clickable links once GTK bug is fixed: bug #612185