From 3b358d603cae000c8f51c05d9523e95eff92f606 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 23 Jun 2005 10:28:31 +0000 Subject: [PATCH] add icons to menu --- src/chat.py | 16 ++++++++--- src/groupchat_window.py | 57 +++++++++++++++++++++++++++++++-------- src/tabbed_chat_window.py | 5 ---- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/src/chat.py b/src/chat.py index b96051bdf..4f7105999 100644 --- a/src/chat.py +++ b/src/chat.py @@ -189,7 +189,7 @@ class Chat: self.plugin.systray.remove_jid(jid, self.account) def populate_popup_menu(self, menu): - '''To be overwritten in parrent class''' + '''To be overwritten in child class''' pass def on_chat_window_button_press_event(self, widget, event): @@ -203,7 +203,7 @@ class Chat: for jid in self.xmls: if jid != self.get_active_jid(): # FIXME: add icons representing contact's status? - item = gtk.MenuItem(self.names[jid]) + item = gtk.MenuItem('switch to %s' % self.names[jid]) item.connect('activate', lambda obj,jid:self.set_active_tab( jid), jid) menu.append(item) @@ -213,6 +213,15 @@ class Chat: # menuitems specific to type of chat self.populate_popup_menu(menu) + item = gtk.CheckMenuItem(_('_Compact View'))# + ' Alt+C') + #FIXME: The accelerator is not used, it's just to show the Alt+c + ag = gtk.AccelGroup() + item.add_accelerator('activate', ag, ord('c'), gtk.gdk.MOD1_MASK, gtk.ACCEL_VISIBLE) + item.set_active(self.get_compact_view()) + item.connect('activate', lambda obj:self.set_compact_view( + not self.get_compact_view())) + menu.append(item) + # show the menu menu.popup(None, None, None, event.button, event.time) menu.show_all() @@ -360,8 +369,7 @@ class Chat: gtklabel = gtk.Label(jid.split('@')[0]) gtklabel.set_property('xalign', 0) - xm.signal_connect('on_close_button_clicked', - self.on_close_button_clicked, jid) + xm.signal_autoconnect(self) #FIXME: text formating buttons will be hidden in 0.8 release for w in ['bold_togglebutton', 'italic_togglebutton', 'underline_togglebutton']: diff --git a/src/groupchat_window.py b/src/groupchat_window.py index ee0c92513..4ab8e19f2 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -135,7 +135,7 @@ class GroupchatWindow(chat.Chat): """When window get focus""" chat.Chat.on_chat_window_focus_in_event(self, widget, event) - def on_groupchat_window_event(self,widget,event): + def on_groupchat_window_event(self, widget, event): if event.type != gtk.gdk.BUTTON_PRESS: return False self.on_chat_window_button_press_event(widget, event) @@ -784,31 +784,66 @@ class GroupchatWindow(chat.Chat): """Add menuitems do popup menu""" # FIXME: add icons / use ItemFactory - item = gtk.MenuItem(_('_History')) + item = gtk.MenuItem() + icon = gtk.Image() + icon.set_from_stock(gtk.STOCK_JUSTIFY_FILL, gtk.ICON_SIZE_BUTTON) + label = gtk.Label(_('_History')) + label.set_use_underline(True) + hbox = gtk.HBox(False, 3) + hbox.pack_start(icon, False, False) + hbox.pack_start(label, False, False) + item.add(hbox) item.connect('activate', self.on_history_button_clicked) menu.append(item) - item = gtk.MenuItem(_('Configure _Room')) + item = gtk.MenuItem() + icon = gtk.Image() + icon.set_from_stock(gtk.STOCK_PROPERTIES, gtk.ICON_SIZE_BUTTON) + label = gtk.Label(_('Configure _Room')) + label.set_use_underline(True) + hbox = gtk.HBox(False, 3) + hbox.pack_start(icon, False, False) + hbox.pack_start(label, False, False) + item.add(hbox) item.connect('activate', self.on_configure_room_menuitem_activate) menu.append(item) - item = gtk.MenuItem(_('Change _Subject')) + item = gtk.MenuItem() + icon = gtk.Image() + icon.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_BUTTON) + label = gtk.Label(_('Change _Subject')) + label.set_use_underline(True) + hbox = gtk.HBox(False, 3) + hbox.pack_start(icon, False, False) + hbox.pack_start(label, False, False) + item.add(hbox) item.connect('activate', self.on_change_subject_menuitem_activate) menu.append(item) - item = gtk.MenuItem(_('Change _Nickname')) + item = gtk.MenuItem() + icon = gtk.Image() + icon.set_from_stock(gtk.STOCK_REDO, gtk.ICON_SIZE_BUTTON) + label = gtk.Label(_('Change _Nickname')) + label.set_use_underline(True) + hbox = gtk.HBox(False, 3) + hbox.pack_start(icon, False, False) + hbox.pack_start(label, False, False) + item.add(hbox) item.connect('activate', self.on_change_nick_menuitem_activate) menu.append(item) - item = gtk.MenuItem(_('_Bookmark This Room')) + item = gtk.MenuItem() + icon = gtk.Image() + icon.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON) + label = gtk.Label(_('_Bookmark This Room')) + label.set_use_underline(True) + hbox = gtk.HBox(False, 3) + hbox.pack_start(icon, False, False) + hbox.pack_start(label, False, False) + item.add(hbox) item.connect('activate', self.on_bookmark_room_menuitem_activate) menu.append(item) - item=gtk.MenuItem(_('_Toggle compact view')) - item.connect('activate', lambda obj:self.set_compact_view( - not self.get_compact_view())) - menu.append(item) - def remove_tab(self, room_jid): if time.time() - self.last_message_time[room_jid] < 2: dialog = dialogs.ConfirmationDialog( diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index 102f241c8..0721a4755 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -470,8 +470,3 @@ class TabbedChatWindow(chat.Chat): menu.append(item) # FIXME: GPG stuff - - item=gtk.MenuItem(_('_Toggle compact view')) - item.connect('activate', lambda obj:self.set_compact_view( - not self.get_compact_view())) - menu.append(item)