static void config_constructed (GObject *object) { GSettings *settings; (G_OBJECT_CLASS (tracker_config_parent_class)->constructed) (object); settings = G_SETTINGS (object); if (G_LIKELY (!g_getenv ("TRACKER_USE_CONFIG_FILES"))) { g_settings_delay (settings); } /* Set up bindings: * * What's interesting here is that 'verbosity' and * 'initial-sleep' are command line arguments that can be * overridden, so we don't update the config when we set them * from main() because it's a session configuration only, not * a permanent one. To do this we use the flag * G_SETTINGS_BIND_GET_NO_CHANGES. * * For the other settings, we don't bind the * G_SETTINGS_BIND_SET because we don't want to save anything, * ever, we only want to know about updates to the settings as * they're changed externally. The only time this may be * different is where we use the environment variable * TRACKER_USE_CONFIG_FILES and we want to write a config * file for convenience. But this is only necessary if the * config is different to the default. */ g_settings_bind (settings, "verbosity", object, "verbosity", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_GET_NO_CHANGES); g_settings_bind (settings, "graphupdated-delay", object, "graphupdated-delay", G_SETTINGS_BIND_GET); }
static void terminal_profile_save (TerminalProfile *profile) { TerminalProfilePrivate *priv = profile->priv; GSettings *changeset; GSList *l; priv->save_idle_id = 0; changeset = g_settings_new_with_path (CONF_PROFILE_SCHEMA, g_strconcat (CONF_PROFILE_PREFIX, priv->profile_dir,"/", NULL)); g_settings_delay (changeset); for (l = priv->dirty_pspecs; l != NULL; l = l->next) { GParamSpec *pspec = (GParamSpec *) l->data; if (pspec->owner_type != TERMINAL_TYPE_PROFILE) continue; if ((pspec->flags & G_PARAM_WRITABLE) == 0) continue; terminal_profile_gsettings_changeset_add (profile, changeset, pspec); } g_slist_free (priv->dirty_pspecs); priv->dirty_pspecs = NULL; g_settings_apply (changeset); g_object_unref (changeset); }
void gkbd_indicator_config_save (GkbdIndicatorConfig * ind_config) { g_settings_delay (ind_config->settings); g_settings_set_int (ind_config->settings, GKBD_INDICATOR_CONFIG_KEY_SECONDARIES, ind_config->secondary_groups_mask); g_settings_set_boolean (ind_config->settings, GKBD_INDICATOR_CONFIG_KEY_SHOW_FLAGS, ind_config->show_flags); g_settings_apply (ind_config->settings); }
static void cc_background_panel_init (CcBackgroundPanel *self) { CcBackgroundPanelPrivate *priv; gchar *objects[] = {"background-panel", NULL }; GError *err = NULL; GtkWidget *widget; priv = self->priv = BACKGROUND_PANEL_PRIVATE (self); priv->builder = gtk_builder_new (); priv->connection = g_application_get_dbus_connection (g_application_get_default ()); gtk_builder_add_objects_from_file (priv->builder, UIDIR"/background.ui", objects, &err); if (err) { g_warning ("Could not load ui: %s", err->message); g_error_free (err); return; } priv->settings = g_settings_new (WP_PATH_ID); g_settings_delay (priv->settings); /* add the top level widget */ widget = WID ("background-panel"); gtk_container_add (GTK_CONTAINER (self), widget); gtk_widget_show_all (GTK_WIDGET (self)); /* setup preview area */ widget = WID ("background-desktop-drawingarea"); g_signal_connect (widget, "draw", G_CALLBACK (on_preview_draw), self); priv->copy_cancellable = g_cancellable_new (); priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); reload_current_bg (self); update_preview (priv, NULL); g_signal_connect (priv->settings, "changed", G_CALLBACK (on_settings_changed), self); widget = WID ("background-set-button"); g_signal_connect (widget, "clicked", G_CALLBACK (on_background_button_clicked), self); }
static void config_constructed (GObject *object) { TrackerConfigFile *config_file; (G_OBJECT_CLASS (tracker_config_parent_class)->constructed) (object); g_settings_delay (G_SETTINGS (object)); /* Migrate keyfile-based configuration */ config_file = tracker_config_file_new (); if (config_file) { tracker_config_file_migrate (config_file, G_SETTINGS (object), migration); g_object_unref (config_file); } }
static gboolean wp_props_wp_set (AppearanceData *data, MateWPItem *item) { gchar *pcolor, *scolor; g_settings_delay (data->wp_settings); if (!strcmp (item->filename, "(none)")) { g_settings_set_string (data->wp_settings, WP_OPTIONS_KEY, "none"); g_settings_set_string (data->wp_settings, WP_FILE_KEY, ""); } else { gchar *uri; if (g_utf8_validate (item->filename, -1, NULL)) uri = g_strdup (item->filename); else uri = g_filename_to_utf8 (item->filename, -1, NULL, NULL, NULL); if (uri == NULL) { g_warning ("Failed to convert filename to UTF-8: %s", item->filename); } else { g_settings_set_string (data->wp_settings, WP_FILE_KEY, uri); g_free (uri); } g_settings_set_enum (data->wp_settings, WP_OPTIONS_KEY, item->options); } g_settings_set_enum (data->wp_settings, WP_SHADING_KEY, item->shade_type); pcolor = gdk_color_to_string (item->pcolor); scolor = gdk_color_to_string (item->scolor); g_settings_set_string (data->wp_settings, WP_PCOLOR_KEY, pcolor); g_settings_set_string (data->wp_settings, WP_SCOLOR_KEY, scolor); g_free (pcolor); g_free (scolor); g_settings_apply (data->wp_settings); return FALSE; }
/** * games_settings_bind_window_state: * @path: a valid #GSettings path * @window: a #GtkWindow * * Restore the window configuration, and persist changes to the window configuration: * window width and height, and maximised and fullscreen state. * @window must not be realised yet. * * To make sure the state is saved at exit, g_settings_sync() must be called. */ void games_settings_bind_window_state (const char *path, GtkWindow *window) { WindowState *state; int width, height; gboolean maximised, fullscreen; g_return_if_fail (GTK_IS_WINDOW (window)); g_return_if_fail (!gtk_widget_get_realized (GTK_WIDGET (window))); state = g_slice_new0 (WindowState); state->window = window; state->settings = g_settings_new_with_path (SCHEMA_NAME, path); /* We delay storing the state until exit */ g_settings_delay (state->settings); g_object_set_data_full (G_OBJECT (window), "GamesSettings::WindowState", state, (GDestroyNotify) free_window_state); g_signal_connect (window, "configure-event", G_CALLBACK (window_configure_event_cb), state); g_signal_connect (window, "window-state-event", G_CALLBACK (window_state_event_cb), state); maximised = g_settings_get_boolean (state->settings, STATE_KEY_MAXIMIZED); fullscreen = g_settings_get_boolean (state->settings, STATE_KEY_FULLSCREEN); width = g_settings_get_int (state->settings, STATE_KEY_WIDTH); height = g_settings_get_int (state->settings, STATE_KEY_HEIGHT); if (width > 0 && height > 0) { gtk_window_set_default_size (GTK_WINDOW (window), width, height); } if (maximised) { gtk_window_maximize (GTK_WINDOW (window)); } if (fullscreen) { gtk_window_fullscreen (GTK_WINDOW (window)); } }
static gboolean sync_idle_cb (gpointer data) { GSettings *changeset; _terminal_debug_print (TERMINAL_DEBUG_ACCELS, "GSettings sync handler\n"); sync_idle_id = 0; changeset = g_settings_new (CONF_KEYS_SCHEMA); g_settings_delay (changeset); g_hash_table_foreach (gsettings_key_to_entry, (GHFunc) add_key_entry_to_changeset, changeset); g_settings_apply(changeset); g_object_unref (changeset); return FALSE; }
static GSettings * get_system_settings (void) { GSettings *settings; gchar **keys; gchar **k; /* FIXME: we need to bind system settings instead of user but * that's currently impossible, not implemented yet. * Hence, reset to system default values. */ /* TODO: Ideally we would like to bind some other key, screensaver-specific. */ settings = g_settings_new ("org.gnome.desktop.background"); g_settings_delay (settings); keys = g_settings_list_keys (settings); for (k = keys; *k; k++) { g_settings_reset (settings, *k); } g_strfreev (keys); return settings; }
void setup_input_tabs (GtkBuilder *builder, GisKeyboardPage *page) { GtkWidget *treeview; GtkTreeViewColumn *column; GtkCellRenderer *cell; GtkListStore *store; GtkTreeSelection *selection; /* set up the list of active inputs */ treeview = WID("active_input_sources"); column = gtk_tree_view_column_new (); cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, TRUE); gtk_tree_view_column_add_attribute (column, cell, "text", NAME_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DESKTOP_APP_INFO); gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store)); input_sources_settings = g_settings_new (GNOME_DESKTOP_INPUT_SOURCES_DIR); g_settings_delay (input_sources_settings); g_object_weak_ref (G_OBJECT (builder), (GWeakNotify) g_object_unref, input_sources_settings); if (!xkb_info) xkb_info = gnome_xkb_info_new (); #ifdef HAVE_IBUS ibus_init (); if (!ibus) { ibus = ibus_bus_new_async (); if (ibus_bus_is_connected (ibus)) fetch_ibus_engines (builder); else g_signal_connect_swapped (ibus, "connected", G_CALLBACK (fetch_ibus_engines), builder); g_object_weak_ref (G_OBJECT (builder), (GWeakNotify) clear_ibus, NULL); } maybe_start_ibus (); #endif populate_with_active_sources (store); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); g_signal_connect_swapped (selection, "changed", G_CALLBACK (update_button_sensitivity), builder); /* set up the buttons */ g_signal_connect (WID("input_source_add"), "clicked", G_CALLBACK (add_input), builder); g_signal_connect (WID("input_source_remove"), "clicked", G_CALLBACK (remove_selected_input), builder); g_signal_connect (WID("input_source_move_up"), "clicked", G_CALLBACK (move_selected_input_up), builder); g_signal_connect (WID("input_source_move_down"), "clicked", G_CALLBACK (move_selected_input_down), builder); g_signal_connect (WID("input_source_show"), "clicked", G_CALLBACK (show_selected_layout), builder); g_signal_connect (WID("input_source_settings"), "clicked", G_CALLBACK (show_selected_settings), builder); /* use an em dash is no shortcut */ update_shortcuts (builder); /* g_signal_connect (WID("jump-to-shortcuts"), "activate-link", G_CALLBACK (go_to_shortcuts), page);*/ g_signal_connect (G_OBJECT (input_sources_settings), "changed::" KEY_INPUT_SOURCES, G_CALLBACK (input_sources_changed), builder); }
static void cc_background_panel_init (CcBackgroundPanel *self) { CcBackgroundPanelPrivate *priv; gchar *objects[] = { "style-liststore", "sources-liststore", "background-panel", "sizegroup", NULL }; GError *err = NULL; GtkWidget *widget; GtkListStore *store; GtkStyleContext *context; priv = self->priv = BACKGROUND_PANEL_PRIVATE (self); priv->builder = gtk_builder_new (); gtk_builder_add_objects_from_file (priv->builder, DATADIR"/background.ui", objects, &err); if (err) { g_warning ("Could not load ui: %s", err->message); g_error_free (err); return; } /* See shell_notify_cb for details */ g_signal_connect (WID ("scrolledwindow1"), "realize", G_CALLBACK (scrolled_realize_cb), self); priv->settings = g_settings_new (WP_PATH_ID); g_settings_delay (priv->settings); store = (GtkListStore*) gtk_builder_get_object (priv->builder, "sources-liststore"); priv->wallpapers_source = bg_wallpapers_source_new (); gtk_list_store_insert_with_values (store, NULL, G_MAXINT, COL_SOURCE_NAME, _("Wallpapers"), COL_SOURCE_TYPE, SOURCE_WALLPAPERS, COL_SOURCE, priv->wallpapers_source, -1); priv->pictures_source = bg_pictures_source_new (); gtk_list_store_insert_with_values (store, NULL, G_MAXINT, COL_SOURCE_NAME, _("Pictures Folder"), COL_SOURCE_TYPE, SOURCE_PICTURES, COL_SOURCE, priv->pictures_source, -1); priv->colors_source = bg_colors_source_new (); gtk_list_store_insert_with_values (store, NULL, G_MAXINT, COL_SOURCE_NAME, _("Colors & Gradients"), COL_SOURCE_TYPE, SOURCE_COLORS, COL_SOURCE, priv->colors_source, -1); #ifdef HAVE_LIBSOCIALWEB priv->flickr_source = bg_flickr_source_new (); gtk_list_store_insert_with_values (store, NULL, G_MAXINT, COL_SOURCE_NAME, _("Flickr"), COL_SOURCE_TYPE, SOURCE_FLICKR, COL_SOURCE, priv->flickr_source, -1); #endif /* add the top level widget */ widget = WID ("background-panel"); gtk_container_add (GTK_CONTAINER (self), widget); gtk_widget_show_all (GTK_WIDGET (self)); /* connect to source change signal */ widget = WID ("sources-combobox"); g_signal_connect (widget, "changed", G_CALLBACK (source_changed_cb), priv); /* select first item */ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); /* connect to the background iconview change signal */ widget = WID ("backgrounds-iconview"); g_signal_connect (widget, "selection-changed", G_CALLBACK (backgrounds_changed_cb), self); /* Join treeview and buttons */ widget = WID ("scrolledwindow1"); context = gtk_widget_get_style_context (widget); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); widget = WID ("toolbar1"); context = gtk_widget_get_style_context (widget); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); g_signal_connect (WID ("add_button"), "clicked", G_CALLBACK (add_button_clicked), self); g_signal_connect (WID ("remove_button"), "clicked", G_CALLBACK (remove_button_clicked), self); /* Add drag and drop support for bg images */ widget = WID ("scrolledwindow1"); gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY); gtk_drag_dest_add_uri_targets (widget); g_signal_connect (widget, "drag-data-received", G_CALLBACK (cc_background_panel_drag_uris), self); /* setup preview area */ gtk_label_set_ellipsize (GTK_LABEL (WID ("background-label")), PANGO_ELLIPSIZE_END); widget = WID ("preview-area"); g_signal_connect (widget, "draw", G_CALLBACK (preview_draw_cb), self); priv->display_base = gdk_pixbuf_new_from_file (DATADIR "/display-base.png", NULL); priv->display_overlay = gdk_pixbuf_new_from_file (DATADIR "/display-overlay.png", NULL); g_signal_connect (WID ("style-combobox"), "changed", G_CALLBACK (style_changed_cb), self); g_signal_connect (WID ("style-pcolor"), "color-set", G_CALLBACK (color_changed_cb), self); g_signal_connect (WID ("style-scolor"), "color-set", G_CALLBACK (color_changed_cb), self); g_signal_connect (WID ("swap-color-button"), "clicked", G_CALLBACK (swap_colors_clicked), self); priv->copy_cancellable = g_cancellable_new (); priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); load_current_bg (self); update_preview (priv, NULL); /* Setup the edit box with our current settings */ source_update_edit_box (priv, TRUE); }
static gboolean handle_file (const gchar *filename) { GKeyFile *keyfile; MateConfClient *client; MateConfValue *value; gint i, j; gchar *mateconf_key; gchar **groups; gchar **keys; GVariantBuilder *builder; GVariant *v; const gchar *s; gchar *str; gint ii; GSList *list, *l; GSettings *settings; GError *error; keyfile = g_key_file_new (); error = NULL; if (!g_key_file_load_from_file (keyfile, filename, 0, &error)) { g_printerr ("%s\n", error->message); g_error_free (error); g_key_file_free (keyfile); return FALSE; } client = mateconf_client_get_default (); groups = g_key_file_get_groups (keyfile, NULL); for (i = 0; groups[i]; i++) { gchar **schema_path; schema_path = g_strsplit (groups[i], ":", 2); if (verbose) { g_print ("collecting settings for schema '%s'\n", schema_path[0]); if (schema_path[1]) g_print ("for storage at '%s'\n", schema_path[1]); } if (schema_path[1] != NULL) settings = g_settings_new_with_path (schema_path[0], schema_path[1]); else settings = g_settings_new (schema_path[0]); g_settings_delay (settings); error = NULL; if ((keys = g_key_file_get_keys (keyfile, groups[i], NULL, &error)) == NULL) { g_printerr ("%s", error->message); g_error_free (error); continue; } for (j = 0; keys[j]; j++) { if (strchr (keys[j], '/') != 0) { g_printerr ("Key '%s' contains a '/'\n", keys[j]); continue; } error = NULL; if ((mateconf_key = g_key_file_get_string (keyfile, groups[i], keys[j], &error)) == NULL) { g_printerr ("%s", error->message); g_error_free (error); continue; } error = NULL; if ((value = mateconf_client_get_without_default (client, mateconf_key, &error)) == NULL) { if (error) { g_printerr ("Failed to get MateConf key '%s': %s\n", mateconf_key, error->message); g_error_free (error); } else { if (verbose) g_print ("Skipping MateConf key '%s', no user value\n", mateconf_key); } g_free (mateconf_key); continue; } switch (value->type) { case MATECONF_VALUE_STRING: if (dry_run) g_print ("set key '%s' to string '%s'\n", keys[j], mateconf_value_get_string (value)); else g_settings_set (settings, keys[j], "s", mateconf_value_get_string (value)); break; case MATECONF_VALUE_INT: if (dry_run) g_print ("set key '%s' to integer '%d'\n", keys[j], mateconf_value_get_int (value)); else g_settings_set (settings, keys[j], "i", mateconf_value_get_int (value)); break; case MATECONF_VALUE_BOOL: if (dry_run) g_print ("set key '%s' to boolean '%d'\n", keys[j], mateconf_value_get_bool (value)); else g_settings_set (settings, keys[j], "b", mateconf_value_get_bool (value)); break; case MATECONF_VALUE_FLOAT: if (dry_run) g_print ("set key '%s' to double '%g'\n", keys[j], mateconf_value_get_float (value)); else g_settings_set (settings, keys[j], "d", mateconf_value_get_float (value)); break; case MATECONF_VALUE_LIST: switch (mateconf_value_get_list_type (value)) { case MATECONF_VALUE_STRING: builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY); list = mateconf_value_get_list (value); if (list != NULL) { for (l = list; l; l = l->next) { MateConfValue *lv = l->data; s = mateconf_value_get_string (lv); g_variant_builder_add (builder, "s", s); } v = g_variant_new ("as", builder); } else v = g_variant_new_array (G_VARIANT_TYPE_STRING, NULL, 0); g_variant_ref_sink (v); if (dry_run) { str = g_variant_print (v, FALSE); g_print ("set key '%s' to a list of strings: %s\n", keys[j], str); g_free (str); } else g_settings_set_value (settings, keys[j], v); g_variant_unref (v); g_variant_builder_unref (builder); break; case MATECONF_VALUE_INT: builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY); list = mateconf_value_get_list (value); if (list != NULL) { for (l = list; l; l = l->next) { MateConfValue *lv = l->data; ii = mateconf_value_get_int (lv); g_variant_builder_add (builder, "i", ii); } v = g_variant_new ("ai", builder); } else v = g_variant_new_array (G_VARIANT_TYPE_INT32, NULL, 0); g_variant_ref_sink (v); if (dry_run) { str = g_variant_print (v, FALSE); g_print ("set key '%s' to a list of integers: %s\n", keys[j], str); g_free (str); } else g_settings_set_value (settings, keys[j], v); g_variant_unref (v); g_variant_builder_unref (builder); break; default: g_printerr ("Keys of type 'list of %s' not handled yet\n", mateconf_value_type_to_string (mateconf_value_get_list_type (value))); break; } break; default: g_printerr ("Keys of type %s not handled yet\n", mateconf_value_type_to_string (value->type)); break; } mateconf_value_free (value); g_free (mateconf_key); } g_strfreev (keys); if (!dry_run) g_settings_apply (settings); g_object_unref (settings); g_strfreev (schema_path); } g_strfreev (groups); g_object_unref (client); return TRUE; }