void nemo_action_constructed (GObject *object) { G_OBJECT_CLASS (parent_class)->constructed (object); NemoAction *action = NEMO_ACTION (object); GKeyFile *key_file = g_key_file_new(); g_key_file_load_from_file (key_file, action->key_file_path, G_KEY_FILE_NONE, NULL); gchar *orig_label = g_key_file_get_locale_string (key_file, ACTION_FILE_GROUP, KEY_NAME, NULL, NULL); gchar *orig_tt = g_key_file_get_locale_string (key_file, ACTION_FILE_GROUP, KEY_COMMENT, NULL, NULL); gchar *icon_name = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_ICON_NAME, NULL); gchar *stock_id = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_STOCK_ID, NULL); gchar *exec_raw = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_EXEC, NULL); gchar *selection_string_raw = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_SELECTION, NULL); gchar *selection_string = g_ascii_strdown (selection_string_raw, -1); g_free (selection_string_raw); gchar *separator = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_SEPARATOR, NULL); gchar *quote_type_string = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_QUOTE_TYPE, NULL); QuoteType quote_type = QUOTE_TYPE_NONE; if (quote_type_string != NULL) { if (g_strcmp0 (quote_type_string, "single") == 0) quote_type = QUOTE_TYPE_SINGLE; else if (g_strcmp0 (quote_type_string, "double") == 0) quote_type = QUOTE_TYPE_DOUBLE; else if (g_strcmp0 (quote_type_string, "backtick") == 0) quote_type = QUOTE_TYPE_BACKTICK; } SelectionType type; if (g_strcmp0 (selection_string, SELECTION_SINGLE_KEY) == 0) type = SELECTION_SINGLE; else if (g_strcmp0 (selection_string, SELECTION_MULTIPLE_KEY) == 0) type = SELECTION_MULTIPLE; else if (g_strcmp0 (selection_string, SELECTION_ANY_KEY) == 0) type = SELECTION_ANY; else if (g_strcmp0 (selection_string, SELECTION_NONE_KEY) == 0) type = SELECTION_NONE; else if (g_strcmp0 (selection_string, SELECTION_NOT_NONE_KEY) == 0) type = SELECTION_NOT_NONE; else { gint val = (int) g_ascii_strtoll (selection_string, NULL, 10); type = val > 0 ? val : SELECTION_SINGLE; } g_free (selection_string); gsize count; gchar **ext = g_key_file_get_string_list (key_file, ACTION_FILE_GROUP, KEY_EXTENSIONS, &count, NULL); gsize mime_count; gchar **mimes = g_key_file_get_string_list (key_file, ACTION_FILE_GROUP, KEY_MIME_TYPES, &mime_count, NULL); gsize condition_count; gchar **conditions = g_key_file_get_string_list (key_file, ACTION_FILE_GROUP, KEY_CONDITIONS, &condition_count, NULL); gboolean escape_space; escape_space = g_key_file_get_boolean (key_file, ACTION_FILE_GROUP, KEY_WHITESPACE, NULL); if (conditions && condition_count > 0) { int j; gchar *condition; for (j = 0; j < condition_count; j++) { condition = conditions[j]; if (g_str_has_prefix (condition, "dbus")) { setup_dbus_condition (action, condition); } } } gchar *exec = NULL; gboolean use_parent_dir = FALSE; strip_custom_modifier (exec_raw, &use_parent_dir, &exec); g_free (exec_raw); GFile *file = g_file_new_for_path (action->key_file_path); GFile *parent = g_file_get_parent (file); gchar *parent_dir = g_file_get_path (parent); g_object_unref (file); g_object_unref (parent); g_object_set (action, "label", orig_label, "tooltip", orig_tt, "icon-name", icon_name, "stock-id", stock_id, "exec", exec, "selection-type", type, "extensions", ext, "mimetypes", mimes, "parent-dir", parent_dir, "use-parent-dir", use_parent_dir, "orig-label", orig_label, "orig-tooltip", orig_tt, "quote-type", quote_type, "separator", separator, "conditions", conditions, "escape-space", escape_space, NULL); g_free (orig_label); g_free (orig_tt); g_free (icon_name); g_free (stock_id); g_free (exec); g_strfreev (ext); g_free (parent_dir); g_free (quote_type_string); g_free (separator); g_strfreev (conditions); g_key_file_free (key_file); }
void nemo_action_constructed (GObject *object) { G_OBJECT_CLASS (parent_class)->constructed (object); NemoAction *action = NEMO_ACTION (object); GKeyFile *key_file = g_key_file_new(); g_key_file_load_from_file (key_file, action->key_file_path, G_KEY_FILE_NONE, NULL); gchar *orig_label = g_key_file_get_locale_string (key_file, ACTION_FILE_GROUP, KEY_NAME, NULL, NULL); gchar *orig_tt = g_key_file_get_locale_string (key_file, ACTION_FILE_GROUP, KEY_COMMENT, NULL, NULL); gchar *icon_name = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_ICON_NAME, NULL); gchar *stock_id = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_STOCK_ID, NULL); gchar *exec_raw = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_EXEC, NULL); gchar *selection_string = g_key_file_get_string (key_file, ACTION_FILE_GROUP, KEY_SELECTION, NULL); SelectionType type; if (g_strcmp0 (selection_string, SELECTION_SINGLE_KEY) == 0) type = SELECTION_SINGLE; else if (g_strcmp0 (selection_string, SELECTION_MULTIPLE_KEY) == 0) type = SELECTION_MULTIPLE; else if (g_strcmp0 (selection_string, SELECTION_ANY_KEY) == 0) type = SELECTION_ANY; else if (g_strcmp0 (selection_string, SELECTION_NONE_KEY) == 0) type = SELECTION_NONE; else if (g_strcmp0 (selection_string, SELECTION_NOT_NONE_KEY) == 0) type = SELECTION_NOT_NONE; else { gint val = (int) g_ascii_strtoll (selection_string, NULL, 10); type = val > 0 ? val : SELECTION_SINGLE; } g_free (selection_string); gsize count; gchar **ext = g_key_file_get_string_list (key_file, ACTION_FILE_GROUP, KEY_EXTENSIONS, &count, NULL); gsize mime_count; gchar **mimes = g_key_file_get_string_list (key_file, ACTION_FILE_GROUP, KEY_MIME_TYPES, &mime_count, NULL); gchar *exec = NULL; gboolean use_parent_dir = FALSE; strip_custom_modifier (exec_raw, &use_parent_dir, &exec); g_free (exec_raw); GFile *file = g_file_new_for_path (action->key_file_path); GFile *parent = g_file_get_parent (file); gchar *parent_dir = g_file_get_path (parent); g_object_unref (file); g_object_unref (parent); g_object_set (action, "label", orig_label, "tooltip", orig_tt, "icon-name", icon_name, "stock-id", stock_id, "exec", exec, "selection-type", type, "ext-length", count, "extensions", ext, "mime-length", mime_count, "mimetypes", mimes, "parent-dir", parent_dir, "use-parent-dir", use_parent_dir, "orig-label", orig_label, "orig-tooltip", orig_tt, NULL); g_free (orig_label); g_free (orig_tt); g_free (icon_name); g_free (stock_id); g_free (exec); g_strfreev (ext); g_free (parent_dir); g_key_file_free (key_file); }