roster_tweaks.Added ability to quickly change the activity and mood.

This commit is contained in:
Denis Fomin
2010-11-15 16:44:07 +03:00
parent 53493b3b73
commit ba2c7ffc33
3 changed files with 135 additions and 4 deletions

View File

@@ -56,4 +56,64 @@
</object> </object>
</child> </child>
</object> </object>
<object class="GtkWindow" id="window2">
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<object class="GtkEntry" id="status_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<signal name="key_press_event" handler="status_changed"/>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="activity_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<signal name="clicked" handler="on_activity_button_clicked"/>
<child>
<object class="GtkImage" id="activity_image">
<property name="visible">True</property>
<property name="stock">gtk-stop</property>
<property name="icon-size">1</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="mood_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<signal name="clicked" handler="on_mood_button_clicked"/>
<child>
<object class="GtkImage" id="mood_image">
<property name="visible">True</property>
<property name="stock">gtk-stop</property>
<property name="icon-size">1</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface> </interface>

View File

@@ -1,7 +1,7 @@
[info] [info]
name: Roster Tweaks name: Roster Tweaks
short_name: roster_tweaks short_name: roster_tweaks
version: 0.3 version: 0.4
description: Allows user to tweak roster window appearance (eg. make it compact). description: Allows user to tweak roster window appearance (eg. make it compact).
Based on ticket #3340: Based on ticket #3340:
http://trac.gajim.org/ticket/3340. http://trac.gajim.org/ticket/3340.

View File

@@ -10,6 +10,9 @@ from common import gajim
from plugins import GajimPlugin from plugins import GajimPlugin
from plugins.helpers import log, log_calls from plugins.helpers import log, log_calls
from plugins.gui import GajimPluginConfigDialog from plugins.gui import GajimPluginConfigDialog
from dialogs import ChangeActivityDialog, ChangeMoodDialog
from common import pep
import gtkgui_helpers
class RosterTweaksPlugin(GajimPlugin): class RosterTweaksPlugin(GajimPlugin):
@@ -24,19 +27,31 @@ class RosterTweaksPlugin(GajimPlugin):
@log_calls('RosterTweaksPlugin') @log_calls('RosterTweaksPlugin')
def activate(self): def activate(self):
self.pep_dict = {}
gajim.interface.roster.status_combobox.set_property('visible', gajim.interface.roster.status_combobox.set_property('visible',
not self.config['hide_status_combo']) not self.config['hide_status_combo'])
gajim.interface.roster.status_combobox.set_no_show_all(True) gajim.interface.roster.status_combobox.set_no_show_all(True)
self.enable_ctrl_m() self.enable_ctrl_m()
vbox = gajim.interface.roster.xml.get_object('roster_vbox2') 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('visible', self.config['quick_status'])
self.status_widget.set_property('no-show-all', True) 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( self.font_desc = self.status_widget.get_pango_context(
).get_font_description() ).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): def enable_ctrl_m(self):
if self.config['use_ctr_m']: if self.config['use_ctr_m']:
@@ -80,6 +95,59 @@ class RosterTweaksPlugin(GajimPlugin):
self.font_desc.set_weight(pango.WEIGHT_NORMAL) self.font_desc.set_weight(pango.WEIGHT_NORMAL)
gobject.timeout_add(1000, widget.modify_font, self.font_desc) 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): class RosterTweaksPluginConfigDialog(GajimPluginConfigDialog):
def init(self): def init(self):
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( 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.set_translation_domain(i18n.APP)
self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
['roster_tweaks_config_vbox']) ['roster_tweaks_config_vbox'])
self.config_vbox = self.xml.get_object('roster_tweaks_config_vbox') self.config_vbox = self.xml.get_object('roster_tweaks_config_vbox')
self.child.pack_start(self.config_vbox) self.child.pack_start(self.config_vbox)
@@ -110,6 +179,8 @@ class RosterTweaksPluginConfigDialog(GajimPluginConfigDialog):
def on_quick_status_toggled(self, button): def on_quick_status_toggled(self, button):
self.plugin.config['quick_status'] = button.get_active() self.plugin.config['quick_status'] = button.get_active()
self.plugin.status_widget.set_property('visible', 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): def on_use_ctr_m_toggled(self, button):
is_ctr_m_enabled = button.get_active() is_ctr_m_enabled = button.get_active()