Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2012-01-05 14:34:10 (GMT)
committer Simon Schampijer <simon@schampijer.de>2012-01-05 14:34:10 (GMT)
commitb92532a3e477406c92b1f76c1e47a323ca5e37e6 (patch)
treecc1d38b12471c8a54ce85848c10d36b91865906d
parent267b079d680688bca3d579f7ffb634fdc2172799 (diff)
Use gtk-notebook-action-widget for the 'add-tab' button
Due to API changes in the GTK Notebook [1] we can add now an action widget to it (e.g. a button to add a new tab). So far our 'add-new-tab'-button in Browse was another special tab. This does simplify the Browse code a lot by using the action widget instead. Yay! There will be a visual difference with this approach, the Button will always be at the far right, but this is acceptable - Safari uses the same style, with a button at the far right for adding a new tab (once a tab is open). [1] http://developer.gnome.org/gtk3/3.0/GtkNotebook.html#gtk-notebook-set-action-widget Signed-off-by: Simon Schampijer <simon@laptop.org> Acked-by: Manuel QuiƱones <manuq@laptop.org>
-rw-r--r--widgets.py30
1 files changed, 2 insertions, 28 deletions
diff --git a/widgets.py b/widgets.py
index 3cfdf1e..d1de3ee 100644
--- a/widgets.py
+++ b/widgets.py
@@ -59,37 +59,11 @@ class BrowserNotebook(Gtk.Notebook):
def __init__(self):
GObject.GObject.__init__(self)
- self._switch_handler = self.connect('switch-page',
- self.__on_switch_page)
tab_add = TabAdd()
tab_add.connect('tab-added', self.on_add_tab)
- empty_page = Gtk.HBox()
- self.append_page(empty_page, tab_add)
- empty_page.show()
+ self.set_action_widget(tab_add, Gtk.PackType.END)
+ tab_add.show()
def on_add_tab(self, obj):
raise NotImplementedError("implement this in the subclass")
-
- def __on_switch_page(self, notebook, page, page_num):
- """Don't switch to the extra tab at the end."""
- if page_num > 0 and page_num == Gtk.Notebook.get_n_pages(self) - 1:
- self.handler_block(self._switch_handler)
- self.set_current_page(-1)
- self.handler_unblock(self._switch_handler)
- self.connect('switch-page', self.__on_switch_page)
- self.stop_emission("switch-page")
-
- def get_n_pages(self):
- """Skip the extra tab at the end on the pages count."""
- return Gtk.Notebook.get_n_pages(self) - 1
-
- def append_page(self, page, label):
- """Append keeping the extra tab at the end."""
- return self.insert_page(page, label, self.get_n_pages())
-
- def set_current_page(self, number):
- """If indexing from the end, skip the extra tab."""
- if number < 0:
- number = self.get_n_pages() - 1
- Gtk.Notebook.set_current_page(self, number)