142
NautilusActionsConfigAction*
143
nautilus_actions_config_gconf_get_action (NautilusActionsConfigGconf* config, const gchar* uuid)
145
g_assert (NAUTILUS_ACTIONS_IS_CONFIG_GCONF (config));
147
g_return_val_if_fail (NAUTILUS_ACTIONS_IS_CONFIG_GCONF (config), NULL);
150
GSList* profile_list = NULL;
155
gchar* gconf_action_dir = g_strdup_printf ("%s/%s", ACTIONS_CONFIG_DIR, uuid);
156
NautilusActionsConfigActionProfile* action_profile;
158
NautilusActionsConfigAction *action = nautilus_actions_config_action_new ();
160
stmp = get_action_string_value (config->conf_client, gconf_action_dir, ACTION_LABEL_ENTRY);
163
nautilus_actions_config_action_free (action);
166
nautilus_actions_config_action_set_label (action, stmp);
169
nautilus_actions_config_action_set_uuid (action, uuid);
171
stmp = get_action_string_value (config->conf_client, gconf_action_dir, ACTION_TOOLTIP_ENTRY);
172
nautilus_actions_config_action_set_tooltip (action, stmp);
175
stmp = get_action_string_value (config->conf_client, gconf_action_dir, ACTION_ICON_ENTRY);
176
nautilus_actions_config_action_set_icon (action, stmp);
179
action->version = get_action_string_value (config->conf_client, gconf_action_dir, ACTION_VERSION_ENTRY);
181
if (g_ascii_strcasecmp (action->version, "2.0") < 0)
183
action_profile = nautilus_actions_config_action_profile_new ();
185
//--> manage backward compatibility
186
stmp = get_action_string_value (config->conf_client, gconf_action_dir, ACTION_PATH_ENTRY);
187
nautilus_actions_config_action_profile_set_path (action_profile, stmp);
190
stmp = get_action_string_value (config->conf_client, gconf_action_dir, ACTION_PARAMS_ENTRY);
191
nautilus_actions_config_action_profile_set_parameters (action_profile, stmp);
194
ltmp = get_action_list_value (config->conf_client, gconf_action_dir, ACTION_BASENAMES_ENTRY);
195
nautilus_actions_config_action_profile_set_basenames (action_profile, ltmp);
196
g_slist_foreach (ltmp, (GFunc) g_free, NULL);
199
nautilus_actions_config_action_profile_set_is_file (action_profile, get_action_bool_value (config->conf_client, gconf_action_dir, ACTION_ISFILE_ENTRY));
201
nautilus_actions_config_action_profile_set_is_dir (action_profile, get_action_bool_value (config->conf_client, gconf_action_dir, ACTION_ISDIR_ENTRY));
203
nautilus_actions_config_action_profile_set_accept_multiple (action_profile, get_action_bool_value (config->conf_client, gconf_action_dir, ACTION_MULTIPLE_ENTRY));
205
ltmp = get_action_list_value (config->conf_client, gconf_action_dir, ACTION_SCHEMES_ENTRY);
206
nautilus_actions_config_action_profile_set_schemes (action_profile, ltmp);
207
g_slist_foreach (ltmp, (GFunc) g_free, NULL);
210
if (g_ascii_strcasecmp (action->version, "1.0") == 0)
212
nautilus_actions_config_action_profile_set_match_case (action_profile, TRUE);
214
ltmp = g_slist_append (action_profile->mimetypes, g_strdup ("*/*"));
215
nautilus_actions_config_action_profile_set_mimetypes (action_profile, ltmp);
216
g_slist_foreach (ltmp, (GFunc) g_free, NULL);
223
nautilus_actions_config_action_profile_set_match_case (action_profile, get_action_bool_value (config->conf_client, gconf_action_dir, ACTION_MATCHCASE_ENTRY));
225
ltmp = get_action_list_value (config->conf_client, gconf_action_dir, ACTION_MIMETYPES_ENTRY);
226
nautilus_actions_config_action_profile_set_mimetypes (action_profile, ltmp);
227
g_slist_foreach (ltmp, (GFunc) g_free, NULL);
232
nautilus_actions_config_action_profile_set_desc_name (action_profile, NAUTILUS_ACTIONS_DEFAULT_PROFILE_DESC_NAME);
233
nautilus_actions_config_action_add_profile (action, NAUTILUS_ACTIONS_DEFAULT_PROFILE_NAME, action_profile, NULL);
237
/* load all defined profiles */
238
profile_list = gconf_client_all_dirs (config->conf_client, gconf_action_dir, NULL);
240
for (iter = profile_list; iter; iter = iter->next)
242
profile_dir = (gchar*)iter->data;
243
profile_name = get_action_profile_name (gconf_action_dir, (gchar*)iter->data);
244
action_profile = nautilus_actions_config_action_profile_new ();
246
stmp = get_action_string_value (config->conf_client, profile_dir, ACTION_PROFILE_DESC_NAME_ENTRY);
249
stmp = g_strdup (profile_name);
251
nautilus_actions_config_action_profile_set_desc_name (action_profile, stmp);
254
stmp = get_action_string_value (config->conf_client, profile_dir, ACTION_PATH_ENTRY);
255
nautilus_actions_config_action_profile_set_path (action_profile, stmp);
258
stmp = get_action_string_value (config->conf_client, profile_dir, ACTION_PARAMS_ENTRY);
259
nautilus_actions_config_action_profile_set_parameters (action_profile, stmp);
262
ltmp = get_action_list_value (config->conf_client, profile_dir, ACTION_BASENAMES_ENTRY);
263
nautilus_actions_config_action_profile_set_basenames (action_profile, ltmp);
264
g_slist_foreach (ltmp, (GFunc) g_free, NULL);
267
nautilus_actions_config_action_profile_set_match_case (action_profile, get_action_bool_value (config->conf_client, profile_dir, ACTION_MATCHCASE_ENTRY));
269
ltmp = get_action_list_value (config->conf_client, profile_dir, ACTION_MIMETYPES_ENTRY);
270
nautilus_actions_config_action_profile_set_mimetypes (action_profile, ltmp);
271
g_slist_foreach (ltmp, (GFunc) g_free, NULL);
274
nautilus_actions_config_action_profile_set_is_file (action_profile, get_action_bool_value (config->conf_client, profile_dir, ACTION_ISFILE_ENTRY));
276
nautilus_actions_config_action_profile_set_is_dir (action_profile, get_action_bool_value (config->conf_client, profile_dir, ACTION_ISDIR_ENTRY));
278
nautilus_actions_config_action_profile_set_accept_multiple (action_profile, get_action_bool_value (config->conf_client, profile_dir, ACTION_MULTIPLE_ENTRY));
280
ltmp = get_action_list_value (config->conf_client, profile_dir, ACTION_SCHEMES_ENTRY);
281
nautilus_actions_config_action_profile_set_schemes (action_profile, ltmp);
282
g_slist_foreach (ltmp, (GFunc) g_free, NULL);
285
nautilus_actions_config_action_add_profile (action, profile_name, action_profile, NULL);
287
g_free (profile_name);
288
g_free (profile_dir);
291
g_slist_free (profile_list);
294
g_free (gconf_action_dir);
299
static gchar* get_action_uuid_from_key (const gchar* key)
301
g_return_val_if_fail (g_str_has_prefix (key, ACTIONS_CONFIG_DIR), NULL);
303
gchar* uuid = g_strdup (key + strlen (ACTIONS_CONFIG_DIR "/"));
304
gchar* pos = g_strstr_len (uuid, strlen (uuid), "/");
122
314
nautilus_actions_config_gconf_init (NautilusActionsConfigGconf *config, NautilusActionsConfigGconfClass *klass)
125
319
config->conf_client = gconf_client_get_default ();
127
321
/* load all defined actions */
128
322
GSList* list = gconf_client_all_dirs (config->conf_client, ACTIONS_CONFIG_DIR, NULL);
130
for (node = list; node != NULL; node = node->next) {
131
NautilusActionsConfigAction *action = nautilus_actions_config_action_new ();
133
action->conf_section = node->data;
134
action->label = get_action_string_value (config->conf_client, node->data, ACTION_LABEL_ENTRY);
135
if (!action->label) {
136
nautilus_actions_config_action_free (action);
140
action->uuid = g_path_get_basename (action->conf_section); // Get the last part of the config section dir
141
action->tooltip = get_action_string_value (config->conf_client, node->data, ACTION_TOOLTIP_ENTRY);
142
action->icon = get_action_string_value (config->conf_client, node->data, ACTION_ICON_ENTRY);
143
action->path = get_action_string_value (config->conf_client, node->data, ACTION_PATH_ENTRY);
144
action->parameters = get_action_string_value (config->conf_client, node->data, ACTION_PARAMS_ENTRY);
145
action->basenames = get_action_list_value (config->conf_client, node->data, ACTION_BASENAMES_ENTRY);
146
action->match_case = get_action_bool_value (config->conf_client, node->data, ACTION_MATCHCASE_ENTRY);
147
action->mimetypes = get_action_list_value (config->conf_client, node->data, ACTION_MIMETYPES_ENTRY);
148
action->is_file = get_action_bool_value (config->conf_client, node->data, ACTION_ISFILE_ENTRY);
149
action->is_dir = get_action_bool_value (config->conf_client, node->data, ACTION_ISDIR_ENTRY);
150
action->accept_multiple_files = get_action_bool_value (config->conf_client, node->data, ACTION_MULTIPLE_ENTRY);
151
action->schemes = get_action_list_value (config->conf_client, node->data, ACTION_SCHEMES_ENTRY);
152
action->version = get_action_string_value (config->conf_client, node->data, ACTION_VERSION_ENTRY);
154
if (g_ascii_strcasecmp (action->version, "1.0") == 0)
156
//--> manage backward compatibility
157
action->match_case = TRUE;
158
action->mimetypes = g_slist_append (action->mimetypes, g_strdup ("*/*"));
162
action->mimetypes = get_action_list_value (config->conf_client, node->data, ACTION_MIMETYPES_ENTRY);
163
action->match_case = get_action_bool_value (config->conf_client, node->data, ACTION_MATCHCASE_ENTRY);
166
/* add the new action to the hash table */
167
g_hash_table_insert (NAUTILUS_ACTIONS_CONFIG (config)->actions, g_strdup (action->uuid), action);
324
for (node = list; node != NULL; node = node->next)
326
gchar* uuid = get_action_uuid_from_key ((gchar*)node->data);
327
NautilusActionsConfigAction *action = nautilus_actions_config_gconf_get_action (config, uuid);
331
/* add the new action to the hash table */
332
g_hash_table_insert (NAUTILUS_ACTIONS_CONFIG (config)->actions, g_strdup (action->uuid), action);
335
// Free the gconf dir string once used
170
339
g_slist_free (list);