move gtk function from pep to gui_interface
This commit is contained in:
parent
23471cbd9d
commit
b74b7f96fa
|
@ -216,8 +216,6 @@ LOCATION_DATA = {
|
||||||
'uri': _('uri')}
|
'uri': _('uri')}
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
import gtk
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger('gajim.c.pep')
|
log = logging.getLogger('gajim.c.pep')
|
||||||
|
|
||||||
|
@ -225,8 +223,6 @@ from common import helpers
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
|
||||||
import gtkgui_helpers
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractPEP(object):
|
class AbstractPEP(object):
|
||||||
|
|
||||||
|
@ -302,10 +298,7 @@ class UserMoodPEP(AbstractPEP):
|
||||||
|
|
||||||
def asPixbufIcon(self):
|
def asPixbufIcon(self):
|
||||||
assert not self._retracted
|
assert not self._retracted
|
||||||
received_mood = self._pep_specific_data['mood']
|
return gajim.interface.get_pep_icon(self)
|
||||||
mood = received_mood if received_mood in MOODS else 'unknown'
|
|
||||||
pixbuf = gtkgui_helpers.load_mood_icon(mood).get_pixbuf()
|
|
||||||
return pixbuf
|
|
||||||
|
|
||||||
def asMarkupText(self):
|
def asMarkupText(self):
|
||||||
assert not self._retracted
|
assert not self._retracted
|
||||||
|
@ -347,9 +340,7 @@ class UserTunePEP(AbstractPEP):
|
||||||
return (tune_dict, retracted)
|
return (tune_dict, retracted)
|
||||||
|
|
||||||
def asPixbufIcon(self):
|
def asPixbufIcon(self):
|
||||||
import os
|
return gajim.interface.get_pep_icon(self)
|
||||||
path = os.path.join(gajim.DATA_DIR, 'emoticons', 'static', 'music.png')
|
|
||||||
return gtk.gdk.pixbuf_new_from_file(path)
|
|
||||||
|
|
||||||
def asMarkupText(self):
|
def asMarkupText(self):
|
||||||
assert not self._retracted
|
assert not self._retracted
|
||||||
|
@ -398,21 +389,7 @@ class UserActivityPEP(AbstractPEP):
|
||||||
|
|
||||||
def asPixbufIcon(self):
|
def asPixbufIcon(self):
|
||||||
assert not self._retracted
|
assert not self._retracted
|
||||||
pep = self._pep_specific_data
|
return gajim.interface.get_pep_icon(self)
|
||||||
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()
|
|
||||||
|
|
||||||
def asMarkupText(self):
|
def asMarkupText(self):
|
||||||
assert not self._retracted
|
assert not self._retracted
|
||||||
|
@ -492,8 +469,7 @@ class UserLocationPEP(AbstractPEP):
|
||||||
self._pep_specific_data
|
self._pep_specific_data
|
||||||
|
|
||||||
def asPixbufIcon(self):
|
def asPixbufIcon(self):
|
||||||
path = gtkgui_helpers.get_icon_path('gajim-earth')
|
return gajim.interface.get_pep_icon(self)
|
||||||
return gtk.gdk.pixbuf_new_from_file(path)
|
|
||||||
|
|
||||||
def asMarkupText(self):
|
def asMarkupText(self):
|
||||||
assert not self._retracted
|
assert not self._retracted
|
||||||
|
|
|
@ -85,6 +85,7 @@ from common.connection_handlers_events import OurShowEvent, \
|
||||||
from common.connection import Connection
|
from common.connection import Connection
|
||||||
from common import jingle
|
from common import jingle
|
||||||
from common.file_props import FilesProp
|
from common.file_props import FilesProp
|
||||||
|
from common import pep
|
||||||
|
|
||||||
import roster_window
|
import roster_window
|
||||||
import profile_window
|
import profile_window
|
||||||
|
@ -2603,6 +2604,36 @@ class Interface:
|
||||||
|
|
||||||
return gc_ctrl and gc_ctrl.type_id == message_control.TYPE_GC
|
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):
|
def create_ipython_window(self):
|
||||||
try:
|
try:
|
||||||
from ipython_view import IPythonView
|
from ipython_view import IPythonView
|
||||||
|
|
Loading…
Reference in New Issue