def _change_layout(self, radio_menu_item: Gtk.RadioMenuItem): if not self._reloading and radio_menu_item.get_active(): function_key = radio_menu_item.function_key event = UserEvent(time=Gtk.get_current_event_time()) event.parameters = [function_key] import pocoy.service as service service.call(self.monitors.setprimarylayout, event)
def create_tab_pos_menuitem(self): """Returns a menu to select which side of the notebook the tabs should be shown""" tab_pos_menu = Menu() tab_pos_menuitem = MenuItem.new_with_label(_('Position')) group = [] for pos in ('top', 'right', 'bottom', 'left'): menuitem = RadioMenuItem.new_with_mnemonic(group, _(pos.capitalize())) group = menuitem.get_group() menuitem.connect('toggled', self._on_tabs_pos_toggled, pos) menuitem.set_active(pos == self.notebook.get_tab_pos().value_nick) tab_pos_menu.append(menuitem) tab_pos_menuitem.set_submenu(tab_pos_menu) return tab_pos_menuitem
def build_menu_radio_list( value_list, callback, pref_value=None, suffix=None, show_notset=False, notset_label='∞', notset_lessthan=0, show_other=False, ): """Build a menu with radio menu items from a list and connect them to the callback. Params: value_list [list]: List of values to build into a menu. callback (function): The function to call when menu item is clicked. pref_value (int): A preferred value to insert into value_list suffix (str): Append a suffix the the menu items in value_list. show_notset (bool): Show the unlimited menu item. notset_label (str): The text for the unlimited menu item. notset_lessthan (int): Activates the unlimited menu item if pref_value is less than this. show_other (bool): Show the `Other` menu item. The pref_value is what you would like to test for the default active radio item. Returns: Menu: The menu radio """ menu = Menu() # Create menuitem to prevent unwanted toggled callback when creating menu. menuitem = RadioMenuItem() group = menuitem.get_group() if pref_value > -1 and pref_value not in value_list: value_list.pop() value_list.append(pref_value) for value in sorted(value_list): item_text = str(value) if suffix: item_text += ' ' + suffix menuitem = RadioMenuItem.new_with_label(group, item_text) if pref_value and value == pref_value: menuitem.set_active(True) if callback: menuitem.connect('toggled', callback) menu.append(menuitem) if show_notset: menuitem = RadioMenuItem.new_with_label(group, notset_label) menuitem.set_name('unlimited') if pref_value and pref_value < notset_lessthan: menuitem.set_active(True) menuitem.connect('toggled', callback) menu.append(menuitem) if show_other: menuitem = SeparatorMenuItem() menu.append(menuitem) menuitem = MenuItem.new_with_label(_('Other...')) menuitem.set_name('other') menuitem.connect('activate', callback) menu.append(menuitem) return menu
def _change_icon(self, radio_menu_item: Gtk.RadioMenuItem): if not self._reloading and radio_menu_item.get_active(): configurations.set_desktop_icon(radio_menu_item.icon_style) self.reload()