Ejemplo n.º 1
0
    def test_scroll_adjustments_signal(self):
        def handler(self, hadj, vadj):
            self.handled = True

        sc = gtk.ScrolledWindow()
        view = GtkView(Canvas())
        view.connect('set-scroll-adjustments', handler)
        sc.add(view)

        assert view.handled
Ejemplo n.º 2
0
    def test_scroll_adjustments_signal(self):
        def handler(self, hadj, vadj):
            self.handled = True

        sc = gtk.ScrolledWindow()
        view = GtkView(Canvas())
        view.connect('set-scroll-adjustments', handler)
        sc.add(view)

        assert view.handled
Ejemplo n.º 3
0
    def construct(self):
        """
        Create the widget.
        
        Returns: the newly created widget, a DockItem.
        """
        assert self.diagram

        view = GtkView(canvas=self.diagram.canvas)
        view.drag_dest_set(gtk.DEST_DEFAULT_MOTION, DiagramTab.VIEW_DND_TARGETS,
                           gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_LINK)

        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolled_window.set_shadow_type(gtk.SHADOW_IN)
        scrolled_window.add(view)
        scrolled_window.show_all()

        view.connect('focus-changed', self._on_view_selection_changed)
        view.connect('selection-changed', self._on_view_selection_changed)
        view.connect_after('key-press-event', self._on_key_press_event)
        view.connect('drag-drop', self._on_drag_drop)
        view.connect('drag-data-received', self._on_drag_data_received)

        self.view = view
        
        self.toolbox = DiagramToolbox(self.diagram, view)
        
        item = DockItem(title=self.title, stock_id='gaphor-diagram')
        item.add(scrolled_window)

        self.widget = item

        return item
Ejemplo n.º 4
0
    def construct(self):
        """
        Create the widget.
        
        Returns: the newly created widget, a DockItem.
        """
        assert self.diagram

        view = GtkView(canvas=self.diagram.canvas)
        view.drag_dest_set(gtk.DEST_DEFAULT_MOTION, DiagramTab.VIEW_DND_TARGETS,
                           gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_LINK)

        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolled_window.set_shadow_type(gtk.SHADOW_IN)
        scrolled_window.add(view)
        scrolled_window.show_all()

        view.connect('focus-changed', self._on_view_selection_changed)
        view.connect('selection-changed', self._on_view_selection_changed)
        view.connect_after('key-press-event', self._on_key_press_event)
        view.connect('drag-drop', self._on_drag_drop)
        view.connect('drag-data-received', self._on_drag_data_received)

        self.view = view
        
        self.toolbox = DiagramToolbox(self.diagram, view)
        
        item = DockItem(title=self.title, stock_id='gaphor-diagram')
        item.add(scrolled_window)

        self.widget = item

        return item
Ejemplo n.º 5
0
    def construct(self):
        """Create the widget.

        Returns: the newly created widget.
        """
        assert self.diagram

        view = GtkView(model=self.diagram, selection=Selection())
        view.drag_dest_set(
            Gtk.DestDefaults.ALL,
            DiagramPage.VIEW_DND_TARGETS,
            Gdk.DragAction.MOVE | Gdk.DragAction.COPY | Gdk.DragAction.LINK,
        )
        self.diagram_css = Gtk.CssProvider.new()
        view.get_style_context().add_provider(self.diagram_css,
                                              Gtk.STYLE_PROVIDER_PRIORITY_USER)

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
        scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
        scrolled_window.add(view)
        scrolled_window.show_all()
        self.widget = scrolled_window

        view.selection.add_handler(self._on_view_selection_changed)
        view.connect("drag-data-received", self._on_drag_data_received)

        self.view = view

        self.widget.action_group = create_action_group(self, "diagram")

        self.select_tool("toolbox-pointer")

        self.set_drawing_style()

        return self.widget
