2006-02-01 [colin] 2.0.0cvs6
authorColin Leroy <colin@colino.net>
Wed, 1 Feb 2006 17:51:14 +0000 (17:51 +0000)
committerColin Leroy <colin@colino.net>
Wed, 1 Feb 2006 17:51:14 +0000 (17:51 +0000)
* src/mimeview.c
Try to get mime type by extension if it is
application/octet-stream
Display a window with possible choices when
encountering unknown mime types
* src/gtk/filesel.c
* src/gtk/filesel.h
Add preview
Allow multiple selection in filtered filesel
(patch by Fabien Vantard)
* src/gtk/pluginwindow.c
Use it (patch by Fabien Vantard)

ChangeLog
PATCHSETS
configure.ac
src/gtk/filesel.c
src/gtk/filesel.h
src/gtk/pluginwindow.c
src/mimeview.c

index 6aa5fea29670805b7eda9f06bffee77a181639f6..f16675ec1c65b33f2e6ec5493577ed83a2a33bc6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2006-02-01 [colin]     2.0.0cvs6
+
+       * src/mimeview.c
+               Try to get mime type by extension if it is
+               application/octet-stream
+               Display a window with possible choices when
+               encountering unknown mime types
+       * src/gtk/filesel.c
+       * src/gtk/filesel.h
+               Add preview
+               Allow multiple selection in filtered filesel
+               (patch by Fabien Vantard)
+       * src/gtk/pluginwindow.c
+               Use it (patch by Fabien Vantard)
+
 2006-02-01 [paul]      2.0.0cvs5
 
        * src/jpilot.c
index 5a35b997f8a10da337297b60530e1a760bf81848..2b3067fdf62047d274907e9bc38e30a946ff74fc 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/plugins/pgpcore/passphrase.c;  cvs diff -u -r 1.382.2.230 -r 1.382.2.231 src/compose.c;  ) > 2.0.0cvs3.patchset
 ( cvs diff -u -r 1.382.2.231 -r 1.382.2.232 src/compose.c;  cvs diff -u -r 1.274.2.93 -r 1.274.2.94 src/mainwindow.c;  cvs diff -u -r 1.94.2.75 -r 1.94.2.76 src/messageview.c;  cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/prefs_send.c;  ) > 2.0.0cvs4.patchset
 ( cvs diff -u -r 1.18.2.15 -r 1.18.2.16 src/jpilot.c;  cvs diff -u -r 1.1.2.20 -r 1.1.2.21 src/prefs_summaries.c;  cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/prefs_wrapping.c;  cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/gtk/icon_legend.c;  cvs diff -u -r 1.1.2.32 -r 1.1.2.33 src/gtk/quicksearch.c;  ) > 2.0.0cvs5.patchset
+( cvs diff -u -r 1.83.2.59 -r 1.83.2.60 src/mimeview.c;  cvs diff -u -r 1.2.2.20 -r 1.2.2.21 src/gtk/filesel.c;  cvs diff -u -r 1.1.4.7 -r 1.1.4.8 src/gtk/filesel.h;  cvs diff -u -r 1.5.2.25 -r 1.5.2.26 src/gtk/pluginwindow.c;  ) > 2.0.0cvs6.patchset
index 90ac8f111b9e4d2919732fa0b10ec053f227e53a..506c922ceb5d4f7c3cd13f5687d347bdbbf3be7f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=5
+EXTRA_VERSION=6
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 23366356f73ce9915815a2a0060f95367e08abe4..bc273f27850a94f3d4694986719486278069a5bd 100644 (file)
 #include "codeconv.h"
 #include "prefs_common.h"
 
+static void
+update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
+{
+       GtkWidget *preview;
+       char *filename;
+       GdkPixbuf *pixbuf;
+       gboolean have_preview;
+
+       preview = GTK_WIDGET (data);
+       filename = gtk_file_chooser_get_preview_filename (file_chooser);
+
+       if (filename == NULL)
+               return;
+
+       pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
+       have_preview = (pixbuf != NULL);
+       g_free (filename);
+
+       gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
+       if (pixbuf)
+               gdk_pixbuf_unref (pixbuf);
+
+       gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
+}
+       
 static GList *filesel_create(const gchar *title, const gchar *path,
                             gboolean multiple_files,
                             gboolean open, gboolean folder_mode,
@@ -68,6 +93,15 @@ static GList *filesel_create(const gchar *title, const gchar *path,
                                            file_filter);
        }
 
+       if (action == GTK_FILE_CHOOSER_ACTION_OPEN) {
+               GtkImage *preview;
+               preview = gtk_image_new ();
+               gtk_file_chooser_set_preview_widget (chooser, preview);
+               g_signal_connect (chooser, "update-preview",
+                           G_CALLBACK (update_preview_cb), preview);
+
+       }
+
        manage_window_set_transient (GTK_WINDOW(chooser));
        gtk_window_set_modal(GTK_WINDOW(chooser), TRUE);
 
@@ -141,6 +175,13 @@ GList *filesel_select_multiple_files_open(const gchar *title)
        return filesel_create(title, NULL, TRUE, TRUE, FALSE, NULL);
 }
 
