static GActionEntry win_entries[] = {
{ "titlebar", activate_toggle, NULL, "false", change_titlebar_state },
- { "color", activate_radio, "s", "'red'", change_radio_state },
{ "shape", activate_radio, "s", "'oval'", change_radio_state },
{ "bold", activate_toggle, NULL, "false", NULL },
{ "about", activate_about, NULL, NULL, NULL },
main (int argc, char *argv[])
{
GtkApplication *app;
+ GSettings *settings;
+ GAction *action;
gtk_init (NULL, NULL);
register_stock_icons ();
app = gtk_application_new ("org.gtk.Demo", 0);
+ settings = g_settings_new ("org.gtk.Demo");
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
+ action = g_settings_create_action (settings, "color");
+
+ g_action_map_add_action (G_ACTION_MAP (app), action);
+
g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
<item label="_Hide Titlebar when maximized" action="win.titlebar"/>
<submenu label="_Color">
<section>
- <item label="_Red" action="win.color" target="red" accel="<Primary>r"/>
- <item label="_Green" action="win.color" target="green" accel="<Primary>g"/>
- <item label="_Blue" action="win.color" target="blue" accel="<Primary>b"/>
+ <item label="_Red" action="app.color" target="red" accel="<Primary>r"/>
+ <item label="_Green" action="app.color" target="green" accel="<Primary>g"/>
+ <item label="_Blue" action="app.color" target="blue" accel="<Primary>b"/>
</section>
</submenu>
<submenu label="_Shape">
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<schemalist>
+
+ <enum id='org.gtk.Demo.Color'>
+ <value nick='red' value='0'/>
+ <value nick='green' value='1'/>
+ <value nick='blue' value='2'/>
+ </enum>
+
+ <schema id='org.gtk.Demo' path='/org/gtk/Demo/'>
+ <key name='color' enum='org.gtk.Demo.Color'>
+ <default>'red'</default>
+ </key>
+ </schema>
+
+</schemalist>