Example #1
0
class DiagramItemToolbox(object):
    def __init__(self, wTree, root):
        self.wTree = wTree
        self.root = root
        self.widget = Wrapbox()
        self.wTree.signal_autoconnect(self)

        action.manager.registerActionService(self)
        self.actionGroup = action.ActionGroup(action.manager, "toolbox", radioPrefix="toolbox-item")
        self.gtkActionGroup = self.actionGroup.createGtkActionGroup(self)
        for action_ in self.actionGroup.radioActions:
            if not action_.name.startswith("toolbox-item"):
                continue
            button = gtk.ToggleToolButton()
            gtkaction = self.gtkActionGroup.get_action(action_.name)
            gtkaction.connect_proxy(button)
            self.widget.add(button)

        # action.connectWidgetTree(self.actionGroup, self.wTree)

    @action.Action("toolbox-item-pointer", "pointer", icon="pointer")
    def item_pointer(self, target, context):
        diagram = self.root.getDiagram()
        view = self.root.views[diagram]

        view.tool = gaphasx.DefaultTool()

    @action.Action("toolbox-item-flow", "flow", icon="flow")
    def item_flow(self, target, context):
        diagram = self.root.getDiagram()
        view = self.root.views[diagram]

        def add():
            obj = concept.Flow()
            diagram.add(obj)
            return diagram.getItem(obj)

        view.tool = gaphas.tool.PlacementTool(add, gaphas.tool.HandleTool(), 0)

    @action.Action("toolbox-item-use", "use", icon="use")
    def item_use(self, target, context):
        diagram = self.root.getDiagram()
        view = self.root.views[diagram]

        def add():
            obj = concept.Use()
            diagram.add(obj)
            return diagram.getItem(obj)

        view.tool = gaphas.tool.PlacementTool(add, gaphas.tool.HandleTool(), 0)
Example #2
0
 def _construct(self, toolboxdef):
     shortcuts = self.shortcuts
     for title, items in toolboxdef:
         wrapbox = Wrapbox()
         for action_name, label, stock_id, shortcut in items:
             button = self.toolbox_button(action_name, stock_id)
             if label:
                 button.set_tooltip_text('%s (%s)' % (label, shortcut))
             self.buttons.append(button)
             wrapbox.add(button)
             button.show()
             shortcuts[shortcut] = action_name
         if title:
             wrapbox_dec = self.make_wrapbox_decorator(title, wrapbox)
             self.pack_start(wrapbox_dec, expand=False)
         else:
             self.pack_start(wrapbox, expand=False)
             wrapbox.show()
Example #3
0
    def __init__(self, wTree, root):
        self.wTree = wTree
        self.root = root
        self.widget = Wrapbox()
        self.wTree.signal_autoconnect(self)

        action.manager.registerActionService(self)
        self.actionGroup = action.ActionGroup(action.manager, "toolbox", radioPrefix="toolbox-item")
        self.gtkActionGroup = self.actionGroup.createGtkActionGroup(self)
        for action_ in self.actionGroup.radioActions:
            if not action_.name.startswith("toolbox-item"):
                continue
            button = gtk.ToggleToolButton()
            gtkaction = self.gtkActionGroup.get_action(action_.name)
            gtkaction.connect_proxy(button)
            self.widget.add(button)
Example #4
0
 def _construct(self, toolboxdef):
     shortcuts = self.shortcuts
     for title, items in toolboxdef:
         wrapbox = Wrapbox()
         for action_name, label, stock_id, shortcut in items:
             button = self.toolbox_button(action_name, stock_id)
             if label:
                 button.set_tooltip_text('%s (%s)' % (label, shortcut))
             self.buttons.append(button)
             wrapbox.add(button)
             button.show()
             shortcuts[shortcut] = action_name
         if title:
             wrapbox_dec = self.make_wrapbox_decorator(title, wrapbox)
             self.pack_start(wrapbox_dec, expand=False)
         else:
             self.pack_start(wrapbox, expand=False)
             wrapbox.show()