From 5d14daf44bae7795994a9a88b5a5458c1f106575 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 9 May 2007 14:38:38 -0400 Subject: [PATCH] Notebook class now use **kwargs to set properties --- sugar/graphics/notebook.py | 28 ++++++++++++++-------------- tests/test-notebook.py | 3 +-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/sugar/graphics/notebook.py b/sugar/graphics/notebook.py index 062b6f19..832bf7ad 100644 --- a/sugar/graphics/notebook.py +++ b/sugar/graphics/notebook.py @@ -29,23 +29,23 @@ class Notebook(gtk.Notebook): __gtype_name__ = 'SugarNotebook' __gproperties__ = { - 'can-close-tabs': (bool, None, None, True, - gobject.PARAM_READWRITE) + 'can-close-tabs': (bool, None, None, False, + gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT_ONLY) } - def __init__(self): - """Initialise the Widget - - Side effects: - Set False the 'can-close-tabs' property - Set True the scrollable notebook property - """ + def __init__(self, **kwargs): + # Initialise the Widget + # + # Side effects: + # Set the 'can-close-tabs' property using **kwargs + # Set True the scrollable notebook property + + gobject.GObject.__init__(self, **kwargs) gtk.Notebook.__init__(self) - self._can_close_tabs = False self.set_scrollable(True) self.show() - + def do_set_property(self, pspec, value): if pspec.name == 'can-close-tabs': self._can_close_tabs = value @@ -92,7 +92,7 @@ class Notebook(gtk.Notebook): return event_box def add_page(self, text_label, widget): - """ Add a new page to the notebook """ + # Add a new page to the notebook if self._can_close_tabs: eventbox = self._create_custom_tab(text_label, widget) self.append_page(widget, eventbox) @@ -101,14 +101,14 @@ class Notebook(gtk.Notebook): pages = self.get_n_pages() - """ Set the new page """ + # Set the new page self.set_current_page(pages - 1) self.show_all() return True def _close_page(self, button, child): - """ Remove a page from the notebook """ + # Remove a page from the notebook page = self.page_num(child) if page != -1: diff --git a/tests/test-notebook.py b/tests/test-notebook.py index fe90de8c..262b38ea 100755 --- a/tests/test-notebook.py +++ b/tests/test-notebook.py @@ -27,8 +27,7 @@ window.connect("destroy", lambda w: gtk.main_quit()) window.set_size_request(800, 600) window.show_all() -nb = Notebook() -nb.set_property('can-close-tabs', True) +nb = Notebook(can_close_tabs=True) window.add(nb)