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 522069 - Improve message styles with themes/plugins (ala Adium)
Improve message styles with themes/plugins (ala Adium)
Status: RESOLVED FIXED
Product: empathy
Classification: Core
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: empathy-maint
empathy-maint
: 522594 553489 (view as bug list)
Depends on:
Blocks: 513176 549909 579151
 
 
Reported: 2008-03-12 17:51 UTC by Xavier Claessens
Modified: 2009-06-11 18:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
EmpathyChatView as GInterface (87.01 KB, patch)
2008-04-19 16:27 UTC, Juan Pizarro
needs-work Details | Review
Proposed fix to current branch (646 bytes, patch)
2008-11-05 15:51 UTC, Pierre-Luc Beaudoin
reviewed Details | Review
Configuration dialog for Pidgin WebKit plugin (50.80 KB, image/png)
2008-11-21 21:32 UTC, Luca Ferretti
  Details

Description Xavier Claessens 2008-03-12 17:51:35 UTC
It would be cool to more complex themes with plugins.

Currently empathy uses the EmpathyChatView widget which inherit from GtkTextView. EmpathyChatView uses EmpathyTheme object to draw messages on itself. EmpathyTheme can be subclassed to implement some functions like append_message so we can create new themes by implementing new subclasses of EmpathyTheme, that could be done in plugins.

I would like to improve that design to make possible to have themes using webkit! The problem is that webkit provides a GtkWebkitView widget so it can't be used with a GtkTextView widget like EmpathyChatView. So my idea is to change EmpathyChatView to be a GInterface, so the needed API won't be implemented directly. EmpathyChatView could then be implemented in two ways: with a class inheriting from GtkTextView and using EmpathyTheme, or with a class inheriting from GtkWebkitView and using CSS based themes.
Comment 1 Achim Frase 2008-03-19 13:25:01 UTC
Maybe this blog post is from interest.

http://www.pidgin.im/~seanegan/cgi-bin/pyblosxom.cgi/htmlwidget.html

The last part of the Post is about webkit and adium message style.

best wishes
Achim
Comment 2 Frederic Peters 2008-04-13 18:15:14 UTC
*** Bug 522594 has been marked as a duplicate of this bug. ***
Comment 3 Frederic Peters 2008-04-13 18:17:01 UTC
I am removing 522594 as a blocked bug since both have been merged.
Comment 4 Frederic Peters 2008-04-13 18:17:44 UTC
I started writing about Adium and how Empathy should be extended in the GNOME wiki, see http://live.gnome.org/Empathy/AdiumThemes
Comment 5 Juan Pizarro 2008-04-18 22:55:46 UTC
I started with this idea, and its works very nice.

I think, there are functionality for all themes, for example empathy_chat_view_get_smiley_menu, empathy_chat_view_set_last_contact, empathy_chat_view_get_last_contact, etc.

I think, this functionality is good to implemented in EmpathyChatView, and not in the inheriting classes.

Comment 6 Xavier Claessens 2008-04-19 07:41:13 UTC
I agree, the API of EmpathyChatView need some cleaning.

empathy_chat_view_get_smiley_menu has nothing to do there, it doesn't use the object, should probably be moved to EmpathyChat.

_get_last_contact() is used only in EmpathyThemeBoxed so it should be moved to that future implementation of the future interface.
Comment 7 Juan Pizarro 2008-04-19 16:27:42 UTC
Created attachment 109548 [details] [review]
EmpathyChatView as GInterface

I add next line in empathy-chat-view.h to avoid causing problems on the rest of empathy code.

#define empathy_chat_view_new(o) EMPATHY_CHAT_VIEW(empathy_chat_simple_view_new(o))

