From eb6fa81854876d6ddde1b702dbc3a563c48c1088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3FMat=3DC4=3D9Bj=3D20Cepl=3F=3D?= Date: Mon, 20 Oct 2014 17:20:38 +0200 Subject: [PATCH] =?UTF-8?q?=3D=3FUTF-8=3Fq=3FDon=3DE2=3D80=3D99t=3D20use?= =?UTF-8?q?=3D20positional=3D20arguments=3D20=3F=3D=20=3D=3FUTF-8=3Fq=3Fwi?= =?UTF-8?q?th=3D20*MenuItem=3D20inits.=3F=3D=20Avoid=20DepreciationWarning?= =?UTF-8?q?=20for=20ImageMenuItem,=20CheckMenuItemi,=20and=20MenuItem.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #7858 Signed-off-by: Matěj Cepl --- src/chat_control.py | 8 +++---- src/conversation_textview.py | 5 ++-- src/groupchat_control.py | 4 ++-- src/gui_interface.py | 2 +- src/gui_menu_builder.py | 15 +++++++----- src/roster_window.py | 56 +++++++++++++++++++++++++++----------------- src/statusicon.py | 13 ++++++---- 7 files changed, 61 insertions(+), 42 deletions(-) --- src/chat_control.py | 8 +++--- src/conversation_textview.py | 5 ++-- src/groupchat_control.py | 4 +-- src/gui_interface.py | 2 +- src/gui_menu_builder.py | 15 ++++++---- src/roster_window.py | 56 ++++++++++++++++++++++-------------- src/statusicon.py | 13 +++++---- 7 files changed, 61 insertions(+), 42 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index a551567c7..e6bfa57c3 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -1083,7 +1083,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): active_tags = self.msg_textview.get_active_tags() for menuitem in menuitems: - item = Gtk.CheckMenuItem(menuitem[0]) + item = Gtk.CheckMenuItem.new_with_label(menuitem[0]) if menuitem[1] in active_tags: item.set_active(True) else: @@ -1095,13 +1095,13 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): item = Gtk.SeparatorMenuItem.new() # separator menu.append(item) - item = Gtk.ImageMenuItem(_('Color')) + item = Gtk.ImageMenuItem.new_with_label(_('Color')) icon = Gtk.Image.new_from_stock(Gtk.STOCK_SELECT_COLOR, Gtk.IconSize.MENU) item.set_image(icon) item.connect('activate', self.on_color_menuitem_activale) menu.append(item) - item = Gtk.ImageMenuItem(_('Font')) + item = Gtk.ImageMenuItem.new_with_label(_('Font')) icon = Gtk.Image.new_from_stock(Gtk.STOCK_SELECT_FONT, Gtk.IconSize.MENU) item.set_image(icon) item.connect('activate', self.on_font_menuitem_activale) @@ -1110,7 +1110,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): item = Gtk.SeparatorMenuItem.new() # separator menu.append(item) - item = Gtk.ImageMenuItem(_('Clear formating')) + item = Gtk.ImageMenuItem.new_with_label(_('Clear formating')) icon = Gtk.Image.new_from_stock(Gtk.STOCK_CLEAR, Gtk.IconSize.MENU) item.set_image(icon) item.connect('activate', self.msg_textview.clear_tags) diff --git a/src/conversation_textview.py b/src/conversation_textview.py index 23fa8bf00..c7580354e 100644 --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -816,7 +816,7 @@ class ConversationTextview(GObject.GObject): else: if dict_link.find('%s') == -1: # we must have %s in the url if not WIKTIONARY - item = Gtk.MenuItem(_( + item = Gtk.MenuItem.new_with_label(_( 'Dictionary URL is missing an "%s" and it is not WIKTIONARY')) item.set_property('sensitive', False) else: @@ -830,7 +830,8 @@ class ConversationTextview(GObject.GObject): search_link = gajim.config.get('search_engine') if search_link.find('%s') == -1: # we must have %s in the url - item = Gtk.MenuItem(_('Web Search URL is missing an "%s"')) + item = Gtk.MenuItem.new_with_label( + _('Web Search URL is missing an "%s"')) item.set_property('sensitive', False) else: item = Gtk.MenuItem.new_with_mnemonic(_('Web _Search for it')) diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 29b1a09a4..c5dc1108c 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -586,14 +586,14 @@ class GroupchatControl(ChatControlBase): item = Gtk.SeparatorMenuItem.new() menu.prepend(item) - item = Gtk.MenuItem(_('Insert Nickname')) + item = Gtk.MenuItem.new_with_label(_('Insert Nickname')) menu.prepend(item) submenu = Gtk.Menu() item.set_submenu(submenu) for nick in sorted(gajim.contacts.get_nick_list(self.account, self.room_jid)): - item = Gtk.MenuItem(nick, use_underline=False) + item = Gtk.MenuItem.new_with_label(nick, use_underline=False) submenu.append(item) id_ = item.connect('activate', self.append_nick_in_msg_textview, nick) diff --git a/src/gui_interface.py b/src/gui_interface.py index 8cd89a4ca..376fef028 100644 --- a/src/gui_interface.py +++ b/src/gui_interface.py @@ -1948,7 +1948,7 @@ class Interface: size = int(round(math.sqrt(len(self.emoticons_images)))) for image in self.emoticons_images: # In Gtk 3.6, Gtk.MenuItem() doesn't contain a label child - item = Gtk.MenuItem('q') + item = Gtk.MenuItem.new_with_label('q') img = Gtk.Image() if isinstance(image[1], GdkPixbuf.PixbufAnimation): img.set_from_animation(image[1]) diff --git a/src/gui_menu_builder.py b/src/gui_menu_builder.py index a82fb5f84..953fbf133 100644 --- a/src/gui_menu_builder.py +++ b/src/gui_menu_builder.py @@ -44,7 +44,8 @@ def build_resources_submenu(contacts, account, action, room_jid=None, for c in contacts: # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) - item = Gtk.ImageMenuItem('%s (%s)' % (c.resource, str(c.priority))) + item = Gtk.ImageMenuItem.new_with_label( + '%s (%s)' % (c.resource, str(c.priority))) icon_name = helpers.get_icon_name_to_show(c, account) icon = state_images[icon_name] item.set_image(icon) @@ -154,7 +155,7 @@ show_bookmarked=False, force_resource=False): item = Gtk.SeparatorMenuItem.new() # separator invite_to_submenu.append(item) for (room_jid, account) in rooms: - menuitem = Gtk.ImageMenuItem(room_jid.split('@')[0]) + menuitem = Gtk.ImageMenuItem.new_with_label(room_jid.split('@')[0]) muc_active_icon = gtkgui_helpers.load_icon('muc_active') menuitem.set_image(muc_active_icon) if len(contact_list) > 1: # several resources @@ -190,7 +191,7 @@ show_bookmarked=False, force_resource=False): item = Gtk.SeparatorMenuItem.new() # separator invite_to_submenu.append(item) for (room_jid, account) in rooms2: - menuitem = Gtk.ImageMenuItem(room_jid.split('@')[0]) + menuitem = Gtk.ImageMenuItem.new_with_label(room_jid.split('@')[0]) muc_inactive_icon = gtkgui_helpers.load_icon('muc_inactive') menuitem.set_image(muc_inactive_icon) if len(contact_list) > 1: # several resources @@ -473,9 +474,10 @@ control=None, gc_contact=None, is_anonymous=True): for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) - status_menuitem = Gtk.ImageMenuItem(helpers.get_uf_show(s)) + status_menuitem = Gtk.ImageMenuItem.new_with_label( + helpers.get_uf_show(s)) status_menuitem.connect('activate', roster.on_send_custom_status, - [(contact, account)], s) + [(contact, account)], s) icon = state_images[s] status_menuitem.set_image(icon) status_menuitems.append(status_menuitem) @@ -619,7 +621,8 @@ def get_transport_menu(contact, account): for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) - status_menuitem = Gtk.ImageMenuItem(helpers.get_uf_show(s)) + status_menuitem = Gtk.ImageMenuItem.new_with_label( + helpers.get_uf_show(s)) status_menuitem.connect('activate', roster.on_send_custom_status, [(contact, account)], s) icon = state_images[s] diff --git a/src/roster_window.py b/src/roster_window.py index b72d59160..6af97853c 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -4850,7 +4850,7 @@ class RosterWindow: # c_dest is None if jid_dest doesn't belong to account return menu = Gtk.Menu() - item = Gtk.MenuItem(_('Send %s to %s') % ( + item = Gtk.MenuItem.new_with_label(_('Send %s to %s') % ( c_source.get_shown_name(), c_dest.get_shown_name())) item.set_use_underline(False) item.connect('activate', self.on_drop_rosterx, account_source, @@ -4862,11 +4862,13 @@ class RosterWindow: source_family = gajim.contacts.get_metacontacts_family( account_source, c_source.jid) if dest_family == source_family and dest_family: - item = Gtk.MenuItem(_('Make %s first contact') % ( + item = Gtk.MenuItem.new_with_label( + _('Make %s first contact') % ( c_source.get_shown_name())) item.set_use_underline(False) else: - item = Gtk.MenuItem(_('Make %s and %s metacontacts') % ( + item = Gtk.MenuItem.new_with_label( + _('Make %s and %s metacontacts') % ( c_source.get_shown_name(), c_dest.get_shown_name())) item.set_use_underline(False) @@ -5333,7 +5335,8 @@ class RosterWindow: continue # new chat - new_chat_item = Gtk.MenuItem(_('using account %s') % account) + new_chat_item = Gtk.MenuItem.new_with_label( + _('using account %s') % account) new_chat_item.set_use_underline(False) new_chat_sub_menu.append(new_chat_item) new_chat_item.connect('activate', @@ -5387,8 +5390,8 @@ class RosterWindow: continue # single message - single_message_item = Gtk.MenuItem(_('using account %s') % \ - account) + single_message_item = Gtk.MenuItem.new_with_label( + _('using account %s') % account) single_message_item.set_use_underline(False) single_message_sub_menu.append(single_message_item) single_message_item.connect('activate', @@ -5397,7 +5400,8 @@ class RosterWindow: # join gc if gajim.connections[account].private_storage_supported: connected_accounts_with_private_storage += 1 - gc_item = Gtk.MenuItem(_('using account %s') % account) + gc_item = Gtk.MenuItem.new_with_label( + _('using account %s') % account) gc_item.set_use_underline(False) gc_sub_menu.append(gc_item) gc_menuitem_menu = Gtk.Menu() @@ -5405,13 +5409,15 @@ class RosterWindow: gc_item.set_submenu(gc_menuitem_menu) # add - add_item = Gtk.MenuItem(_('to %s account') % account) + add_item = Gtk.MenuItem.new_with_label( + _('to %s account') % account) add_item.set_use_underline(False) add_sub_menu.append(add_item) add_item.connect('activate', self.on_add_new_contact, account) # disco - disco_item = Gtk.MenuItem(_('using %s account') % account) + disco_item = Gtk.MenuItem.new_with_label( + _('using %s account') % account) disco_item.set_use_underline(False) disco_sub_menu.append(disco_item) disco_item.connect('activate', @@ -5470,7 +5476,8 @@ class RosterWindow: profile_avatar_sub_menu = Gtk.Menu() for account in connected_accounts_with_vcard: # profile, avatar - profile_avatar_item = Gtk.MenuItem(_('of account %s') % account) + profile_avatar_item = Gtk.MenuItem.new_with_label( + _('of account %s') % account) profile_avatar_item.set_use_underline(False) profile_avatar_sub_menu.append(profile_avatar_item) profile_avatar_item.connect('activate', @@ -5511,7 +5518,8 @@ class RosterWindow: accounts.append(account) accounts.sort() for account in accounts: - advanced_item = Gtk.MenuItem(_('for account %s') % account) + advanced_item = Gtk.MenuItem.new_with_label( + _('for account %s') % account) advanced_item.set_use_underline(False) advanced_sub_menu.append(advanced_item) advanced_menuitem_menu = \ @@ -5594,7 +5602,7 @@ class RosterWindow: pep_submenu = Gtk.Menu() pep_menuitem.set_submenu(pep_submenu) def add_item(label, opt_name, func): - item = Gtk.CheckMenuItem(label) + item = Gtk.CheckMenuItem.new_with_label(label) pep_submenu.append(item) if not dbus_support.supported: item.set_sensitive(False) @@ -5609,7 +5617,8 @@ class RosterWindow: add_item(_('Publish Location'), 'publish_location', self.on_publish_location_toggled) - pep_config = Gtk.ImageMenuItem(_('Configure Services...')) + pep_config = Gtk.ImageMenuItem.new_with_label( + _('Configure Services...')) item = Gtk.SeparatorMenuItem.new() pep_submenu.append(item) pep_config.set_sensitive(True) @@ -5718,7 +5727,7 @@ class RosterWindow: accounts.sort() for account in accounts: state_images = gtkgui_helpers.load_iconset(path) - item = Gtk.ImageMenuItem(account) + item = Gtk.ImageMenuItem.new_with_label(account) show = gajim.SHOW_LIST[gajim.connections[account].connected] icon = state_images[show] item.set_image(icon) @@ -5780,11 +5789,11 @@ class RosterWindow: send_group_message_item.set_submenu(send_group_message_submenu) menu.append(send_group_message_item) - group_message_to_all_item = Gtk.MenuItem.new_with_mnemonic(_( + group_message_to_all_item = Gtk.MenuItem.new_with_label(_( 'To all users')) send_group_message_submenu.append(group_message_to_all_item) - group_message_to_all_online_item = Gtk.MenuItem.new_with_mnemonic( + group_message_to_all_online_item = Gtk.MenuItem.new_with_label( _('To all online users')) send_group_message_submenu.append(group_message_to_all_online_item) @@ -5825,7 +5834,8 @@ class RosterWindow: for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) - status_menuitem = Gtk.ImageMenuItem(helpers.get_uf_show(s)) + status_menuitem = Gtk.ImageMenuItem.new_with_label( + helpers.get_uf_show(s)) status_menuitem.connect('activate', self.on_send_custom_status, list_, s, group) icon = state_images[s] @@ -5867,8 +5877,8 @@ class RosterWindow: if is_blocked and gajim.connections[account].\ privacy_rules_supported: - unblock_menuitem = Gtk.ImageMenuItem.new_with_mnemonic(_( - '_Unblock')) + unblock_menuitem = Gtk.ImageMenuItem.new_with_mnemonic( + _('_Unblock')) icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, Gtk.IconSize.MENU) unblock_menuitem.set_image(icon) @@ -5876,7 +5886,8 @@ class RosterWindow: group) menu.append(unblock_menuitem) else: - block_menuitem = Gtk.ImageMenuItem.new_with_mnemonic(_('_Block')) + block_menuitem = Gtk.ImageMenuItem.new_with_mnemonic( + _('_Block')) icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, Gtk.IconSize.MENU) block_menuitem.set_image(icon) @@ -6003,7 +6014,8 @@ class RosterWindow: # Block if is_blocked and privacy_rules_supported: - unblock_menuitem = Gtk.ImageMenuItem.new_with_mnemonic(_('_Unblock')) + unblock_menuitem = Gtk.ImageMenuItem.new_with_mnemonic( + _('_Unblock')) icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, Gtk.IconSize.MENU) unblock_menuitem.set_image(icon) unblock_menuitem.connect('activate', self.on_unblock, list_) @@ -6203,7 +6215,7 @@ class RosterWindow: for bookmark in gajim.connections[account].bookmarks: # Do not use underline. - item = Gtk.MenuItem(bookmark['name']) + item = Gtk.MenuItem.new_with_label(bookmark['name']) item.set_use_underline(False) item.connect('activate', self.on_bookmark_menuitem_activate, account, bookmark) diff --git a/src/statusicon.py b/src/statusicon.py index 3c524b300..1b73af413 100644 --- a/src/statusicon.py +++ b/src/statusicon.py @@ -274,7 +274,8 @@ class StatusIcon: for account in accounts_list: if gajim.account_is_connected(account): # for chat_with - item = Gtk.MenuItem(_('using account %s') % account) + item = Gtk.MenuItem.new_with_label( + _('using account %s') % account) account_menu_for_chat_with.append(item) item.connect('activate', self.on_new_chat, account) @@ -321,14 +322,15 @@ class StatusIcon: if gajim.connections[account].private_storage_supported: connected_accounts_with_private_storage += 1 # for single message - item = Gtk.MenuItem(_('using account %s') % account) + item = Gtk.MenuItem.new_with_label( + _('using account %s') % account) item.connect('activate', self.on_single_message_menuitem_activate, account) account_menu_for_single_message.append(item) # join gc - gc_item = Gtk.MenuItem(_('using account %s') % account, - use_underline=False) + gc_item = Gtk.MenuItem.new_with_label( + _('using account %s') % account, use_underline=False) gc_sub_menu.append(gc_item) gc_menuitem_menu = Gtk.Menu() gajim.interface.roster.add_bookmarks_list(gc_menuitem_menu, @@ -364,7 +366,8 @@ class StatusIcon: if os.name == 'nt': if self.added_hide_menuitem is False: self.systray_context_menu.prepend(Gtk.SeparatorMenuItem.new()) - item = Gtk.MenuItem(_('Hide this menu')) + item = Gtk.MenuItem.new_with_label( + _('Hide this menu')) self.systray_context_menu.prepend(item) self.added_hide_menuitem = True