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>
* libnautilus-private/nautilus-mime-application-chooser.[ch]:
......
......@@ -30,8 +30,10 @@
#include "nautilus-open-with-dialog.h"
#include "nautilus-signaller.h"
#include "nautilus-file.h"
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
#include <string.h>
#include <glib/gi18n-lib.h>
......@@ -657,37 +659,59 @@ set_uri_and_type (NautilusMimeApplicationChooser *chooser,
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
set_uri_and_type_for_multiple_files (NautilusMimeApplicationChooser *chooser,
GList *uris,
const char *mime_type)
{
char *label;
char *extension;
char *name;
GFile *file;
char *first_extension;
gboolean same_extension;
GList *iter;
chooser->details->for_multiple_files = TRUE;
chooser->details->uri = NULL;
chooser->details->orig_mime_type = g_strdup (mime_type);
extension = NULL;
iter = uris;
while (extension == NULL && iter != NULL) {
g_free (extension);
file = g_file_new_for_uri ((const char *) uris->data);
name = g_file_get_basename (file);
extension = get_extension (name);
same_extension = TRUE;
first_extension = get_extension_from_file (NAUTILUS_FILE (uris->data));
iter = uris->next;
while (iter != NULL) {
char *extension_current;
extension_current = get_extension_from_file (NAUTILUS_FILE (iter->data));
if (eel_strcmp (first_extension, extension_current)) {
same_extension = FALSE;
g_free (extension_current);
break;
}
iter = iter->next;
g_free (name);
g_object_unref (file);
g_free (extension_current);
}
if (!same_extension) {
set_extension_and_description (NAUTILUS_MIME_APPLICATION_CHOOSER (chooser),
extension, mime_type);
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:"),
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