+GList *filesel_select_multiple_files_open_with_filter( const gchar *title,
+                                                       const gchar *path,
+                                                       const gchar *filter)
+{
+       return filesel_create (title, path, TRUE, TRUE, FALSE, filter);
+}
+
 /**
  * This function lets the user select one file.
  * This opens an Open type dialog if "file" is NULL, 
index 00a04caf8f43b6fbbde90936b7be34ae1f7f0ffd..2b56e4f70094b1113ed66c69f21c1e3a492a6b98 100644 (file)
@@ -30,5 +30,8 @@ gchar *filesel_select_file_open_folder(const gchar *title, const gchar *path);
 gchar *filesel_select_file_save_folder(const gchar *title, const gchar *path);
 
 GList *filesel_select_multiple_files_open(const gchar *title);
+GList *filesel_select_multiple_files_open_with_filter( const gchar *title,
+                                                       const gchar *path,
+                                                       const gchar *filter);
 
 #endif /* __FILESEL_H__ */
index 8e213921cc4a0122d2e81211703256b1d2b4bbd0..764532ff8c19ff8e973ba6d00f7b029ef77ac043 100644 (file)
@@ -152,22 +152,35 @@ static void unload_cb(GtkButton *button, PluginWindow *pluginwindow)
 
 static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
 {
-       gchar *file, *error = NULL;
-
-       file = filesel_select_file_open_with_filter(_("Select Plugin to load"), 
-                                                   get_plugin_dir(), 
-                                                   "*." G_MODULE_SUFFIX);
-       if (file == NULL)
-               return;
-
-       plugin_load(file, &error);
-       if (error != NULL) {
-               alertpanel_error(_("The following error occured while loading the plugin:\n%s\n"), error);
-               g_free(error);
-       }
+       GList *file_list;
+
+       file_list = filesel_select_multiple_files_open_with_filter(
+                       _("Select Plugin to load"), get_plugin_dir(), 
+                       "*." G_MODULE_SUFFIX);
+
+       if (file_list) {
+               GList *tmp;
+
+               for ( tmp = file_list; tmp; tmp = tmp->next) {
+                       gchar *file, *error = NULL;
+
+                       file = (gchar *) tmp->data;
+                       if (!file) continue;
+                       plugin_load(file, &error);
+                       if (error != NULL) {
+                               alertpanel_error(
+                               _("The following error occured while loading the plugin [%s] :\n%s\n"),
+                               file, error);
+                               g_free(error);
+                       }
+
+                       /* FIXME: globally or atom-ly : ? */
+                       set_plugin_list(pluginwindow);
+                       g_free(file);
+               }
 
-       set_plugin_list(pluginwindow);
-       g_free(file);
+               g_list_free(file_list);
+       }               
 }
 
 static gboolean pluginwindow_key_pressed(GtkWidget *widget, GdkEventKey *event,
@@ -364,9 +377,10 @@ static GtkWidget *pluginwindow_list_view_create(PluginWindow *pluginwindow)
        model = GTK_TREE_MODEL(pluginwindow_create_data_store());
        list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
        g_object_unref(model);  
-       
+
        gtk_tree_view_set_rules_hint(list_view, prefs_common.enable_rules_hint);
-       
+       gtk_tree_view_set_search_column (list_view, 0);
+
        selector = gtk_tree_view_get_selection(list_view);
        gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
        gtk_tree_selection_set_select_function(selector, pluginwindow_selected,
index 10ce627434cd749d54ca612b0bf8f9b7ba9e0924..1c352611b321cd81f501753b0a4abd271b8393f0 100644 (file)
@@ -1020,7 +1020,7 @@ static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
                              MimeView *mimeview)
 {
        MimeInfo *partinfo;
-
+       AlertValue val;
        if (mimeview->opened == node) return;
        mimeview->opened = node;
        gtk_ctree_node_moveto(ctree, node, -1, 0.5, 0);
@@ -1048,9 +1048,28 @@ static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
                
                        break;
                default:
-                       mimeview->textview->default_text = TRUE;        
+                       mimeview->textview->default_text = TRUE;
                        mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
-                       textview_show_mime_part(mimeview->textview, partinfo);
+                       textview_clear(mimeview->textview);
+                       val = alertpanel_full(_("Unknown part type"), 
+                                             _("The type of this part is unknown. What would you like "
+                                               "to do with it?"),
+                                             GTK_STOCK_SAVE, GTK_STOCK_OPEN, _("Display as text"),
+                                             FALSE, NULL, ALERT_WARNING, G_ALERTALTERNATE);
+                       switch (val) {
+                               case G_ALERTDEFAULT:
+                                       mimeview_save_as(mimeview);
+                                       break;
+                               case G_ALERTALTERNATE:
+                                       mimeview_open_with(mimeview);
+                                       break;
+                               case G_ALERTOTHER:
+                                       mimeview_display_as_text(mimeview);
+                                       break;
+                               default:
+                                       textview_show_mime_part(mimeview->textview, partinfo);
+                       }
+                       
                        break;
                }
        }
@@ -1568,8 +1587,15 @@ static void mimeview_open_with(MimeView *mimeview)
                prefs_common.mime_open_cmd_history =
                        add_history(NULL, prefs_common.mime_open_cmd);
 
-       content_type = procmime_get_content_type_str(partinfo->type,
+       if ((partinfo->type == MIMETYPE_APPLICATION) &&
+            (!g_ascii_strcasecmp(partinfo->subtype, "octet-stream"))) {
+               /* guess content-type from filename */
+               content_type = procmime_get_mime_type(filename);
+       } 
+       if (content_type == NULL) {
+               content_type = procmime_get_content_type_str(partinfo->type,
                        partinfo->subtype);
+       }
        mime_command = mailcap_get_command_for_type(content_type);
        g_free(content_type);
        cmd = input_dialog_combo