static void copy_entry (GConfClient *src, const char *path, GConfChangeSet *changes, const char **excludes) { GConfValue *value; if (path_is_excluded (path, excludes)) return; value = gconf_client_get (src, path, NULL); if (value) { gconf_change_set_set (changes, path, value); gconf_value_free (value); } }
bool Conf::GetInt(const gchar *key, int *val) { GConfValue *value = NULL; if (!gconf_client) return false; value = gconf_client_get(gconf_client, key, NULL); if (value) { *val = gconf_value_get_int(value); gconf_value_free(value); } else { return false; } return true; }
/** * Gets the border width */ gfloat cpumeter_gconf_get_border_width(GConfClient* client) { gfloat width; GConfValue *value = gconf_client_get(client, GCONF_BORDER_WIDTH, NULL); if (value) { width = gconf_client_get_float(client, GCONF_BORDER_WIDTH, NULL); } else { width = GCONF_DEFAULT_BORDER_WIDTH; gconf_client_set_float(client, GCONF_BORDER_WIDTH, GCONF_DEFAULT_BORDER_WIDTH, NULL); } return width; }
/** * Get the graph update frequency. */ guint cpumeter_gconf_get_update_frequency(GConfClient* client) { guint update_freq; GConfValue *value = gconf_client_get(client, GCONF_UPDATE_FREQ, NULL); if (value) { update_freq = gconf_client_get_int(client, GCONF_UPDATE_FREQ, NULL); } else { update_freq = GCONF_DEFAULT_UPDATE_FREQ; gconf_client_set_int(client, GCONF_UPDATE_FREQ, GCONF_DEFAULT_UPDATE_FREQ, NULL); } return update_freq; }
/** * Should we do the CPU - nn% subtitle? */ gboolean cpumeter_gconf_do_subtitle(GConfClient* client) { gboolean do_subtitle; GConfValue *value = gconf_client_get(client, GCONF_DO_SUBTITLE, NULL); if (value) { do_subtitle = gconf_client_get_bool(client, GCONF_DO_SUBTITLE, NULL); } else { do_subtitle = GCONF_DEFAULT_DO_SUBTITLE; gconf_client_set_bool(client, GCONF_DO_SUBTITLE, GCONF_DEFAULT_DO_SUBTITLE, NULL); } return do_subtitle; }
/** * Should we do the pretty gradient on the graph. */ gboolean cpumeter_gconf_use_gradient(GConfClient* client) { gboolean do_gradient; GConfValue *value = gconf_client_get(client, GCONF_DO_GRADIENT, NULL); if (value) { do_gradient = gconf_client_get_bool(client, GCONF_DO_GRADIENT, NULL); } else { do_gradient = GCONF_DEFAULT_DO_GRADIENT; gconf_client_set_bool(client, GCONF_DO_GRADIENT, GCONF_DEFAULT_DO_GRADIENT, NULL); } return do_gradient; }
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); }
/** * panel_applet_gconf_get_value: * @applet: a #PanelApplet. * @key: a GConf key name. * @error: a #GError, or %NULL. * * Convenience wrapper around gconf_client_get_value() to get the value of @key * in the per-instance GConf directory of @applet. * * Returns: the value of @key. * * Deprecated: 3.0: Use #GSettings to store per-instance settings. **/ GConfValue * panel_applet_gconf_get_value (PanelApplet *applet, const gchar *key, GError **error) { GConfClient *client; gchar *full_key; GConfValue *retval; g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL); full_key = panel_applet_gconf_get_full_key (applet, key); client = panel_applet_gconf_get_client (); retval = gconf_client_get (client, full_key, error); g_free (full_key); return retval; }
static gboolean xmonadlog_applet_fill(PanelApplet *applet) { GtkWidget *label = gtk_label_new("Waiting for XMonad"); // Set up Gconf GConfClient* client = gconf_client_get_default(); gconf_client_add_dir(client, "/apps/xmonad-log-applet", GCONF_CLIENT_PRELOAD_NONE, NULL); gconf_client_notify_add(client, "/apps/xmonad-log-applet/width-chars", xmonadlog_applet_size_change, label, NULL, NULL); GConfValue* gcValue = NULL; gcValue = gconf_client_get(client, "/apps/xmonad-log-applet/width-chars", NULL); int width = 80; if (gcValue && gcValue->type == GCONF_VALUE_INT) { width = gconf_value_get_int(gcValue); } gtk_label_set_width_chars(GTK_LABEL(label), width); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment((GtkMisc *)label, 0.0, 0.5); set_up_dbus_transfer(label); g_signal_connect(applet, "change-background", G_CALLBACK(change_bg), NULL); gtk_container_add(GTK_CONTAINER(applet), label); gtk_widget_show_all(GTK_WIDGET(applet)); return TRUE; }
bool Conf::GetString(const gchar *key, gchar **val) { GConfValue *value = NULL; const gchar *sValue = NULL; if (!gconf_client) return false; value = gconf_client_get(gconf_client, key, NULL); if (value) { sValue = gconf_value_get_string(value); if (*val) g_free(*val); *val = g_strdup(sValue); gconf_value_free(value); } else { return false; } return true; }
GConfValue* eel_gconf_get_value (const char *key) { GConfValue *value = NULL; GConfClient *client; GError *error = NULL; g_return_val_if_fail (key != NULL, NULL); client = eel_gconf_client_get_global (); g_return_val_if_fail (client != NULL, NULL); value = gconf_client_get (client, key, &error); if (eel_gconf_handle_error (&error)) { if (value != NULL) { gconf_value_free (value); value = NULL; } } return value; }
/** * Return an string from the specified GConf key * * @param key The GConf key to get the values from * @param[out] value Will contain a newly allocated string with the value * @return TRUE on success, FALSE on failure */ gboolean mce_gconf_get_string(const gchar *const key, gchar **value) { gboolean status = FALSE; GError *error = NULL; GConfValue *gcv; if( gconf_disabled ) { mce_log(LL_DEBUG, "blocked %s query", key); goto EXIT; } gcv = gconf_client_get(gconf_client, key, &error); if (gcv == NULL) { mce_log((error != NULL) ? LL_WARN : LL_INFO, "Could not retrieve %s from GConf; %s", key, (error != NULL) ? error->message : "Key not set"); goto EXIT; } if ((gcv->type != GCONF_VALUE_STRING)) { mce_log(LL_ERR, "GConf key %s should have type: %d, but has type: %d", key, GCONF_VALUE_STRING, gcv->type); goto EXIT; } *value = g_strdup(gconf_value_get_string(gcv)); gconf_value_free(gcv); status = TRUE; EXIT: g_clear_error(&error); return status; }
static int electron_manager_update_rom (ElectronManager *eman, int rom_num, GError **error) { GConfValue *value = NULL; ElectronManagerPrivate *priv = eman->priv; int ret = 0; if (priv->gconf) { gchar *full_key = g_strconcat (ELECTRON_MANAGER_ROMS_CONF_DIR, "/", electron_manager_rom_table[rom_num].key, NULL); value = gconf_client_get (priv->gconf, full_key, NULL); g_free (full_key); if (value && (value->type != GCONF_VALUE_STRING || gconf_value_get_string (value)[0] == '\0')) { gconf_value_free (value); value = NULL; } } if (value == NULL) { if (electron_manager_rom_table[rom_num].page == -1) electron_clear_os_rom (eman->data); else electron_clear_paged_rom (eman->data, electron_manager_rom_table[rom_num].page); } else { FILE *file; gchar *filename; GError *conv_error = NULL; if ((filename = g_filename_from_utf8 (gconf_value_get_string (value), -1, NULL, NULL, &conv_error)) == NULL) { g_set_error (error, ELECTRON_MANAGER_ERROR, ELECTRON_MANAGER_ERROR_FILE, _("Failed to convert \"%s\" to correct filename encoding: %s"), gconf_value_get_string (value), conv_error->message); g_error_free (conv_error); ret = -1; } else { if ((file = g_fopen (filename, "rb")) == NULL) { g_set_error (error, ELECTRON_MANAGER_ERROR, ELECTRON_MANAGER_ERROR_FILE, _("Failed to load \"%s\": %s"), gconf_value_get_string (value), strerror (errno)); ret = -1; } else { int load_ret; if (electron_manager_rom_table[rom_num].page == -1) load_ret = electron_load_os_rom (eman->data, file); else load_ret = electron_load_paged_rom (eman->data, electron_manager_rom_table[rom_num].page, file); if (load_ret == -1) { g_set_error (error, ELECTRON_MANAGER_ERROR, ELECTRON_MANAGER_ERROR_FILE, _("Failed to load \"%s\": %s"), gconf_value_get_string (value), ferror (file) ? strerror (errno) : _("ROM file too short")); ret = -1; } fclose (file); } g_free (filename); } gconf_value_free (value); } return ret; }
static void construct(CPU_plug_data **p) { GConfValue *value; *p = g_malloc(sizeof(CPU_plug_data)); CPU_plug_data * data = *p; gchar * svalue; data->max_width_left = -1; data->max_width_right = -1; data->timer = 100; data->user = 0; data->sys = 0; data->idle = 100; data->iowait = 0; data->emotive_text = FALSE; svalue = gconf_client_get_string(get_dashboard_gconf(), GCONF_CPU_METER_NO_GTK_BG, NULL); if (!svalue) { gconf_client_set_string(get_dashboard_gconf(), GCONF_CPU_METER_NO_GTK_BG, svalue = g_strdup("999999ee"), NULL); } awn_cairo_string_to_color(svalue, &data->bg); g_free(svalue); svalue = gconf_client_get_string(get_dashboard_gconf(), GCONF_CPU_METER_NO_GTK_FG, NULL); if (!svalue) { gconf_client_set_string(get_dashboard_gconf(), GCONF_CPU_METER_NO_GTK_FG, svalue = g_strdup("000000ff"), NULL); } awn_cairo_string_to_color(svalue, &data->fg); g_free(svalue); value = gconf_client_get(get_dashboard_gconf(), GCONF_CPU_SIZE_MULT, NULL); if (value) { data->size_mult = gconf_client_get_float(get_dashboard_gconf(), GCONF_CPU_SIZE_MULT, NULL); } else { data->size_mult = 1.72; gconf_client_set_float(get_dashboard_gconf(), GCONF_CPU_SIZE_MULT, data->size_mult, NULL); } value = gconf_client_get(get_dashboard_gconf(), GCONF_CPU_REFRESH, NULL); if (value) { data->refresh = gconf_client_get_int(get_dashboard_gconf(), GCONF_CPU_REFRESH, NULL); } else { data->refresh = 500; set_refresh(*p, data->refresh); } value = gconf_client_get(get_dashboard_gconf(), GCONF_CPU_METER, NULL); if (value) { data->shiny_graphs = gconf_client_get_bool(get_dashboard_gconf(), GCONF_CPU_METER, NULL); } else { data->shiny_graphs = TRUE; gconf_client_set_bool(get_dashboard_gconf(), GCONF_CPU_METER, data->shiny_graphs, NULL); } value = gconf_client_get(get_dashboard_gconf(), GCONF_CPU_METER_USE_2_COLOUR_GRADIENT , NULL); if (value) { data->two_colour_gradient = gconf_client_get_bool(get_dashboard_gconf(), GCONF_CPU_METER_USE_2_COLOUR_GRADIENT , NULL); } else { data->two_colour_gradient = FALSE; gconf_client_set_bool(get_dashboard_gconf(), GCONF_CPU_METER_USE_2_COLOUR_GRADIENT, data->two_colour_gradient, NULL); } svalue = gconf_client_get_string(get_dashboard_gconf(), GCONF_CPU_METER_START_COLOUR, NULL); if (!svalue) { gconf_client_set_string(get_dashboard_gconf(), GCONF_CPU_METER_START_COLOUR, svalue = g_strdup("00FF10bb"), NULL); } awn_cairo_string_to_color(svalue, &data->colour_meter_start); g_free(svalue); svalue = gconf_client_get_string(get_dashboard_gconf(), GCONF_CPU_METER_MIDDLE_COLOUR, NULL); if (!svalue) { gconf_client_set_string(get_dashboard_gconf(), GCONF_CPU_METER_MIDDLE_COLOUR, svalue = g_strdup("EEC83177"), NULL); } awn_cairo_string_to_color(svalue, &data->colour_meter_middle); g_free(svalue); svalue = gconf_client_get_string(get_dashboard_gconf(), GCONF_CPU_METER_STOP_COLOUR, NULL); if (!svalue) { gconf_client_set_string(get_dashboard_gconf(), GCONF_CPU_METER_STOP_COLOUR, svalue = g_strdup("FF0010ee"), NULL); } awn_cairo_string_to_color(svalue, &data->colour_meter_end); g_free(svalue); //data->pats[] is initialized once i render.. then needs to be free'd in constructor }
/** * gconf_bridge_bind_window * @bridge: A #GConfBridge * @key_prefix: The prefix of the GConf keys * @window: A #GtkWindow * @bind_size: TRUE to bind the size of @window * @bind_pos: TRUE to bind the position of @window * * On calling this function @window will be resized to the values * specified by "@key_prefix<!-- -->_width" and "@key_prefix<!-- -->_height" * and maximixed if "@key_prefix<!-- -->_maximized is TRUE if * @bind_size is TRUE, and moved to the values specified by * "@key_prefix<!-- -->_x" and "@key_prefix<!-- -->_y" if @bind_pos is TRUE. * The respective GConf values will be updated when the window is resized * and/or moved. * * Return value: The ID of the new binding. **/ guint gconf_bridge_bind_window (GConfBridge *bridge, const gchar *key_prefix, GtkWindow *window, gboolean bind_size, gboolean bind_pos) { WindowBinding *binding; g_return_val_if_fail (bridge != NULL, 0); g_return_val_if_fail (key_prefix != NULL, 0); g_return_val_if_fail (GTK_IS_WINDOW (window), 0); /* Create new binding. */ binding = g_new (WindowBinding, 1); binding->type = BINDING_WINDOW; binding->id = new_id (); binding->bind_size = bind_size; binding->bind_pos = bind_pos; binding->key_prefix = g_strdup (key_prefix); binding->window = window; binding->sync_timeout_id = 0; /* Set up GConf keys & sync window to GConf values */ if (bind_size) { gchar *key; GConfValue *width_val, *height_val, *maximized_val; key = g_strconcat (key_prefix, "_width", NULL); width_val = gconf_client_get (bridge->client, key, NULL); g_free (key); key = g_strconcat (key_prefix, "_height", NULL); height_val = gconf_client_get (bridge->client, key, NULL); g_free (key); key = g_strconcat (key_prefix, "_maximized", NULL); maximized_val = gconf_client_get (bridge->client, key, NULL); g_free (key); if (width_val && height_val) { gtk_window_resize (window, gconf_value_get_int (width_val), gconf_value_get_int (height_val)); gconf_value_free (width_val); gconf_value_free (height_val); } else if (width_val) { gconf_value_free (width_val); } else if (height_val) { gconf_value_free (height_val); } if (maximized_val) { if (gconf_value_get_bool (maximized_val)) { /* Maximize is not done immediately, but to * count with proper window size, resize it * before. The previous size is restored * after the maximization is changed, * in window_binding_state_event_cb(). */ gint width = 0, height = 0; GdkScreen *screen; gtk_window_get_size (window, &width, &height); g_object_set_data ( G_OBJECT (window), "binding-premax-width", GINT_TO_POINTER (width)); g_object_set_data ( G_OBJECT (window), "binding-premax-height", GINT_TO_POINTER (height)); screen = gtk_window_get_screen (window); gtk_window_resize (window, gdk_screen_get_width (screen), gdk_screen_get_height (screen)); gtk_window_maximize (window); } gconf_value_free (maximized_val); } } if (bind_pos) { gchar *key; GConfValue *x_val, *y_val; key = g_strconcat (key_prefix, "_x", NULL); x_val = gconf_client_get (bridge->client, key, NULL); g_free (key); key = g_strconcat (key_prefix, "_y", NULL); y_val = gconf_client_get (bridge->client, key, NULL); g_free (key); if (x_val && y_val) { gtk_window_move (window, gconf_value_get_int (x_val), gconf_value_get_int (y_val)); gconf_value_free (x_val); gconf_value_free (y_val); } else if (x_val) { gconf_value_free (x_val); } else if (y_val) { gconf_value_free (y_val); } } /* Connect to window size change notifications */ binding->configure_event_id = g_signal_connect (window, "configure-event", G_CALLBACK (window_binding_configure_event_cb), binding); binding->window_state_event_id = g_signal_connect (window, "window_state_event", G_CALLBACK (window_binding_state_event_cb), binding); binding->unmap_id = g_signal_connect (window, "unmap", G_CALLBACK (window_binding_unmap_cb), binding); /* Handle case where window gets destroyed */ g_object_weak_ref (G_OBJECT (window), window_binding_window_destroyed, binding); /* Insert binding */ g_hash_table_insert (bridge->bindings, GUINT_TO_POINTER (binding->id), binding); /* Done */ return binding->id; }
/** * gconf_bridge_bind_window * @bridge: A #GConfBridge * @key_prefix: The prefix of the GConf keys * @window: A #GtkWindow * @bind_size: TRUE to bind the size of @window * @bind_pos: TRUE to bind the position of @window * * On calling this function @window will be resized to the values * specified by "@key_prefix<!-- -->_width" and "@key_prefix<!-- -->_height" * and maximixed if "@key_prefix<!-- -->_maximized is TRUE if * @bind_size is TRUE, and moved to the values specified by * "@key_prefix<!-- -->_x" and "@key_prefix<!-- -->_y" if @bind_pos is TRUE. * The respective GConf values will be updated when the window is resized * and/or moved. * * Return value: The ID of the new binding. **/ guint gconf_bridge_bind_window (GConfBridge *bridge, const char *key_prefix, GtkWindow *window, gboolean bind_size, gboolean bind_pos) { WindowBinding *binding; g_return_val_if_fail (bridge != NULL, 0); g_return_val_if_fail (key_prefix != NULL, 0); g_return_val_if_fail (GTK_IS_WINDOW (window), 0); /* Create new binding. */ binding = g_new (WindowBinding, 1); binding->type = BINDING_WINDOW; binding->id = new_id (); binding->bind_size = bind_size; binding->bind_pos = bind_pos; binding->key_prefix = g_strdup (key_prefix); binding->window = window; binding->sync_timeout_id = 0; /* Set up GConf keys & sync window to GConf values */ if (bind_size) { char *key; GConfValue *width_val, *height_val, *maximized_val; key = g_strconcat (key_prefix, "_width", NULL); width_val = gconf_client_get (bridge->client, key, NULL); g_free (key); key = g_strconcat (key_prefix, "_height", NULL); height_val = gconf_client_get (bridge->client, key, NULL); g_free (key); key = g_strconcat (key_prefix, "_maximized", NULL); maximized_val = gconf_client_get (bridge->client, key, NULL); g_free (key); if (width_val && height_val) { gtk_window_resize (window, gconf_value_get_int (width_val), gconf_value_get_int (height_val)); gconf_value_free (width_val); gconf_value_free (height_val); } else if (width_val) { gconf_value_free (width_val); } else if (height_val) { gconf_value_free (height_val); } if (maximized_val) { if (gconf_value_get_bool (maximized_val)) { gtk_window_maximize (window); } gconf_value_free (maximized_val); } } if (bind_pos) { char *key; GConfValue *x_val, *y_val; key = g_strconcat (key_prefix, "_x", NULL); x_val = gconf_client_get (bridge->client, key, NULL); g_free (key); key = g_strconcat (key_prefix, "_y", NULL); y_val = gconf_client_get (bridge->client, key, NULL); g_free (key); if (x_val && y_val) { gtk_window_move (window, gconf_value_get_int (x_val), gconf_value_get_int (y_val)); gconf_value_free (x_val); gconf_value_free (y_val); } else if (x_val) { gconf_value_free (x_val); } else if (y_val) { gconf_value_free (y_val); } } /* Connect to window size change notifications */ binding->configure_event_id = g_signal_connect (window, "configure-event", G_CALLBACK (window_binding_configure_event_cb), binding); binding->configure_event_id = g_signal_connect (window, "window_state_event", G_CALLBACK (window_binding_state_event_cb), binding); binding->unmap_id = g_signal_connect (window, "unmap", G_CALLBACK (window_binding_unmap_cb), binding); /* Handle case where window gets destroyed */ g_object_weak_ref (G_OBJECT (window), window_binding_window_destroyed, binding); /* Insert binding */ g_hash_table_insert (bridge->bindings, GUINT_TO_POINTER (binding->id), binding); /* Done */ return binding->id; }
/** * gconf_bridge_bind_property_full * @bridge: A #GConfBridge * @key: A GConf key to be bound * @object: A #GObject * @prop: The property of @object to be bound * @delayed_sync: TRUE if there should be a delay between property changes * and syncs to GConf. Set to TRUE when binding to a rapidly-changing * property, for example the "value" property on a #GtkAdjustment. * * Binds @key to @prop, causing them to have the same value at all times. * * The types of @key and @prop should be compatible. Floats and doubles, and * ints, uints, longs, unlongs, int64s, uint64s, chars, uchars and enums * can be matched up. Booleans and strings can only be matched to their * respective types. * * On calling this function the current value of @key will be set to @prop. * * Return value: The ID of the new binding. **/ guint gconf_bridge_bind_property_full (GConfBridge *bridge, const char *key, GObject *object, const char *prop, gboolean delayed_sync) { GParamSpec *pspec; PropBinding *binding; char *signal; GConfValue *val; g_return_val_if_fail (bridge != NULL, 0); g_return_val_if_fail (key != NULL, 0); g_return_val_if_fail (G_IS_OBJECT (object), 0); g_return_val_if_fail (prop != NULL, 0); /* First, try to fetch the propertys GParamSpec off the object */ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), prop); if (G_UNLIKELY (pspec == NULL)) { g_warning ("gconf_bridge_bind_property_full: A property \"%s\" " "was not found. Please make sure you are passing " "the right property name.", prop); return 0; } /* GParamSpec found: All good, create new binding. */ binding = g_new (PropBinding, 1); binding->type = BINDING_PROP; binding->id = new_id (); binding->delayed_mode = delayed_sync; binding->val_changes = NULL; binding->key = g_strdup (key); binding->object = object; binding->prop = pspec; binding->sync_timeout_id = 0; /* Watch GConf key */ binding->val_notify_id = gconf_client_notify_add (bridge->client, key, prop_binding_pref_changed, binding, NULL, NULL); /* Connect to property change notifications */ signal = g_strconcat ("notify::", prop, NULL); binding->prop_notify_id = g_signal_connect (object, signal, G_CALLBACK (prop_binding_prop_changed), binding); g_free (signal); /* Sync object to value from GConf, if set */ val = gconf_client_get (bridge->client, key, NULL); if (val) { prop_binding_sync_pref_to_prop (binding, val); gconf_value_free (val); } /* Handle case where watched object gets destroyed */ g_object_weak_ref (object, prop_binding_object_destroyed, binding); /* Insert binding */ g_hash_table_insert (bridge->bindings, GUINT_TO_POINTER (binding->id), binding); /* Done */ return binding->id; }
/** * gconf_bridge_bind_string_list_store * @bridge: A #GConfBridge * @key: A GConf key to be bound * @list_store: A #GtkListStore * * On calling this function single string column #GtkListStore @list_store * will be kept synchronized with the GConf string list value pointed to by * @key. On calling this function @list_store will be populated with the * strings specified by the value of @key. * * Return value: The ID of the new binding. **/ guint gconf_bridge_bind_string_list_store (GConfBridge *bridge, const char *key, GtkListStore *list_store) { GtkTreeModel *tree_model; gboolean have_one_column, is_string_column; ListStoreBinding *binding; GConfValue *val; g_return_val_if_fail (bridge != NULL, 0); g_return_val_if_fail (key != NULL, 0); g_return_val_if_fail (GTK_IS_LIST_STORE (list_store), 0); /* Check list store suitability */ tree_model = GTK_TREE_MODEL (list_store); have_one_column = (gtk_tree_model_get_n_columns (tree_model) == 1); is_string_column = (gtk_tree_model_get_column_type (tree_model, 0) == G_TYPE_STRING); if (G_UNLIKELY (!have_one_column || !is_string_column)) { g_warning ("gconf_bridge_bind_string_list_store: Only " "GtkListStores with exactly one string column are " "supported."); return 0; } /* Create new binding. */ binding = g_new (ListStoreBinding, 1); binding->type = BINDING_LIST_STORE; binding->id = new_id (); binding->key = g_strdup (key); binding->val_changes = NULL; binding->list_store = list_store; binding->sync_idle_id = 0; /* Watch GConf key */ binding->val_notify_id = gconf_client_notify_add (bridge->client, key, list_store_binding_pref_changed, binding, NULL, NULL); /* Connect to ListStore change notifications */ binding->row_inserted_id = g_signal_connect_swapped (list_store, "row-inserted", G_CALLBACK (list_store_binding_store_changed_cb), binding); binding->row_changed_id = g_signal_connect_swapped (list_store, "row-inserted", G_CALLBACK (list_store_binding_store_changed_cb), binding); binding->row_deleted_id = g_signal_connect_swapped (list_store, "row-inserted", G_CALLBACK (list_store_binding_store_changed_cb), binding); binding->rows_reordered_id = g_signal_connect_swapped (list_store, "row-inserted", G_CALLBACK (list_store_binding_store_changed_cb), binding); /* Sync object to value from GConf, if set */ val = gconf_client_get (bridge->client, key, NULL); if (val) { list_store_binding_sync_pref_to_store (binding, val); gconf_value_free (val); } /* Handle case where watched object gets destroyed */ g_object_weak_ref (G_OBJECT (list_store), list_store_binding_store_destroyed, binding); /* Insert binding */ g_hash_table_insert (bridge->bindings, GUINT_TO_POINTER (binding->id), binding); /* Done */ return binding->id; }
gboolean open_file (Ebook * ebook, const gchar * filename) { GtkProgressBar * progressbar; GtkStatusbar * statusbar; guint id; GtkWidget * window; PopplerRectangle * rect; GError * err; gint G_GNUC_UNUSED pages; gchar * uri, * msg; GVfs * vfs; GFileInfo * ginfo; GError * result; GConfValue *value; gboolean lines, hyphens, pagenums; vfs = g_vfs_get_default (); if (g_vfs_is_active(vfs)) ebook->gfile = g_vfs_get_file_for_path (vfs, filename); else ebook->gfile = g_file_new_for_commandline_arg (filename); ginfo = g_file_query_info (ebook->gfile, G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, NULL, &result); if (0 == g_file_info_get_attribute_uint64 (ginfo, G_FILE_ATTRIBUTE_STANDARD_SIZE)) { g_object_unref (ebook->gfile); g_object_unref (ginfo); g_warning ("%s", result->message); return FALSE; } uri = g_file_get_uri (ebook->gfile); err = NULL; pages = 0; rect = poppler_rectangle_new (); rect->x1 = rect->y1 = 0; window = GTK_WIDGET(gtk_builder_get_object (ebook->builder, "gpdfwindow")); progressbar = GTK_PROGRESS_BAR(gtk_builder_get_object (ebook->builder, "progressbar")); gtk_progress_bar_set_fraction (progressbar, 0.0); statusbar = GTK_STATUSBAR(gtk_builder_get_object (ebook->builder, "statusbar")); id = gtk_statusbar_get_context_id (statusbar, PACKAGE); msg = g_strconcat (_("Loading ebook:"), g_file_get_basename (ebook->gfile), NULL); gtk_statusbar_push (statusbar, id, msg); ebook->PDFDoc = poppler_document_new_from_file (uri, NULL, &err); gtk_progress_bar_set_fraction (progressbar, 0.0); /* long lines support */ value = gconf_client_get(ebook->client, ebook->long_lines.key, NULL); if (value) lines = gconf_value_get_bool(value); else lines = TRUE; /* page numbers support */ value = gconf_client_get(ebook->client, ebook->page_number.key, NULL); if (value) pagenums = gconf_value_get_bool(value); else pagenums = TRUE; /* join hyphens support */ value = gconf_client_get(ebook->client, ebook->join_hyphens.key, NULL); if (value) hyphens = gconf_value_get_bool(value); else hyphens = TRUE; if (POPPLER_IS_DOCUMENT (ebook->PDFDoc)) { #ifdef HAVE_GTKSPELL GtkSpell *spell; gchar * G_GNUC_UNUSED lang; #endif GtkWidget * G_GNUC_UNUSED spell_check; GtkTextView * text_view; GtkTextBuffer * buffer; gboolean state; static Equeue queue; spell_check = GTK_WIDGET(gtk_builder_get_object (ebook->builder, "spellcheckmenuitem")); text_view = GTK_TEXT_VIEW(gtk_builder_get_object (ebook->builder, "textview")); buffer = gtk_text_view_get_buffer (text_view); state = gconf_client_get_bool (ebook->client, ebook->spell_check.key, NULL); #ifdef HAVE_GTKSPELL spell = gtkspell_get_from_text_view (text_view); lang = gconf_client_get_string (ebook->client, ebook->language.key, NULL); /* updating the text area with spell enabled is very slow */ if (state) gtkspell_detach (spell); #endif pages = poppler_document_get_n_pages (ebook->PDFDoc); queue.ebook = ebook; queue.c = 0; queue.lines = lines; queue.hyphens = hyphens; queue.pagenums = pagenums; queue.rect = rect; /* whether to enable spell once all pages are loaded. */ queue.spell_state = state; /* loading a file is a single user action */ gtk_text_buffer_begin_user_action (buffer); g_timeout_add (30, load_pdf, &queue); } else { g_message ("err: %s", err->message); return FALSE; } msg = g_strconcat (PACKAGE, " - ", g_file_get_basename (ebook->gfile), NULL); gtk_window_set_title (GTK_WINDOW(window), msg); return TRUE; }
static void cheese_gconf_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { CheeseGConf *self; self = CHEESE_GCONF (object); CheeseGConfPrivate *priv = CHEESE_GCONF_GET_PRIVATE (self); char *effects; GSList *list, *tmp; switch (prop_id) { case GCONF_PROP_COUNTDOWN: g_value_set_boolean (value, gconf_client_get_bool (priv->client, CHEESE_GCONF_PREFIX "/countdown", NULL)); break; case GCONF_PROP_FLASH: g_value_set_boolean (value, gconf_client_get_bool (priv->client, CHEESE_GCONF_PREFIX "/flash", NULL)); break; case GCONF_PROP_CAMERA: g_value_set_string (value, gconf_client_get_string (priv->client, CHEESE_GCONF_PREFIX "/camera", NULL)); break; case GCONF_PROP_SELECTED_EFFECTS: effects = NULL; list = gconf_client_get_list (priv->client, CHEESE_GCONF_PREFIX "/selected_effects", GCONF_VALUE_STRING, NULL); tmp = list; while (tmp != NULL) { char *str = tmp->data; int j; str[0] = g_ascii_toupper (str[0]); for (j = 1; j < g_utf8_strlen (str, -1); j++) { if (str[j] == '-') { str[j] = ' '; str[j + 1] = g_ascii_toupper (str[j + 1]); } else if (str[j] == '_') { str[j] = '/'; str[j + 1] = g_ascii_toupper (str[j + 1]); } } if (effects == NULL) effects = g_strdup (str); else { gchar *dummy = effects; effects = g_strjoin (",", effects, str, NULL); g_free (dummy); } g_free (tmp->data); tmp = g_slist_next (tmp); } g_value_set_string (value, effects); g_slist_free (list); g_slist_free (tmp); break; case GCONF_PROP_X_RESOLUTION: g_value_set_int (value, gconf_client_get_int (priv->client, CHEESE_GCONF_PREFIX "/x_resolution", NULL)); break; case GCONF_PROP_Y_RESOLUTION: g_value_set_int (value, gconf_client_get_int (priv->client, CHEESE_GCONF_PREFIX "/y_resolution", NULL)); break; case GCONF_PROP_BRIGHTNESS: if (!gconf_client_get (priv->client, CHEESE_GCONF_PREFIX "/brightness", NULL)) g_value_set_double (value, G_PARAM_SPEC_DOUBLE (pspec)->default_value); else g_value_set_double (value, gconf_client_get_float (priv->client, CHEESE_GCONF_PREFIX "/brightness", NULL)); break; case GCONF_PROP_CONTRAST: if (!gconf_client_get (priv->client, CHEESE_GCONF_PREFIX "/contrast", NULL)) g_value_set_double (value, G_PARAM_SPEC_DOUBLE (pspec)->default_value); else g_value_set_double (value, gconf_client_get_float (priv->client, CHEESE_GCONF_PREFIX "/contrast", NULL)); break; case GCONF_PROP_SATURATION: if (!gconf_client_get (priv->client, CHEESE_GCONF_PREFIX "/saturation", NULL)) g_value_set_double (value, G_PARAM_SPEC_DOUBLE (pspec)->default_value); else g_value_set_double (value, gconf_client_get_float (priv->client, CHEESE_GCONF_PREFIX "/saturation", NULL)); break; case GCONF_PROP_HUE: if (!gconf_client_get (priv->client, CHEESE_GCONF_PREFIX "/hue", NULL)) g_value_set_double (value, G_PARAM_SPEC_DOUBLE (pspec)->default_value); else g_value_set_double (value, gconf_client_get_float (priv->client, CHEESE_GCONF_PREFIX "/hue", NULL)); break; case GCONF_PROP_VIDEO_PATH: g_value_set_string (value, gconf_client_get_string (priv->client, CHEESE_GCONF_PREFIX "/video_path", NULL)); break; case GCONF_PROP_PHOTO_PATH: g_value_set_string (value, gconf_client_get_string (priv->client, CHEESE_GCONF_PREFIX "/photo_path", NULL)); break; case GCONF_PROP_ENABLE_DELETE: g_value_set_boolean (value, gconf_client_get_bool (priv->client, CHEESE_GCONF_PREFIX "/enable_delete", NULL)); break; case GCONF_PROP_WIDE_MODE: g_value_set_boolean (value, gconf_client_get_bool (priv->client, CHEESE_GCONF_PREFIX "/wide_mode", NULL)); break; case GCONF_PROP_BURST_DELAY: g_value_set_int (value, gconf_client_get_int (priv->client, CHEESE_GCONF_PREFIX "/burst_delay", NULL)); break; case GCONF_PROP_BURST_REPEAT: g_value_set_int (value, gconf_client_get_int (priv->client, CHEESE_GCONF_PREFIX "/burst_repeat", NULL)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }