static GVariant * set_contrast_mapping (const GValue *value, const GVariantType *expected_type, gpointer user_data) { gboolean hc; CcUaPanel *self = user_data; CcUaPanelPrivate *priv = self->priv; GVariant *ret = NULL; hc = g_value_get_boolean (value); if (hc) { ret = g_variant_new_string (HIGH_CONTRAST_THEME); g_settings_set_string (priv->interface_settings, KEY_ICON_THEME, HIGH_CONTRAST_THEME); g_settings_set_string (priv->wm_settings, KEY_WM_THEME, HIGH_CONTRAST_THEME); } else { g_settings_reset (priv->interface_settings, KEY_GTK_THEME); g_settings_reset (priv->interface_settings, KEY_ICON_THEME); g_settings_reset (priv->wm_settings, KEY_WM_THEME); } return ret; }
static void default_size_reset_cb (GtkWidget *button, GSettings *profile) { g_settings_reset (profile, TERMINAL_PROFILE_DEFAULT_SIZE_COLUMNS_KEY); g_settings_reset (profile, TERMINAL_PROFILE_DEFAULT_SIZE_ROWS_KEY); }
static void reset_compat_defaults_cb (GtkWidget *button, GSettings *profile) { g_settings_reset (profile, TERMINAL_PROFILE_DELETE_BINDING_KEY); g_settings_reset (profile, TERMINAL_PROFILE_BACKSPACE_BINDING_KEY); g_settings_reset (profile, TERMINAL_PROFILE_ENCODING_KEY); g_settings_reset (profile, TERMINAL_PROFILE_CJK_UTF8_AMBIGUOUS_WIDTH_KEY); }
static void use_default_callback (NemoColumnChooser *chooser, gpointer user_data) { g_settings_reset (nemo_list_view_preferences, NEMO_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS); g_settings_reset (nemo_list_view_preferences, NEMO_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER); set_columns_from_settings (chooser); }
void gm_pref_store_set_string(GmPrefStore * store, const gchar * key, gchar * value) { if (store == NULL) return; #if HAVE_GSETTINGS if (value == NULL) { g_settings_reset(store->settings, key); } else { g_settings_set_string(store->settings, key, value); } #else #ifdef HAVE_GCONF gchar *full_key; full_key = g_strdup_printf("/apps/%s/preferences/%s", store->context, key); gconf_client_unset(store->gconf, full_key, NULL); if (value != NULL && strlen(g_strstrip(value)) > 0) gconf_client_set_string(store->gconf, full_key, value, NULL); g_free(full_key); #else if (value != NULL && strlen(g_strstrip(value)) > 0) { g_key_file_set_string(store->keyfile, store->context, key, value); } else { g_key_file_remove_key(store->keyfile, store->context, key, NULL); } #endif #endif }
void QGSettings::resetValue(const QString &key) { Q_D(QGSettings); if (!d->valid) return; gchar *keyName = Utils::fromCamelCase(key); g_settings_reset(d->settings, keyName); g_free(keyName); }
void gnc_gsettings_reset (const gchar *schema, const gchar *key) { GSettings *settings_ptr = gnc_gsettings_get_settings_ptr (schema); g_return_if_fail (G_IS_SETTINGS (settings_ptr)); if (gnc_gsettings_is_valid_key (settings_ptr, key)) g_settings_reset (settings_ptr, key); else PERR ("Invalid key %s for schema %s", key, schema); }
static void reset_to_defaults (GtkWidget * button, GtkBuilder * dialog) { MatekbdKeyboardConfig empty_kbd_config; matekbd_keyboard_config_init (&empty_kbd_config, engine); matekbd_keyboard_config_save_to_gsettings (&empty_kbd_config); matekbd_keyboard_config_term (&empty_kbd_config); g_settings_reset (xkb_general_settings, "default-group"); /* all the rest is g-s-d's business */ }
static GVariant * set_contrast_mapping (const GValue *value, const GVariantType *expected_type, gpointer user_data) { gboolean hc; GSettings *settings = user_data; GVariant *ret = NULL; hc = g_value_get_boolean (value); if (hc) { ret = g_variant_new_string (HIGH_CONTRAST_THEME); g_settings_set_string (settings, KEY_ICON_THEME, HIGH_CONTRAST_THEME); } else { g_settings_reset (settings, KEY_GTK_THEME); g_settings_reset (settings, KEY_ICON_THEME); } return ret; }
static void reset_to_defaults (GtkWidget * button, GtkBuilder * dialog) { GkbdKeyboardConfig empty_kbd_config; gkbd_keyboard_config_init (&empty_kbd_config, engine); gkbd_keyboard_config_save (&empty_kbd_config); gkbd_keyboard_config_term (&empty_kbd_config); g_settings_reset (xkb_desktop_settings, GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP); /* all the rest is g-s-d's business */ }
static void contrast_combobox_changed_cb (GtkComboBox *box, CcUaPanel *panel) { CcUaPanelPrivate *priv = panel->priv; gchar *theme_name = NULL; GtkTreeIter iter; gtk_combo_box_get_active_iter (box, &iter); gtk_tree_model_get (gtk_combo_box_get_model (box), &iter, CONTRAST_MODEL_THEME_COLUMN, &theme_name, -1); if (g_strcmp0 (theme_name, "")) { /* disable overlay scrollbars for a11y */ if (g_strcmp0 (theme_name, "HighContrast") == 0 || g_strcmp0 (theme_name, "HighContrastInverse") == 0) g_settings_set_boolean (priv->interface_settings, "ubuntu-overlay-scrollbars", FALSE); else g_settings_reset (priv->interface_settings, "ubuntu-overlay-scrollbars"); g_settings_set_string (priv->interface_settings, GTK_THEME_KEY, theme_name); g_settings_set_string (priv->interface_settings, ICON_THEME_KEY, theme_name); } else { /* reset overlay scrollbars key */ g_settings_reset (priv->interface_settings, "ubuntu-overlay-scrollbars"); g_settings_reset (priv->interface_settings, GTK_THEME_KEY); g_settings_reset (priv->interface_settings, ICON_THEME_KEY); } g_free (theme_name); }
int togglePac(bool turnOn, const char* pacUrl) { int ret = RET_NO_ERROR; #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // deprecated since version 2.36, must leave here or prior glib will crash g_type_init(); #pragma GCC diagnostic warning "-Wdeprecated-declarations" GSettings* setting = g_settings_new("org.gnome.system.proxy"); if (turnOn == true) { gboolean success = g_settings_set_string(setting, "mode", "auto"); if (!success) { fprintf(stderr, "error setting mode to auto\n"); ret = SYSCALL_FAILED; goto cleanup; } success = g_settings_set_string(setting, "autoconfig-url", pacUrl); if (!success) { fprintf(stderr, "error setting autoconfig-url to %s\n", pacUrl); ret = SYSCALL_FAILED; goto cleanup; } } else { if (strlen(pacUrl) != 0) { // clear pac setting only if it's equal to pacUrl char* old_mode = g_settings_get_string(setting, "mode"); char* old_pac_url = g_settings_get_string(setting, "autoconfig-url"); if (strcmp(old_mode, "auto") != 0 || strcmp(old_pac_url, pacUrl) != 0 ) { fprintf(stderr, "current pac url setting is not %s, skipping\n", pacUrl); goto cleanup; } } g_settings_reset(setting, "autoconfig-url"); gboolean success = g_settings_set_string(setting, "mode", "none"); if (!success) { fprintf(stderr, "error setting mode to none\n"); ret = SYSCALL_FAILED; goto cleanup; } } cleanup: g_settings_sync(); g_object_unref(setting); return ret; }
static GVariant * set_large_text_mapping (const GValue *value, const GVariantType *expected_type, gpointer user_data) { gboolean large; GSettings *settings = user_data; GVariant *ret = NULL; large = g_value_get_boolean (value); if (large) ret = g_variant_new_double (DPI_FACTOR_LARGE); else g_settings_reset (settings, KEY_TEXT_SCALING_FACTOR); return ret; }
/** * defkey_cb * @widget: widget * @data: callback data * * Description: * handles message from the default key buttons **/ static void defkey_cb (GtkWidget * widget, gpointer data) { gint i; for (i = 0; i < N_KEYS; ++i) { GVariant *variant; char buffer[64]; g_snprintf (buffer, sizeof (buffer), KEY_CONTROL_KEY, i); g_settings_reset (settings, buffer); variant = g_settings_get_default_value (settings, buffer); properties.keys[i] = g_variant_get_int32 (variant); g_variant_unref (variant); } keyboard_set (properties.keys); }
void gm_pref_store_unset(GmPrefStore * store, const gchar * key) { if (store == NULL) return; #if HAVE_GSETTINGS g_settings_reset(store->settings, key); #else #ifdef HAVE_GCONF gchar *full_key; full_key = g_strdup_printf("/apps/%s/preferences/%s", store->context, key); gconf_client_unset(store->gconf, full_key, NULL); g_free(full_key); #else g_key_file_remove_key(store->keyfile, store->context, key, NULL); #endif #endif }
static void text_scaling_factor_combo_box_changed (GtkComboBox *box, CcUaPanel *panel) { CcUaPanelPrivate *priv = panel->priv; GtkTreeIter iter; gfloat factor; gtk_combo_box_get_active_iter (box, &iter); gtk_tree_model_get (gtk_combo_box_get_model (box), &iter, DPI_MODEL_FACTOR_COLUMN, &factor, -1); if (factor == 1.0) g_settings_reset (priv->interface_settings, "text-scaling-factor"); else g_settings_set_double (priv->interface_settings, "text-scaling-factor", factor); }
void gsd_settings_migrate_check (const gchar *origin_schema, const gchar *origin_path, const gchar *dest_schema, const gchar *dest_path, GsdSettingsMigrateEntry entries[], guint n_entries) { GSettings *origin_settings, *dest_settings; GVariant *variant; guint i; origin_settings = g_settings_new_with_path (origin_schema, origin_path); dest_settings = g_settings_new_with_path (dest_schema, dest_path); for (i = 0; i < n_entries; i++) { variant = g_settings_get_user_value (origin_settings, entries[i].origin_key); if (!variant) continue; if (entries[i].dest_key) { if (entries[i].func) { GVariant *modified; modified = entries[i].func (variant); g_variant_unref (variant); variant = g_variant_ref_sink (modified); } g_settings_set_value (dest_settings, entries[i].dest_key, variant); } g_settings_reset (origin_settings, entries[i].origin_key); g_variant_unref (variant); } g_object_unref (origin_settings); g_object_unref (dest_settings); }
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 settings_manager_clear_list (SettingsManager* self) { GSettings* _tmp0_; g_return_if_fail (self != NULL); _tmp0_ = self->priv->settings; g_settings_reset (_tmp0_, "interested-media-players"); }
void mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info) { GSettings *interface_settings; GSettings *marco_settings; GSettings *mouse_settings; GSettings *notification_settings = NULL; const char * const *schemas; gboolean schema_exists; gint i; gchar *old_key; gint old_key_int; interface_settings = g_settings_new (INTERFACE_SCHEMA); marco_settings = g_settings_new (MARCO_SCHEMA); mouse_settings = g_settings_new (MOUSE_SCHEMA); /* We need this because mate-control-center does not depend on mate-notification-daemon, * and if we try to get notification theme without schema installed, gsettings crashes * see https://bugzilla.gnome.org/show_bug.cgi?id=651225 */ schemas = g_settings_list_schemas (); schema_exists = FALSE; for (i = 0; schemas[i] != NULL; i++) { if (g_strcmp0 (schemas[i], NOTIFICATION_SCHEMA) == 0) { schema_exists = TRUE; break; } } if (schema_exists == TRUE) { notification_settings = g_settings_new (NOTIFICATION_SCHEMA); } /* Set the gtk+ key */ old_key = g_settings_get_string (interface_settings, GTK_THEME_KEY); if (compare (old_key, meta_theme_info->gtk_theme_name)) { g_settings_set_string (interface_settings, GTK_THEME_KEY, meta_theme_info->gtk_theme_name); } g_free (old_key); /* Set the color scheme key */ old_key = g_settings_get_string (interface_settings, COLOR_SCHEME_KEY); if (compare (old_key, meta_theme_info->gtk_color_scheme)) { /* only save the color scheme if it differs from the default scheme for the selected gtk theme */ gchar *newval, *gtkcols; newval = meta_theme_info->gtk_color_scheme; gtkcols = gtkrc_get_color_scheme_for_theme (meta_theme_info->gtk_theme_name); if (newval == NULL || !strcmp (newval, "") || mate_theme_color_scheme_equal (newval, gtkcols)) { g_settings_reset (interface_settings, COLOR_SCHEME_KEY); } else { g_settings_set_string (interface_settings, COLOR_SCHEME_KEY, newval); } g_free (gtkcols); } g_free (old_key); /* Set the wm key */ g_settings_set_string (marco_settings, MARCO_THEME_KEY, meta_theme_info->marco_theme_name); /* set the icon theme */ old_key = g_settings_get_string (interface_settings, ICON_THEME_KEY); if (compare (old_key, meta_theme_info->icon_theme_name)) { g_settings_set_string (interface_settings, ICON_THEME_KEY, meta_theme_info->icon_theme_name); } g_free (old_key); /* set the notification theme */ if (notification_settings != NULL) { if (meta_theme_info->notification_theme_name != NULL) { old_key = g_settings_get_string (notification_settings, NOTIFICATION_THEME_KEY); if (compare (old_key, meta_theme_info->notification_theme_name)) { g_settings_set_string (notification_settings, NOTIFICATION_THEME_KEY, meta_theme_info->notification_theme_name); } g_free (old_key); } } /* Set the cursor theme key */ #ifdef HAVE_XCURSOR old_key = g_settings_get_string (mouse_settings, CURSOR_THEME_KEY); if (compare (old_key, meta_theme_info->cursor_theme_name)) { g_settings_set_string (mouse_settings, CURSOR_THEME_KEY, meta_theme_info->cursor_theme_name); } old_key_int = g_settings_get_int (mouse_settings, CURSOR_SIZE_KEY); if (old_key_int != meta_theme_info->cursor_size) { g_settings_set_int (mouse_settings, CURSOR_SIZE_KEY, meta_theme_info->cursor_size); } #else old_key = g_settings_get_string (mouse_settings, CURSOR_FONT_KEY); if (compare (old_key, meta_theme_info->cursor_theme_name)) { g_settings_set_string (mouse_settings, CURSOR_FONT_KEY, meta_theme_info->cursor_theme_name); } #endif g_free (old_key); g_object_unref (interface_settings); g_object_unref (marco_settings); g_object_unref (mouse_settings); if (notification_settings != NULL) g_object_unref (notification_settings); }
gint tracker_control_general_run (void) { GError *error = NULL; GSList *pids; GSList *l; gchar *str; gpointer verbosity_type_enum_class_pointer = NULL; TrackerVerbosity set_log_verbosity_value = TRACKER_VERBOSITY_ERRORS; /* Constraints */ if (kill_option != TERM_NONE && terminate_option != TERM_NONE) { g_printerr ("%s\n", _("You can not use the --kill and --terminate arguments together")); return EXIT_FAILURE; } if ((hard_reset || soft_reset) && terminate_option != TERM_NONE) { g_printerr ("%s\n", _("You can not use the --terminate with --hard-reset or --soft-reset, --kill is implied")); return EXIT_FAILURE; } if (hard_reset && soft_reset) { g_printerr ("%s\n", _("You can not use the --hard-reset and --soft-reset arguments together")); return EXIT_FAILURE; } if (get_log_verbosity && set_log_verbosity) { g_printerr ("%s\n", _("You can not use the --get-logging and --set-logging arguments together")); return EXIT_FAILURE; } if (set_log_verbosity) { if (g_ascii_strcasecmp (set_log_verbosity, "debug") == 0) { set_log_verbosity_value = TRACKER_VERBOSITY_DEBUG; } else if (g_ascii_strcasecmp (set_log_verbosity, "detailed") == 0) { set_log_verbosity_value = TRACKER_VERBOSITY_DETAILED; } else if (g_ascii_strcasecmp (set_log_verbosity, "minimal") == 0) { set_log_verbosity_value = TRACKER_VERBOSITY_MINIMAL; } else if (g_ascii_strcasecmp (set_log_verbosity, "errors") == 0) { set_log_verbosity_value = TRACKER_VERBOSITY_ERRORS; } else { g_printerr ("%s\n", _("Invalid log verbosity, try 'debug', 'detailed', 'minimal' or 'errors'")); return EXIT_FAILURE; } } if (hard_reset || soft_reset) { /* Imply --kill */ kill_option = TERM_ALL; } if (get_log_verbosity || set_log_verbosity) { GType etype; /* Since we don't reference this enum anywhere, we do * it here to make sure it exists when we call * g_type_class_peek(). This wouldn't be necessary if * it was a param in a GObject for example. * * This does mean that we are leaking by 1 reference * here and should clean it up, but it doesn't grow so * this is acceptable. */ etype = tracker_verbosity_get_type (); verbosity_type_enum_class_pointer = g_type_class_ref (etype); } /* Unless we are stopping processes or listing processes, * don't iterate them. */ if (kill_option != TERM_NONE || terminate_option != TERM_NONE || list_processes) { guint32 own_pid; guint32 own_uid; gchar *own_pid_str; pids = get_pids (); str = g_strdup_printf (g_dngettext (NULL, "Found %d PID…", "Found %d PIDs…", g_slist_length (pids)), g_slist_length (pids)); g_print ("%s\n", str); g_free (str); /* Establish own uid/pid */ own_pid = (guint32) getpid (); own_pid_str = g_strdup_printf ("%d", own_pid); own_uid = get_uid_for_pid (own_pid_str, NULL); g_free (own_pid_str); for (l = pids; l; l = l->next) { GError *error = NULL; gchar *filename; gchar *contents = NULL; gchar **strv; guint uid; uid = get_uid_for_pid (l->data, &filename); /* Stat the file and make sure current user == file owner */ if (uid != own_uid) { continue; } /* Get contents to determine basename */ if (!g_file_get_contents (filename, &contents, NULL, &error)) { str = g_strdup_printf (_("Could not open '%s'"), filename); g_printerr ("%s, %s\n", str, error ? error->message : _("no error given")); g_free (str); g_clear_error (&error); g_free (contents); g_free (filename); continue; } strv = g_strsplit (contents, "^@", 2); if (strv && strv[0]) { gchar *basename; basename = g_path_get_basename (strv[0]); if ((g_str_has_prefix (basename, "tracker") == TRUE || g_str_has_prefix (basename, "lt-tracker") == TRUE) && g_str_has_suffix (basename, "-control") == FALSE && g_str_has_suffix (basename, "-status-icon") == FALSE) { pid_t pid; pid = atoi (l->data); str = g_strdup_printf (_("Found process ID %d for '%s'"), pid, basename); g_print ("%s\n", str); g_free (str); if (terminate_option != TERM_NONE) { if ((terminate_option == TERM_STORE && !g_str_has_suffix (basename, "tracker-store")) || (terminate_option == TERM_MINERS && !strstr (basename, "tracker-miner"))) { continue; } if (kill (pid, SIGTERM) == -1) { const gchar *errstr = g_strerror (errno); str = g_strdup_printf (_("Could not terminate process %d"), pid); g_printerr (" %s, %s\n", str, errstr ? errstr : _("no error given")); g_free (str); } else { str = g_strdup_printf (_("Terminated process %d"), pid); g_print (" %s\n", str); g_free (str); } } else if (kill_option != TERM_NONE) { if ((kill_option == TERM_STORE && !g_str_has_suffix (basename, "tracker-store")) || (kill_option == TERM_MINERS && !strstr (basename, "tracker-miner"))) { continue; } if (kill (pid, SIGKILL) == -1) { const gchar *errstr = g_strerror (errno); str = g_strdup_printf (_("Could not kill process %d"), pid); g_printerr (" %s, %s\n", str, errstr ? errstr : _("no error given")); g_free (str); } else { str = g_strdup_printf (_("Killed process %d"), pid); g_print (" %s\n", str); g_free (str); } } } g_free (basename); } g_strfreev (strv); g_free (contents); g_free (filename); } g_slist_foreach (pids, (GFunc) g_free, NULL); g_slist_free (pids); /* If we just wanted to list processes, all done */ if (list_processes && terminate_option == TERM_NONE && kill_option == TERM_NONE) { return EXIT_SUCCESS; } } if (hard_reset || soft_reset) { guint log_handler_id; #ifndef DISABLE_JOURNAL gchar *rotate_to; TrackerDBConfig *db_config; gsize chunk_size; gint chunk_size_mb; #endif /* DISABLE_JOURNAL */ /* Set log handler for library messages */ log_handler_id = g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL, log_handler, NULL); g_log_set_default_handler (log_handler, NULL); #ifndef DISABLE_JOURNAL db_config = tracker_db_config_new (); chunk_size_mb = tracker_db_config_get_journal_chunk_size (db_config); chunk_size = (gsize) ((gsize) chunk_size_mb * (gsize) 1024 * (gsize) 1024); rotate_to = tracker_db_config_get_journal_rotate_destination (db_config); /* This call is needed to set the journal's filename */ tracker_db_journal_set_rotating ((chunk_size_mb != -1), chunk_size, rotate_to); g_free (rotate_to); g_object_unref (db_config); #endif /* DISABLE_JOURNAL */ /* Clean up (select_cache_size and update_cache_size don't matter here) */ if (!tracker_db_manager_init (TRACKER_DB_MANAGER_REMOVE_ALL, NULL, FALSE, FALSE, 100, 100, NULL, NULL, NULL, &error)) { g_message ("Error initializing database: %s", error->message); g_free (error); return EXIT_FAILURE; } #ifndef DISABLE_JOURNAL tracker_db_journal_init (NULL, FALSE, NULL); #endif /* DISABLE_JOURNAL */ tracker_db_manager_remove_all (hard_reset); tracker_db_manager_shutdown (); #ifndef DISABLE_JOURNAL tracker_db_journal_shutdown (NULL); #endif /* DISABLE_JOURNAL */ /* Unset log handler */ g_log_remove_handler (NULL, log_handler_id); } if (remove_config) { GMainLoop *main_loop; GFile *file; TrackerCrawler *crawler; const gchar *suffix = ".cfg"; const gchar *home_conf_dir; gchar *path; GSList *all, *l; crawler = tracker_crawler_new (); main_loop = g_main_loop_new (NULL, FALSE); g_signal_connect (crawler, "check-file", G_CALLBACK (crawler_check_file_cb), &suffix); g_signal_connect (crawler, "finished", G_CALLBACK (crawler_finished_cb), main_loop); /* Go through service files */ /* Check the default XDG_DATA_HOME location */ home_conf_dir = g_getenv ("XDG_CONFIG_HOME"); if (home_conf_dir && tracker_path_has_write_access_or_was_created (home_conf_dir)) { path = g_build_path (G_DIR_SEPARATOR_S, home_conf_dir, "tracker", NULL); } else { home_conf_dir = g_getenv ("HOME"); if (!home_conf_dir || !tracker_path_has_write_access_or_was_created (home_conf_dir)) { home_conf_dir = g_get_home_dir (); } path = g_build_path (G_DIR_SEPARATOR_S, home_conf_dir, ".config", "tracker", NULL); } file = g_file_new_for_path (path); g_free (path); g_print ("%s\n", _("Removing configuration files…")); tracker_crawler_start (crawler, file, FALSE); g_object_unref (file); g_main_loop_run (main_loop); g_object_unref (crawler); g_print ("%s\n", _("Resetting existing configuration…")); all = tracker_gsettings_get_all (NULL); if (!all) { return EXIT_FAILURE; } for (l = all; l; l = l->next) { ComponentGSettings *c = l->data; gchar **keys, **p; if (!c) { continue; } g_print (" %s\n", c->name); keys = g_settings_list_keys (c->settings); for (p = keys; p && *p; p++) { g_print (" %s\n", *p); g_settings_reset (c->settings, *p); } if (keys) { g_strfreev (keys); } g_settings_apply (c->settings); } tracker_gsettings_free (all); } /* Deal with logging changes AFTER the config may have been * reset, this way users can actually use --remove-config with * the --set-logging switch. */ if (get_log_verbosity) { GSList *all; gint longest = 0; all = tracker_gsettings_get_all (&longest); if (!all) { return EXIT_FAILURE; } g_print ("%s:\n", _("Components")); tracker_gsettings_print_verbosity (all, longest, TRUE); g_print ("\n"); /* Miners */ g_print ("%s (%s):\n", _("Miners"), _("Only those with config listed")); tracker_gsettings_print_verbosity (all, longest, FALSE); g_print ("\n"); tracker_gsettings_free (all); } if (set_log_verbosity) { GSList *all; gchar *str; gint longest = 0; all = tracker_gsettings_get_all (&longest); if (!all) { return EXIT_FAILURE; } str = g_strdup_printf (_("Setting log verbosity for all components to '%s'…"), set_log_verbosity); g_print ("%s\n", str); g_print ("\n"); g_free (str); tracker_gsettings_set_all (all, set_log_verbosity_value); tracker_gsettings_free (all); /* We free to make sure we get new settings and that * they're saved properly. */ all = tracker_gsettings_get_all (&longest); if (!all) { return EXIT_FAILURE; } g_print ("%s:\n", _("Components")); tracker_gsettings_print_verbosity (all, longest, TRUE); g_print ("\n"); /* Miners */ g_print ("%s (%s):\n", _("Miners"), _("Only those with config listed")); tracker_gsettings_print_verbosity (all, longest, FALSE); g_print ("\n"); tracker_gsettings_free (all); } if (verbosity_type_enum_class_pointer) { g_type_class_unref (verbosity_type_enum_class_pointer); } if (start) { TrackerMinerManager *manager; GSList *miners, *l; if (hard_reset || soft_reset) { g_print ("%s\n", _("Waiting one second before starting miners…")); /* Give a second's grace to avoid race conditions */ g_usleep (G_USEC_PER_SEC); } g_print ("%s\n", _("Starting miners…")); /* Auto-start the miners here */ manager = tracker_miner_manager_new_full (TRUE, &error); if (!manager) { g_printerr (_("Could not start miners, manager could not be created, %s"), error ? error->message : "unknown error"); g_printerr ("\n"); g_clear_error (&error); return EXIT_FAILURE; } miners = tracker_miner_manager_get_available (manager); /* Get the status of all miners, this will start all * miners not already running. */ for (l = miners; l; l = l->next) { const gchar *display_name; gdouble progress = 0.0; display_name = tracker_miner_manager_get_display_name (manager, l->data); if (!tracker_miner_manager_get_status (manager, l->data, NULL, &progress, NULL)) { g_printerr (" ✗ %s (%s)\n", display_name, _("perhaps a disabled plugin?")); } else { g_print (" ✓ %s\n", display_name); } g_free (l->data); } g_slist_free (miners); g_object_unref (manager); } if (backup) { GDBusConnection *connection; GDBusProxy *proxy; GError *error = NULL; GVariant *v; gchar *uri; uri = get_uri_from_arg (backup); g_print ("%s\n", _("Backing up database")); g_print (" %s\n", uri); connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (!connection) { g_critical ("Could not connect to the D-Bus session bus, %s", error ? error->message : "no error given."); g_clear_error (&error); g_free (uri); return EXIT_FAILURE; } proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.Tracker1", "/org/freedesktop/Tracker1/Backup", "org.freedesktop.Tracker1.Backup", NULL, &error); if (error) { g_critical ("Could not create proxy on the D-Bus session bus, %s", error ? error->message : "no error given."); g_clear_error (&error); g_free (uri); return EXIT_FAILURE; } /* Backup/Restore can take some time */ g_dbus_proxy_set_default_timeout (proxy, G_MAXINT); v = g_dbus_proxy_call_sync (proxy, "Save", g_variant_new ("(s)", uri), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (proxy) { g_object_unref (proxy); } if (error) { g_critical ("Could not backup database, %s", error ? error->message : "no error given."); g_clear_error (&error); g_free (uri); return EXIT_FAILURE; } if (v) { g_variant_unref (v); } g_free (uri); } if (restore) { GDBusConnection *connection; GDBusProxy *proxy; GError *error = NULL; GVariant *v; gchar *uri; uri = get_uri_from_arg (restore); g_print ("%s\n", _("Restoring database from backup")); g_print (" %s\n", uri); connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (!connection) { g_critical ("Could not connect to the D-Bus session bus, %s", error ? error->message : "no error given."); g_clear_error (&error); g_free (uri); return EXIT_FAILURE; } proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.Tracker1", "/org/freedesktop/Tracker1/Backup", "org.freedesktop.Tracker1.Backup", NULL, &error); if (error) { g_critical ("Could not create proxy on the D-Bus session bus, %s", error ? error->message : "no error given."); g_clear_error (&error); g_free (uri); return EXIT_FAILURE; } /* Backup/Restore can take some time */ g_dbus_proxy_set_default_timeout (proxy, G_MAXINT); v = g_dbus_proxy_call_sync (proxy, "Restore", g_variant_new ("(s)", uri), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (proxy) { g_object_unref (proxy); } if (error) { g_critical ("Could not restore database, %s", error ? error->message : "no error given."); g_clear_error (&error); g_free (uri); return EXIT_FAILURE; } if (v) { g_variant_unref (v); } g_free (uri); } return EXIT_SUCCESS; }
int main (int argc, char **argv) { UpgradeNotifier *un; GError *error = NULL; // init if(!gtk_init_with_args (&argc, &argv, _("- inform about updates"), entries, "update-notifier", &error) ) { fprintf(stderr, _("Failed to init the UI: %s\n"), error ? error->message : _("unknown error")); exit(1); } notify_init("update-notifier"); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); if (HOOK_DEBUG || UPDATE_DEBUG || INOTIFY_DEBUG || UEVENT_DEBUG || RELEASE_DEBUG || MISC_DEBUG) g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); // setup a custom debug log handler g_log_set_handler ("inotify", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("hooks", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("update", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("uevent", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("release", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_set_application_name (_("update-notifier")); gtk_window_set_default_icon_name ("update-notifier"); //g_print("starting update-notifier\n"); /* Create the UpgradeNotifier object */ un = g_new0 (UpgradeNotifier, 1); un->settings = g_settings_new(SETTINGS_SCHEMA); // do not run as system user (e.g. guest user) if (system_user(un) && !FORCE_START) { g_warning("not starting for system user"); exit(0); } // do not run as system user (e.g. guest user) if (FORCE_RELEASE_CHECK) g_settings_reset(un->settings, SETTINGS_KEY_LAST_RELEASE_CHECK); // check if it is running already if (!up_get_clipboard ()) { g_warning ("already running?"); return 1; } // check for update-notifier dir and create if needed gchar *dirname = g_strdup_printf("%s/update-notifier", g_get_user_config_dir()); if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) g_mkdir(dirname, 0700); g_free(dirname); // delay icon creation for 30s so that the desktop // login is not slowed down by update-notifier g_timeout_add_seconds(STARTUP_DELAY, (GSourceFunc)(tray_icons_init), un); // initial check for avahi avahi_disabled_check(); /* setup inserted-cdroms checker */ if(!cdroms_init(un)) { g_warning("initializing cdroms failed"); } // init release checker release_checker_init(un); // init uevent monitoring (missing firmware, etc.) uevent_init(); // init gio file monitoring monitor_init (un); /* Start the main gtk loop */ g_unix_signal_add_full (G_PRIORITY_DEFAULT, SIGINT, sigint_cb, NULL, NULL); gtk_main (); return 0; }
void mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info) { GSettings *interface_settings; GSettings *marco_settings; GSettings *mouse_settings; GSettings *notification_settings = NULL; gchar *old_key; gint old_key_int; interface_settings = g_settings_new (INTERFACE_SCHEMA); marco_settings = g_settings_new (MARCO_SCHEMA); mouse_settings = g_settings_new (MOUSE_SCHEMA); if (mate_gsettings_schema_exists (NOTIFICATION_SCHEMA)) { notification_settings = g_settings_new (NOTIFICATION_SCHEMA); } /* Set the gtk+ key */ old_key = g_settings_get_string (interface_settings, GTK_THEME_KEY); if (compare (old_key, meta_theme_info->gtk_theme_name)) { g_settings_set_string (interface_settings, GTK_THEME_KEY, meta_theme_info->gtk_theme_name); } g_free (old_key); /* Set the color scheme key */ old_key = g_settings_get_string (interface_settings, COLOR_SCHEME_KEY); if (compare (old_key, meta_theme_info->gtk_color_scheme)) { /* only save the color scheme if it differs from the default scheme for the selected gtk theme */ gchar *newval, *gtkcols; newval = meta_theme_info->gtk_color_scheme; gtkcols = gtkrc_get_color_scheme_for_theme (meta_theme_info->gtk_theme_name); if (newval == NULL || !strcmp (newval, "") || mate_theme_color_scheme_equal (newval, gtkcols)) { g_settings_reset (interface_settings, COLOR_SCHEME_KEY); } else { g_settings_set_string (interface_settings, COLOR_SCHEME_KEY, newval); } g_free (gtkcols); } g_free (old_key); /* Set the wm key */ g_settings_set_string (marco_settings, MARCO_THEME_KEY, meta_theme_info->marco_theme_name); /* set the icon theme */ old_key = g_settings_get_string (interface_settings, ICON_THEME_KEY); if (compare (old_key, meta_theme_info->icon_theme_name)) { g_settings_set_string (interface_settings, ICON_THEME_KEY, meta_theme_info->icon_theme_name); } g_free (old_key); /* set the notification theme */ if (notification_settings != NULL) { if (meta_theme_info->notification_theme_name != NULL) { old_key = g_settings_get_string (notification_settings, NOTIFICATION_THEME_KEY); if (compare (old_key, meta_theme_info->notification_theme_name)) { g_settings_set_string (notification_settings, NOTIFICATION_THEME_KEY, meta_theme_info->notification_theme_name); } g_free (old_key); } } /* Set the cursor theme key */ #ifdef HAVE_XCURSOR old_key = g_settings_get_string (mouse_settings, CURSOR_THEME_KEY); if (compare (old_key, meta_theme_info->cursor_theme_name)) { g_settings_set_string (mouse_settings, CURSOR_THEME_KEY, meta_theme_info->cursor_theme_name); } old_key_int = g_settings_get_int (mouse_settings, CURSOR_SIZE_KEY); if (old_key_int != meta_theme_info->cursor_size) { g_settings_set_int (mouse_settings, CURSOR_SIZE_KEY, meta_theme_info->cursor_size); } #else old_key = g_settings_get_string (mouse_settings, CURSOR_FONT_KEY); if (compare (old_key, meta_theme_info->cursor_theme_name)) { g_settings_set_string (mouse_settings, CURSOR_FONT_KEY, meta_theme_info->cursor_theme_name); } #endif g_free (old_key); g_object_unref (interface_settings); g_object_unref (marco_settings); g_object_unref (mouse_settings); if (notification_settings != NULL) g_object_unref (notification_settings); }
static gint reset_run (void) { GError *error = NULL; if (hard_reset && soft_reset) { g_printerr ("%s\n", _("You can not use the --hard and --soft arguments together")); return EXIT_FAILURE; } /* KILL processes first... */ if (hard_reset || soft_reset) { tracker_process_stop (TRACKER_PROCESS_TYPE_NONE, TRACKER_PROCESS_TYPE_ALL); } if (hard_reset || soft_reset) { guint log_handler_id; #ifndef DISABLE_JOURNAL gchar *rotate_to; TrackerDBConfig *db_config; gsize chunk_size; gint chunk_size_mb; #endif /* DISABLE_JOURNAL */ /* Set log handler for library messages */ log_handler_id = g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL, log_handler, NULL); g_log_set_default_handler (log_handler, NULL); #ifndef DISABLE_JOURNAL db_config = tracker_db_config_new (); chunk_size_mb = tracker_db_config_get_journal_chunk_size (db_config); chunk_size = (gsize) ((gsize) chunk_size_mb * (gsize) 1024 * (gsize) 1024); rotate_to = tracker_db_config_get_journal_rotate_destination (db_config); /* This call is needed to set the journal's filename */ tracker_db_journal_set_rotating ((chunk_size_mb != -1), chunk_size, rotate_to); g_free (rotate_to); g_object_unref (db_config); #endif /* DISABLE_JOURNAL */ /* Clean up (select_cache_size and update_cache_size don't matter here) */ if (!tracker_db_manager_init (TRACKER_DB_MANAGER_REMOVE_ALL, NULL, FALSE, FALSE, 100, 100, NULL, NULL, NULL, &error)) { g_message ("Error initializing database: %s", error->message); g_free (error); return EXIT_FAILURE; } #ifndef DISABLE_JOURNAL tracker_db_journal_init (NULL, FALSE, NULL); #endif /* DISABLE_JOURNAL */ tracker_db_manager_remove_all (hard_reset); tracker_db_manager_shutdown (); #ifndef DISABLE_JOURNAL tracker_db_journal_shutdown (NULL); #endif /* DISABLE_JOURNAL */ /* Unset log handler */ g_log_remove_handler (NULL, log_handler_id); if (!remove_config) { return EXIT_SUCCESS; } } if (remove_config) { GFile *file; const gchar *home_conf_dir; gchar *path; GSList *all, *l; /* Check the default XDG_DATA_HOME location */ home_conf_dir = g_getenv ("XDG_CONFIG_HOME"); if (home_conf_dir && tracker_path_has_write_access_or_was_created (home_conf_dir)) { path = g_build_path (G_DIR_SEPARATOR_S, home_conf_dir, "tracker", NULL); } else { home_conf_dir = g_getenv ("HOME"); if (!home_conf_dir || !tracker_path_has_write_access_or_was_created (home_conf_dir)) { home_conf_dir = g_get_home_dir (); } path = g_build_path (G_DIR_SEPARATOR_S, home_conf_dir, ".config", "tracker", NULL); } file = g_file_new_for_path (path); g_free (path); g_print ("%s\n", _("Removing configuration files…")); directory_foreach (file, ".cfg", (GFunc) delete_file, NULL); g_object_unref (file); g_print ("%s\n", _("Resetting existing configuration…")); all = tracker_gsettings_get_all (NULL); if (!all) { return EXIT_FAILURE; } for (l = all; l; l = l->next) { ComponentGSettings *c = l->data; gchar **keys, **p; if (!c) { continue; } g_print (" %s\n", c->name); keys = g_settings_list_keys (c->settings); for (p = keys; p && *p; p++) { g_print (" %s\n", *p); g_settings_reset (c->settings, *p); } if (keys) { g_strfreev (keys); } g_settings_apply (c->settings); } g_settings_sync (); tracker_gsettings_free (all); return EXIT_SUCCESS; } /* All known options have their own exit points */ g_warn_if_reached (); return EXIT_FAILURE; }
static gboolean migrate_keyfile_to_settings (TrackerConfigMigrationEntry *entries, TrackerConfigFile *file, GSettings *settings) { gint i; for (i = 0; entries[i].type != G_TYPE_INVALID; i++) { if (!g_key_file_has_key (file->key_file, entries[i].file_section, entries[i].file_key, NULL)) { g_settings_reset (settings, entries[i].settings_key); continue; } switch (entries[i].type) { case G_TYPE_INT: case G_TYPE_ENUM: { gint val; val = g_key_file_get_integer (file->key_file, entries[i].file_section, entries[i].file_key, NULL); if (entries[i].type == G_TYPE_INT) { g_settings_set_int (settings, entries[i].settings_key, val); } else { g_settings_set_enum (settings, entries[i].settings_key, val); } break; } case G_TYPE_BOOLEAN: { gboolean val; val = g_key_file_get_boolean (file->key_file, entries[i].file_section, entries[i].file_key, NULL); g_settings_set_boolean (settings, entries[i].settings_key, val); break; } case G_TYPE_POINTER: { gchar **vals; vals = g_key_file_get_string_list (file->key_file, entries[i].file_section, entries[i].file_key, NULL, NULL); if (vals) { g_settings_set_strv (settings, entries[i].settings_key, (const gchar * const *) vals); g_strfreev (vals); } break; } default: g_assert_not_reached (); break; } } return TRUE; }
static void color_scheme_defaults_button_clicked_cb (GtkWidget *button, AppearanceData *data) { g_settings_reset (data->interface_settings, COLOR_SCHEME_KEY); gtk_widget_set_sensitive (appearance_capplet_get_widget (data, "color_scheme_defaults_button"), FALSE); }
//! //! @brief Resets a value in a key //! @param settings The GSettings object to act on You will have to get it yourself using lw_preferences_get_settings_object //! @param key A string identifying the key to reset //! void lw_preferences_reset_value (GSettings* settings, const char *key) { g_settings_reset (settings, key); }
static void ccsGSettingsWrapperResetKeyDefault (CCSGSettingsWrapper *wrapper, const char *key) { GSETTINGS_WRAPPER_PRIVATE (wrapper); g_settings_reset (gswPrivate->settings, key); }