/* * Code implementing a group of radio buttons with different Xft option combinations. * If one of the buttons is matched by the GConf key, we pick it. Otherwise we * show the group as inconsistent. */ static void font_render_get_gconf (GConfClient *client, Antialiasing *antialiasing, Hinting *hinting) { gchar *antialias_str = gconf_client_get_string (client, FONT_ANTIALIASING_KEY, NULL); gchar *hint_str = gconf_client_get_string (client, FONT_HINTING_KEY, NULL); gint val; val = ANTIALIAS_GRAYSCALE; if (antialias_str) { gconf_string_to_enum (antialias_enums, antialias_str, &val); g_free (antialias_str); } *antialiasing = val; val = HINT_FULL; if (hint_str) { gconf_string_to_enum (hint_enums, hint_str, &val); g_free (hint_str); } *hinting = val; }
static void set_toolbar_style (AppearanceData *data, const char *value) { static const GtkToolbarStyle gtk_toolbar_styles[] = { GTK_TOOLBAR_BOTH, GTK_TOOLBAR_BOTH_HORIZ, GTK_TOOLBAR_ICONS, GTK_TOOLBAR_TEXT }; int enum_val; if (!gconf_string_to_enum (toolbar_style_enums, value, &enum_val)) enum_val = 0; gtk_toolbar_set_style (GTK_TOOLBAR (glade_xml_get_widget (data->xml, "toolbar_toolbar")), gtk_toolbar_styles[enum_val]); }
static GConfValue * action_to_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; const gchar *str; gint val = 0; str = (value && (value->type == GCONF_VALUE_STRING)) ? gconf_value_get_string (value) : NULL; new_value = gconf_value_new (GCONF_VALUE_INT); gconf_string_to_enum (actions_lookup_table, str, &val); gconf_value_set_int (new_value, val); return new_value; }
static GConfValue * toolbar_to_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; const gchar *str; gint val; str = (value && (value->type == GCONF_VALUE_STRING)) ? gconf_value_get_string (value) : NULL; if (!gconf_string_to_enum (toolbar_style_enums, str, &val)) val = 0; new_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (new_value, val); return new_value; }
gboolean panel_action_button_load_from_drag (PanelToplevel *toplevel, PanelObjectPackType pack_type, int pack_index, const char *drag_string, int *old_applet_idx) { PanelActionButtonType type = PANEL_ACTION_NONE; gboolean retval = FALSE; char **elements; if (strncmp (drag_string, "ACTION:", strlen ("ACTION:"))) return retval; elements = g_strsplit (drag_string, ":", 0); g_assert (elements != NULL); if (!elements [1] || !elements [2]) { g_strfreev (elements); return retval; } if (!gconf_string_to_enum (panel_action_type_map, elements [1], (gpointer) &type)) { g_strfreev (elements); return retval; } g_return_val_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST, FALSE); if (panel_action_get_is_deprecated (type)) return retval; if (strcmp (elements [2], "NEW")) { *old_applet_idx = strtol (elements [2], NULL, 10); retval = TRUE; /* Remove the old applet */ } g_strfreev (elements); panel_action_button_create (toplevel, pack_type, pack_index, type); return retval; }
static GConfValue * bell_flash_to_widget (GConfPropertyEditor *peditor, const GConfValue *value) { GConfValue *new_value; const gchar *str; gint val = 2; str = (value && (value->type == GCONF_VALUE_STRING)) ? gconf_value_get_string (value) : NULL; new_value = gconf_value_new (GCONF_VALUE_INT); if (value->type == GCONF_VALUE_STRING) { gconf_string_to_enum (bell_flash_enums, str, &val); } gconf_value_set_int (new_value, val); return new_value; }
static void enum_group_load (EnumGroup *group) { gchar *str = gconf_client_get_string (group->client, group->gconf_key, NULL); gint val = group->default_value; GSList *tmp_list; if (str) gconf_string_to_enum (group->enums, str, &val); g_free (str); in_change = TRUE; for (tmp_list = group->items; tmp_list; tmp_list = tmp_list->next) { EnumItem *item = tmp_list->data; if (val == item->value) gtk_toggle_button_set_active (item->widget, TRUE); } in_change = FALSE; }
static void update_proxy_settings (void) { char *mode, *http_proxy, *https_proxy = NULL, *no_proxy = NULL; GSList *ignore; /* resolver_gnome is locked */ if (proxy_user) { g_free (proxy_user); proxy_user = NULL; } if (proxy_password) { memset (proxy_password, 0, strlen (proxy_password)); g_free (proxy_password); proxy_password = NULL; } /* Get new settings */ mode = gconf_client_get_string ( gconf_client, SOUP_GCONF_PROXY_MODE, NULL); if (!mode || !gconf_string_to_enum (proxy_mode_map, mode, (int *)&proxy_mode)) proxy_mode = SOUP_PROXY_RESOLVER_GNOME_MODE_NONE; g_free (mode); if (proxy_mode == SOUP_PROXY_RESOLVER_GNOME_MODE_NONE) { if (libproxy_factory) { /* Unset anything we previously set */ g_unsetenv ("PX_CONFIG_ORDER"); g_unsetenv ("http_proxy"); g_unsetenv ("https_proxy"); g_unsetenv ("no_proxy"); } return; } else if (proxy_mode == SOUP_PROXY_RESOLVER_GNOME_MODE_AUTO) { char *autoconfig_url; autoconfig_url = gconf_client_get_string ( gconf_client, SOUP_GCONF_PROXY_AUTOCONFIG_URL, NULL); if (autoconfig_url && !strncmp (autoconfig_url, "http", 4)) http_proxy = g_strconcat ("pac+", autoconfig_url, NULL); else http_proxy = g_strdup ("wpad://"); g_free (autoconfig_url); } else /* SOUP_PROXY_RESOLVER_GNOME_MODE_MANUAL */ { char *host; guint port; host = gconf_client_get_string ( gconf_client, SOUP_GCONF_HTTP_PROXY_HOST, NULL); if (!host || !*host) { g_free (host); proxy_mode = SOUP_PROXY_RESOLVER_GNOME_MODE_NONE; return; } port = gconf_client_get_int ( gconf_client, SOUP_GCONF_HTTP_PROXY_PORT, NULL); if (port) { http_proxy = g_strdup_printf ("http://%s:%u", host, port); } else http_proxy = g_strdup_printf ("http://%s", host); g_free (host); if (!gconf_client_get_bool (gconf_client, SOUP_GCONF_USE_SAME_PROXY, NULL)) { host = gconf_client_get_string ( gconf_client, SOUP_GCONF_HTTPS_PROXY_HOST, NULL); port = gconf_client_get_int ( gconf_client, SOUP_GCONF_HTTPS_PROXY_PORT, NULL); if (host && *host) { if (port) { https_proxy = g_strdup_printf ( "http://%s:%u", host, port); } else { https_proxy = g_strdup_printf ( "http://%s", host); } } g_free (host); } if (gconf_client_get_bool (gconf_client, SOUP_GCONF_HTTP_USE_AUTH, NULL)) { proxy_user = gconf_client_get_string ( gconf_client, SOUP_GCONF_HTTP_PROXY_USER, NULL); proxy_password = gconf_client_get_string ( gconf_client, SOUP_GCONF_HTTP_PROXY_PASSWORD, NULL); } } ignore = gconf_client_get_list ( gconf_client, SOUP_GCONF_PROXY_IGNORE_HOSTS, GCONF_VALUE_STRING, NULL); if (ignore) { GString *ignore_list; GSList *i; ignore_list = g_string_new (NULL); for (i = ignore; i; i = i->next) { if (ignore_list->len) g_string_append_c (ignore_list, ','); g_string_append (ignore_list, i->data); g_free (i->data); } g_slist_free (ignore); no_proxy = g_string_free (ignore_list, FALSE); } g_setenv ("PX_CONFIG_ORDER", "envvar", TRUE); g_setenv ("http_proxy", http_proxy, TRUE); g_free (http_proxy); if (https_proxy) { g_setenv ("https_proxy", https_proxy, TRUE); g_free (https_proxy); } else g_unsetenv ("https_proxy"); if (no_proxy) { g_setenv ("no_proxy", no_proxy, TRUE); g_free (no_proxy); } else g_unsetenv ("no_proxy"); /* If we haven't created a proxy factory or thread pool yet, * do so. If we already have one, we don't need to update * anything, because it rechecks the environment variables * every time. */ if (!libproxy_factory) libproxy_factory = px_proxy_factory_new (); if (proxy_mode == SOUP_PROXY_RESOLVER_GNOME_MODE_AUTO && !libproxy_threadpool) { libproxy_threadpool = g_thread_pool_new (libproxy_threadpool_func, NULL, -1, FALSE, NULL); } }