Commit b05751df authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Cosimo Cecchi

Finish work on open with tab with multiple files selected. (#343930).

2008-02-20  Cosimo Cecchi  <cosimoc@gnome.org>

	* libnautilus-private/nautilus-mime-application-chooser.c:
	(get_extension_from_file), (set_uri_and_type_for_multiple_files):
	Finish work on open with tab with multiple files selected. (#343930).

svn path=/trunk/; revision=13784
parent 78fb3fc4
2008-02-20 Cosimo Cecchi <cosimoc@gnome.org>
* libnautilus-private/nautilus-mime-application-chooser.c:
(get_extension_from_file), (set_uri_and_type_for_multiple_files):
Finish work on open with tab with multiple files selected. (#343930).
2008-02-20 Alexander Larsson <alexl@redhat.com> 2008-02-20 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-mime-application-chooser.[ch]: * libnautilus-private/nautilus-mime-application-chooser.[ch]:
......
...@@ -30,8 +30,10 @@ ...@@ -30,8 +30,10 @@
#include "nautilus-open-with-dialog.h" #include "nautilus-open-with-dialog.h"
#include "nautilus-signaller.h" #include "nautilus-signaller.h"
#include "nautilus-file.h"
#include <eel/eel-stock-dialogs.h> #include <eel/eel-stock-dialogs.h>
#include <eel/eel-glib-extensions.h> #include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
#include <string.h> #include <string.h>
#include <glib/gi18n-lib.h> #include <glib/gi18n-lib.h>
...@@ -657,37 +659,59 @@ set_uri_and_type (NautilusMimeApplicationChooser *chooser, ...@@ -657,37 +659,59 @@ set_uri_and_type (NautilusMimeApplicationChooser *chooser,
return TRUE; return TRUE;
} }
static char *
get_extension_from_file (NautilusFile *nfile)
{
char *name;
char *extension;
name = nautilus_file_get_name (nfile);
extension = get_extension (name);
g_free (name);
return extension;
}
static gboolean static gboolean
set_uri_and_type_for_multiple_files (NautilusMimeApplicationChooser *chooser, set_uri_and_type_for_multiple_files (NautilusMimeApplicationChooser *chooser,
GList *uris, GList *uris,
const char *mime_type) const char *mime_type)
{ {
char *label; char *label;
char *extension; char *first_extension;
char *name; gboolean same_extension;
GFile *file;
GList *iter; GList *iter;
chooser->details->for_multiple_files = TRUE; chooser->details->for_multiple_files = TRUE;
chooser->details->uri = NULL; chooser->details->uri = NULL;
chooser->details->orig_mime_type = g_strdup (mime_type); chooser->details->orig_mime_type = g_strdup (mime_type);
extension = NULL; same_extension = TRUE;
iter = uris; first_extension = get_extension_from_file (NAUTILUS_FILE (uris->data));
iter = uris->next;
while (extension == NULL && iter != NULL) {
g_free (extension); while (iter != NULL) {
char *extension_current;
file = g_file_new_for_uri ((const char *) uris->data);
name = g_file_get_basename (file); extension_current = get_extension_from_file (NAUTILUS_FILE (iter->data));
extension = get_extension (name); if (eel_strcmp (first_extension, extension_current)) {
same_extension = FALSE;
g_free (extension_current);
break;
}
iter = iter->next; iter = iter->next;
g_free (name); g_free (extension_current);
g_object_unref (file);
} }
set_extension_and_description (NAUTILUS_MIME_APPLICATION_CHOOSER (chooser), if (!same_extension) {
extension, mime_type); set_extension_and_description (NAUTILUS_MIME_APPLICATION_CHOOSER (chooser),
g_free (extension); NULL, mime_type);
} else {
set_extension_and_description (NAUTILUS_MIME_APPLICATION_CHOOSER (chooser),
first_extension, mime_type);
}
g_free (first_extension);
label = g_strdup_printf (_("Open all files of type \"%s\" with:"), label = g_strdup_printf (_("Open all files of type \"%s\" with:"),
chooser->details->type_description); chooser->details->type_description);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment