示例#1
0
static GSList *
mc_load_macros (MCData *mc)
{
    MateConfValue *macro_patterns;
    MateConfValue *macro_commands;
    GSList     *macros_list = NULL;
    MateConfClient *client;
    
    client = mateconf_client_get_default ();
    macro_patterns = mateconf_client_get (client,
		    "/apps/mini-commander/macro_patterns", NULL);
    macro_commands = mateconf_client_get (client,
		    "/apps/mini-commander/macro_commands", NULL);
    
    if (macro_patterns && macro_commands) {
    	GSList *patterns;
	GSList *commands;

        patterns = mateconf_value_get_list (macro_patterns);
        commands = mateconf_value_get_list (macro_commands);

	for (; patterns && commands; patterns = patterns->next, commands = commands->next) {
            MateConfValue *v1 = patterns->data;
            MateConfValue *v2 = commands->data;
	    MCMacro    *macro;
            const char *pattern, *command;
            
            pattern = mateconf_value_get_string (v1);
            command = mateconf_value_get_string (v2);

	    if (!(macro = mc_macro_new (pattern, command)))
		continue;

	    macros_list = g_slist_prepend (macros_list, macro);
        }
    } else {    
	int i;

	for (i = 0; i < G_N_ELEMENTS (mc_default_macros); i++)
	    macros_list = g_slist_prepend (macros_list,
					   mc_macro_new (mc_default_macros [i].pattern,
							 mc_default_macros [i].command));
    }

    macros_list = g_slist_reverse (macros_list);

    if (macro_commands)
	mateconf_value_free (macro_commands);

    if (macro_patterns)
	mateconf_value_free (macro_patterns);

    return macros_list;
}
static gboolean
get_mateconf_value_with_default (PlumaDrawspacesPlugin *plugin,
			      const gchar           *key,
			      gboolean               def)
{
	MateConfValue *value;
	gboolean ret;

	value = mateconf_client_get (plugin->priv->mateconf_client,
				  key, NULL);

	if (value != NULL && value->type == MATECONF_VALUE_BOOL)
	{
		ret = mateconf_value_get_bool (value);
	}
	else
	{
		ret = def;
	}

	if (value != NULL)
	{
		mateconf_value_free (value);
	}

	return ret;
}
MateConfValue *
mate_panel_applet_mateconf_get_value (MatePanelApplet  *applet,
			      const gchar  *key,
			      GError      **opt_error)
{
	MateConfClient  *client;
	gchar        *full_key;
	MateConfValue   *retval;
	GError      **error = NULL;
	GError       *our_error = NULL;

	g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);

	if (opt_error)
		error = opt_error;
	else
		error = &our_error;

	full_key = mate_panel_applet_mateconf_get_full_key (applet, key);

	client = mate_panel_applet_mateconf_get_client ();

	retval = mateconf_client_get (client, full_key, error);

	g_free (full_key);

	if (!opt_error && our_error) {
		g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message);
		g_error_free (our_error);
	}

	return retval;
}
void
mateconf_bookmarks_hook_up_menu (MateConfEditorWindow *window,
			      GtkWidget *menu,
			      GtkWidget *add_bookmark,
			      GtkWidget *edit_bookmarks)
{
	MateConfClient *client;
	guint notify_id;

	g_object_set_data (G_OBJECT (menu), "editor-window", window);

	client = mateconf_client_get_default ();
	
	/* Add a notify function */
	mateconf_client_add_dir (client, "/apps/mateconf-editor/bookmarks",
			      MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	notify_id = mateconf_client_notify_add (client, "/apps/mateconf-editor/bookmarks",
					     mateconf_bookmarks_key_changed, menu, NULL, NULL);
	g_object_set_data_full (G_OBJECT (menu), "notify-id", GINT_TO_POINTER (notify_id),
				remove_notify_id);


	notify_id = mateconf_client_notify_add (client, "/desktop/mate/interface/menus_have_icons",
					     mateconf_bookmarks_have_icons_notify, menu, NULL, NULL); 
	g_object_set_data_full (G_OBJECT (menu), "notify-id-x", GINT_TO_POINTER (notify_id),
				remove_notify_id);

	mateconf_bookmarks_update_menu (menu);

        {
                gboolean have_icons;
                MateConfValue *value;
                GError *err;

                err = NULL;
                value = mateconf_client_get (client, "/desktop/mate/interface/menus_have_icons", &err);

                if (err != NULL || value == NULL || value->type != MATECONF_VALUE_BOOL)
                        return;

                have_icons = mateconf_value_get_bool (value);
                mateconf_bookmarks_set_have_icons (menu, have_icons);

                mateconf_value_free (value);
        }

	if ( ! mateconf_client_key_is_writable (client, "/apps/mateconf-editor/bookmarks", NULL)) {
		gtk_widget_set_sensitive (add_bookmark, FALSE);
		gtk_widget_set_sensitive (edit_bookmarks, FALSE);
	}

	g_object_unref (client);
}
static void
setup_model_entry (GtkBuilder * dialog)
{
	MateConfValue *value;

	value = mateconf_client_get (xkb_mateconf_client,
				  MATEKBD_KEYBOARD_CONFIG_KEY_MODEL, NULL);
	set_model_text (WID ("xkb_model_pick"), value);
	if (value != NULL)
		mateconf_value_free (value);

	mateconf_client_notify_add (xkb_mateconf_client,
				 MATEKBD_KEYBOARD_CONFIG_KEY_MODEL,
				 (MateConfClientNotifyFunc) model_key_changed,
				 dialog, NULL, NULL);
}