[Sugar-devel] [HELP] Shell port to GTK3+: Removing hardcoded styles-- facing issue

Manuel Quiñones manuq at laptop.org
Fri Aug 10 07:23:37 EDT 2012


Hi Kartik,

2012/8/10 Kartik Kumar <kartik.peri at gmail.com>:
> Hi,
>
> I am trying to close open items listed over here:
> http://wiki.sugarlabs.org/go/Features/GTK3/Shell

Great.

> -To Remove hardcoding styles from files like "aboutcomputer/view.py" by
> referring to http://wiki.sugarlabs.org/go/Features/GTK3/Theme.  I have
> created sugar-theme.css within "aboutcomputer" directory which is referring
> to CSS present at "sugar-artwork/gtk3/theme/gtk.css"

Just add styles in the sugar-artwork component,
sugar-artwork/gtk3/theme/gtk-widgets.css.em .

That is a template file that produces two css when you "make install"
the component.

If you want to add style to a particular widget (ie control panel) use
the gtype name.  In controlpanel/gui.py you will see:  __gtype_name__
= 'SugarControlPanel'

Then you can add rules to it.

> Then I made changes to aboutcomputer/view.py to load the CSS: (changes are
> highlighted in bold):
>
> from gettext import gettext as _
>
> #import GTK
>
> from sugar.graphics import style
>
> from jarabe import config
> from jarabe.controlpanel.sectionview import SectionView
>
> from gi.repository import GTK
>
>
> USE_LOCAL_CSS = True
>
> class AboutComputer(SectionView):
>     def __init__(self, model, alerts=None):
>         SectionView.__init__(self)
>
>         self._model = model
>
>         self.set_border_width(style.DEFAULT_SPACING * 2)
>         self.set_spacing(style.DEFAULT_SPACING)
>
>         self._group = GTK.SizeGroup(GTK.SIZE_GROUP_HORIZONTAL)
>
>         scrollwindow = GTK.ScrolledWindow()
>         scrollwindow.set_policy(GTK.POLICY_NEVER, GTK.POLICY_AUTOMATIC)
>         self.pack_start(scrollwindow, expand=True)
>         scrollwindow.show()
>
>         self._vbox = GTK.VBox()
>         scrollwindow.add_with_viewport(self._vbox)
>         self._vbox.show()
>
>         self._setup_identity()
>
>         self._setup_software()
>         self._setup_copyright()
>
>     if USE_LOCAL_CSS:
>         css_provider = GTK.CssProvider()
>         css_provcss_provider.load_from_path('sugar-theme.css')
>         context = GTK.StyleContext()
>         context.add_provider_for_screen(screen, css_provider,
>         GTK.STYLE_PROVIDER_PRIORITY_USER)
>
> Now when I view click on "My Computer" under "My Settings", I can see error
> in shell.log.
> The error is like :
>
> File
> "/home/kartik/Sugar_Build_Repo/sugar-build/install/lib/python2.7/site-packages/jarabe/controlpanel/gui.py",
> line 223, in show_section_view
>     globals(), locals(), ['view'])
>   File
> "/home/kartik/Sugar_Build_Repo/sugar-build/install/share/sugar/extensions/cpsection/aboutcomputer/view.py",
> line 28, in <module>
>     from gi.repository import GTK
>   File
> "/home/kartik/Sugar_Build_Repo/sugar-build/install/lib/python2.7/site-packages/gi/__init__.py",
> line 23, in <module>
>     from ._gi import _API, Repository
> ImportError: could not import gobject (error was: ImportError('When using
> gi.repository you must not import static modules like "gobject". Please
> change all occurrences of "import gobject" to "from gi.repository import
> GObject".',))
>
> I even tried to change the statement within
> /sugar-build/install/lib/python2.7/site-packages/gi/__init__.py
> from : import gi._gobject
> to this : from gi.repository import GObject
>
> But of no use. It is giving the same error.
> I am using Sugar 0.96
>
> Can anyone please provide pointers? Any help will be greatly appreciated :)
>
>
> Cheers!
> Kartik Perisetla
>
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>



-- 
.. manuq ..


More information about the Sugar-devel mailing list