#include "empathy-chat-simple-view.h"
Comment 8 Xavier Claessens 2008-04-19 16:59:07 UTC
Seems a good start, didn't looked in details at the patch yet. I see the patch is generated using git, could you push your branch on a public repository please? It's easier to track changes :)
Comment 9 Juan Pizarro 2008-04-19 21:51:36 UTC
(In reply to comment #8)
> Seems a good start, didn't looked in details at the patch yet. I see the patch
> is generated using git, could you push your branch on a public repository
> please? It's easier to track changes :)
> 
The repository is http://icc.utalca.cl/~jpizarro/empathy, and the branch is bug522069
Comment 10 Guillaume Desmottes 2008-04-22 07:26:43 UTC
We have a student who'll work on this as a SoC project.

For information, seems Psi as a similar project too http://code.google.com/soc/2008/xmpp/appinfo.html?csaid=2E3332B677411001
Comment 11 Xavier Claessens 2008-07-08 10:59:46 UTC
The SoC student stopped for personal reasons. I continued Juan's branch, you can see the code in my 'adium' branch: http://git.collabora.co.uk/?p=user/xclaesse/empathy.git;a=shortlog;h=refs/heads/adium
Comment 12 Xavier Claessens 2008-07-16 14:58:12 UTC
I did most of the work myself at guadec. I got it mostly working! Code can be found in my 'adium' branch: http://git.collabora.co.uk/?p=user/xclaesse/empathy.git;a=shortlog;h=refs/heads/adium

Juan: Thanks for your patch, I included it in my branch and added looots of refactoring.

http://people.collabora.co.uk/~xclaesse/empathy-webkit.png
Comment 13 Achim Frase 2008-07-16 16:26:27 UTC
At first I would like to thank every contributor for this great work.

I hop this is the right place to ask.

As this was a GSOC Project, the Roadmap (http://live.gnome.org/Empathy/Roadmap) says that the webkit theme will be included not until the 2.26 release.

To my mind that is a bit late, as it seems this work has progressed very well.

I would like to know if this great feature will make it into the 2.24 release?

Regards
Achim
Comment 14 Xavier Claessens 2008-07-16 16:54:17 UTC
I don't know... it depends if I have time to clean everything and make it more solid. Things that still need to be done:
 - Smiley and URL in the message.
 - Support other themes than the one I tested. Seems each theme as some little different ways to do the magic.
 - Add a UI to select/install adium themes.
 - Change the CSS of the theme on-the-fly.
 - Fallback when the contact has no avatar.
 - Fallback when some optional parts of the theme are not present.
 - Implement all functionalities required by the EmpathyChatView interface. Currently only the append_message is implemented.

So as you see I'm on the stage where I can do some screenshots but it's not really usable yet.
Comment 15 Achim Frase 2008-07-16 17:02:39 UTC
okay, thanks for your quick reply.
Comment 16 Juan Pizarro 2008-07-16 23:27:10 UTC
I have implemented the Smiley and URL in the message part.

The code is in:
http://icc.utalca.cl/cgi-bin/gitweb.cgi?p=git/empathy.git;a=shortlog;h=refs/heads/webkit

Comment 18 Xavier Claessens 2008-07-17 06:53:40 UTC
Ah, I didn't see that you continued the work on you branch, sorry. I'll check if I can import some stuff from you.
Comment 19 Xavier Claessens 2008-07-19 11:21:40 UTC
Some updated:
 - Smiley and URL now work correctly.
 - A default Template.html is now provided and the correct fallbacks are done so all themes I tested work.
 - The preference dialog can select an adium theme to use.
 - When the contact has no avatar it fallback to stock_person image. It make webkit crash, see https://bugs.webkit.org/show_bug.cgi?id=19370.

What still need to be done:
 - Implement all functions from EmpathyChatView interface.
 - Select a variant CSS style.
 - Implementations of EmpathyChatView should not be part of the API/ABI of libempathy-gtk otherwise ABI change if we enable/disable webkit support.

Not directly related to adium, but it's part of the refactoring in the adium branch: EmpathyThemeManager should not set tags on EmpathyThemeIrc and EmpathyThemeBoxes itself but those objects should have properties and setting those properties should change tags.
Comment 20 Xavier Claessens 2008-09-24 07:00:17 UTC
*** Bug 553489 has been marked as a duplicate of this bug. ***
Comment 21 Xavier Claessens 2008-11-03 21:05:48 UTC
I updated the adium branch.
 - All functions of EmpathyChatView are implemented by EmpathyThemeAdium now.
 - The webkit's context menu is now removed and a custom one is made.
 - Variant CSS style is let for future improvement, not required to merge the branch.
 - We still need a way to not have empathy_theme_adium_* in ABI.
 - The branch needs a review.
Comment 22 Pierre-Luc Beaudoin 2008-11-05 14:56:20 UTC
Ok I am running the new adium branch now.  It it nice to see that is has matured since July :)

There are still some quirks, here is my findings:
 - The clear option on the context menu should not be the first in the list.  When I select text and right click on it, copy should be the first option (as in GtkEntry). 
 - When you start a new conversation with a person, the history is brought up in the window (as expected) but there is no marker to differentiate old and new text.  Something is needed here.
 - Some basic themes doesn't work.  For instance Modern should work (as it doesn't have styles).  By debugging, I found that WebKit is expecting an absolute path to a file name as the last parameter of webkit_web_view_load_html_string.  But adding a extra / at the end of the path works also fine (patch to be attached).

