static void nemo_desktop_item_properties_exec_drag_data_received (GtkWidget *widget, GdkDragContext *context, int x, int y, GtkSelectionData *selection_data, guint info, guint time, GtkEntry *entry) { char **uris; gboolean exactly_one; NemoFile *file; GKeyFile *key_file; char *uri, *type, *exec; uris = g_strsplit (gtk_selection_data_get_data (selection_data), "\r\n", 0); exactly_one = uris[0] != NULL && (uris[1] == NULL || uris[1][0] == '\0'); if (!exactly_one) { g_strfreev (uris); return; } file = nemo_file_get_by_uri (uris[0]); g_return_if_fail (file != NULL); uri = nemo_file_get_uri (file); if (nemo_file_is_mime_type (file, "application/x-desktop")) { key_file = _g_key_file_new_from_uri (uri, G_KEY_FILE_NONE, NULL); if (key_file != NULL) { type = g_key_file_get_string (key_file, MAIN_GROUP, "Type", NULL); if (type != NULL && strcmp (type, "Application") == 0) { exec = g_key_file_get_string (key_file, MAIN_GROUP, "Exec", NULL); if (exec != NULL) { g_free (uri); uri = exec; } } g_free (type); g_key_file_free (key_file); } } gtk_entry_set_text (entry, uri?uri:""); gtk_widget_grab_focus (GTK_WIDGET (entry)); g_free (uri); nemo_file_unref (file); g_strfreev (uris); }
gboolean nemo_action_get_visibility (NemoAction *action, GList *selection, NemoFile *parent) { gboolean selection_type_show = FALSE; gboolean extension_type_show = TRUE; gboolean condition_type_show = TRUE; recalc_dbus_conditions (action); if (!nemo_action_get_dbus_satisfied (action)) goto out; gchar **conditions = nemo_action_get_conditions (action); guint condition_count = conditions != NULL ? g_strv_length (conditions) : 0; if (condition_count > 0) { int j; gchar *condition; for (j = 0; j < condition_count; j++) { condition = conditions[j]; if (g_strcmp0 (condition, "desktop") == 0) { gchar *name = nemo_file_get_display_name (parent); if (g_strcmp0 (name, "x-nemo-desktop") != 0) condition_type_show = FALSE; g_free (name); } else if (g_strcmp0 (condition, "removable") == 0) { gboolean is_removable = FALSE; if (g_list_length (selection) > 0) { GMount *mount = nemo_file_get_mount (selection->data); if (mount) { GDrive *drive = g_mount_get_drive (mount); if (drive) { if (g_drive_is_media_removable (drive)) is_removable = TRUE; g_object_unref (drive); } } } condition_type_show = is_removable; } else if (g_str_has_prefix (condition, "gsettings")) { condition_type_show = check_gsettings_condition (action, condition); } if (!condition_type_show) break; } } if (!condition_type_show) goto out; SelectionType selection_type = nemo_action_get_selection_type (action); GList *iter; guint selected_count = g_list_length (selection); switch (selection_type) { case SELECTION_SINGLE: selection_type_show = selected_count == 1; break; case SELECTION_MULTIPLE: selection_type_show = selected_count > 1; break; case SELECTION_NOT_NONE: selection_type_show = selected_count > 0; break; case SELECTION_NONE: selection_type_show = selected_count == 0; break; case SELECTION_ANY: selection_type_show = TRUE; break; default: selection_type_show = selected_count == selection_type; break; } gchar **extensions = nemo_action_get_extension_list (action); gchar **mimetypes = nemo_action_get_mimetypes_list (action); guint ext_count = extensions != NULL ? g_strv_length (extensions) : 0; guint mime_count = mimetypes != NULL ? g_strv_length (mimetypes) : 0; if (ext_count == 1 && g_strcmp0 (extensions[0], "any") == 0) goto out; gboolean found_match = TRUE; for (iter = selection; iter != NULL && found_match; iter = iter->next) { found_match = FALSE; gchar *raw_fn = nemo_file_get_name (NEMO_FILE (iter->data)); gchar *filename = g_ascii_strdown (raw_fn, -1); g_free (raw_fn); int i; gboolean is_dir = get_is_dir_hack (iter->data); if (ext_count > 0) { for (i = 0; i < ext_count; i++) { if (g_strcmp0 (extensions[i], "dir") == 0) { if (is_dir) { found_match = TRUE; break; } } else if (g_strcmp0 (extensions[i], "none") == 0) { if (g_strrstr (filename, ".") == NULL) { found_match = TRUE; break; } } else if (g_strcmp0 (extensions[i], "nodirs") == 0) { if (!is_dir) { found_match = TRUE; break; } } else { gchar *str = g_ascii_strdown (extensions[i], -1); if (g_str_has_suffix (filename, str)) { found_match = TRUE; } g_free (str); if (found_match) { break; } } } g_free (filename); } if (mime_count > 0) { for (i = 0; i < mime_count; i++) { if (nemo_file_is_mime_type (NEMO_FILE (iter->data), mimetypes[i])) { found_match = TRUE; break; } } } if (nemo_file_is_mime_type (NEMO_FILE (iter->data), "application/x-nemo-link")) { found_match = FALSE; } } extension_type_show = found_match; out: return selection_type_show && extension_type_show && condition_type_show; }