예제 #1
0
gboolean
gnc_gconf_schemas_found (void)
{
    GConfSchema* schema;
    GError *err = NULL;
    gchar *key;

    if (our_client == NULL)
        our_client = gconf_client_get_default();

    key = gnc_gconf_make_schema_key(GCONF_GENERAL_REGISTER, "use_theme_colors");
    schema = gconf_client_get_schema(our_client, key, &err);
    g_free(key);
    if (schema == NULL)
    {
        return FALSE;
    }
    gconf_schema_free(schema);

    /* Set up convenience callback for general section */

    gconf_general_cb_id =
        gnc_gconf_add_anon_notification(GCONF_GENERAL, gnc_gconf_general_changed,
                                        NULL);
    return TRUE;
}
static void
install_default_macros_list (GConfClient *client,
			     const char  *key,
			     int          offset)
{
	GConfSchema *schema;
	GConfValue  *value;
	GSList      *list = NULL;
	GError      *error;
	int          i;

	error = NULL;
	schema = gconf_client_get_schema (client, key, &error);
	if (error) {
		g_warning (_("Cannot get schema for %s: %s"), key, error->message);
		g_error_free (error);
		return;
	}

	/* gconf has started to return NULL with no error set. */
	g_return_if_fail (schema != NULL);

	/* Some sanity checks */
	g_assert (gconf_schema_get_type (schema) == GCONF_VALUE_LIST);
	g_assert (gconf_schema_get_list_type (schema) == GCONF_VALUE_STRING);

	value = gconf_value_new (GCONF_VALUE_LIST);
	gconf_value_set_list_type (value, GCONF_VALUE_STRING);

	for (i = 0; i < G_N_ELEMENTS (mc_default_macros); i++)
		list = g_slist_prepend (list,
					gconf_value_new_from_string (GCONF_VALUE_STRING,
								     G_STRUCT_MEMBER (char *, &mc_default_macros [i], offset),
								     NULL));
	list = g_slist_reverse (list);

	gconf_value_set_list_nocopy (value, list);
	list = NULL;

	gconf_schema_set_default_value_nocopy (schema, value);
	value = NULL;

	error = NULL;
	gconf_client_set_schema (client, key, schema, &error);
	if (error) {
		g_warning (_("Cannot set schema for %s: %s"), key, error->message);
		g_error_free (error);
	}

	gconf_schema_free (schema);

	printf (_("Set default list value for %s\n"), key);
}
static void
gnc_reset_warnings_add_one (GConfEntry *entry, GtkWidget *box)
{
    const gchar *name, *schema_name, *desc, *long_desc = NULL;
    GtkWidget *checkbox;
    GConfSchema *schema = NULL;

    ENTER(" ");
    name = strrchr(entry->key, '/') + 1;
    schema_name = gconf_entry_get_schema_name(entry);
    if (schema_name)
        schema = gnc_gconf_get_schema(NULL, schema_name, NULL);
    if (schema)
    {
        DEBUG("found schema %p", schema);
        desc = gconf_schema_get_short_desc(schema);
        DEBUG("description %s", desc);
        long_desc = gconf_schema_get_long_desc(schema);
        checkbox = gtk_check_button_new_with_label(desc ? desc : name);
        if (long_desc)
        {
            GtkTooltips *tips;
            tips = g_object_get_data(G_OBJECT(box), TIPS_STRING);
            if (!tips)
            {
                tips = gtk_tooltips_new();
                g_object_set_data(G_OBJECT(box), TIPS_STRING, tips);
            }
            gtk_tooltips_set_tip(tips, checkbox, long_desc, NULL);
        }
        gconf_schema_free(schema);
    }
    else
    {
        DEBUG("no schema");
        checkbox = gtk_check_button_new_with_label(name);
    }

    gtk_widget_set_name(checkbox, entry->key);
    g_signal_connect_swapped(G_OBJECT(checkbox), "toggled",
                             (GCallback)gnc_reset_warnings_update_widgets,
                             box);
    gtk_box_pack_start_defaults(GTK_BOX(box), checkbox);
    LEAVE(" ");
}