static void action_activated_callback (GtkMenuItem *item, NemoAction *action) { GFile *desktop_location = nemo_get_desktop_location (); NemoFile *desktop_file = nemo_file_get (desktop_location); g_object_unref (desktop_location); nemo_action_activate (NEMO_ACTION (action), NULL, desktop_file); }
static void nemo_action_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NemoAction *action; action = NEMO_ACTION (object); switch (prop_id) { case PROP_KEY_FILE_PATH: g_value_set_string (value, action->key_file_path); break; case PROP_SELECTION_TYPE: g_value_set_int (value, action->selection_type); break; case PROP_EXTENSIONS: g_value_set_pointer (value, action->extensions); break; case PROP_MIMES: g_value_set_pointer (value, action->mimetypes); break; case PROP_EXEC: g_value_set_string (value, action->exec); break; case PROP_PARENT_DIR: g_value_set_string (value, action->parent_dir); break; case PROP_USE_PARENT_DIR: g_value_set_boolean (value, action->use_parent_dir); break; case PROP_ORIG_LABEL: g_value_set_string (value, action->orig_label); break; case PROP_ORIG_TT: g_value_set_string (value, action->orig_tt); break; case PROP_QUOTE_TYPE: g_value_set_int (value, action->quote_type); break; case PROP_SEPARATOR: g_value_set_string (value, action->separator); break; case PROP_CONDITIONS: g_value_set_pointer (value, action->conditions); break; case PROP_ESCAPE_SPACE: g_value_set_boolean (value, action->escape_space); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void nemo_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NemoAction *action; action = NEMO_ACTION (object); switch (prop_id) { case PROP_KEY_FILE_PATH: nemo_action_set_key_file_path (action, g_value_get_string (value)); break; case PROP_SELECTION_TYPE: action->selection_type = g_value_get_int (value); break; case PROP_EXTENSIONS: nemo_action_set_extensions (action, g_value_get_pointer (value)); break; case PROP_MIMES: nemo_action_set_mimetypes (action, g_value_get_pointer (value)); break; case PROP_EXT_LENGTH: action->ext_length = g_value_get_int (value); break; case PROP_MIME_LENGTH: action->mime_length = g_value_get_int (value); break; case PROP_EXEC: nemo_action_set_exec (action, g_value_get_string (value)); break; case PROP_PARENT_DIR: nemo_action_set_parent_dir (action, g_value_get_string (value)); break; case PROP_USE_PARENT_DIR: action->use_parent_dir = g_value_get_boolean (value); break; case PROP_ORIG_LABEL: nemo_action_set_orig_label (action, g_value_get_string (value)); break; case PROP_ORIG_TT: nemo_action_set_orig_tt (action, g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void nemo_action_finalize (GObject *object) { NemoAction *action = NEMO_ACTION (object); g_free (action->key_file_path); g_strfreev (action->extensions); g_free (action->exec); g_free (action->parent_dir); g_free (action->orig_label); g_free (action->orig_tt); G_OBJECT_CLASS (parent_class)->finalize (object); }
static void nemo_action_finalize (GObject *object) { NemoAction *action = NEMO_ACTION (object); g_free (action->key_file_path); g_strfreev (action->extensions); g_strfreev (action->mimetypes); g_strfreev (action->conditions); g_free (action->exec); g_free (action->parent_dir); g_free (action->orig_label); g_free (action->orig_tt); if (action->dbus) { g_list_free_full (action->dbus, (GDestroyNotify) dbus_condition_free); } G_OBJECT_CLASS (parent_class)->finalize (object); }
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); }