Beispiel #1
0
    def _update(self):
        if self.history is None:
            return

        for button in self.get_children()[2:]:
            self.remove(button)
        self._selected = None

        paths = self.get_paths()
        for path, label in zip(paths, shortest_unique_names(paths)):
            button = gtk.ToggleButton(label=label)
            button.set_use_underline(False)
            button.zim_path = path
            button.connect('clicked', self.on_button_clicked)
            button.connect('popup-menu', self.on_button_popup_menu)
            button.connect('button-release-event',
                           self.do_button_release_event)
            button.connect('drag-data-get', self.on_drag_data_get)
            button.drag_source_set(gtk.gdk.BUTTON1_MASK,
                                   (INTERNAL_PAGELIST_TARGET, ),
                                   gtk.gdk.ACTION_LINK)
            button.show()
            self.add(button)

        # FIXME tooltips seem not to work - not sure why
        if gtk.gtk_version >= (2, 12) \
        and gtk.pygtk_version >= (2, 12):
            for button in self.get_children()[2:]:
                button.set_tooltip_text(button.zim_path.name)
        else:
            tooltips = gtk.Tooltips()
            for button in self.get_children()[2:]:
                tooltips.set_tip(button, button.zim_path.name)
Beispiel #2
0
 def runTest(self):
     from zim.notebook.page import shortest_unique_names
     paths = [
         Path('Test'),
         Path('Foo'),
         Path('2017:03:01'),
         Path('2018:03:01'),
         Path('2018:02:01'),
         Path('Foo:Bar'),
         Path('Dus:Foo')
     ]
     wanted = [
         'Test', 'Foo', '2017:03:01', '2018:03:01', '02:01', 'Bar',
         'Dus:Foo'
     ]
     self.assertEqual(shortest_unique_names(paths), wanted)
Beispiel #3
0
    def _update(self):
        for button in self.get_children()[2:]:
            self.remove(button)
        self._selected = None

        paths = list(self.get_paths())
        for path, label in zip(paths, shortest_unique_names(paths)):
            button = Gtk.ToggleButton(label=path.basename)
            button.set_use_underline(False)
            button.zim_path = path
            button.connect('clicked', self.on_button_clicked)
            button.connect('popup-menu', self.on_button_popup_menu)
            button.connect('button-release-event',
                           self.do_button_release_event)
            button.connect('drag-data-get', self.on_drag_data_get)
            button.drag_source_set(
                Gdk.ModifierType.BUTTON1_MASK,
                (Gtk.TargetEntry.new(*INTERNAL_PAGELIST_TARGET), ),
                Gdk.DragAction.LINK)
            button.show()
            self.add(button)

        for button in self.get_children()[2:]:
            button.set_tooltip_text(button.zim_path.name)
Beispiel #4
0
    def _update(self, *a):
        for button in self.get_scrolled_children():
            self.remove(button)

        paths = list(self.get_paths())
        for path, label in zip(paths, shortest_unique_names(paths)):
            button = Gtk.ToggleButton(label=label, use_underline=False)
            button.set_tooltip_text(path.name)
            button.get_child().set_ellipsize(Pango.EllipsizeMode.MIDDLE)
            button.zim_path = path
            button.connect('clicked', self.on_button_clicked)
            button.connect('popup-menu', self.on_button_popup_menu)
            button.connect('button-release-event',
                           self.on_button_release_event)
            button.connect('drag-data-get', self.on_drag_data_get)
            button.drag_source_set(
                Gdk.ModifierType.BUTTON1_MASK,
                (Gtk.TargetEntry.new(*INTERNAL_PAGELIST_TARGET), ),
                Gdk.DragAction.LINK)
            button.show_all()
            self.add(button)

        if self.page is not None:
            self._select(self.page)