GNOME Bugzilla – Bug 522069
Improve message styles with themes/plugins (ala Adium)
Last modified: 2009-06-11 18:56:06 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.
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
*** Bug 522594 has been marked as a duplicate of this bug. ***
I am removing 522594 as a blocked bug since both have been merged.
I started writing about Adium and how Empathy should be extended in the GNOME wiki, see http://live.gnome.org/Empathy/AdiumThemes
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.
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.
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"
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 :)
(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
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
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
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
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
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.
okay, thanks for your quick reply.
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
The code for the Smiley-URL was added on the next two commit. http://icc.utalca.cl/cgi-bin/gitweb.cgi?p=git/empathy.git;a=commit;h=dbd42cb47c8de3d802db3a0c8a1ebbaa97c2fd70 http://icc.utalca.cl/cgi-bin/gitweb.cgi?p=git/empathy.git;a=commit;h=eea4ee78adc5b0d3c314da8ab3c08697ab39fbbe
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.
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.
*** Bug 553489 has been marked as a duplicate of this bug. ***
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.
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).
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.
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.
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.
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.
Just as reference, here[1] is a Pidgin pluging to use WebKit. [1]https://launchpad.net/pidgin-webkit
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.
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
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
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...
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.
(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.
Xavier, just a question. Is the "adium" or the "chat-refactor" branch the one to follow?
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.
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.
(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.
Great! chat-refactor has been merged and will be part of Empathy 2.25.3 :D
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.
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.
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?
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.
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
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?
I rebased it on master, it should be ready for review.
Empathy master now prints a configure report. Please upgrade it according the new optionnal dep(s).
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