def make_check_action(self, action, check_group, label, groups, shortcuts): gtk_action = gtk.ToggleAction(action, label, None, None) self.actions[action] = gtk_action callback = menus.lookup_handler(gtk_action.get_name()) if callback is not None: gtk_action.connect("toggled", self.on_activate, callback) if check_group not in self.check_groups: self.check_groups[check_group] = list() self.check_groups[check_group].append(gtk_action) self.action_groups[groups[0]].add_action(gtk_action)
def handleMenuItem_(self, sender): action = sender.representedObject() if action == "PresentActualSize": self.present_movie('natural-size') elif action == "PresentDoubleSize": self.present_movie('double-size') elif action == "PresentHalfSize": self.present_movie('half-size') elif action == "ShowMain": app.widgetapp.window.nswindow.makeKeyAndOrderFront_(sender) else: handler = menus.lookup_handler(action) if handler is not None: handler() else: logging.warn("No handler for %s" % action)
def setup_action(self, gtk_action, groups, shortcuts): callback = menus.lookup_handler(gtk_action.get_name()) if callback is not None: gtk_action.connect("activate", self.on_activate, callback) action_group_name = groups[0] action_group = self.action_groups[action_group_name] if shortcuts is None or len(shortcuts) == 0: action_group.add_action(gtk_action) else: action_group.add_action_with_accel(gtk_action, get_accel_string(shortcuts[0])) for shortcut in shortcuts[1:]: shortcut_name = gtk_action.get_name() + str(id(shortcut)) extra_action = gtk.Action(shortcut_name, None, None, None) extra_action.set_visible(False) if callback is not None: extra_action.connect('activate', self.on_activate, callback) action_group.add_action_with_accel(extra_action, get_accel_string(shortcut))
def setup_action(self, gtk_action, groups, shortcuts): action_name = gtk_action.get_name() self.actions[action_name] = gtk_action callback = menus.lookup_handler(action_name) if callback is not None: gtk_action.connect("activate", self.on_activate, callback) action_group_name = groups[0] action_group = self.action_groups[action_group_name] if shortcuts is None or len(shortcuts) == 0: action_group.add_action(gtk_action) else: action_group.add_action_with_accel(gtk_action, get_accel_string(shortcuts[0])) for shortcut in shortcuts[1:]: shortcut_name = gtk_action.get_name() + str(id(shortcut)) extra_action = gtk.Action(shortcut_name, None, None, None) extra_action.set_visible(False) if callback is not None: extra_action.connect('activate', self.on_activate, callback) action_group.add_action_with_accel(extra_action, get_accel_string(shortcut))