Notebook class now use **kwargs to set properties
This commit is contained in:
parent
00e8348c73
commit
5d14daf44b
@ -29,23 +29,23 @@ class Notebook(gtk.Notebook):
|
|||||||
__gtype_name__ = 'SugarNotebook'
|
__gtype_name__ = 'SugarNotebook'
|
||||||
|
|
||||||
__gproperties__ = {
|
__gproperties__ = {
|
||||||
'can-close-tabs': (bool, None, None, True,
|
'can-close-tabs': (bool, None, None, False,
|
||||||
gobject.PARAM_READWRITE)
|
gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT_ONLY)
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, **kwargs):
|
||||||
"""Initialise the Widget
|
# Initialise the Widget
|
||||||
|
#
|
||||||
Side effects:
|
# Side effects:
|
||||||
Set False the 'can-close-tabs' property
|
# Set the 'can-close-tabs' property using **kwargs
|
||||||
Set True the scrollable notebook property
|
# Set True the scrollable notebook property
|
||||||
"""
|
|
||||||
|
gobject.GObject.__init__(self, **kwargs)
|
||||||
gtk.Notebook.__init__(self)
|
gtk.Notebook.__init__(self)
|
||||||
|
|
||||||
self._can_close_tabs = False
|
|
||||||
self.set_scrollable(True)
|
self.set_scrollable(True)
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def do_set_property(self, pspec, value):
|
def do_set_property(self, pspec, value):
|
||||||
if pspec.name == 'can-close-tabs':
|
if pspec.name == 'can-close-tabs':
|
||||||
self._can_close_tabs = value
|
self._can_close_tabs = value
|
||||||
@ -92,7 +92,7 @@ class Notebook(gtk.Notebook):
|
|||||||
return event_box
|
return event_box
|
||||||
|
|
||||||
def add_page(self, text_label, widget):
|
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:
|
if self._can_close_tabs:
|
||||||
eventbox = self._create_custom_tab(text_label, widget)
|
eventbox = self._create_custom_tab(text_label, widget)
|
||||||
self.append_page(widget, eventbox)
|
self.append_page(widget, eventbox)
|
||||||
@ -101,14 +101,14 @@ class Notebook(gtk.Notebook):
|
|||||||
|
|
||||||
pages = self.get_n_pages()
|
pages = self.get_n_pages()
|
||||||
|
|
||||||
""" Set the new page """
|
# Set the new page
|
||||||
self.set_current_page(pages - 1)
|
self.set_current_page(pages - 1)
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _close_page(self, button, child):
|
def _close_page(self, button, child):
|
||||||
""" Remove a page from the notebook """
|
# Remove a page from the notebook
|
||||||
page = self.page_num(child)
|
page = self.page_num(child)
|
||||||
|
|
||||||
if page != -1:
|
if page != -1:
|
||||||
|
@ -27,8 +27,7 @@ window.connect("destroy", lambda w: gtk.main_quit())
|
|||||||
window.set_size_request(800, 600)
|
window.set_size_request(800, 600)
|
||||||
window.show_all()
|
window.show_all()
|
||||||
|
|
||||||
nb = Notebook()
|
nb = Notebook(can_close_tabs=True)
|
||||||
nb.set_property('can-close-tabs', True)
|
|
||||||
|
|
||||||
window.add(nb)
|
window.add(nb)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user