Otherwize, the current way to select the themes is rudimentary and should be improve before a big public release.  Something along http://bugzilla.gnome.org/show_bug.cgi?id=541438 which automatically detects themes in /usr/share/adium/themes and .adium ... (such a path should be standardized amoung all adium theme consumers).
Comment 23 Pierre-Luc Beaudoin 2008-11-05 15:51:56 UTC
Created attachment 122031 [details] [review]
Proposed fix to current branch

Here is the subtile change to the basedir.  There are many ways to produce the same path, but I think this one is the lightess at run time.
Comment 24 Xavier Claessens 2008-11-06 09:24:06 UTC
Thanks, I included the patch in my branch.(In reply to comment #22)

>  - The clear option on the context menu should not be the first in the list. 
> When I select text and right click on it, copy should be the first option (as
> in GtkEntry). 

It is the same for normal themes. You could open another bug for this.

>  - When you start a new conversation with a person, the history is brought up
> in the window (as expected) but there is no marker to differentiate old and new
> text.  Something is needed here.

Same than above.

>  - Some basic themes doesn't work.  For instance Modern should work (as it
> doesn't have styles).  By debugging, I found that WebKit is expecting an
> absolute path to a file name as the last parameter of
> webkit_web_view_load_html_string.  But adding a extra / at the end of the path
> works also fine (patch to be attached).

Thanks, I included the patch in my branch.

> Otherwize, the current way to select the themes is rudimentary and should be
> improve before a big public release.  Something along
> http://bugzilla.gnome.org/show_bug.cgi?id=541438 which automatically detects
> themes in /usr/share/adium/themes and .adium ... (such a path should be
> standardized amoung all adium theme consumers).

We can improve this later, it does not block the merging of the branch.

Comment 25 Pierre-Luc Beaudoin 2008-11-11 15:30:47 UTC
Also: when you use /me with Adium themes messages show up in a funny way...

/me slaps Xavier 
produces
slaps Xavier

I think it'd be better if the username was inserted before.  Adium themes don't support such action messages so that would be a nice workaround.
Comment 26 Pierre-Luc Beaudoin 2008-11-19 05:28:02 UTC
I did more reviewing tonigh:

+»·······/* FIXME: Does webkit provide an API for that? We have wrap=true in
+»······· * find_next and find_previous to work around this problem. */
You can remove that, there is no API to get the find abilities, and it should always be able to go forward or previous.

That's the only thing I have to said about the code.  

If you correct the "ugly" /me, it should be fine to merge.  Most of the changes are code being moved... 

I've been using the branch since you published it and I didn't experience any issues with it (appart for themes with variants which don't load properly).  That can be fixed afterwards.
Comment 27 Luca Ferretti 2008-11-21 21:26:43 UTC
Just as reference, here[1] is a Pidgin pluging to use WebKit.

[1]https://launchpad.net/pidgin-webkit
Comment 28 Luca Ferretti 2008-11-21 21:32:30 UTC
Created attachment 123197 [details]
Configuration dialog for Pidgin WebKit plugin

pidgin-webkit is able to manage variants. Here is the dialog to configure it.

Adium themes are stored in $HOME/.purple/message_styles/

Maybe could be good use a common location for both programs.
Comment 29 Pierre-Luc Beaudoin 2008-11-21 21:48:27 UTC
I have a better Adium Theme Browser for Empathy here: http://git.collabora.co.uk/?p=user/pierlux/empathy.git;a=shortlog;h=refs/heads/pierlux-adium-theme-browser

It builds upon the Adium branch.  It doesn't deal with variants yet, but that could be added later. 

Luca I totally agree all IM clients supporting Adium themes should standardize on a path.  I vote /usr/share/adium/styles/ and ~/.adium/styles
Comment 30 Achim Frase 2008-11-21 21:58:07 UTC
I thought nowadays the configurations are stored in $HOME/.config.

http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html

I vote for ~/.config/adium/styles.

Regards
Achim
Comment 31 Xavier Claessens 2008-11-25 09:32:42 UTC
Adium themes are not configs, they are data. So I vote for $XDG_DATA_DIRS/adium/styles so it will be in ~/.local/share, /usr/share, etc...
Comment 32 Cosimo Cecchi 2008-12-12 14:22:44 UTC
WRT the chat-refactor branch by Xavier, that mostly looks right to me, but I have some minor comments:

- theme_boxes_get_avatar_pixbuf_with_cache () maybe should belong to empathy-ui-utils.c and be public, otherwise no other clients can use the cache feature.

- don't use g_return_val_if_fail (tag != NULL, NULL) in empathy_chat_text_view_tag_set (), as that would make empathy exit is G_DEBUG="fatal_warnings" or "fatal_critical", which I don't think it's the case if the tag doesn't exist.

- theme_irc_finalize () does nothing more than the calling the parent class finalize, so should be removed

- in empathy-text-chat-view.c, the LAST_CONTACT property and the _get_last_contact () function are not coherent; the property increases the refcount of the object, while the function doesn't. You should make the function return g_object_ref (priv->last_contact).

- in empathy-chat-window.c, you don't seem to unref the EmpathySmileyManager you get.
Comment 33 Xavier Claessens 2008-12-12 15:46:21 UTC
(In reply to comment #32)
> - theme_boxes_get_avatar_pixbuf_with_cache () maybe should belong to
> empathy-ui-utils.c and be public, otherwise no other clients can use the cache
> feature.

So far that function is only used for EmpathyThemeBoxes. We can still make that function public if needed somewhere else. It is better to add later than realise that the API is wrong and then change public API.

> - don't use g_return_val_if_fail (tag != NULL, NULL) in
> empathy_chat_text_view_tag_set (), as that would make empathy exit is
> G_DEBUG="fatal_warnings" or "fatal_critical", which I don't think it's the case
> if the tag doesn't exist.

Right, I can just return in that case. Fixed.

> - theme_irc_finalize () does nothing more than the calling the parent class
> finalize, so should be removed

Fixed.

> - in empathy-text-chat-view.c, the LAST_CONTACT property and the
> _get_last_contact () function are not coherent; the property increases the
> refcount of the object, while the function doesn't. You should make the
> function return g_object_ref (priv->last_contact).

This is intentional. property getters like empathy_foo_get_bar() never return a new ref (same for strings, it does not dup). If I need a getter that returns a new ref I call if empathy_foo_dup_bar(), or simply call g_object_get (foo, "bar");

telepathy-glib follow the same rule, so it is consistent.

> - in empathy-chat-window.c, you don't seem to unref the EmpathySmileyManager
> you get.

right, fixed.

Comment 34 Luca Ferretti 2008-12-12 16:12:52 UTC
Xavier, just a question. Is the "adium" or the "chat-refactor" branch the one to follow?
Comment 35 Xavier Claessens 2008-12-12 16:19:48 UTC
Luca: I have split the adium branch in 2 branches: First there is chat-refactor that make a big refactor of the code to make possible to add themes ala adium. Adium branch is based on that chat-refactor branch and add the actual adium/webkit code.

We are now reviewing chat-refactor branch so it can hopefully be merged soon. After that the adium/webkit code will be reviewed.
Comment 36 Xavier Claessens 2008-12-12 17:31:55 UTC
Found a bug in the adium branch: When clicking on a link like "www.foo.com" webkit magically prepend the basedir because it is not an absolute path. We should prepend http:// ourself in that case.

I write it here so I don't forget to fix that.
Comment 37 Cosimo Cecchi 2008-12-13 15:12:45 UTC
(In reply to comment #33)
> (In reply to comment #32)
> > - theme_boxes_get_avatar_pixbuf_with_cache () maybe should belong to
> > empathy-ui-utils.c and be public, otherwise no other clients can use the cache
> > feature.
> 
> So far that function is only used for EmpathyThemeBoxes. We can still make that
> function public if needed somewhere else. It is better to add later than
> realise that the API is wrong and then change public API.

Ok, this makes sense. I think the branch is ready to be merged then.
Comment 38 Xavier Claessens 2008-12-16 09:38:59 UTC
Great! chat-refactor has been merged and will be part of Empathy 2.25.3 :D
Comment 39 Peter Janak 2009-02-19 16:20:27 UTC
How is working coming along for the adium branch? I see nothing has been done in the past few months. I am really excited to see this flourish.
Comment 40 Peter Janak 2009-02-19 16:27:40 UTC
Oh, there is also something I noticed. The %service% tag isn't acted upon. For instance, in the theme I'm using, the %service% tag is used to display the service type for the message (AIM, JABBER, et cetera). With this branch, just %service% shows up.
Comment 41 Xavier Claessens 2009-02-20 11:19:04 UTC
The adium branch does not apply on master anymore, I'll have to rebase it and resolve conflicts. This is for GNOME 2.27 because we are already in UI freeze anyway...

If you want to contribute feel free to open your own branch, help is welcome, especially from someone who know how adium themes are supposed to work. Atm my code is only guesses from what I've seen in most themes I tested.

Of course a list of themes that does not work is something we need to debug the code! Or is there a full documentation of the theme format?
Comment 42 Peter Janak 2009-02-20 13:51:54 UTC
I was indeed thinking about diving in and contributing to the branch. I'll start looking at the full API for Empathy probably towards the end of next week (finals for Uni, hooray!). As for a documentation on the themes, I'm not sure. I can certainly check that out. Please let us know when you've completed the rebase, as I know I would love to see theme support with all the features for 2.26.
Comment 43 Peter Janak 2009-02-20 14:08:19 UTC
Here is the closest thing I managed to find for a theme "API". It lists all the valid keywords the the themes can use and which files they can be found in, as well as basic structure like things:

http://trac.adiumx.com/wiki/CreatingMessageStyles
Comment 44 Guillaume Desmottes 2009-05-05 22:05:16 UTC
Xavier is http://git.collabora.co.uk/?p=user/xclaesse/empathy.git;a=shortlog;h=refs/heads/adium now up to date and ready for review?
Comment 45 Xavier Claessens 2009-05-09 21:21:24 UTC
I rebased it on master, it should be ready for review.
Comment 46 Guillaume Desmottes 2009-05-25 13:07:36 UTC
Empathy master now prints a configure report. Please upgrade it according the new optionnal dep(s).
Comment 47 Xavier Claessens 2009-06-11 18:55:50 UTC
Voilà! I merged the adium branch in master, it will be available with Empathy 2.27.3.

There are still work to be done, but that's a good start.

For more information, please check http://live.gnome.org/Empathy/Themes