Ejemplo n.º 6
0
    def construct(self):
        """
        Create the widget.

        Returns: the newly created widget.
        """
        assert self.diagram

        view = GtkView(canvas=self.diagram.canvas)
        try:
            view.set_css_name("diagramview")
        except AttributeError:
            pass  # Gtk.Widget.set_css_name() is added in 3.20
        view.drag_dest_set(
            Gtk.DestDefaults.ALL,
            DiagramPage.VIEW_DND_TARGETS,
            Gdk.DragAction.MOVE | Gdk.DragAction.COPY | Gdk.DragAction.LINK,
        )

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
        scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
        scrolled_window.add(view)
        scrolled_window.show_all()
        self.widget = scrolled_window

        view.connect("focus-changed", self._on_view_selection_changed)
        view.connect("selection-changed", self._on_view_selection_changed)
        view.connect_after("key-press-event", self._on_key_press_event)
        view.connect("drag-data-received", self._on_drag_data_received)

        self.view = view

        self.widget.action_group = create_action_group(self, "diagram")

        shortcuts = self.get_toolbox_shortcuts()

        def shortcut_action(widget, event):
            action_name = shortcuts.get((event.keyval, event.state))
            if action_name:
                widget.get_toplevel().get_action_group(
                    "diagram").lookup_action("select-tool").change_state(
                        GLib.Variant.new_string(action_name))

        self.widget.connect("key-press-event", shortcut_action)
        self._on_sloppy_lines()
        self.select_tool("toolbox-pointer")

        self.set_drawing_style(self.properties.get("diagram.sloppiness", 0))

        return self.widget
Ejemplo n.º 7
0
    def construct(self):
        """
        Create the widget.

        Returns: the newly created widget.
        """
        assert self.diagram

        view = GtkView(canvas=self.diagram.canvas)
        try:
            view.set_css_name("diagramview")
        except AttributeError:
            pass  # Gtk.Widget.set_css_name() is added in 3.20
        view.drag_dest_set(
            Gtk.DestDefaults.ALL,
            DiagramPage.VIEW_DND_TARGETS,
            Gdk.DragAction.MOVE | Gdk.DragAction.COPY | Gdk.DragAction.LINK,
        )

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
        scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
        scrolled_window.add(view)
        scrolled_window.show_all()
        self.widget = scrolled_window

        view.connect("focus-changed", self._on_view_selection_changed)
        view.connect("selection-changed", self._on_view_selection_changed)
        view.connect_after("key-press-event", self._on_key_press_event)
        # view.connect("drag-drop", self._on_drag_drop)
        view.connect("drag-data-received", self._on_drag_data_received)

        self.view = view

        self.toolbox = DiagramToolbox(
            self.diagram,
            view,
            self.element_factory,
            self.event_manager,
            self.properties,
        )

        return self.widget
Ejemplo n.º 8
0
    def construct(self):
        """
        Create the widget.

        Returns: the newly created widget.
        """
        assert self.diagram

        view = GtkView(canvas=self.diagram.canvas)
        try:
            view.set_css_name("diagramview")
        except AttributeError:
            pass  # Gtk.Widget.set_css_name() is added in 3.20
        view.drag_dest_set(
            Gtk.DestDefaults.ALL,
            DiagramPage.VIEW_DND_TARGETS,
            Gdk.DragAction.MOVE | Gdk.DragAction.COPY | Gdk.DragAction.LINK,
        )

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
        scrolled_window.add(view)
        scrolled_window.show_all()
        self.widget = scrolled_window

        view.connect("focus-changed", self._on_view_selection_changed)
        view.connect("selection-changed", self._on_view_selection_changed)
        view.connect_after("key-press-event", self._on_key_press_event)
        # view.connect("drag-drop", self._on_drag_drop)
        view.connect("drag-data-received", self._on_drag_data_received)

        self.view = view

        self.toolbox = DiagramToolbox(self.diagram, view)

        return self.widget