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 GSList * mc_load_macros (MCData *mc) { gchar **macro_patterns; gchar **macro_commands; GSList *macros_list = NULL; guint i; macro_patterns = g_settings_get_strv (mc->global_settings, KEY_MACRO_PATTERNS); macro_commands = g_settings_get_strv (mc->global_settings, KEY_MACRO_COMMANDS); for (i = 0; macro_patterns[i] != NULL && macro_commands[i] != NULL; i++) { MCMacro *macro; if (!(macro = mc_macro_new (macro_patterns[i], macro_commands[i]))) continue; macros_list = g_slist_prepend (macros_list, macro); } g_strfreev (macro_patterns); g_strfreev (macro_commands); macros_list = g_slist_reverse (macros_list); return macros_list; }