static void update_settings_cb (GtkTreeSelection *selection, gpointer user_data) { GtkBuilder *builder = GTK_BUILDER (user_data); GtkTreeModel *model; GtkTreeIter iter; gchar *active_id; GtkWidget *treeview; GSettings *locale_settings; gchar *current_setting; if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { return; } gtk_tree_model_get (model, &iter, 0, &active_id, -1); treeview = GTK_WIDGET (gtk_builder_get_object (builder, "region_selector")); locale_settings = g_object_get_data (G_OBJECT (treeview), "settings"); current_setting = g_settings_get_string (locale_settings, "region"); if (g_strcmp0 (active_id, current_setting) != 0) { g_settings_set_string (locale_settings, "region", active_id); } g_free (current_setting); g_free (active_id); }
static void on_notify_font_theme (GSettings* settings, const gchar* key, gpointer user_data) { Sourceview *sv; sv = ANJUTA_SOURCEVIEW(user_data); if (g_settings_get_boolean (settings, key)) { /* FIXME: GSettings */ #if 0 GConfClient *gclient = gconf_client_get_default (); gchar *desktop_fixed_font; desktop_fixed_font = gconf_client_get_string (gclient, DESKTOP_FIXED_FONT, NULL); if (desktop_fixed_font) anjuta_view_set_font(sv->priv->view, FALSE, desktop_fixed_font); else anjuta_view_set_font(sv->priv->view, TRUE, NULL); g_free (desktop_fixed_font); #endif } else { gchar* font = g_settings_get_string (settings, FONT); anjuta_view_set_font(sv->priv->view, FALSE, font); g_free (font); } }
static void pluma_prefs_manager_smart_home_end_changed (GSettings *settings, gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); if (strcmp (key, GPM_SMART_HOME_END) == 0) { GtkSourceSmartHomeEndType smart_he; GList *views; GList *l; smart_he = get_smart_home_end_from_string (g_settings_get_string (settings, key)); views = pluma_app_get_views (pluma_app_get_default ()); l = views; while (l != NULL) { gtk_source_view_set_smart_home_end (GTK_SOURCE_VIEW (l->data), smart_he); l = l->next; } g_list_free (views); } }
static void wp_options_changed (GSettings *settings, gchar *key, AppearanceData *data) { MateWPItem *item; gchar *option; option = g_settings_get_string (settings, key); /* "none" means we don't use a background image */ if (option == NULL || !strcmp (option, "none")) { /* temporarily disconnect so we don't override settings when * updating the selection */ data->wp_update_settings = FALSE; wp_uri_changed ("(none)", data); data->wp_update_settings = TRUE; if (option) g_free (option); return; } item = get_selected_item (data, NULL); if (item != NULL) { item->options = g_settings_get_enum (settings, key); wp_option_menu_set (data, item->options, FALSE); } g_free (option); }
void gm_window_get_size (GmWindow *self, int *x, int *y) { gchar *conf_key_size = NULL; gchar *size = NULL; gchar **couple = NULL; g_return_if_fail (GM_IS_WINDOW (self) && x != NULL && y != NULL); conf_key_size = g_strdup_printf ("%s/size", self->priv->key); size = g_settings_get_string (self->priv->settings, "size"); if (size) couple = g_strsplit (size, ",", 0); if (x && couple && couple [0]) *x = atoi (couple [0]); if (y && couple && couple [1]) *y = atoi (couple [1]); g_free (conf_key_size); g_free (size); g_strfreev (couple); }
/* location of the second time zone user has selected. Free with g_free. */ gchar * calendar_config_get_day_second_zone (void) { calendar_config_init (); return g_settings_get_string (config, "day-second-zone"); }
static GtkSourceStyleScheme * get_default_style_scheme (GSettings *editor_settings) { GtkSourceStyleSchemeManager *manager; gchar *scheme_id; GtkSourceStyleScheme *def_style; manager = gtk_source_style_scheme_manager_get_default (); scheme_id = g_settings_get_string (editor_settings, GEDIT_SETTINGS_SCHEME); def_style = gtk_source_style_scheme_manager_get_scheme (manager, scheme_id); if (def_style == NULL) { g_warning ("Default style scheme '%s' cannot be found, falling back to 'classic' style scheme ", scheme_id); def_style = gtk_source_style_scheme_manager_get_scheme (manager, "classic"); if (def_style == NULL) { g_warning ("Style scheme 'classic' cannot be found, check your GtkSourceView installation."); } } g_free (scheme_id); return def_style; }
static void shell_window_init_switcher_style (EShellWindow *shell_window) { GtkAction *action; GSettings *settings; GtkToolbarStyle style; gchar *string; settings = e_util_ref_settings ("org.gnome.evolution.shell"); action = ACTION (SWITCHER_STYLE_ICONS); string = g_settings_get_string (settings, "buttons-style"); g_object_unref (settings); if (string != NULL) { if (strcmp (string, "icons") == 0) style = GTK_TOOLBAR_ICONS; else if (strcmp (string, "text") == 0) style = GTK_TOOLBAR_TEXT; else if (strcmp (string, "both") == 0) style = GTK_TOOLBAR_BOTH_HORIZ; else style = -1; gtk_radio_action_set_current_value ( GTK_RADIO_ACTION (action), style); g_free (string); } g_signal_connect ( action, "changed", G_CALLBACK (shell_window_save_switcher_style_cb), shell_window); }
static gchar * get_proxy_ftp (GsPlugin *plugin) { GsPluginData *priv = gs_plugin_get_data (plugin); GString *string = NULL; guint port; GDesktopProxyMode proxy_mode; g_autofree gchar *host = NULL; proxy_mode = g_settings_get_enum (priv->settings, "mode"); if (proxy_mode != G_DESKTOP_PROXY_MODE_MANUAL) return NULL; host = g_settings_get_string (priv->settings_ftp, "host"); if (host == NULL) return NULL; port = g_settings_get_int (priv->settings_ftp, "port"); if (port == 0) return NULL; /* make PackageKit proxy string */ string = g_string_new (host); if (port > 0) g_string_append_printf (string, ":%i", port); return g_string_free (string, FALSE); }
static GtkTreeModel* create_style_model (GSettings* settings, GtkTreeIter** current) { GtkListStore* model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); GtkSourceStyleSchemeManager* manager = gtk_source_style_scheme_manager_get_default(); const gchar* const *styles = gtk_source_style_scheme_manager_get_scheme_ids (manager); const gchar* const *style; gchar* current_style = g_settings_get_string (settings, SOURCEVIEW_STYLE); *current = NULL; for (style = styles; *style != NULL; style++) { GtkTreeIter iter; GtkSourceStyleScheme* scheme = gtk_source_style_scheme_manager_get_scheme (manager, *style); const gchar* id = gtk_source_style_scheme_get_id (scheme); gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, COLUMN_NAME, gtk_source_style_scheme_get_name (scheme), COLUMN_DESC, gtk_source_style_scheme_get_description (scheme), COLUMN_ID, id, -1); if (current_style && g_str_equal (id, current_style)) { *current = gtk_tree_iter_copy (&iter); } } g_free (current_style); return GTK_TREE_MODEL (model); }
static void toolbar_style_cb (GSettings *settings, gchar *key, AppearanceData *data) { set_toolbar_style (data, g_settings_get_string (settings, key)); }
static void set_alt_click_value () { gboolean match_found = FALSE; gchar *mouse_move_modifier; gchar *value; int i; mouse_move_modifier = g_settings_get_string (marco_settings, MARCO_MOUSE_MODIFIER_KEY); /* We look for a matching modifier and set it. */ if (mouse_move_modifier != NULL) { for (i = 0; i < n_mouse_modifiers; i ++) { value = g_strdup_printf ("<%s>", mouse_modifiers[i].value); if (strcmp (value, mouse_move_modifier) == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mouse_modifiers[i].radio), TRUE); match_found = TRUE; break; } g_free (value); } g_free (mouse_move_modifier); } /* No matching modifier was found; we set all the toggle buttons to be * insensitive. */ for (i = 0; i < n_mouse_modifiers; i++) { gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (mouse_modifiers[i].radio), ! match_found); } }
static void maybe_add_app_id (CcNotificationsPanel *panel, const char *canonical_app_id) { Application *app; gchar *path; gchar *full_app_id; GSettings *settings; GAppInfo *app_info; if (g_hash_table_contains (panel->known_applications, canonical_app_id)) return; path = g_strconcat (APP_PREFIX, canonical_app_id, "/", NULL); settings = g_settings_new_with_path (APP_SCHEMA, path); full_app_id = g_settings_get_string (settings, "application-id"); app_info = G_APP_INFO (g_desktop_app_info_new (full_app_id)); if (app_info == NULL) { /* The application cannot be found, probably it was uninstalled */ g_object_unref (settings); } else { app = g_slice_new (Application); app->canonical_app_id = g_strdup (canonical_app_id); app->settings = settings; app->app_info = app_info; add_application (panel, app); } g_free (path); g_free (full_app_id); }
static void baseuri_changed_cb (GSettings *settings, const gchar *key, gpointer user_data) { /* * The conflict between separation of the prefs and the main window, * and the problem of duplication, is very clear here. This code is * identical to the code in the main key listener, but modifying the * prefs window from the main is ugly. Maybe put the validation code * into sj-utils? */ const char* base_uri, *current_uri; g_return_if_fail (strcmp (key, SJ_SETTINGS_BASEURI) == 0); base_uri = g_settings_get_string (settings, key); if (base_uri == NULL || base_uri[0] == '\0') { GFile *dir; char *dir_uri; dir = sj_get_default_music_directory (); dir_uri = g_file_get_uri (dir); gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb), dir_uri); g_free (dir_uri); g_object_unref (dir); } else { current_uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb)); if (current_uri == NULL || strcmp (current_uri, base_uri) != 0) gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb), base_uri); } }
static void load_unlock_options (GcrPrompt *prompt) { GSettings *settings; gchar *method; gboolean chosen; settings = gkd_gpg_agent_settings (); method = g_settings_get_string (settings, "gpg-cache-method"); if (!method) { method = g_strdup (GCR_UNLOCK_OPTION_SESSION); /* COMPAT: with old seahorse-agent settings that were migrated */ } else if (g_str_equal (method, "gnome")) { g_free (method); method = g_strdup (GCR_UNLOCK_OPTION_ALWAYS); } else if (g_str_equal (method, "internal")) { g_free (method); method = g_strdup (GCR_UNLOCK_OPTION_SESSION); } chosen = g_str_equal (GCR_UNLOCK_OPTION_ALWAYS, method); gcr_prompt_set_choice_chosen (prompt, chosen); g_free (method); }
static void spell_setup_languages (void) { static GSettings *gsettings = NULL; gchar *str; if (gsettings == NULL) { /* FIXME: this is never uninitialised */ gsettings = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA); g_signal_connect (gsettings, "changed::" EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES, G_CALLBACK (spell_notify_languages_cb), NULL); } if (languages) { return; } languages = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) empathy_spell_free_language); str = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES); if (str != NULL) { gchar **strv; gint i; strv = g_strsplit (str, ",", -1); i = 0; while (strv && strv[i]) { SpellLanguage *lang; DEBUG ("Setting up language:'%s'", strv[i]); lang = g_slice_new0 (SpellLanguage); lang->config = enchant_broker_init (); lang->speller = enchant_broker_request_dict (lang->config, strv[i]); if (lang->speller == NULL) { DEBUG ("language '%s' has no valid dict", strv[i]); } else { g_hash_table_insert (languages, g_strdup (strv[i]), lang); } i++; } if (strv) { g_strfreev (strv); } g_free (str); } }
static void handle_preference_init_string (void) { MetaStringPreference *cursor = preferences_string; while (cursor->base.key != NULL) { char *value; /* Complex keys have a mapping function to check validity */ if (cursor->handler) { if (cursor->target) meta_bug ("%s has both a target and a handler\n", cursor->base.key); g_settings_get_mapped (SETTINGS (cursor->base.schema), cursor->base.key, cursor->handler, NULL); } else { if (!cursor->target) meta_bug ("%s must have handler or target\n", cursor->base.key); if (*(cursor->target)) g_free (*(cursor->target)); value = g_settings_get_string (SETTINGS (cursor->base.schema), cursor->base.key); *(cursor->target) = value; } ++cursor; } }
static void webkit_pref_callback_font_family (GSettings *settings, const char *key, gpointer data) { char *webkit_pref = data; char *value = NULL; char *schema = NULL; g_object_get (settings, "schema-id", &schema, NULL); /* If we are changing a GNOME font value and we are not using GNOME fonts in * Epiphany, return. */ if (g_strcmp0 (schema, EPHY_PREFS_WEB_SCHEMA) != 0 && g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_USE_GNOME_FONTS) != TRUE) { g_free (schema); return; } g_free (schema); value = g_settings_get_string (settings, key); if (value) { PangoFontDescription *desc; const char *family = NULL; desc = pango_font_description_from_string (value); family = pango_font_description_get_family (desc); g_object_set (webkit_settings, webkit_pref, family, NULL); pango_font_description_free (desc); } g_free (value); }
static gchar * calendar_config_get_timezone_stored (void) { calendar_config_init (); return g_settings_get_string (config, "timezone"); }
static void cc_ua_panel_set_shortcut_label (CcUaPanel *self, const char *label, const char *key) { GtkWidget *widget; char *value; char *text; guint accel_key, *keycode; GdkModifierType mods; widget = WID (self->priv->builder, label); value = g_settings_get_string (self->priv->mediakeys_settings, key); if (value == NULL || *value == '\0') { gtk_label_set_text (GTK_LABEL (widget), _("No shortcut set")); g_free (value); return; } gtk_accelerator_parse_with_keycode (value, &accel_key, &keycode, &mods); if (accel_key == 0 && keycode == NULL && mods == 0) { gtk_label_set_text (GTK_LABEL (widget), _("No shortcut set")); g_free (value); g_warning ("Failed to parse keyboard shortcut: '%s'", value); return; } g_free (value); text = gtk_accelerator_get_label_with_keycode (gtk_widget_get_display (widget), accel_key, *keycode, mods); g_free (keycode); gtk_label_set_text (GTK_LABEL (widget), text); g_free (text); }
/* * get_font_family: * * Return a font description for the font setting. Must be freed. */ static PangoFontDescription * get_font_family(void) { I7App *theapp = i7_app_get(); GSettings *prefs = i7_app_get_prefs(theapp); switch(g_settings_get_enum(prefs, PREFS_FONT_SET)) { case FONT_MONOSPACE: return get_desktop_monospace_font(); case FONT_CUSTOM: { char *customfont = g_settings_get_string(prefs, PREFS_CUSTOM_FONT); PangoFontDescription *retval; if(customfont) { retval = pango_font_description_from_string(customfont); g_free(customfont); return retval; } /* else fall through */ } default: ; } return get_desktop_standard_font(); }
/** * static applet config functions */ static void matekbd_indicator_config_load_font (MatekbdIndicatorConfig * ind_config) { ind_config->font_family = g_settings_get_string (ind_config->settings, MATEKBD_INDICATOR_CONFIG_KEY_FONT_FAMILY); if (ind_config->font_family == NULL || ind_config->font_family[0] == '\0') { PangoFontDescription *fd = NULL; GtkStyle *style = gtk_rc_get_style_by_paths (gtk_settings_get_default (), GTK_STYLE_PATH, GTK_STYLE_PATH, GTK_TYPE_LABEL); if (style != NULL) fd = style->font_desc; if (fd != NULL) { ind_config->font_family = g_strdup (pango_font_description_to_string(fd)); } } xkl_debug (150, "font: [%s]\n", ind_config->font_family); }
static char * panel_util_get_file_display_for_common_files (GFile *file) { GFile *compare; compare = g_file_new_for_path (g_get_home_dir ()); if (g_file_equal (file, compare)) { GSettings *settings = g_settings_new (GNOME_NAUTILUS_DESKTOP_SCHEMA); char *home_foler_name = g_settings_get_string (settings, GNOME_NAUTILUS_DESKTOP_HOME_ICON_NAME_KEY); g_object_unref (compare); g_object_unref (settings); if (PANEL_GLIB_STR_EMPTY (home_foler_name)) { g_free (home_foler_name); return g_strdup (_("Home Folder")); } else { return home_foler_name; } } g_object_unref (compare); compare = g_file_new_for_path ("/"); if (g_file_equal (file, compare)) { g_object_unref (compare); /* Translators: this is the same string as the one found in * nautilus */ return g_strdup (_("File System")); } g_object_unref (compare); return NULL; }
static GtkWidget * get_config_widgets (const char *bdaddr, const char **uuids) { GtkWidget *button; GSettings *settings; char *old_bdaddr; settings = g_settings_new (GPS_ID); button = gtk_check_button_new_with_label (_("Use this GPS device for Geolocation services")); g_object_set_data_full (G_OBJECT (button), "bdaddr", g_strdup (bdaddr), g_free); g_object_set_data_full (G_OBJECT (button), "settings", settings, g_object_unref); /* Is it already setup? */ old_bdaddr = g_settings_get_string (settings, GPS_KEY); if (g_strcmp0 (old_bdaddr, bdaddr) == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); g_object_set_data (G_OBJECT (button), "bdaddr", old_bdaddr); } else { g_free (old_bdaddr); } /* And set the signal */ g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (toggle_button), NULL); return button; }
char * logview_prefs_get_monospace_font_name (LogviewPrefs *prefs) { g_assert (LOGVIEW_IS_PREFS (prefs)); return (g_settings_get_string (prefs->priv->interface_prefs, MATE_MONOSPACE_FONT_NAME)); }
static void new_chatroom_dialog_select_last_account (GSettings *gsettings, EmpathyAccountChooser *account_chooser) { const gchar *account_path; TpAccountManager *manager; TpSimpleClientFactory *factory; TpAccount *account; TpConnectionStatus status; account_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ROOM_LAST_ACCOUNT); DEBUG ("Selecting account path '%s'", account_path); manager = tp_account_manager_dup (); factory = tp_proxy_get_factory (manager); account = tp_simple_client_factory_ensure_account (factory, account_path, NULL, NULL); if (account != NULL) { status = tp_account_get_connection_status (account, NULL); if (status == TP_CONNECTION_STATUS_CONNECTED) { empathy_account_chooser_set_account (account_chooser, account); } g_object_unref (account); } g_object_unref (manager); }
static void init_fonts(Sourceview* sv) { gboolean font_theme; font_theme = FALSE; //g_settings_get_boolean (sv->priv->settings, FONT_THEME); if (!font_theme) { gchar* font = g_settings_get_string (sv->priv->settings, FONT); anjuta_view_set_font(sv->priv->view, FALSE, font); g_free (font); } #if 0 else { /* FIXME: Get font from GSettings */ GConfClient *gclient; gchar *desktop_fixed_font; gclient = gconf_client_get_default (); desktop_fixed_font = gconf_client_get_string (gclient, DESKTOP_FIXED_FONT, NULL); if (desktop_fixed_font) anjuta_view_set_font(sv->priv->view, FALSE, desktop_fixed_font); else anjuta_view_set_font(sv->priv->view, TRUE, NULL); g_free (desktop_fixed_font); g_object_unref (gclient); } #endif }
/* Based on gdesktopappinfo.c in GIO */ static gchar * find_terminal_executable (void) { gsize i; gchar *path = NULL; g_autoptr(GSettings) terminal_settings = NULL; g_autofree gchar *gsettings_terminal = NULL; const gchar *terminals[] = { NULL, /* GSettings */ "x-terminal-emulator", /* Debian's alternative system */ "gnome-terminal", NULL, /* getenv ("TERM") */ "nxterm", "color-xterm", "rxvt", "xterm", "dtterm" }; /* This is deprecated, but at least the user can specify it! */ terminal_settings = g_settings_new ("org.gnome.desktop.default-applications.terminal"); gsettings_terminal = g_settings_get_string (terminal_settings, "exec"); terminals[0] = gsettings_terminal; /* This is generally one of the fallback terminals */ terminals[3] = g_getenv ("TERM"); for (i = 0; i < G_N_ELEMENTS (terminals) && path == NULL; ++i) { if (terminals[i] != NULL) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS path = g_find_program_in_path (terminals[i]); G_GNUC_END_IGNORE_DEPRECATIONS } }
static void pluma_prefs_manager_wrap_mode_changed (GSettings *settings, gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); if (strcmp (key, GPM_WRAP_MODE) == 0) { GtkWrapMode wrap_mode; GList *views; GList *l; wrap_mode = get_wrap_mode_from_string (g_settings_get_string(settings, key)); views = pluma_app_get_views (pluma_app_get_default ()); l = views; while (l != NULL) { gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (l->data), wrap_mode); l = l->next; } g_list_free (views); } }
static void on_gdl_style_changed (GSettings* settings, const gchar* key, gpointer user_data) { AnjutaWindow* win = ANJUTA_WINDOW (user_data); GdlSwitcherStyle style = GDL_SWITCHER_STYLE_BOTH; gchar* pr_style = g_settings_get_string (settings, key); if (strcasecmp (pr_style, "Text") == 0) style = GDL_SWITCHER_STYLE_TEXT; else if (strcasecmp (pr_style, "Icon") == 0) style = GDL_SWITCHER_STYLE_ICON; else if (strcasecmp (pr_style, "Both") == 0) style = GDL_SWITCHER_STYLE_BOTH; else if (strcasecmp (pr_style, "Toolbar") == 0) style = GDL_SWITCHER_STYLE_TOOLBAR; else if (strcasecmp (pr_style, "Tabs") == 0) style = GDL_SWITCHER_STYLE_TABS; g_object_set (gdl_dock_layout_get_master (win->layout_manager), "switcher-style", style, NULL); g_free (pr_style); }