better mime type selection in `file attachment' property dialog
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Fri, 29 Jun 2001 18:48:24 +0000 (18:48 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Fri, 29 Jun 2001 18:48:24 +0000 (18:48 +0000)
ChangeLog.claws
src/compose.c
src/procmime.c
src/procmime.h

index 28573ecb9dd9c4b7dcef957721151ab47ee5df8e..4ba838a766878a5b297b585320355fd4d066b2c5 100644 (file)
@@ -1,3 +1,10 @@
+2001-06-29 [alfons]
+
+       * src/compose.c
+       * src/mimeproc.[ch]
+               allow selecting an attached files' mime type from a 
+               list of types.
+
 2001-06-29 [paul]
 
        * more sync with sylpheed 0.5.0pre3
index db91a0d2981a0705ea924ee20749ef3d22849b51..eeeea48030fe5988be3473d4706a8cb0a451305f 100644 (file)
@@ -3638,6 +3638,7 @@ static void compose_attach_property_create(gboolean *cancelled)
        GtkWidget *hbbox;
        GtkWidget *ok_btn;
        GtkWidget *cancel_btn;
+       GList     *mime_type_list, *strlist;
 
        debug_print("Creating attach_property window...\n");
 
@@ -3662,7 +3663,32 @@ static void compose_attach_property_create(gboolean *cancelled)
        gtk_table_set_row_spacings(GTK_TABLE(table), 8);
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
-       SET_LABEL_AND_ENTRY(_("MIME type"), mimetype_entry, 0);
+       label = gtk_label_new(_("MIME type")); 
+       gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, (0 + 1), 
+                        GTK_FILL, 0, 0, 0); 
+       gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); 
+       mimetype_entry = gtk_combo_new(); 
+       gtk_table_attach(GTK_TABLE(table), mimetype_entry, 1, 2, 0, (0 + 1), 
+                        GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+                        
+       /* stuff with list */
+       mime_type_list = procmime_get_mime_type_list();
+       strlist = NULL;
+       for (; mime_type_list != NULL; mime_type_list = mime_type_list->next) {
+               MimeType *type = (MimeType *) mime_type_list->data;
+               strlist = g_list_append(strlist, 
+                               g_strdup_printf("%s/%s",
+                                       type->type, type->sub_type));
+       }
+       
+       gtk_combo_set_popdown_strings(GTK_COMBO(mimetype_entry), strlist);
+
+       for (mime_type_list = strlist; mime_type_list != NULL; 
+               mime_type_list = mime_type_list->next)
+               g_free(mime_type_list->data);
+       g_list_free(strlist);
+                        
+       mimetype_entry = GTK_COMBO(mimetype_entry)->entry;                       
 
        label = gtk_label_new(_("Encoding"));
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
index 4b80c2fa93aea478641cc774d4c7a3569903bbe7..d4036bfb8b5bf749d2195197a118de5885ba5012 100644 (file)
@@ -44,8 +44,6 @@
 #endif
 
 static GHashTable *procmime_get_mime_type_table        (void);
-static GList *procmime_get_mime_type_list      (void);
-
 
 MimeInfo *procmime_mimeinfo_new(void)
 {
@@ -805,7 +803,7 @@ static GHashTable *procmime_get_mime_type_table(void)
        return table;
 }
 
-static GList *procmime_get_mime_type_list(void)
+GList *procmime_get_mime_type_list(void)
 {
        GList *list = NULL;
        FILE *fp;
@@ -813,6 +811,9 @@ static GList *procmime_get_mime_type_list(void)
        gchar *p, *delim;
        MimeType *mime_type;
 
+       if (mime_type_list) 
+               return mime_type_list;
+
        if ((fp = fopen(SYSCONFDIR "/mime.types", "r")) == NULL) {
                FILE_OP_ERROR(SYSCONFDIR "/mime.types", "fopen");
                return NULL;
index 6206738cd8d45efbcec6f0c0e575c1871861cb29..3d6067bb9099a334410e2be51a7b7f5ef2261159 100644 (file)
@@ -136,6 +136,8 @@ gchar *procmime_get_tmp_file_name   (MimeInfo       *mimeinfo);
 
 gchar *procmime_get_mime_type          (const gchar    *filename);
 
+GList *procmime_get_mime_type_list     (void);
+
 EncodingType procmime_get_encoding_for_charset (const gchar    *charset);
 const gchar *procmime_get_encoding_str         (EncodingType    encoding);