def _get_container(self, actions, horiz = True): "return Gtk container with the specified actions or None for no actions" if not actions: return None #print "ACTIONS:", actions if len(actions) > 1: bar = gtk.Toolbar() if horiz: bar.set_orientation(gtk.ORIENTATION_HORIZONTAL) else: bar.set_orientation(gtk.ORIENTATION_VERTICAL) bar.set_style(gtk.TOOLBAR_BOTH) # disable overflow menu to get toolbar sized correctly for panels bar.set_show_arrow(False) bar.set_tooltips(True) else: bar = None tooltips = gtk.Tooltips() for action in actions: #print action offset = action.find("=") if offset >= 0: # handle "<name>=<keycode>" action specification name = action[:offset] text = action[offset+1:] (widget, tip) = self._create_key_control(name, text) widget.set_tooltip(tooltips, "Insert " + tip) elif action == "|": widget = gtk.SeparatorToolItem() elif action == "close": if bar: widget = create_toolbutton(gtk.STOCK_CLOSE, self._close_cb) else: widget = create_button("Close", self._close_cb) else: widget = self.actions.get_action(action).create_tool_item() if not widget: continue if bar: if action != "|": widget.set_expand(True) bar.insert(widget, -1) if bar: return bar return widget
def _get_container(self, actions, horiz = True): "return Gtk container with the specified actions or None for no actions" if not actions: return None #print("ACTIONS:", actions) if len(actions) > 1: bar = gtk.Toolbar() if horiz: bar.set_orientation(gtk.ORIENTATION_HORIZONTAL) else: bar.set_orientation(gtk.ORIENTATION_VERTICAL) bar.set_style(gtk.TOOLBAR_BOTH) # disable overflow menu to get toolbar sized correctly for panels bar.set_show_arrow(False) else: bar = None for action in actions: #print(action) offset = action.find("=") if offset >= 0: # handle "<name>=<keycode>" action specification name = action[:offset] text = action[offset+1:] widget = self._create_key_control(name, text) elif action == "|": widget = gtk.SeparatorToolItem() elif action == "close": if bar: widget = create_toolbutton(gtk.STOCK_CLOSE, self._close_cb) else: widget = create_button("Close", self._close_cb) else: widget = self.actions.get_action(action).create_tool_item() if not widget: continue if bar: if action != "|": widget.set_expand(True) bar.insert(widget, -1) if bar: return bar return widget