changeset 4c68e1f6d9ca in /home/hg/repos/gajim
branches: details:http://hg.gajim.org/gajim?cmd=changeset;node=4c68e1f6d9ca description: move gtk function from pep to gui_interface
diffstat:
src/common/pep.py | 32 ++++---------------------------- src/gui_interface.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 28 deletions(-)
diffs (125 lines):
diff -r c2e195470071 -r 4c68e1f6d9ca src/common/pep.py --- a/src/common/pep.py Sat Apr 06 12:24:26 2013 +0200 +++ b/src/common/pep.py Sat Apr 06 12:25:19 2013 +0200 @@ -216,8 +216,6 @@ 'uri': _('uri')}
import gobject -import gtk - import logging log = logging.getLogger('gajim.c.pep')
@@ -225,8 +223,6 @@ import nbxmpp from common import gajim
-import gtkgui_helpers -
class AbstractPEP(object):
@@ -302,10 +298,7 @@
def asPixbufIcon(self): assert not self._retracted - received_mood = self._pep_specific_data['mood'] - mood = received_mood if received_mood in MOODS else 'unknown' - pixbuf = gtkgui_helpers.load_mood_icon(mood).get_pixbuf() - return pixbuf + return gajim.interface.get_pep_icon(self)
def asMarkupText(self): assert not self._retracted @@ -347,9 +340,7 @@ return (tune_dict, retracted)
def asPixbufIcon(self): - import os - path = os.path.join(gajim.DATA_DIR, 'emoticons', 'static', 'music.png') - return gtk.gdk.pixbuf_new_from_file(path) + return gajim.interface.get_pep_icon(self)
def asMarkupText(self): assert not self._retracted @@ -398,21 +389,7 @@
def asPixbufIcon(self): assert not self._retracted - pep = self._pep_specific_data - activity = pep['activity'] - - has_known_activity = activity in ACTIVITIES - has_known_subactivity = (has_known_activity and ('subactivity' in pep) - and (pep['subactivity'] in ACTIVITIES[activity])) - - if has_known_activity: - if has_known_subactivity: - subactivity = pep['subactivity'] - return gtkgui_helpers.load_activity_icon(activity, subactivity).get_pixbuf() - else: - return gtkgui_helpers.load_activity_icon(activity).get_pixbuf() - else: - return gtkgui_helpers.load_activity_icon('unknown').get_pixbuf() + return gajim.interface.get_pep_icon(self)
def asMarkupText(self): assert not self._retracted @@ -492,8 +469,7 @@ self._pep_specific_data
def asPixbufIcon(self): - path = gtkgui_helpers.get_icon_path('gajim-earth') - return gtk.gdk.pixbuf_new_from_file(path) + return gajim.interface.get_pep_icon(self)
def asMarkupText(self): assert not self._retracted diff -r c2e195470071 -r 4c68e1f6d9ca src/gui_interface.py --- a/src/gui_interface.py Sat Apr 06 12:24:26 2013 +0200 +++ b/src/gui_interface.py Sat Apr 06 12:25:19 2013 +0200 @@ -85,6 +85,7 @@ from common.connection import Connection from common import jingle from common.file_props import FilesProp +from common import pep
import roster_window import profile_window @@ -2603,6 +2604,36 @@
return gc_ctrl and gc_ctrl.type_id == message_control.TYPE_GC
+ def get_pep_icon(self, pep_obj): + if isinstance(pep_obj, pep.UserMoodPEP): + received_mood = pep_obj._pep_specific_data['mood'] + mood = received_mood if received_mood in pep.MOODS else 'unknown' + return gtkgui_helpers.load_mood_icon(mood).get_pixbuf() + elif isinstance(pep_obj, pep.UserTunePEP): + path = os.path.join(gajim.DATA_DIR, 'emoticons', 'static', 'music.png') + return gtk.gdk.pixbuf_new_from_file(path) + elif isinstance(pep_obj, pep.UserActivityPEP): + pep_ = pep_obj._pep_specific_data + activity = pep_['activity'] + + has_known_activity = activity in pep.ACTIVITIES + has_known_subactivity = (has_known_activity and ('subactivity' in + pep_) and (pep_['subactivity'] in pep.ACTIVITIES[activity])) + + if has_known_activity: + if has_known_subactivity: + subactivity = pep_['subactivity'] + return gtkgui_helpers.load_activity_icon(activity, + subactivity).get_pixbuf() + else: + return gtkgui_helpers.load_activity_icon(activity).\ + get_pixbuf() + else: + return gtkgui_helpers.load_activity_icon('unknown').get_pixbuf() + elif isinstance(pep_obj, pep.UserLocationPEP): + path = gtkgui_helpers.get_icon_path('gajim-earth') + return gtk.gdk.pixbuf_new_from_file(path) + def create_ipython_window(self): try: from ipython_view import IPythonView