"Execute command..." entry in roster in contact's popup menu, plus two fixes.
The fixes: * when received a single message from a contact that has one resource online, 'start chat' entry in popup menu open only that message, not the chat * when contact has more resources online, 'rename item' entry in popup menu doesn't work
This commit is contained in:
parent
e66a8a3430
commit
8a959c846b
2 changed files with 52 additions and 18 deletions
|
@ -136,6 +136,26 @@
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImageMenuItem" id="execute_command_menuitem">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Execute Command...</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
|
||||||
|
<child internal-child="image">
|
||||||
|
<widget class="GtkImage" id="image1467">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-execute</property>
|
||||||
|
<property name="icon_size">1</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkSeparatorMenuItem" id="separator5">
|
<widget class="GtkSeparatorMenuItem" id="separator5">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -1256,6 +1256,8 @@ class RosterWindow:
|
||||||
'assign_openpgp_key_menuitem')
|
'assign_openpgp_key_menuitem')
|
||||||
add_special_notification_menuitem = xml.get_widget(
|
add_special_notification_menuitem = xml.get_widget(
|
||||||
'add_special_notification_menuitem')
|
'add_special_notification_menuitem')
|
||||||
|
execute_command_menuitem = xml.get_widget(
|
||||||
|
'execute_command_menuitem')
|
||||||
|
|
||||||
add_special_notification_menuitem.hide()
|
add_special_notification_menuitem.hide()
|
||||||
add_special_notification_menuitem.set_no_show_all(True)
|
add_special_notification_menuitem.set_no_show_all(True)
|
||||||
|
@ -1279,27 +1281,39 @@ class RosterWindow:
|
||||||
|
|
||||||
contacts = gajim.contacts.get_contact(account, jid)
|
contacts = gajim.contacts.get_contact(account, jid)
|
||||||
if len(contacts) > 1: # sevral resources
|
if len(contacts) > 1: # sevral resources
|
||||||
sub_menu = gtk.Menu()
|
def resources_submenu(action):
|
||||||
start_chat_menuitem.set_submenu(sub_menu)
|
""" Build a submenu with contact's resources. """
|
||||||
|
sub_menu = gtk.Menu()
|
||||||
|
|
||||||
iconset = gajim.config.get('iconset')
|
iconset = gajim.config.get('iconset')
|
||||||
if not iconset:
|
if not iconset:
|
||||||
iconset = DEFAULT_ICONSET
|
iconset = DEFAULT_ICONSET
|
||||||
path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
|
path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
|
||||||
for c in contacts:
|
for c in contacts:
|
||||||
# icon MUST be different instance for every item
|
# icon MUST be different instance for every item
|
||||||
state_images = self.load_iconset(path)
|
state_images = self.load_iconset(path)
|
||||||
item = gtk.ImageMenuItem(c.resource + ' (' + str(c.priority) + ')')
|
item = gtk.ImageMenuItem(c.resource + ' (' + str(c.priority) + ')')
|
||||||
icon_name = helpers.get_icon_name_to_show(c, account)
|
icon_name = helpers.get_icon_name_to_show(c, account)
|
||||||
icon = state_images[icon_name]
|
icon = state_images[icon_name]
|
||||||
item.set_image(icon)
|
item.set_image(icon)
|
||||||
sub_menu.append(item)
|
sub_menu.append(item)
|
||||||
item.connect('activate', self.on_open_chat_window, c, account,
|
item.connect('activate', action, c, account,
|
||||||
c.resource)
|
c.resource)
|
||||||
|
return sub_menu
|
||||||
|
|
||||||
|
start_chat_menuitem.set_submenu(resources_submenu(self.on_open_chat_window))
|
||||||
|
execute_command_menuitem.set_submenu(resources_submenu(self.on_open_chat_window))
|
||||||
|
|
||||||
else: # one resource
|
else: # one resource
|
||||||
start_chat_menuitem.connect('activate',
|
start_chat_menuitem.connect('activate',
|
||||||
self.on_roster_treeview_row_activated, path)
|
self.on_open_chat_window, contact, account)
|
||||||
|
# we cannot execute commands when the resource is unknown
|
||||||
|
if contact.resource:
|
||||||
|
execute_command_menuitem.connect('activate',
|
||||||
|
self.on_roster_treeview_row_activated, path)
|
||||||
|
else:
|
||||||
|
execute_command_menuitem.hide()
|
||||||
|
execute_command_menuitem.set_no_show_all(True)
|
||||||
|
|
||||||
if contact.resource:
|
if contact.resource:
|
||||||
send_file_menuitem.connect('activate',
|
send_file_menuitem.connect('activate',
|
||||||
|
@ -1368,7 +1382,7 @@ class RosterWindow:
|
||||||
for widget in [start_chat_menuitem, send_single_message_menuitem,
|
for widget in [start_chat_menuitem, send_single_message_menuitem,
|
||||||
rename_menuitem, edit_groups_menuitem, send_file_menuitem,
|
rename_menuitem, edit_groups_menuitem, send_file_menuitem,
|
||||||
subscription_menuitem, add_to_roster_menuitem,
|
subscription_menuitem, add_to_roster_menuitem,
|
||||||
remove_from_roster_menuitem]:
|
remove_from_roster_menuitem, execute_commands_menuitem]:
|
||||||
widget.set_sensitive(False)
|
widget.set_sensitive(False)
|
||||||
|
|
||||||
#FIXME: create menu for sub contacts
|
#FIXME: create menu for sub contacts
|
||||||
|
|
Loading…
Add table
Reference in a new issue