def add_menu_item(self, menu_path, handler): """ Add a new item into the main menu bar of the application. Menu items created through this method are automatically removed when the plugin is disabled. :param str menu_path: The path to the menu item, delimited with > characters. :param handler: The callback function to be connected to the new :py:class:`Gtk.MenuItem` instance's activate signal. :return: The newly created and added menu item. :rtype: :py:class:`Gtk.MenuItem` """ menu_path = [path_item.strip() for path_item in menu_path.split('>')] menu_path = [path_item for path_item in menu_path if path_item] if menu_path[0][0] != '_': menu_path[0] = '_' + menu_path[0] menu_item = Gtk.MenuItem.new_with_label(menu_path.pop()) self.signal_connect('activate', handler, gobject=menu_item) menu_bar = self.application.main_window.menu_bar.menubar gui_utilities.gtk_menu_insert_by_path(menu_bar, menu_path, menu_item) menu_item.show() self._widgets.append(menu_item) return menu_item
def add_menu_item(self, menu_path, handler): """ Add a new item into the main menu bar of the application. Menu items created through this method are automatically removed when the plugin is disabled. :param str menu_path: The path to the menu item, delimited with > characters. :param handler: The callback function to be connected to the new :py:class:`Gtk.MenuItem` instance's activate signal. :return: The newly created and added menu item. :rtype: :py:class:`Gtk.MenuItem` """ menu_path = [path_item.strip() for path_item in menu_path.split('>')] menu_path = [path_item for path_item in menu_path if path_item] if menu_path[0][0] != '_': menu_path[0] = '_' + menu_path[0] menu_item = Gtk.MenuItem.new_with_label(menu_path.pop()) self.signal_connect('activate', handler, gobject=menu_item) menu_bar = self.application.main_window.menu_bar.menubar gui_utilities.gtk_menu_insert_by_path(menu_bar, menu_path, menu_item) menu_item.show() self._widgets.append(menu_item) return menu_item
def _insert_menu_item(self, menu_path, menu_item): menu_bar = self.application.main_window.menu_bar.menubar gui_utilities.gtk_menu_insert_by_path(menu_bar, menu_path, menu_item) menu_item.show() self._widgets.append(menu_item) return menu_item
def _insert_menu_item(self, menu_path, menu_item): menu_bar = self.application.main_window.menu_bar.menubar gui_utilities.gtk_menu_insert_by_path(menu_bar, menu_path, menu_item) menu_item.show() self._widgets.append(menu_item) return menu_item