[Sugar-devel] [PATCH browse] Make the LinkInfo that is displayed at the bottom left themable

Simon Schampijer simon at schampijer.de
Fri Mar 16 05:25:52 EDT 2012


Add a gtype_name to make it easily accessible from the theme. We have
to do the same for the overlay as well in order to be able to
set the 'background-color' of the label. Labels don't create their own
window to render themselves into. Instead, they draw themselves
directly onto their parents window, so we have to set the background-color
of the parent in order to set the labels' background color [1].

The patch does adjust the gtype_names to be consistent.

[1] http://developer.gnome.org/gtk-faq/stable/x810.html

Signed-off-by: Simon Schampijer <simon at schampijer.de>
---
 browser.py |   17 +++++++++++++----
 widgets.py |    4 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/browser.py b/browser.py
index 5dea721..0886580 100644
--- a/browser.py
+++ b/browser.py
@@ -286,7 +286,18 @@ Gtk.rc_parse_string('''
     widget "*browse-tab-close" style "browse-tab-close"''')
 
 
+class LinkInfo(Gtk.Label):
+    __gtype_name__ = 'BrowseLinkInfo'
+
+    def __init__(self):
+        GObject.GObject.__init__(self)
+        self.set_halign(Gtk.Align.START)
+        self.set_valign(Gtk.Align.END)
+
+
 class TabPage(Gtk.Overlay):
+    __gtype_name__ = 'BrowseTabPage'
+
     def __init__(self, browser):
         GObject.GObject.__init__(self)
 
@@ -294,9 +305,7 @@ class TabPage(Gtk.Overlay):
         self._showing_load_status = False
         self._requested_uri = None
 
-        link_info = Gtk.Label()
-        link_info.set_halign(Gtk.Align.START)
-        link_info.set_valign(Gtk.Align.END)
+        link_info = LinkInfo()
         self.add_overlay(link_info)
         link_info.show()
 
@@ -351,7 +360,7 @@ class TabPage(Gtk.Overlay):
 
 
 class TabLabel(Gtk.HBox):
-    __gtype_name__ = 'TabLabel'
+    __gtype_name__ = 'BrowseTabLabel'
 
     __gsignals__ = {
         'tab-close': (GObject.SignalFlags.RUN_FIRST,
diff --git a/widgets.py b/widgets.py
index d1de3ee..df5bdb0 100644
--- a/widgets.py
+++ b/widgets.py
@@ -23,7 +23,7 @@ from sugar3.graphics.icon import Icon
 
 
 class TabAdd(Gtk.HBox):
-    __gtype_name__ = 'TabAdd'
+    __gtype_name__ = 'BrowseTabAdd'
 
     __gsignals__ = {
         'tab-added': (GObject.SignalFlags.RUN_FIRST,
@@ -53,7 +53,7 @@ class TabAdd(Gtk.HBox):
 
 
 class BrowserNotebook(Gtk.Notebook):
-    __gtype_name__ = 'BrowserNotebook'
+    __gtype_name__ = 'BrowseNotebook'
 
     """Handle an extra tab at the end with an Add Tab button."""
 
-- 
1.7.7.6



More information about the Sugar-devel mailing list