From ecb476d79629a8bc1ed9875e572f286db6cbe0b3 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Thu, 4 Aug 2005 14:57:36 +0000 Subject: [PATCH] action button in TC now is functional --- src/chat.py | 57 +++++++++++++++++++++++++---------------- src/groupchat_window.py | 10 -------- src/gtkgui.glade | 1 + 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/chat.py b/src/chat.py index 3a5eb1b9f..e839d4e9d 100644 --- a/src/chat.py +++ b/src/chat.py @@ -178,8 +178,8 @@ class Chat: if self.plugin.windows['logs'].has_key(jid): self.plugin.windows['logs'][jid].window.present() else: - self.plugin.windows['logs'][jid] = history_window.\ - HistoryWindow(self.plugin, jid, self.account) + self.plugin.windows['logs'][jid] = history_window.HistoryWindow( + self.plugin, jid, self.account) def on_chat_window_focus_in_event(self, widget, event): """When window gets focus""" @@ -202,6 +202,12 @@ class Chat: isactive = widget.get_active() self.set_compact_view(isactive) + def on_actions_button_clicked(self, widget): + '''popup action menu''' + menu = self.prepare_context_menu() + menu.popup(None, None, None, 1, 0) + menu.show_all() + def remove_possible_switch_to_menuitems(self, menu): ''' remove duplicate 'Switch to' if they exist and return clean menu''' childs = menu.get_children() @@ -228,28 +234,35 @@ class Chat: return menu + def prepare_context_menu(self): + '''sets compact view menuitem active state + sets active and sensitivity state for toggle_gpg_menuitem + and remove possible 'Switch to' menuitems''' + if self.widget_name == 'groupchat_window': + menu = self.gc_popup_menu + childs = menu.get_children() + # compact_view_menuitem + childs[5].set_active(self.compact_view_current_state) + elif self.widget_name == 'tabbed_chat_window': + menu = self.tabbed_chat_popup_menu + childs = menu.get_children() + # check if gpg capabitlies or else make gpg toggle insensitive + jid = self.get_active_jid() + gpg_btn = self.xmls[jid].get_widget('gpg_togglebutton') + isactive = gpg_btn.get_active() + issensitive = gpg_btn.get_property('sensitive') + childs[3].set_active(isactive) + childs[3].set_property('sensitive', issensitive) + # compact_view_menuitem + childs[4].set_active(self.compact_view_current_state) + menu = self.remove_possible_switch_to_menuitems(menu) + + return menu + def on_chat_window_button_press_event(self, widget, event): '''If right-clicked, show popup''' if event.button == 3: # right click - if self.widget_name == 'groupchat_window': - menu = self.gc_popup_menu - childs = menu.get_children() - # compact_view_menuitem - childs[5].set_active(self.compact_view_current_state) - elif self.widget_name == 'tabbed_chat_window': - menu = self.tabbed_chat_popup_menu - childs = menu.get_children() - # check if gpg capabitlies or else make gpg toggle insensitive - jid = self.get_active_jid() - gpg_btn = self.xmls[jid].get_widget('gpg_togglebutton') - isactive = gpg_btn.get_active() - issensitive = gpg_btn.get_property('sensitive') - childs[3].set_active(isactive) - childs[3].set_property('sensitive', issensitive) - # compact_view_menuitem - childs[4].set_active(self.compact_view_current_state) - menu = self.remove_possible_switch_to_menuitems(menu) - + menu = self.prepare_context_menu() # common menuitems (tab switches) if len(self.xmls) > 1: # if there is more than one tab menu.append(gtk.MenuItem()) # seperator @@ -1132,7 +1145,7 @@ class Chat: self.paint_banner(jid) def set_compact_view(self, state): - '''Toggle compact view''' + '''Toggle compact view. state is bool''' self.compact_view_current_state = state for jid in self.xmls: diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 68ba0670a..5517f1c06 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -1063,16 +1063,6 @@ class GroupchatWindow(chat.Chat): else: # it is root (eg. group) bgcolor = gajim.config.get_per('themes', theme, 'groupbgcolor') renderer.set_property('cell-background', bgcolor) - - def on_actions_button_clicked(self, widget): - """popup action menu""" - menu = self.gc_popup_menu - childs = menu.get_children() - # compact_view_menuitem - childs[5].set_active(self.compact_view_current_state) - menu = self.remove_possible_switch_to_menuitems(menu) - menu.popup(None, None, None, 1, 0) - menu.show_all() def on_list_treeview_button_press_event(self, widget, event): """popup user's group's or agent menu""" diff --git a/src/gtkgui.glade b/src/gtkgui.glade index e06abf56c..a5f456e03 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -17095,6 +17095,7 @@ Maybe I'll refactor later GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False + 480 True False True