From ba2c7ffc330100d5e7822c775c086acddb39429b Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Mon, 15 Nov 2010 16:44:07 +0300 Subject: roster_tweaks.Added ability to quickly change the activity and mood. --- roster_tweaks/roster_tweaks.py | 77 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) (limited to 'roster_tweaks/roster_tweaks.py') diff --git a/roster_tweaks/roster_tweaks.py b/roster_tweaks/roster_tweaks.py index 78592c7..05c0dca 100644 --- a/roster_tweaks/roster_tweaks.py +++ b/roster_tweaks/roster_tweaks.py @@ -10,6 +10,9 @@ from common import gajim from plugins import GajimPlugin from plugins.helpers import log, log_calls from plugins.gui import GajimPluginConfigDialog +from dialogs import ChangeActivityDialog, ChangeMoodDialog +from common import pep +import gtkgui_helpers class RosterTweaksPlugin(GajimPlugin): @@ -24,19 +27,31 @@ class RosterTweaksPlugin(GajimPlugin): @log_calls('RosterTweaksPlugin') def activate(self): + self.pep_dict = {} gajim.interface.roster.status_combobox.set_property('visible', not self.config['hide_status_combo']) gajim.interface.roster.status_combobox.set_no_show_all(True) self.enable_ctrl_m() vbox = gajim.interface.roster.xml.get_object('roster_vbox2') - self.status_widget = gtk.Entry(max=0) + self.GTK_BUILDER_FILE_PATH = self.local_file_path( + 'config_dialog.ui') + self.xml = gtk.Builder() + self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, ['hbox1']) + self.status_widget = self.xml.get_object('status_entry') self.status_widget.set_property('visible', self.config['quick_status']) self.status_widget.set_property('no-show-all', True) - self.status_widget.connect('key-press-event', self.status_changed) self.font_desc = self.status_widget.get_pango_context( ).get_font_description() - vbox.pack_start(self.status_widget, False) + self.activity_button = self.xml.get_object('activity_button') + self.activity_button.set_property('no-show-all', True) + self.activity_button.set_property('visible', self.config['quick_status']) + self.mood_button = self.xml.get_object('mood_button') + self.mood_button.set_property('no-show-all', True) + self.mood_button.set_property('visible', self.config['quick_status']) + hbox = self.xml.get_object('hbox1') + vbox.pack_start(hbox, False) + self.xml.connect_signals(self) def enable_ctrl_m(self): if self.config['use_ctr_m']: @@ -80,6 +95,59 @@ class RosterTweaksPlugin(GajimPlugin): self.font_desc.set_weight(pango.WEIGHT_NORMAL) gobject.timeout_add(1000, widget.modify_font, self.font_desc) + def on_activity_button_clicked(self, widget): + def on_response(activity, subactivity, text): + self.pep_dict['activity'] = activity or '' + self.pep_dict['subactivity'] = subactivity or '' + self.pep_dict['activity_text'] = text + self.draw_activity() + accounts = gajim.connections.keys() + for account in accounts: + gajim.interface.roster.send_pep(account, self.pep_dict) + ChangeActivityDialog(on_response, self.pep_dict.get('activity', None), + self.pep_dict.get('subactivity',None), + self.pep_dict.get('activity_text', None)) + + def on_mood_button_clicked(self, widget): + def on_response(mood, text): + self.pep_dict['mood'] = mood or '' + self.pep_dict['mood_text'] = text + self.draw_mood() + accounts = gajim.connections.keys() + for account in accounts: + gajim.interface.roster.send_pep(account, self.pep_dict) + ChangeMoodDialog(on_response, self.pep_dict.get('mood', None), + self.pep_dict.get('mood_text', None)) + + def draw_activity(self): + """ + Set activity button + """ + img = self.xml.get_object('activity_image') + if 'activity' in self.pep_dict and self.pep_dict['activity'] in \ + pep.ACTIVITIES: + if 'subactivity' in self.pep_dict and self.pep_dict['subactivity'] \ + in pep.ACTIVITIES[self.pep_dict['activity']]: + img.set_from_pixbuf(gtkgui_helpers.load_activity_icon( + self.pep_dict['activity'], self.pep_dict['subactivity']).\ + get_pixbuf()) + else: + img.set_from_pixbuf(gtkgui_helpers.load_activity_icon( + self.pep_dict['activity']).get_pixbuf()) + else: + img.set_from_stock('gtk-stop', gtk.ICON_SIZE_MENU) + + def draw_mood(self): + """ + Set mood button + """ + img = self.xml.get_object('mood_image') + if 'mood' in self.pep_dict and self.pep_dict['mood'] in pep.MOODS: + img.set_from_pixbuf(gtkgui_helpers.load_mood_icon( + self.pep_dict['mood']).get_pixbuf()) + else: + img.set_from_stock('gtk-stop', gtk.ICON_SIZE_MENU) + class RosterTweaksPluginConfigDialog(GajimPluginConfigDialog): def init(self): self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( @@ -88,6 +156,7 @@ class RosterTweaksPluginConfigDialog(GajimPluginConfigDialog): self.xml.set_translation_domain(i18n.APP) self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, ['roster_tweaks_config_vbox']) + self.config_vbox = self.xml.get_object('roster_tweaks_config_vbox') self.child.pack_start(self.config_vbox) @@ -110,6 +179,8 @@ class RosterTweaksPluginConfigDialog(GajimPluginConfigDialog): def on_quick_status_toggled(self, button): self.plugin.config['quick_status'] = button.get_active() self.plugin.status_widget.set_property('visible', button.get_active()) + self.plugin.mood_button.set_property('visible', button.get_active()) + self.plugin.activity_button.set_property('visible', button.get_active()) def on_use_ctr_m_toggled(self, button): is_ctr_m_enabled = button.get_active() -- cgit v1.2.3