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
def create_item(self, ui_component): #, widget, title, placement=None): """ Create an item for a ui component. This method can be called from UIComponents. """ item = DockItem(ui_component.title) item.add(ui_component.open()) group = DockGroup() group.insert_item(item) placement = ui_component.placement if placement: if placement == 'floating': add_new_group_floating(group, self.layout, ui_component.size) else: location = self.layout.get_widgets(placement[1])[0] { 'left': add_new_group_left, 'right': add_new_group_right, 'above': add_new_group_above, 'below': add_new_group_below }[placement[0]](location, group) else: add_new_group_floating(group) item.show() item.ui_component = ui_component group.show()
def setup_items(one_other, n_items): if one_other == 'one': index = 0 else: index = world.item_index + 1 for n in range(int(n_items)): button = gtk.Button() item = DockItem(icon_name='file', title='Item %s' % n, title_tooltip_text='') item.add(button) item.show() world.groups[index].add(item) world.item_index = index
def dock_item_factory(parent, title, tooltip, icon_name=None, stock_id=None, pos=None, vispos=None, current=None, name=None): item = DockItem(_(title), _(tooltip), icon_name, stock_id) if name: item.set_name(name) if pos: pos = int(pos) if vispos: vispos = int(vispos) parent.insert_item(item, pos, vispos) item.show() return item