A good setting to demonstrate one-way binding is the View/Toolbar
setting. When the menu item is switched on or off, we want to update the
setting, but not the other way around. This is so that when you have
multiple windows, turning the toolbar off in one doesn't turn the
toolbar off in the others, but when you open a new window, the toolbar
is shown or hidden depending on the last choice you made.
aboutwindow = GTK_WIDGET(load_object("aboutwindow"));
prefswindow = GTK_WIDGET(load_object("prefswindow"));
GtkActionGroup *actiongroup = GTK_ACTION_GROUP(load_object("actiongroup"));
aboutwindow = GTK_WIDGET(load_object("aboutwindow"));
prefswindow = GTK_WIDGET(load_object("prefswindow"));
GtkActionGroup *actiongroup = GTK_ACTION_GROUP(load_object("actiongroup"));
+
+ /* Set the default value of the "View/Toolbar" menu item upon creation of a
+ new window to the "show-toolbar-default" setting, but bind the setting
+ one-way only - we don't want toolbars to disappear suddenly */
GtkToggleAction *toolbar_action = GTK_TOGGLE_ACTION(load_object("toolbar"));
GtkToggleAction *toolbar_action = GTK_TOGGLE_ACTION(load_object("toolbar"));
+ gtk_toggle_action_set_active(toolbar_action, g_settings_get_boolean(state_settings, "show-toolbar-default"));
+ g_settings_bind(state_settings, "show-toolbar-default", toolbar_action, "active", G_SETTINGS_BIND_SET);
const gchar **ptr;
GtkRecentFilter *filter = gtk_recent_filter_new();
const gchar **ptr;
GtkRecentFilter *filter = gtk_recent_filter_new();
+ <key name="show-toolbar-default" type="b">
+ <default>true</default>
+ <summary>Show toolbar by default</summary>
+ <description>
+ Whether to show or hide the toolbar by default in new game windows.
+ </description>
+ </key>
+
</schema>
</schemalist>
\ No newline at end of file
</schema>
</schemalist>
\ No newline at end of file