/* Menu Callback: Lock/Unlock sticky notes */ void menu_toggle_lock_cb(GtkAction *action, StickyNotesApplet *applet) { gboolean locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); if (gconf_client_key_is_writable(stickynotes->gconf, GCONF_PATH "/settings/locked", NULL)) gconf_client_set_bool(stickynotes->gconf, GCONF_PATH "/settings/locked", locked, NULL); }
gboolean gm_conf_is_key_writable (const gchar *key) { g_return_val_if_fail (key != NULL, FALSE); return gconf_client_key_is_writable (client, key, NULL); }
static gboolean marina_prefs_key_is_writable (const gchar* key) { marina_debug (DEBUG_PREFS); g_return_val_if_fail (gconf_client != NULL, FALSE); return gconf_client_key_is_writable (gconf_client, key, NULL); }
void gfloppy_config_save (GFloppyConfig *config, GConfClient *client) { GError *error = NULL; g_return_if_fail (config != NULL); g_return_if_fail (client != NULL); if (gconf_client_key_is_writable (client, "/apps/gfloppy/default_fs", &error)) gconf_client_set_string (client, "/apps/gfloppy/default_fs", config->default_fs, &error); check_gconf_error (&error); if (gconf_client_key_is_writable (client, "/apps/gfloppy/default_formatting_mode", &error)) gconf_client_set_int (client, "/apps/gfloppy/default_formatting_mode", config->default_formatting_mode, &error); check_gconf_error (&error); }
static void marina_prefs_set_int (const gchar* key, gint value) { marina_debug (DEBUG_PREFS); g_return_if_fail (gconf_client != NULL); g_return_if_fail (gconf_client_key_is_writable (gconf_client, key, NULL)); gconf_client_set_int (gconf_client, key, value, NULL); }
static void setup_sensitivity (PagerData *pager, GladeXML *xml, const char *wid1, const char *wid2, const char *wid3, const char *key) { PanelApplet *applet = PANEL_APPLET (pager->applet); GConfClient *client = gconf_client_get_default (); char *fullkey; GtkWidget *w; if (key[0] == '/') fullkey = g_strdup (key); else fullkey = panel_applet_gconf_get_full_key (applet, key); if (gconf_client_key_is_writable (client, fullkey, NULL)) { g_object_unref (G_OBJECT (client)); g_free (fullkey); return; } g_object_unref (G_OBJECT (client)); g_free (fullkey); w = glade_xml_get_widget (xml, wid1); g_assert (w != NULL); g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE, GINT_TO_POINTER (1)); gtk_widget_set_sensitive (w, FALSE); if (wid2 != NULL) { w = glade_xml_get_widget (xml, wid2); g_assert (w != NULL); g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE, GINT_TO_POINTER (1)); gtk_widget_set_sensitive (w, FALSE); } if (wid3 != NULL) { w = glade_xml_get_widget (xml, wid3); g_assert (w != NULL); g_object_set_data (G_OBJECT (w), NEVER_SENSITIVE, GINT_TO_POINTER (1)); gtk_widget_set_sensitive (w, FALSE); } }
static GtkWidget* entry_attached_to(GConfClient* client, const gchar* key) { GtkWidget* entry; GtkWidget* hbox; GtkWidget* label; gchar* val; guint notify_id; entry = gtk_entry_new(); gtk_object_set_data_full(GTK_OBJECT(entry), "key", g_strdup(key), g_free); val = gconf_client_get_string(client, key, NULL); gtk_entry_set_text(GTK_ENTRY(entry), val ? val : ""); g_free(val); notify_id = gconf_client_notify_add(client, key, entry_notify_func, entry, NULL, NULL); gtk_object_set_data(GTK_OBJECT(entry), "notify_id", GUINT_TO_POINTER(notify_id)); gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(entry_changed_callback), client); gtk_signal_connect(GTK_OBJECT(entry), "destroy", GTK_SIGNAL_FUNC(entry_destroyed_callback), client); hbox = gtk_hbox_new(FALSE, 10); label = gtk_label_new(key); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); /* Set sensitive according to whether the key is writable or not. */ gtk_widget_set_sensitive (entry, gconf_client_key_is_writable (client, key, NULL)); return hbox; }
static void toggle_button_init (EMNetworkPrefs *prefs, GtkToggleButton *toggle, const gchar *key) { gboolean bool; bool = gconf_client_get_bool (prefs->gconf, key, NULL); gtk_toggle_button_set_active (toggle, bool); g_object_set_data ((GObject *) toggle, "key", (gpointer) key); g_signal_connect (toggle, "toggled", G_CALLBACK (toggle_button_toggled), prefs); if (!gconf_client_key_is_writable (prefs->gconf, key, NULL)) gtk_widget_set_sensitive ((GtkWidget *) toggle, FALSE); }
gboolean eel_gconf_key_is_writable (const char *key) { gboolean result; GError *error = NULL; g_return_val_if_fail (key != NULL, FALSE); result = gconf_client_key_is_writable (eel_gconf_client_get_global (), key, &error); if (eel_gconf_handle_error (&error)) { return result; } return result; }
static GtkWidget* create_config_entry(GtkWidget* prefs_dialog, GConfClient* client, const gchar* config_key) { GtkWidget* frame; GtkWidget* entry; GConfValue* initial = NULL; frame = gtk_frame_new(config_key); entry = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(frame), entry); initial = gconf_client_get(client, config_key, NULL); if (initial != NULL && initial->type == GCONF_VALUE_STRING) { const gchar* str = gconf_value_get_string(initial); gtk_entry_set_text(GTK_ENTRY(entry), str); } if (initial) gconf_value_free(initial); g_object_set_data(entry, "client", client); g_object_set_data(entry, "key", g_strdup(config_key)); g_signal_connect(entry, "destroy", G_CALLBACK(config_entry_destroy_callback), NULL); g_signal_connect(entry, "changed", G_CALLBACK(config_entry_changed_callback), prefs_dialog); /* A dubious hack; set the entry as object data using its config key as the key so we can find it in the prefs dialog revert code */ g_object_set_data(prefs_dialog, config_key, entry); /* Set the entry insensitive if the key it edits isn't writable */ gtk_widget_set_sensitive (entry, gconf_client_key_is_writable (client, config_key, NULL)); return frame; }
/* Preferences Callback : Save. */ void preferences_save_cb (gpointer data) { gint width = gtk_adjustment_get_value (stickynotes->w_prefs_width); gint height = gtk_adjustment_get_value (stickynotes->w_prefs_height); gboolean sys_color = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color)); gboolean sys_font = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_font)); gboolean sticky = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky)); gboolean force_default = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force)); gboolean desktop_hide = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop)); if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/defaults/width", NULL)) gconf_client_set_int (stickynotes->gconf, GCONF_PATH "/defaults/width", width, NULL); if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/defaults/height", NULL)) gconf_client_set_int (stickynotes->gconf, GCONF_PATH "/defaults/height", height, NULL); if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/settings/use_system_color", NULL)) gconf_client_set_bool (stickynotes->gconf, GCONF_PATH "/settings/use_system_color", sys_color, NULL); if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/settings/use_system_font", NULL)) gconf_client_set_bool (stickynotes->gconf, GCONF_PATH "/settings/use_system_font", sys_font, NULL); if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/settings/sticky", NULL)) gconf_client_set_bool (stickynotes->gconf, GCONF_PATH "/settings/sticky", sticky, NULL); if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/settings/force_default", NULL)) gconf_client_set_bool (stickynotes->gconf, GCONF_PATH "/settings/force_default", force_default, NULL); if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/settings/desktop_hide", NULL)) gconf_client_set_bool (stickynotes->gconf, GCONF_PATH "/settings/desktop_hide", desktop_hide, NULL); }
gboolean mc_key_writable (MCData *mc, const char *key) { gboolean writable; char *fullkey; static GConfClient *client = NULL; if (client == NULL) client = gconf_client_get_default (); fullkey = panel_applet_gconf_get_full_key (mc->applet, key); writable = gconf_client_key_is_writable (client, fullkey, NULL); g_free (fullkey); return writable; }
static gboolean gconf_settings_backend_get_writable (GSettingsBackend *backend, const gchar *name) { GConfSettingsBackend *gconf = GCONF_SETTINGS_BACKEND (backend); GConfValue *value; /* We don't support checking writabality for a whole subpath, so we just say * it's not writable in such a case. */ if (name[strlen(name) - 1] == '/') return FALSE; value = gconf_client_get (gconf->priv->client, name, NULL); if (value == NULL) return TRUE; else gconf_value_free (value); return gconf_client_key_is_writable (gconf->priv->client, name, NULL); }
/** * gpk_prefs_update_freq_combo_setup: **/ static void gpk_prefs_update_freq_combo_setup (void) { guint value; gboolean is_writable; GtkWidget *widget; GConfClient *client; client = gconf_client_get_default (); widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_check")); is_writable = gconf_client_key_is_writable (client, GPK_CONF_FREQUENCY_GET_UPDATES, NULL); value = gconf_client_get_int (client, GPK_CONF_FREQUENCY_GET_UPDATES, NULL); egg_debug ("value from gconf %i", value); g_object_unref (client); /* do we have permission to write? */ gtk_widget_set_sensitive (widget, is_writable); /* set a simple text model */ gpk_prefs_update_freq_combo_simple_text (widget); gtk_combo_box_append_text (GTK_COMBO_BOX (widget), PK_FREQ_HOURLY_TEXT); gtk_combo_box_append_text (GTK_COMBO_BOX (widget), PK_FREQ_DAILY_TEXT); gtk_combo_box_append_text (GTK_COMBO_BOX (widget), PK_FREQ_WEEKLY_TEXT); gtk_combo_box_append_text (GTK_COMBO_BOX (widget), PK_FREQ_NEVER_TEXT); /* select the correct entry */ if (value == GPK_PREFS_VALUE_HOURLY) gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); else if (value == GPK_PREFS_VALUE_DAILY) gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1); else if (value == GPK_PREFS_VALUE_WEEKLY) gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2); else if (value == GPK_PREFS_VALUE_NEVER) gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 3); /* only do this after else we redraw the window */ g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (gpk_prefs_update_freq_combo_changed), NULL); }
static void setup_sensitivity (TasklistData *tasklist, GConfClient *client, GladeXML *xml, const char *wid1, const char *wid2, const char *wid3, const char *key) { PanelApplet *applet = PANEL_APPLET (tasklist->applet); char *fullkey; GtkWidget *w; fullkey = panel_applet_gconf_get_full_key (applet, key); if (gconf_client_key_is_writable (client, fullkey, NULL)) { g_free (fullkey); return; } g_free (fullkey); w = glade_xml_get_widget (xml, wid1); g_assert (w != NULL); gtk_widget_set_sensitive (w, FALSE); if (wid2 != NULL) { w = glade_xml_get_widget (xml, wid2); g_assert (w != NULL); gtk_widget_set_sensitive (w, FALSE); } if (wid3 != NULL) { w = glade_xml_get_widget (xml, wid3); g_assert (w != NULL); gtk_widget_set_sensitive (w, FALSE); } }
void stickynotes_applet_update_menus(void) { GList *l; gboolean inconsistent = FALSE; gboolean locked = gconf_client_get_bool(stickynotes->gconf, GCONF_PATH "/settings/locked", NULL); gboolean locked_writable = gconf_client_key_is_writable(stickynotes->gconf, GCONF_PATH "/settings/locked", NULL); for (l = stickynotes->notes; l != NULL; l = l->next) { StickyNote *note = l->data; if (note->locked != locked) { inconsistent = TRUE; break; } } for (l = stickynotes->applets; l != NULL; l = l->next) { StickyNotesApplet *applet = l->data; GSList *proxies, *p; GtkAction *action = gtk_action_group_get_action (applet->action_group, "lock"); g_object_set (action, "active", locked, "sensitive", locked_writable, NULL); proxies = gtk_action_get_proxies (action); for (p = proxies; p; p = g_slist_next (p)) { if (GTK_IS_CHECK_MENU_ITEM (p->data)) { gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (p->data), inconsistent); } } } }
/** * gpk_prefs_auto_update_combo_setup: **/ static void gpk_prefs_auto_update_combo_setup (void) { gchar *value; gboolean is_writable; GtkWidget *widget; GpkUpdateEnum update; GConfClient *client; client = gconf_client_get_default (); widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_install")); is_writable = gconf_client_key_is_writable (client, GPK_CONF_AUTO_UPDATE, NULL); value = gconf_client_get_string (client, GPK_CONF_AUTO_UPDATE, NULL); if (value == NULL) { egg_warning ("invalid schema, please re-install"); return; } egg_debug ("value from gconf %s", value); update = gpk_update_enum_from_text (value); g_free (value); g_object_unref (client); /* do we have permission to write? */ gtk_widget_set_sensitive (widget, is_writable); /* set a simple text model */ gpk_prefs_update_freq_combo_simple_text (widget); gtk_combo_box_append_text (GTK_COMBO_BOX (widget), PK_UPDATE_ALL_TEXT); gtk_combo_box_append_text (GTK_COMBO_BOX (widget), PK_UPDATE_SECURITY_TEXT); gtk_combo_box_append_text (GTK_COMBO_BOX (widget), PK_UPDATE_NONE_TEXT); /* we can do this as it's the same order */ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), update); /* only do this after else we redraw the window */ g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (gpk_prefs_update_combo_changed), NULL); }
void stickynotes_applet_init_prefs(void) { stickynotes->builder = gtk_builder_new (); gtk_builder_add_from_file (stickynotes->builder, BUILDER_PATH, NULL); stickynotes->w_prefs = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "preferences_dialog")); stickynotes->w_prefs_width = gtk_spin_button_get_adjustment ( GTK_SPIN_BUTTON (gtk_builder_get_object ( stickynotes->builder, "width_spin"))); stickynotes->w_prefs_height = gtk_spin_button_get_adjustment ( GTK_SPIN_BUTTON (gtk_builder_get_object ( stickynotes->builder, "height_spin"))); stickynotes->w_prefs_color = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "default_color")); stickynotes->w_prefs_font_color = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "prefs_font_color")); stickynotes->w_prefs_sys_color = GTK_WIDGET (>K_CHECK_BUTTON ( gtk_builder_get_object (stickynotes->builder, "sys_color_check"))->toggle_button); stickynotes->w_prefs_font = GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "default_font")); stickynotes->w_prefs_sys_font = GTK_WIDGET (>K_CHECK_BUTTON ( gtk_builder_get_object (stickynotes->builder, "sys_font_check"))->toggle_button); stickynotes->w_prefs_sticky = GTK_WIDGET (>K_CHECK_BUTTON ( gtk_builder_get_object (stickynotes->builder, "sticky_check"))->toggle_button); stickynotes->w_prefs_force = GTK_WIDGET (>K_CHECK_BUTTON ( gtk_builder_get_object (stickynotes->builder, "force_default_check"))->toggle_button); stickynotes->w_prefs_desktop = GTK_WIDGET (>K_CHECK_BUTTON ( gtk_builder_get_object (stickynotes->builder, "desktop_hide_check"))->toggle_button); g_signal_connect (G_OBJECT (stickynotes->w_prefs), "response", G_CALLBACK (preferences_response_cb), NULL); g_signal_connect (G_OBJECT (stickynotes->w_prefs), "delete-event", G_CALLBACK (preferences_delete_cb), NULL); g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_width), "value-changed", G_CALLBACK (preferences_save_cb), NULL); g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_height), "value-changed", G_CALLBACK (preferences_save_cb), NULL); g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_sys_color), "toggled", G_CALLBACK (preferences_save_cb), NULL); g_signal_connect_swapped (G_OBJECT(stickynotes->w_prefs_sys_font), "toggled", G_CALLBACK (preferences_save_cb), NULL); g_signal_connect (G_OBJECT (stickynotes->w_prefs_color), "color-set", G_CALLBACK (preferences_color_cb), NULL); g_signal_connect (G_OBJECT (stickynotes->w_prefs_font_color), "color-set", G_CALLBACK (preferences_color_cb), NULL); g_signal_connect (G_OBJECT (stickynotes->w_prefs_font), "font-set", G_CALLBACK (preferences_font_cb), NULL); g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_sticky), "toggled", G_CALLBACK (preferences_save_cb), NULL); g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_force), "toggled", G_CALLBACK (preferences_save_cb), NULL); g_signal_connect_swapped (G_OBJECT (stickynotes->w_prefs_desktop), "toggled", G_CALLBACK (preferences_save_cb), NULL); { GtkSizeGroup *group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); gtk_size_group_add_widget(group, GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "width_label"))); gtk_size_group_add_widget(group, GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "height_label"))); gtk_size_group_add_widget(group, GTK_WIDGET (gtk_builder_get_object (stickynotes->builder, "prefs_color_label"))); g_object_unref(group); } if (!gconf_client_key_is_writable(stickynotes->gconf, GCONF_PATH "/defaults/width", NULL)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "width_label")), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "width_spin")), FALSE); } if (!gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/defaults/height", NULL)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "height_label")), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "height_spin")), FALSE); } if (!gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/defaults/color", NULL)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "prefs_color_label")), FALSE); gtk_widget_set_sensitive (stickynotes->w_prefs_color, FALSE); } if (!gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/defaults/font_color", NULL)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "prefs_font_color_label")), FALSE); gtk_widget_set_sensitive (stickynotes->w_prefs_font_color, FALSE); } if (!gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/settings/use_system_color", NULL)) gtk_widget_set_sensitive (stickynotes->w_prefs_sys_color, FALSE); if (!gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/defaults/font", NULL)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "prefs_font_label")), FALSE); gtk_widget_set_sensitive (stickynotes->w_prefs_font, FALSE); } if (!gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/settings/use_system_font", NULL)) gtk_widget_set_sensitive (stickynotes->w_prefs_sys_font, FALSE); if (!gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/settings/sticky", NULL)) gtk_widget_set_sensitive (stickynotes->w_prefs_sticky, FALSE); if (!gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/settings/force_default", NULL)) gtk_widget_set_sensitive (stickynotes->w_prefs_force, FALSE); stickynotes_applet_update_prefs(); }
/* Create an entry used to edit the given config key */ static GtkWidget* create_config_entry (GtkWidget *prefs_dialog, GConfClient *client, const gchar *config_key, gboolean focus) { GtkWidget *hbox; GtkWidget *entry; GtkWidget *label; char *str; hbox = gtk_hbox_new (FALSE, 5); label = gtk_label_new (config_key); entry = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), entry, FALSE, FALSE, 0); /* this will print an error via default error handler * if the key isn't set to a string */ str = gconf_client_get_string (client, config_key, NULL); if (str) { gtk_entry_set_text (GTK_ENTRY (entry), str); g_free (str); } g_object_set_data (G_OBJECT (entry), "client", client); g_object_set_data_full (G_OBJECT (entry), "key", g_strdup (config_key), (GDestroyNotify) g_free); /* Commit changes if the user focuses out, or hits enter; we don't * do this on "changed" since it'd probably be a bit too slow to * round-trip to the server on every "changed" signal. */ g_signal_connect (G_OBJECT (entry), "focus_out_event", G_CALLBACK (config_entry_commit), NULL); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (config_entry_commit), NULL); /* Set the entry insensitive if the key it edits isn't writable. * Technically, we should update this sensitivity if the key gets * a change notify, but that's probably overkill. */ gtk_widget_set_sensitive (entry, gconf_client_key_is_writable (client, config_key, NULL)); if (focus) gtk_widget_grab_focus (entry); return hbox; }
static void em_network_prefs_construct (EMNetworkPrefs *prefs) { GtkWidget *toplevel; GSList *l, *ignore; gchar *buf; EMConfig *ec; EMConfigTargetPrefs *target; gboolean locked; gint i, val, port; prefs->gconf = gconf_client_get_default (); /* Make sure our custom widget classes are registered with * GType before we load the GtkBuilder definition file. */ E_TYPE_MAIL_JUNK_OPTIONS; EM_TYPE_FOLDER_SELECTION_BUTTON; prefs->builder = gtk_builder_new (); e_load_ui_builder_definition (prefs->builder, "mail-config.ui"); /** @HookPoint-EMConfig: Network Preferences * @Id: org.gnome.evolution.mail.networkPrefs * @Type: E_CONFIG_BOOK * @Class: org.gnome.evolution.mail.config:1.0 * @Target: EMConfigTargetPrefs * * The network preferences settings page. */ ec = em_config_new(E_CONFIG_BOOK, "org.gnome.evolution.mail.networkPrefs"); l = NULL; for (i = 0; i < G_N_ELEMENTS (emnp_items); i++) l = g_slist_prepend (l, &emnp_items[i]); e_config_add_items ((EConfig *) ec, l, emnp_free, prefs); /* Proxy tab */ /* Default Behavior */ locked = !gconf_client_key_is_writable (prefs->gconf, GCONF_E_PROXY_TYPE_KEY, NULL); val = gconf_client_get_int (prefs->gconf, GCONF_E_PROXY_TYPE_KEY, NULL); /* no auto-proxy at the moment */ if (val == NETWORK_PROXY_AUTOCONFIG) val = NETWORK_PROXY_SYS_SETTINGS; prefs->sys_proxy = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "rdoSysSettings")); gtk_toggle_button_set_active (prefs->sys_proxy, val == NETWORK_PROXY_SYS_SETTINGS); if (locked) gtk_widget_set_sensitive ((GtkWidget *) prefs->sys_proxy, FALSE); d(g_print ("Sys settings ----!!! \n")); prefs->no_proxy = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "rdoNoProxy")); gtk_toggle_button_set_active (prefs->no_proxy, val == NETWORK_PROXY_DIRECT_CONNECTION); if (locked) gtk_widget_set_sensitive ((GtkWidget *) prefs->no_proxy, FALSE); d(g_print ("No proxy settings ----!!! \n")); /* no auto-proxy at the moment */ #if 0 prefs->auto_proxy = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "rdoAutoConfig")); prefs->auto_proxy_url = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtAutoConfigUrl")); gtk_toggle_button_set_active (prefs->auto_proxy, val == NETWORK_PROXY_AUTOCONFIG); g_signal_connect (prefs->auto_proxy_url, "changed", G_CALLBACK(widget_entry_changed_cb), GCONF_E_AUTOCONFIG_URL_KEY); if (locked) gtk_widget_set_sensitive ((GtkWidget *) prefs->auto_proxy, FALSE); #endif d(g_print ("Auto config settings ----!!! \n")); prefs->manual_proxy = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "rdoManualProxy")); prefs->http_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtHttpHost")); prefs->https_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtHttpsHost")); prefs->socks_host = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtSocksHost")); prefs->ignore_hosts = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtIgnoreHosts")); prefs->http_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnHttpPort")); prefs->https_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnHttpsPort")); prefs->socks_port = GTK_SPIN_BUTTON (e_builder_get_widget (prefs->builder, "spnSocksPort")); prefs->lbl_http_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpHost")); prefs->lbl_http_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpPort")); prefs->lbl_https_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpsHost")); prefs->lbl_https_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblHttpsPort")); prefs->lbl_socks_host = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblSocksHost")); prefs->lbl_socks_port = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblSocksPort")); prefs->lbl_ignore_hosts = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblIgnoreHosts")); prefs->use_auth = GTK_TOGGLE_BUTTON (e_builder_get_widget (prefs->builder, "chkUseAuth")); toggle_button_init (prefs, prefs->use_auth, GCONF_E_USE_AUTH_KEY); prefs->lbl_auth_user = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblAuthUser")); prefs->lbl_auth_pwd = GTK_LABEL (e_builder_get_widget (prefs->builder, "lblAuthPwd")); prefs->auth_user = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtAuthUser")); prefs->auth_pwd = GTK_ENTRY (e_builder_get_widget (prefs->builder, "txtAuthPwd")); /* Manual proxy options */ g_signal_connect (prefs->http_host, "changed", G_CALLBACK (widget_entry_changed_cb), (gpointer) GCONF_E_HTTP_HOST_KEY); g_signal_connect (prefs->https_host, "changed", G_CALLBACK (widget_entry_changed_cb), (gpointer) GCONF_E_HTTPS_HOST_KEY); g_signal_connect (prefs->ignore_hosts, "changed", G_CALLBACK (ignore_hosts_entry_changed_cb), (gpointer) GCONF_E_IGNORE_HOSTS_KEY); g_signal_connect (prefs->http_port, "value_changed", G_CALLBACK (widget_entry_changed_cb), (gpointer) GCONF_E_HTTP_PORT_KEY); g_signal_connect (prefs->https_port, "value_changed", G_CALLBACK (widget_entry_changed_cb), (gpointer) GCONF_E_HTTPS_PORT_KEY); g_signal_connect (prefs->socks_host, "changed", G_CALLBACK (widget_entry_changed_cb), (gpointer) GCONF_E_SOCKS_HOST_KEY); g_signal_connect (prefs->socks_port, "value_changed", G_CALLBACK (widget_entry_changed_cb), (gpointer) GCONF_E_SOCKS_PORT_KEY); g_signal_connect (prefs->auth_user, "changed", G_CALLBACK (widget_entry_changed_cb), (gpointer) GCONF_E_AUTH_USER_KEY); g_signal_connect (prefs->auth_pwd, "changed", G_CALLBACK (widget_entry_changed_cb), (gpointer) GCONF_E_AUTH_PWD_KEY); gtk_toggle_button_set_active (prefs->manual_proxy, val == NETWORK_PROXY_MANUAL); g_signal_connect (prefs->sys_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs); g_signal_connect (prefs->no_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs); #if 0 g_signal_connect (prefs->auto_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs); #endif g_signal_connect (prefs->manual_proxy, "toggled", G_CALLBACK (notify_proxy_type_changed), prefs); if (locked) gtk_widget_set_sensitive ((GtkWidget *) prefs->manual_proxy, FALSE); d(g_print ("Manual settings ----!!! \n")); buf = gconf_client_get_string (prefs->gconf, GCONF_E_HTTP_HOST_KEY, NULL); gtk_entry_set_text (prefs->http_host, buf ? buf : ""); g_free (buf); buf = gconf_client_get_string (prefs->gconf, GCONF_E_HTTPS_HOST_KEY, NULL); gtk_entry_set_text (prefs->https_host, buf ? buf : ""); g_free (buf); buf = gconf_client_get_string (prefs->gconf, GCONF_E_SOCKS_HOST_KEY, NULL); gtk_entry_set_text (prefs->socks_host, buf ? buf : ""); g_free (buf); buf = NULL; ignore = gconf_client_get_list (prefs->gconf, GCONF_E_IGNORE_HOSTS_KEY, GCONF_VALUE_STRING, NULL); if (ignore) { /* reconstruct comma-separated list */ GSList *sl; GString *str = NULL; for (sl = ignore; sl; sl = sl->next) { const gchar *value = sl->data; if (value && *value) { if (!str) { str = g_string_new (value); } else { g_string_append (str, ","); g_string_append (str, value); } } } g_slist_foreach (ignore, (GFunc) g_free, NULL); g_slist_free (ignore); if (str) buf = g_string_free (str, FALSE); } gtk_entry_set_text (prefs->ignore_hosts, buf ? buf : ""); g_free (buf); buf = gconf_client_get_string (prefs->gconf, GCONF_E_AUTH_USER_KEY, NULL); gtk_entry_set_text (prefs->auth_user, buf ? buf : ""); g_free (buf); buf = gconf_client_get_string (prefs->gconf, GCONF_E_AUTH_PWD_KEY, NULL); gtk_entry_set_text (prefs->auth_pwd, buf ? buf : ""); g_free (buf); port = gconf_client_get_int (prefs->gconf, GCONF_E_HTTP_PORT_KEY, NULL); gtk_spin_button_set_value (prefs->http_port, (gdouble) port); port = gconf_client_get_int (prefs->gconf, GCONF_E_HTTPS_PORT_KEY, NULL); gtk_spin_button_set_value (prefs->https_port, (gdouble) port); port = gconf_client_get_int (prefs->gconf, GCONF_E_SOCKS_PORT_KEY, NULL); gtk_spin_button_set_value (prefs->socks_port, (gdouble) port); emnp_set_markups (prefs); if (val == NETWORK_PROXY_DIRECT_CONNECTION || val == NETWORK_PROXY_SYS_SETTINGS) { emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE); emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, FALSE); } else if (val == NETWORK_PROXY_AUTOCONFIG) { emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, FALSE); emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, TRUE); } else if (val == NETWORK_PROXY_MANUAL) { emnp_set_sensitiveness (prefs, NETWORK_PROXY_AUTOCONFIG, FALSE); emnp_set_sensitiveness (prefs, NETWORK_PROXY_MANUAL, TRUE); } /* get our toplevel widget */ target = em_config_target_new_prefs (ec, prefs->gconf); e_config_set_target ((EConfig *) ec, (EConfigTarget *) target); toplevel = e_config_create_widget ((EConfig *) ec); gtk_container_add (GTK_CONTAINER (prefs), toplevel); }
static void mc_preferences_setup_dialog (GtkBuilder *builder, MCData *mc) { MCPrefsDialog *dialog; GtkCellRenderer *renderer; GConfClient *client; GdkColor color; dialog = &mc->prefs_dialog; g_signal_connect (dialog->dialog, "response", G_CALLBACK (preferences_response), mc); gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog), GTK_RESPONSE_CLOSE); gtk_window_set_default_size (GTK_WINDOW (dialog->dialog), 400, -1); dialog->auto_complete_history_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "auto_complete_history_toggle")); dialog->size_spinner = GTK_WIDGET (gtk_builder_get_object (builder, "size_spinner")); dialog->use_default_theme_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "default_theme_toggle")); dialog->fg_color_picker = GTK_WIDGET (gtk_builder_get_object (builder, "fg_color_picker")); dialog->bg_color_picker = GTK_WIDGET (gtk_builder_get_object (builder, "bg_color_picker")); dialog->macros_tree = GTK_WIDGET (gtk_builder_get_object (builder, "macros_tree")); dialog->delete_button = GTK_WIDGET (gtk_builder_get_object (builder, "delete_button")); dialog->add_button = GTK_WIDGET (gtk_builder_get_object (builder, "add_button")); /* History based autocompletion */ g_signal_connect (dialog->auto_complete_history_toggle, "toggled", G_CALLBACK (auto_complete_history_toggled), mc); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->auto_complete_history_toggle), mc->preferences.auto_complete_history); if ( ! mc_key_writable (mc, "autocomplete_history")) hard_set_sensitive (dialog->auto_complete_history_toggle, FALSE); /* Width */ gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->size_spinner), mc->preferences.normal_size_x); g_signal_connect (dialog->size_spinner, "value_changed", G_CALLBACK (size_value_changed), mc); if ( ! mc_key_writable (mc, "normal_size_x")) { hard_set_sensitive (dialog->size_spinner, FALSE); hard_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "size_label")), FALSE); hard_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "size_post_label")), FALSE); } /* Use default theme */ g_signal_connect (dialog->use_default_theme_toggle, "toggled", G_CALLBACK (use_default_theme_toggled), mc); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->use_default_theme_toggle), mc->preferences.show_default_theme); if ( ! mc_key_writable (mc, "show_default_theme")) hard_set_sensitive (dialog->use_default_theme_toggle, FALSE); /* Foreground color */ g_signal_connect (dialog->fg_color_picker, "color_set", G_CALLBACK (foreground_color_set), mc); color.red = mc->preferences.cmd_line_color_fg_r; color.green = mc->preferences.cmd_line_color_fg_g; color.blue = mc->preferences.cmd_line_color_fg_b; gtk_color_button_set_color (GTK_COLOR_BUTTON (dialog->fg_color_picker), &color); soft_set_sensitive (dialog->fg_color_picker, !mc->preferences.show_default_theme); if ( ! mc_key_writable (mc, "cmd_line_color_fg_r") || ! mc_key_writable (mc, "cmd_line_color_fg_g") || ! mc_key_writable (mc, "cmd_line_color_fg_b")) { hard_set_sensitive (dialog->fg_color_picker, FALSE); hard_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "fg_color_label")), FALSE); } /* Background color */ g_signal_connect (dialog->bg_color_picker, "color_set", G_CALLBACK (background_color_set), mc); color.red = mc->preferences.cmd_line_color_bg_r; color.green = mc->preferences.cmd_line_color_bg_g; color.blue = mc->preferences.cmd_line_color_bg_b; gtk_color_button_set_color (GTK_COLOR_BUTTON (dialog->bg_color_picker), &color); soft_set_sensitive (dialog->bg_color_picker, !mc->preferences.show_default_theme); if ( ! mc_key_writable (mc, "cmd_line_color_bg_r") || ! mc_key_writable (mc, "cmd_line_color_bg_g") || ! mc_key_writable (mc, "cmd_line_color_bg_b")) { hard_set_sensitive (dialog->bg_color_picker, FALSE); hard_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "bg_color_label")), FALSE); } /* Macros Delete and Add buttons */ g_signal_connect (dialog->delete_button, "clicked", G_CALLBACK (macro_delete), mc); g_signal_connect (dialog->add_button, "clicked", G_CALLBACK (macro_add), mc); client = gconf_client_get_default (); if ( ! gconf_client_key_is_writable (client, "/apps/mini-commander/macro_patterns", NULL) || ! gconf_client_key_is_writable (client, "/apps/mini-commander/macro_commands", NULL)) { hard_set_sensitive (dialog->add_button, FALSE); hard_set_sensitive (dialog->delete_button, FALSE); hard_set_sensitive (dialog->macros_tree, FALSE); } /* Macros tree view */ dialog->macros_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING, NULL); gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->macros_tree), GTK_TREE_MODEL (dialog->macros_store)); renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, "editable", TRUE, NULL); g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_PATTERN)); g_signal_connect (renderer, "edited", G_CALLBACK (macro_edited), mc); gtk_tree_view_insert_column_with_attributes ( GTK_TREE_VIEW (dialog->macros_tree), -1, _("Pattern"), renderer, "text", COLUMN_PATTERN, NULL); renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, "editable", TRUE, NULL); g_object_set_data (G_OBJECT (renderer), "column", GINT_TO_POINTER (COLUMN_COMMAND)); g_signal_connect (renderer, "edited", G_CALLBACK (macro_edited), mc); gtk_tree_view_insert_column_with_attributes ( GTK_TREE_VIEW (dialog->macros_tree), -1, _("Command"), renderer, "text", COLUMN_COMMAND, NULL); show_macros_list (mc); }
void stickynotes_applet_update_prefs (void) { int height; gboolean sys_color, sys_font, sticky, force_default, desktop_hide; char *font_str; char *color_str, *font_color_str; GdkColor color, font_color; gint width = gconf_client_get_int(stickynotes->gconf, GCONF_PATH "/defaults/width", NULL); width = MAX (width, 1); height = gconf_client_get_int (stickynotes->gconf, GCONF_PATH "/defaults/height", NULL); height = MAX (height, 1); sys_color = gconf_client_get_bool (stickynotes->gconf, GCONF_PATH "/settings/use_system_color", NULL); sys_font = gconf_client_get_bool (stickynotes->gconf, GCONF_PATH "/settings/use_system_font", NULL); sticky = gconf_client_get_bool (stickynotes->gconf, GCONF_PATH "/settings/sticky", NULL); force_default = gconf_client_get_bool (stickynotes->gconf, GCONF_PATH "/settings/force_default", NULL); font_str = gconf_client_get_string (stickynotes->gconf, GCONF_PATH "/defaults/font", NULL); desktop_hide = gconf_client_get_bool (stickynotes->gconf, GCONF_PATH "/settings/desktop_hide", NULL); if (!font_str) { font_str = g_strdup ("Sans 10"); } color_str = gconf_client_get_string (stickynotes->gconf, GCONF_PATH "/defaults/color", NULL); if (!color_str) { color_str = g_strdup ("#ECF833"); } font_color_str = gconf_client_get_string (stickynotes->gconf, GCONF_PATH "/defaults/font_color", NULL); if (!font_color_str) { font_color_str = g_strdup ("#000000"); } gdk_color_parse (color_str, &color); g_free (color_str); gdk_color_parse (font_color_str, &font_color); g_free (font_color_str); gtk_adjustment_set_value (stickynotes->w_prefs_width, width); gtk_adjustment_set_value (stickynotes->w_prefs_height, height); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color), sys_color); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(stickynotes->w_prefs_sys_font), sys_font); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky), sticky); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force), force_default); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop), desktop_hide); gtk_color_button_set_color ( GTK_COLOR_BUTTON (stickynotes->w_prefs_color), &color); gtk_color_button_set_color ( GTK_COLOR_BUTTON (stickynotes->w_prefs_font_color), &font_color); gtk_font_button_set_font_name ( GTK_FONT_BUTTON (stickynotes->w_prefs_font), font_str); g_free (font_str); if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/defaults/color", NULL)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "prefs_color_label")), !sys_color); gtk_widget_set_sensitive (stickynotes->w_prefs_color, !sys_color); } if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/defaults/prefs_font_color", NULL)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "prefs_font_color_label")), !sys_color); gtk_widget_set_sensitive (stickynotes->w_prefs_font_color, !sys_color); } if (gconf_client_key_is_writable (stickynotes->gconf, GCONF_PATH "/defaults/font", NULL)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( stickynotes->builder, "prefs_font_label")), !sys_font); gtk_widget_set_sensitive (stickynotes->w_prefs_font, !sys_font); } }