move gtk function from pep to gui_interface

This commit is contained in:
Yann Leboulanger 2013-04-06 12:25:19 +02:00
parent 23471cbd9d
commit b74b7f96fa
2 changed files with 35 additions and 28 deletions

View File

@ -216,8 +216,6 @@ LOCATION_DATA = {
'uri': _('uri')}
import gobject
import gtk
import logging
log = logging.getLogger('gajim.c.pep')
@ -225,8 +223,6 @@ from common import helpers
import nbxmpp
from common import gajim
import gtkgui_helpers
class AbstractPEP(object):
@ -302,10 +298,7 @@ class UserMoodPEP(AbstractPEP):
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 @@ class UserTunePEP(AbstractPEP):
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 @@ class UserActivityPEP(AbstractPEP):
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 @@ class UserLocationPEP(AbstractPEP):
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

View File

@ -85,6 +85,7 @@ from common.connection_handlers_events import OurShowEvent, \
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 @@ class Interface:
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