GNOME Bugzilla – Bug 735918
demo: revamp and modernize demo code
Last modified: 2017-12-06 16:45:43 UTC
The demo code is a bit out of date in terms of modern GTK+ style usage. We should revamp the demo to follow the newer HIG as well as clean things up. Some initial thoughts: * Move the pygobject/demos/gtk-demo to pygobject/demo since we only have one demo and it should be the launching app for any platform related demos we want to show. * Use better color scheme for Gtk.SourceView which takes into account dark themes. The default Gtk.SourceView has way too much contrast in terms of color scheme. "oblivion" and "kate" for dark and light respectively are much more reasonable. * Remove usage of deprecated APIs, specifically usage of stock id's need to be updated. * Use a HeaderBar for the main window. * Change the side panel TreeView to a ListBox * Use GMenuModel to at least show an about dialog for the demo. * Add demos for new widgets: Gtk.FlowBox, Gtk.ActionBar, Gtk.Revealer, Gtk.Popover, Gtk.Switch.
Created attachment 285195 [details] [review] demo: Rename demos/gtk-demo to simply demo Move the entire "pygobject/demos/gtk-demo" folder to "pygobject/demo". Since we only have a single demo app which should be used for all platform demos we can remove the diectory obfuscation.
Created attachment 285196 [details] [review] demo: Rename gtk-demo.py to demo.py Remove GTK+ specificity which also allows the demo app to be used as one of the demos itself.
Created attachment 285197 [details] [review] demo: PyFlakes and PEP8 fixes Since PyFlakes and PEP8 are not currently run on the demo due to it not being packaged, manually check and fix this for now.
Created attachment 285198 [details] [review] demo: Cleanup app title and application id Change demo application title to "PyGI Code Demos" and app id to "org.gnome.pygi.demo". Additionally remove __gtype_name__ since this is not needed.
Created attachment 285199 [details] [review] demo: Use different Gtk.SourceView color scheme Change color scheme based on 'gtk-application-prefer-dark-theme' using schemes with less contrast than the Gtk.SourceView defaults.
Created attachment 285200 [details] [review] demo: Use HeaderBar for main app window
Created attachment 285201 [details] [review] demo: Use main demo program as the first demo
Review of attachment 285200 [details] [review]: Note the StackSwitcher should eventually be centered over the main view which can be done in follow up patches.
Created attachment 285314 [details] [review] Add Gtk.FlowBox example Added a new example for the Gtk.FlowBox class added in GTK+ 3.12. This example already makes use of Gtk.HeaderBar.
(In reply to comment #1) > Created an attachment (id=285195) [details] [review] > demo: Rename demos/gtk-demo to simply demo Hi Simon, > Move the entire "pygobject/demos/gtk-demo" folder to "pygobject/demo". > Since we only have a single demo app which should be used for all > platform demos we can remove the diectory obfuscation. I wouldn't change this, what if in the near future we will add another demo such as the icon browser and/or the widget factory (or anything else)? We would have to move it again. I don't see the plural "demos" a big issue.
(In reply to comment #10) > (In reply to comment #1) > > Created an attachment (id=285195) [details] [review] [details] [review] > > demo: Rename demos/gtk-demo to simply demo > > Hi Simon, > > > Move the entire "pygobject/demos/gtk-demo" folder to "pygobject/demo". > > Since we only have a single demo app which should be used for all > > platform demos we can remove the diectory obfuscation. > > I wouldn't change this, what if in the near future we will add another demo > such as the icon browser and/or the widget factory (or anything else)? We would > have to move it again. Part of the idea here is our demo is a singular launch pad for anything we want to demo (anything in the GNOME-platform not just specific to GTK+), which in this case would include the icon browser or widget factory. Do you see a problem with this idea? > I don't see the plural "demos" a big issue. We already have the plurality underneath gtk-demo, so it just seemed like overkill to have demos/gtk-demo/demos. The other part of this was preliminary work on packaging the demo as an installable bin. So perhaps pygobject/demo is actually wrong and it should be pygobject/gidemo or pygobject/gi/demo: pygobject/bin/pygi-demo # executable shim for the Python app pygobject/gi/demo # what gets imported by the executable shim
An additional idea for the singular demo launcher idea is we can add a filter/search feature to the hierarchy panel. So I can then search for "headerbar" and only demos which include the case insensitive text (in the code and description) would show up in the left panel.
Notes from pbor: <pbor> sfeltman: please not the kate scheme :-) <pbor> it is there just for historical reasons I'd either go classic on white and oblivion on dark or solarized and solarized dark if you want to look fancy Classic on white and oblivion on dark seems fine. My main gripe is default dark is basically unreadable in terms of the blue comments (at least on my monitory). Solarized looks interesting as well though.
Created attachment 285551 [details] [review] demo: Add new Gtk.FlowBox example Added a new example for the Gtk.FlowBox class added in GTK+ 3.12. This example additionally makes use of Gtk.HeaderBar.
Review of attachment 285551 [details] [review]: The usage of a DrawingArea and Button are just too slow for this demo. I've simplified it by limiting the swatch to a single Label with text. I think it's important we don't leave people with the impression that pygi is slow.
(In reply to comment #15) > Review of attachment 285551 [details] [review]: > > The usage of a DrawingArea and Button are just too slow for this demo. I've > simplified it by limiting the swatch to a single Label with text. I think it's On my hardware the usage of Button and Drawing area is pretty fast, I haven't noticed a sloppy performance. > important we don't leave people with the impression that pygi is slow. Sure that makes sense, everybody likes to blame python :)
(In reply to comment #11) > this case would include the icon browser or widget factory. Do you see a > problem with this idea? Probably I was just focusing on replicating the same structure that GTK+ has, not a big deal after all. > The other part of this was preliminary work on packaging the demo as an > installable bin. So perhaps pygobject/demo is actually wrong and it should be > pygobject/gidemo or pygobject/gi/demo: > > pygobject/bin/pygi-demo # executable shim for the Python app > pygobject/gi/demo # what gets imported by the executable shim Shipping the demo code is for sure a good idea, a lot of people are not aware that this code even exist.
Comment on attachment 285198 [details] [review] demo: Cleanup app title and application id Imo we are stuck with "pygobject" now. Adding pygi to pygobject/gi adds just one more name and potential confusion. Since that is the main change here, dropping this.
Comment on attachment 285199 [details] [review] demo: Use different Gtk.SourceView color scheme This seems like a rare corner case as the default is not to prefer dark.
Comment on attachment 285201 [details] [review] demo: Use main demo program as the first demo I don't think the demo code is a good example.
I went ahead and pushed most of this before it bit rots. Hope that's OK. If there are any other ideas for improving/adding demos or pursuing an installed version of this I think it's best if that gets handled in separate/new bug reports.