GNOME Bugzilla – Bug 742664
Portabilitiy issues with GTK-Inspector 32-bit and non-gnome3 desktop
Last modified: 2015-01-11 19:08:05 UTC
Created attachment 294175 [details] Fake org.gnome.desktop.interface.gschema.xml - during initialization the GTK-Inspector spits a lot of g_warnings, like Gtk-WARNING **: gtktreestore.c:1042: Invalid column number 58682896 added to iter (remember to end your list of columns with a -1) These are due to size mismatch between resource-list .c and .ui of GtkTreeStore::model::column[3] as guint64 vs gsize in code. - due to the unforgiveness of GSettings API the following code g_error(s): settings = g_settings_new ("org.gnome.desktop.interface"); current_theme = g_settings_get_string (settings, "gtk-theme"); without a compiled org.gnome.desktop.interface.gschema.xml file. That code is from gtk/inspector/visual.c. IMHO the best fix would be a redesign of GSettings API to make all those g_error superfluous (or at least much less probable). As a kludge I'm attaching the minimal settings file I've used.
Created attachment 294176 [details] Screenshow of GTK-Inspector with win32 theme To create the atached screenshot I hacked on part of Gtk+ 3.16 Roadmap, namely "Include icon theme in builds for other platforms". But that's stuff for another bug report.
(In reply to comment #0) > - due to the unforgiveness of GSettings API the following code g_error(s): > > settings = g_settings_new ("org.gnome.desktop.interface"); > current_theme = g_settings_get_string (settings, "gtk-theme"); > > without a compiled org.gnome.desktop.interface.gschema.xml file. That code > is from gtk/inspector/visual.c. > > IMHO the best fix would be a redesign of GSettings API to make all those > g_error superfluous (or at least much less probable). no, that would not be the best fix at all; and no, it won't happen. there is API enough in GSettings to discover if a schema is available, and if not, ignore the setting. > As a kludge I'm attaching the minimal settings file I've used. the actual fix would be to not get that string out of GSettings on !G_OS_UNIX; alternatively, use GSettingsSchemaSource to check if the "org.gnome.desktop.interface" schema exists, and if it does not, use GtkSettings:gtk-theme-name instead of the GSettings value.
(In reply to comment #2) > the actual fix would be to not get that string out of GSettings on !G_OS_UNIX; So with G_OS_UNIX it's OK to g_error() with missing schema? > alternatively, use GSettingsSchemaSource to check if the > "org.gnome.desktop.interface" schema exists, and if it does not, use > GtkSettings:gtk-theme-name instead of the GSettings value. So if "org.gnome.desktop.interface" exists it _must_ contain 'monospace-font-name', 'gtk-theme' and 'icon-theme'? I was looking for something like g_settings_has_key() but could not find anything like that. So for now I'll use the kludge mentioned above.
(In reply to comment #3) > (In reply to comment #2) > > the actual fix would be to not get that string out of GSettings on !G_OS_UNIX; > So with G_OS_UNIX it's OK to g_error() with missing schema? yes, because there's an expectation of settings being properly installed. > > alternatively, use GSettingsSchemaSource to check if the > > "org.gnome.desktop.interface" schema exists, and if it does not, use > > GtkSettings:gtk-theme-name instead of the GSettings value. > So if "org.gnome.desktop.interface" exists it _must_ contain > 'monospace-font-name', 'gtk-theme' and 'icon-theme'? yes: https://git.gnome.org/browse/gsettings-desktop-schemas/tree/schemas/org.gnome.desktop.interface.gschema.xml.in.in > I was looking for something like g_settings_has_key() but could not find > anything like that. So for now I'll use the kludge mentioned above. or you could install gsettings-desktop-schemas instead.
(In reply to comment #4) > or you could install gsettings-desktop-schemas instead. Which kind of contradicts portability (or cross-platform-ness), wouldn't it? Things like "cursor-blink-timeout" or "toolbar-icons-size" could be got from the real systems desktop settings, not from some compiled Gnome defaults. Meanwhile this bug is closed as fixed, but I wonder how that could happen without any code change in resource-list.c. Or is some push to origin/gtk-3-14 still pending?
Something like: diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c index 44fb34c..ce0d966 100644 --- a/gtk/inspector/resource-list.c +++ b/gtk/inspector/resource-list.c @@ -99,7 +99,7 @@ load_resources_recurse (GtkInspectorResourceList *sl, gtk_tree_store_set (sl->priv->model, &iter, COLUMN_COUNT, count, - COLUMN_SIZE, size, + COLUMN_SIZE, (guint64)size, -1); *count_out += count; *size_out += size;
(In reply to comment #5) > (In reply to comment #4) > > or you could install gsettings-desktop-schemas instead. > Which kind of contradicts portability (or cross-platform-ness), wouldn't it? > Things like "cursor-blink-timeout" or "toolbar-icons-size" could be got from > the real systems desktop settings, not from some compiled Gnome defaults. the existence of the default in the schema does not reflect whether those settings get updated using the system's API or not. the schemas only define the type and default value of a setting.
the issue has been fixed in Git: https://git.gnome.org/browse/gtk+/commit/?id=6384167054307ce7af249e40e47973d4761d97ab inspector: Don't use GSettings directly It is not necessary here, and using GtkSettings gives us a greater chance to not fail e.g. on Windows. https://bugzilla.gnome.org/show_bug.cgi?id=742664 it will be backported to 3.14 once a new release of 3.14 is due.
Thanks for the fast responses, but this is still not fixing the pure 32-bit portability issue from comment 1 and comment 6. The Gtk-WARNING **: gtktreestore.c:1042: Invalid column number 58682896 added to iter (remember to end your list of columns with a -1) is also visible on Linux Mint. Only condtion AFAICT sizeof(gsize)<sizeof(guin64).
(In reply to comment #9) > Thanks for the fast responses, but this is still not fixing the pure 32-bit > portability issue from comment 1 and comment 6. The > > Gtk-WARNING **: gtktreestore.c:1042: Invalid column number > 58682896 added to iter (remember to end your list of columns with a -1) > > is also visible on Linux Mint. Only condtion AFAICT > sizeof(gsize)<sizeof(guin64). let's clone this bug and track the other issue separately.
Looking at the patch and my settings file there is still the same issue with monospace-font-name (inspector/css-editor.c). Overall there are more unconditional g_settings_get_*() calls, namely in gtkfilechooserwidget.c(settings_load) and gtkcolorchooserwidget.c(gtk_color_chooser_widget_init). But maybe I misinterpret Matthias' commit log "Don't use GSettings directly" ;) But at least these other two are using g_settings_new ("org.gtk.*") settings.
there is nothing wrong in principle with using gsettings on windows. the calls in gtk/* are using schemas that are shipped with GTK+. The ones I removed in gtk/inspector/* are a little different, because we can't really guarantee the presence of gnome schemas on windows.