summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-04-22 18:01:32 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-04-27 14:06:21 +0200
commit4f77bc78c2ecb12fbea35f0de1734f1a065d4393 (patch)
tree538c355c6881b2d550bf68c1e38b7e9f631ebb0f
parent9cf4bbacb7ac1d70a7830d45a9b75d7489cb61d5 (diff)
downloadnautilus-4f77bc78c2ecb12fbea35f0de1734f1a065d4393.tar.gz
view: allow open with another app for multiple files
As we allow to open them with the default app, but in this case we have to ensure all selected files can be opened by a single app.
-rw-r--r--src/nautilus-view.c57
1 files changed, 22 insertions, 35 deletions
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 1e28f1615..f8d49b300 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -1042,61 +1042,53 @@ app_chooser_dialog_response_cb (GtkDialog *dialog,
gpointer user_data)
{
GtkWindow *parent_window;
- NautilusFile *file;
+ GList *files;
GAppInfo *info;
- GList files;
parent_window = user_data;
+ files = g_object_get_data (G_OBJECT (dialog), "directory-view:files");
- if (response_id != GTK_RESPONSE_OK) {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- return;
- }
+ if (response_id != GTK_RESPONSE_OK)
+ goto out;
info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog));
- file = g_object_get_data (G_OBJECT (dialog), "directory-view:file");
g_signal_emit_by_name (nautilus_signaller_get_current (), "mime-data-changed");
- files.next = NULL;
- files.prev = NULL;
- files.data = file;
- nautilus_launch_application (info, &files, parent_window);
+ nautilus_launch_application (info, files, parent_window);
- gtk_widget_destroy (GTK_WIDGET (dialog));
g_object_unref (info);
+out:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void
choose_program (NautilusView *view,
- NautilusFile *file)
+ GList *files)
{
GtkWidget *dialog;
- GFile *location;
+ gchar *mime_type;
GtkWindow *parent_window;
g_assert (NAUTILUS_IS_VIEW (view));
- g_assert (NAUTILUS_IS_FILE (file));
- nautilus_file_ref (file);
- location = nautilus_file_get_location (file);
+ mime_type = nautilus_file_get_mime_type (files->data);
parent_window = nautilus_view_get_containing_window (view);
- dialog = gtk_app_chooser_dialog_new (parent_window,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
- location);
- g_object_set_data_full (G_OBJECT (dialog),
- "directory-view:file",
- g_object_ref (file),
- (GDestroyNotify)g_object_unref);
+ dialog = gtk_app_chooser_dialog_new_for_content_type (parent_window,
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT |
+ GTK_DIALOG_USE_HEADER_BAR,
+ mime_type);
+ g_object_set_data_full (G_OBJECT (dialog),
+ "directory-view:files",
+ files,
+ (GDestroyNotify) nautilus_file_list_free);
gtk_widget_show (dialog);
- g_signal_connect_object (dialog, "response",
+ g_signal_connect_object (dialog, "response",
G_CALLBACK (app_chooser_dialog_response_cb),
parent_window, 0);
-
- g_object_unref (location);
- nautilus_file_unref (file);
}
static void
@@ -1107,12 +1099,7 @@ open_with_other_program (NautilusView *view)
g_assert (NAUTILUS_IS_VIEW (view));
selection = nautilus_view_get_selection (view);
-
- if (selection_contains_one_item_in_menu_callback (view, selection)) {
- choose_program (view, NAUTILUS_FILE (selection->data));
- }
-
- nautilus_file_list_free (selection);
+ choose_program (view, selection);
}
static void
@@ -5988,7 +5975,7 @@ real_update_actions_state (NautilusView *view)
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
"open-with-other-application");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- app != NULL && selection_count == 1);
+ app != NULL);
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
"open-item-new-tab");