remove switch to menuitems. fixes #1674
This commit is contained in:
parent
d59178c385
commit
bffcec6899
3 changed files with 9 additions and 41 deletions
|
@ -641,28 +641,6 @@ class ChatControlBase(MessageControl):
|
||||||
color.blue = int((color.blue * p) + (mask * (1 - p)))
|
color.blue = int((color.blue * p) + (mask * (1 - p)))
|
||||||
return color
|
return color
|
||||||
|
|
||||||
def remove_possible_switch_to_menuitems(self, menu):
|
|
||||||
''' remove duplicate 'Switch to' if they exist and return clean menu'''
|
|
||||||
childs = menu.get_children()
|
|
||||||
|
|
||||||
contact = self.parent_win.get_active_contact()
|
|
||||||
jid = contact.jid
|
|
||||||
|
|
||||||
if self.type_id == message_control.TYPE_GC:
|
|
||||||
start_removing_from = 6 # # this is from the seperator and after
|
|
||||||
else:
|
|
||||||
if _('Not in Roster') in contact.groups: # for add_to_roster_menuitem
|
|
||||||
childs[5].show()
|
|
||||||
childs[5].set_no_show_all(False)
|
|
||||||
else:
|
|
||||||
childs[5].hide()
|
|
||||||
childs[5].set_no_show_all(True)
|
|
||||||
start_removing_from = 6 # this is from the seperator and after
|
|
||||||
|
|
||||||
for child in childs[start_removing_from:]:
|
|
||||||
menu.remove(child)
|
|
||||||
return menu
|
|
||||||
|
|
||||||
def set_compact_view(self, state):
|
def set_compact_view(self, state):
|
||||||
'''Toggle compact view. state is bool'''
|
'''Toggle compact view. state is bool'''
|
||||||
MessageControl.set_compact_view(self, state)
|
MessageControl.set_compact_view(self, state)
|
||||||
|
@ -1147,8 +1125,7 @@ class ChatControl(ChatControlBase):
|
||||||
|
|
||||||
def prepare_context_menu(self):
|
def prepare_context_menu(self):
|
||||||
'''sets compact view menuitem active state
|
'''sets compact view menuitem active state
|
||||||
sets active and sensitivity state for toggle_gpg_menuitem
|
sets active and sensitivity state for toggle_gpg_menuitem'''
|
||||||
and remove possible 'Switch to' menuitems'''
|
|
||||||
menu = self.popup_menu
|
menu = self.popup_menu
|
||||||
childs = menu.get_children()
|
childs = menu.get_children()
|
||||||
# check if gpg capabitlies or else make gpg toggle insensitive
|
# check if gpg capabitlies or else make gpg toggle insensitive
|
||||||
|
@ -1164,9 +1141,16 @@ class ChatControl(ChatControlBase):
|
||||||
childs[2].set_sensitive(False)
|
childs[2].set_sensitive(False)
|
||||||
else:
|
else:
|
||||||
childs[2].set_sensitive(True)
|
childs[2].set_sensitive(True)
|
||||||
|
|
||||||
# compact_view_menuitem
|
# compact_view_menuitem
|
||||||
childs[4].set_active(self.compact_view_current)
|
childs[4].set_active(self.compact_view_current)
|
||||||
menu = self.remove_possible_switch_to_menuitems(menu)
|
|
||||||
|
if _('Not in Roster') in contact.groups: # for add_to_roster_menuitem
|
||||||
|
childs[5].show()
|
||||||
|
childs[5].set_no_show_all(False)
|
||||||
|
else:
|
||||||
|
childs[5].hide()
|
||||||
|
childs[5].set_no_show_all(True)
|
||||||
|
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
|
|
|
@ -322,7 +322,6 @@ class GroupchatControl(ChatControlBase):
|
||||||
childs[1].set_sensitive(False)
|
childs[1].set_sensitive(False)
|
||||||
childs[2].set_sensitive(False)
|
childs[2].set_sensitive(False)
|
||||||
childs[3].set_sensitive(False)
|
childs[3].set_sensitive(False)
|
||||||
menu = self.remove_possible_switch_to_menuitems(menu)
|
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
def on_message(self, nick, msg, tim):
|
def on_message(self, nick, msg, tim):
|
||||||
|
|
|
@ -441,21 +441,6 @@ class MessageWindow:
|
||||||
|
|
||||||
def popup_menu(self, event):
|
def popup_menu(self, event):
|
||||||
menu = self.get_active_control().prepare_context_menu()
|
menu = self.get_active_control().prepare_context_menu()
|
||||||
# common menuitems (tab switches)
|
|
||||||
if self.get_num_controls() > 1: # if there is more than one tab
|
|
||||||
menu.append(gtk.SeparatorMenuItem()) # seperator
|
|
||||||
for ctrl in self.controls():
|
|
||||||
jid = ctrl.contact.jid
|
|
||||||
if jid != self.get_active_jid():
|
|
||||||
item = gtk.ImageMenuItem(_('Switch to %s') %\
|
|
||||||
ctrl.contact.get_shown_name())
|
|
||||||
img = gtk.image_new_from_stock(gtk.STOCK_JUMP_TO,
|
|
||||||
gtk.ICON_SIZE_MENU)
|
|
||||||
item.set_image(img)
|
|
||||||
item.connect('activate',
|
|
||||||
lambda obj, jid:self.set_active_tab(jid, ctrl.account),
|
|
||||||
jid)
|
|
||||||
menu.append(item)
|
|
||||||
# show the menu
|
# show the menu
|
||||||
menu.popup(None, None, None, event.button, event.time)
|
menu.popup(None, None, None, event.button, event.time)
|
||||||
menu.show_all()
|
menu.show_all()
|
||||||
|
|
Loading…
Add table
Reference in a new issue