<p>Hi, regarding the task of removal of hardcoded styles, I have done few changes:</p>
<p>* imported Gtk, Gdk and Gobject<br>
* repalaced gtk with Gtk<br>
* referring to CSS 'gtk-widgets-100.css' within css_provider's load_from_file method. I assume 'gtk-widgets-100.css' is generated by the 'gtk-widgets.css.em' (Please correct me if I am wrong here)</p>
<p>I would like to understand- How shell is applying styles loaded using css_provider in the gtk3 example here : <a href="http://wiki.sugarlabs.org/go/Features/GTK3/Theme">http://wiki.sugarlabs.org/go/Features/GTK3/Theme</a> since 'context' isn't used anywhere with gtk widgets?</p>
<p>Am I heading in the right direction? Feedback is appreciated!</p>
<p>Please let me know for any concern.</p>
<p>Signed-off-by: Kartik Perisetla <<a href="mailto:kartik.peri@gmail.com">kartik.peri@gmail.com</a>><br>
---<br>
extensions/cpsection/aboutcomputer/view.py | 97 ++++++++++++++++------------<br>
1 file changed, 55 insertions(+), 42 deletions(-)</p>
<p>diff --git a/extensions/cpsection/aboutcomputer/view.py b/extensions/cpsection/aboutcomputer/view.py<br>
index 6d59102..b565263 100644<br>
--- a/extensions/cpsection/aboutcomputer/view.py<br>
+++ b/extensions/cpsection/aboutcomputer/view.py<br>
@@ -18,13 +18,16 @@</p>
<p> from gettext import gettext as _</p>
<p>-import gtk<br>
-<br>
from sugar.graphics import style</p>
<p> from jarabe import config<br>
from jarabe.controlpanel.sectionview import SectionView</p>
<p>+from gi.repository import Gtk<br>
+from gi.repository import Gdk<br>
+from gi.repository import GObject<br>
+<br>
+USE_LOCAL_CSS = True</p>
<p> class AboutComputer(SectionView):<br>
def __init__(self, model, alerts=None):<br>
@@ -35,14 +38,14 @@ class AboutComputer(SectionView):<br>
self.set_border_width(style.DEFAULT_SPACING * 2)<br>
self.set_spacing(style.DEFAULT_SPACING)</p>
<p>- self._group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)<br>
+ self._group = Gtk.SizeGroup(Gtk.SIZE_GROUP_HORIZONTAL)</p>
<p>- scrollwindow = gtk.ScrolledWindow()<br>
- scrollwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)<br>
+ scrollwindow = Gtk.ScrolledWindow()<br>
+ scrollwindow.set_policy(Gtk.POLICY_NEVER, Gtk.POLICY_AUTOMATIC)<br>
self.pack_start(scrollwindow, expand=True)<br>
scrollwindow.show()</p>
<p>- self._vbox = gtk.VBox()<br>
+ self._vbox = Gtk.VBox()<br>
scrollwindow.add_with_viewport(self._vbox)<br>
self._vbox.show()</p>
<p>@@ -50,29 +53,39 @@ class AboutComputer(SectionView):</p>
<p> self._setup_software()<br>
self._setup_copyright()<br>
+<br>
+ screen = Gdk.Screen.get_default()<br>
+ if USE_LOCAL_CSS:<br>
+ css_provider = Gtk.CssProvider()<br>
+ css_provider.load_from_path('gtk-widgets-100.css')<br>
+<br>
+ context = Gtk.StyleContext()<br>
+ context.add_provider_for_screen(screen, css_provider,<br>
+ Gtk.STYLE_PROVIDER_PRIORITY_USER)<br>
+</p>
<p> def _setup_identity(self):<br>
- separator_identity = gtk.HSeparator()<br>
+ separator_identity = Gtk.HSeparator()<br>
self._vbox.pack_start(separator_identity, expand=False)<br>
separator_identity.show()</p>
<p>- label_identity = gtk.Label(_('Identity'))<br>
+ label_identity = Gtk.Label(_('Identity'))<br>
label_identity.set_alignment(0, 0)<br>
self._vbox.pack_start(label_identity, expand=False)<br>
label_identity.show()<br>
- vbox_identity = gtk.VBox()<br>
+ vbox_identity = Gtk.VBox()<br>
vbox_identity.set_border_width(style.DEFAULT_SPACING * 2)<br>
vbox_identity.set_spacing(style.DEFAULT_SPACING)</p>
<p>- box_identity = gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
- label_serial = gtk.Label(_('Serial Number:'))<br>
+ box_identity = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
+ label_serial = Gtk.Label(_('Serial Number:'))<br>
label_serial.set_alignment(1, 0)<br>
- label_serial.modify_fg(gtk.STATE_NORMAL,<br>
- style.COLOR_SELECTION_GREY.get_gdk_color())<br>
+ #label_serial.modify_fg(Gtk.STATE_NORMAL,@selection_grey)<br>
+<br>
box_identity.pack_start(label_serial, expand=False)<br>
self._group.add_widget(label_serial)<br>
label_serial.show()<br>
- label_serial_no = gtk.Label(self._model.get_serial_number())<br>
+ label_serial_no = Gtk.Label(self._model.get_serial_number())<br>
label_serial_no.set_alignment(0, 0)<br>
box_identity.pack_start(label_serial_no, expand=False)<br>
label_serial_no.show()<br>
@@ -83,73 +96,73 @@ class AboutComputer(SectionView):<br>
vbox_identity.show()</p>
<p> def _setup_software(self):<br>
- separator_software = gtk.HSeparator()<br>
+ separator_software = Gtk.HSeparator()<br>
self._vbox.pack_start(separator_software, expand=False)<br>
separator_software.show()</p>
<p>- label_software = gtk.Label(_('Software'))<br>
+ label_software = Gtk.Label(_('Software'))<br>
label_software.set_alignment(0, 0)<br>
self._vbox.pack_start(label_software, expand=False)<br>
label_software.show()<br>
- box_software = gtk.VBox()<br>
+ box_software = Gtk.VBox()<br>
box_software.set_border_width(style.DEFAULT_SPACING * 2)<br>
box_software.set_spacing(style.DEFAULT_SPACING)</p>
<p>- box_build = gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
- label_build = gtk.Label(_('Build:'))<br>
+ box_build = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
+ label_build = Gtk.Label(_('Build:'))<br>
label_build.set_alignment(1, 0)<br>
- label_build.modify_fg(gtk.STATE_NORMAL,<br>
+ label_build.modify_fg(Gtk.STATE_NORMAL,<br>
style.COLOR_SELECTION_GREY.get_gdk_color())<br>
box_build.pack_start(label_build, expand=False)<br>
self._group.add_widget(label_build)<br>
label_build.show()<br>
- label_build_no = gtk.Label(self._model.get_build_number())<br>
+ label_build_no = Gtk.Label(self._model.get_build_number())<br>
label_build_no.set_alignment(0, 0)<br>
box_build.pack_start(label_build_no, expand=False)<br>
label_build_no.show()<br>
box_software.pack_start(box_build, expand=False)<br>
box_build.show()</p>
<p>- box_sugar = gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
- label_sugar = gtk.Label(_('Sugar:'))<br>
+ box_sugar = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
+ label_sugar = Gtk.Label(_('Sugar:'))<br>
label_sugar.set_alignment(1, 0)<br>
- label_sugar.modify_fg(gtk.STATE_NORMAL,<br>
+ label_sugar.modify_fg(Gtk.STATE_NORMAL,<br>
style.COLOR_SELECTION_GREY.get_gdk_color())<br>
box_sugar.pack_start(label_sugar, expand=False)<br>
self._group.add_widget(label_sugar)<br>
label_sugar.show()<br>
- label_sugar_ver = gtk.Label(config.version)<br>
+ label_sugar_ver = Gtk.Label(config.version)<br>
label_sugar_ver.set_alignment(0, 0)<br>
box_sugar.pack_start(label_sugar_ver, expand=False)<br>
label_sugar_ver.show()<br>
box_software.pack_start(box_sugar, expand=False)<br>
box_sugar.show()</p>
<p>- box_firmware = gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
- label_firmware = gtk.Label(_('Firmware:'))<br>
+ box_firmware = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
+ label_firmware = Gtk.Label(_('Firmware:'))<br>
label_firmware.set_alignment(1, 0)<br>
- label_firmware.modify_fg(gtk.STATE_NORMAL,<br>
+ label_firmware.modify_fg(Gtk.STATE_NORMAL,<br>
style.COLOR_SELECTION_GREY.get_gdk_color())<br>
box_firmware.pack_start(label_firmware, expand=False)<br>
self._group.add_widget(label_firmware)<br>
label_firmware.show()<br>
- label_firmware_no = gtk.Label(self._model.get_firmware_number())<br>
+ label_firmware_no = Gtk.Label(self._model.get_firmware_number())<br>
label_firmware_no.set_alignment(0, 0)<br>
box_firmware.pack_start(label_firmware_no, expand=False)<br>
label_firmware_no.show()<br>
box_software.pack_start(box_firmware, expand=False)<br>
box_firmware.show()</p>
<p>- box_wireless_fw = gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
- label_wireless_fw = gtk.Label(_('Wireless Firmware:'))<br>
+ box_wireless_fw = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
+ label_wireless_fw = Gtk.Label(_('Wireless Firmware:'))<br>
label_wireless_fw.set_alignment(1, 0)<br>
- label_wireless_fw.modify_fg(gtk.STATE_NORMAL,<br>
+ label_wireless_fw.modify_fg(Gtk.STATE_NORMAL,<br>
style.COLOR_SELECTION_GREY.get_gdk_color())<br>
box_wireless_fw.pack_start(label_wireless_fw, expand=False)<br>
self._group.add_widget(label_wireless_fw)<br>
label_wireless_fw.show()<br>
wireless_fw_no = self._model.get_wireless_firmware()<br>
- label_wireless_fw_no = gtk.Label(wireless_fw_no)<br>
+ label_wireless_fw_no = Gtk.Label(wireless_fw_no)<br>
label_wireless_fw_no.set_alignment(0, 0)<br>
box_wireless_fw.pack_start(label_wireless_fw_no, expand=False)<br>
label_wireless_fw_no.show()<br>
@@ -160,24 +173,24 @@ class AboutComputer(SectionView):<br>
box_software.show()</p>
<p> def _setup_copyright(self):<br>
- separator_copyright = gtk.HSeparator()<br>
+ separator_copyright = Gtk.HSeparator()<br>
self._vbox.pack_start(separator_copyright, expand=False)<br>
separator_copyright.show()</p>
<p>- label_copyright = gtk.Label(_('Copyright and License'))<br>
+ label_copyright = Gtk.Label(_('Copyright and License'))<br>
label_copyright.set_alignment(0, 0)<br>
self._vbox.pack_start(label_copyright, expand=False)<br>
label_copyright.show()<br>
- vbox_copyright = gtk.VBox()<br>
+ vbox_copyright = Gtk.VBox()<br>
vbox_copyright.set_border_width(style.DEFAULT_SPACING * 2)<br>
vbox_copyright.set_spacing(style.DEFAULT_SPACING)</p>
<p> copyright_text = '© 2006-2012 One Laptop per Child Association Inc,' \<br>
' Sugar Labs Inc, Red Hat Inc, Collabora Ltd and' \<br>
' Contributors.'<br>
- label_copyright = gtk.Label(copyright_text)<br>
+ label_copyright = Gtk.Label(copyright_text)<br>
label_copyright.set_alignment(0, 0)<br>
- label_copyright.set_size_request(gtk.gdk.screen_width() / 2, -1)<br>
+ label_copyright.set_size_request(Gtk.gdk.screen_width() / 2, -1)<br>
label_copyright.set_line_wrap(True)<br>
label_copyright.show()<br>
vbox_copyright.pack_start(label_copyright, expand=False)<br>
@@ -187,14 +200,14 @@ class AboutComputer(SectionView):<br>
' GNU General Public License, and you are welcome to'<br>
' change it and/or distribute copies of it under'<br>
' certain conditions described therein.')<br>
- label_info = gtk.Label(info_text)<br>
+ label_info = Gtk.Label(info_text)<br>
label_info.set_alignment(0, 0)<br>
label_info.set_line_wrap(True)<br>
- label_info.set_size_request(gtk.gdk.screen_width() / 2, -1)<br>
+ label_info.set_size_request(Gtk.gdk.screen_width() / 2, -1)<br>
label_info.show()<br>
vbox_copyright.pack_start(label_info, expand=False)</p>
<p>- expander = gtk.Expander(_('Full license:'))<br>
+ expander = Gtk.Expander(_('Full license:'))<br>
expander.connect('notify::expanded', self.license_expander_cb)<br>
expander.show()<br>
vbox_copyright.pack_start(expander, expand=True)<br>
@@ -206,7 +219,7 @@ class AboutComputer(SectionView):<br>
# load/destroy the license viewer on-demand, to avoid storing the<br>
# GPL in memory at all times<br>
if expander.get_expanded():<br>
- view_license = gtk.TextView()<br>
+ view_license = Gtk.TextView()<br>
view_license.set_editable(False)<br>
view_license.get_buffer().set_text(self._model.get_license())<br>
view_license.show()<br>
--<br>
1.7.10.4</p>