* sync with main changes of 2002-10-04
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Sun, 13 Oct 2002 14:12:29 +0000 (14:12 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Sun, 13 Oct 2002 14:12:29 +0000 (14:12 +0000)
- drop changes to src/compose.c (requires claws specific changes)

- drop changes to src/prefs_folder_item.c (claws implementation
  seems to be working)

12 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/account.c
src/account.h
src/folder.c
src/folder.h
src/mainwindow.c
src/menu.c
src/menu.h
src/prefs_common.c

index f2a1ef7..e4550d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2002-10-04
+
+       * src/account.[ch]: account_find_from_item(): new.
+       * src/compose.c:
+         compose_reply(), compose_forward(), compose_redirect()
+         src/mainwindow.c: compose_cb(): select optimal account when
+         composing.
+       * src/folder.[ch]: added FolderItem::apply_sub.
+       * src/menu.[ch]: menu_find_option_menu_index(): new. It finds the
+         index of option menu which contains the specified data.
+       * src/prefs_folder_item(): added Compose tab, and the setting of
+         folder account.
+
 2002-10-04
 
        * configure.in: added $LDAP_LIBS for lber library detection.
index 1b12cad..dc4ad80 100644 (file)
@@ -1,3 +1,12 @@
+2002-10-12 [alfons]    0.8.5claws27
+
+       * sync with main changes of 2002-10-04
+
+       - drop changes to src/compose.c (requires claws specific changes)
+
+       - drop changes to src/prefs_folder_item.c (claws implementation
+         seems to be working)
+
 2002-10-12 [colin]     0.8.5claws26
 
        * src/mainwindow.c
index 8968b2d..5c42a5d 100644 (file)
@@ -1,3 +1,16 @@
+2002-10-04
+
+       * src/account.[ch]: account_find_from_item(): ¿·µ¬¡£
+       * src/compose.c:
+         compose_reply(), compose_forward(), compose_redirect()
+         src/mainwindow.c: compose_cb(): ºîÀ®»þ¤ËºÇŬ¤Ê¥¢¥«¥¦¥ó¥È¤òÁªÂò
+         ¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+       * src/folder.[ch]: FolderItem::apply_sub ¤òÄɲá£
+       * src/menu.[ch]: menu_find_option_menu_index(): ¿·µ¬¡£»ØÄꤷ¤¿
+         ¥Ç¡¼¥¿¤ò´Þ¤à¥ª¥×¥·¥ç¥ó¥á¥Ë¥å¡¼¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¸¡º÷¤¹¤ë¡£
+       * src/prefs_folder_item(): ºîÀ®¥¿¥Ö¤È¡¢¥Õ¥©¥ë¥À¥¢¥«¥¦¥ó¥È¤ÎÀßÄê¤ò
+         Äɲá£
+
 2002-10-04
 
        * configure.in: lber ¥é¥¤¥Ö¥é¥ê¤Î¸¡½Ð¤Ë $LDAP_LIBS ¤òÄɲá£
index dbfe591..5aa4383 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws26
+EXTRA_VERSION=claws27
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index bdd2ad0..37f84e2 100644 (file)
@@ -169,6 +169,33 @@ void account_save_config_all(void)
        prefs_account_save_config_all(account_list);
 }
 
+/*
+ * account_find_all_from_address:
+ * @ac_list: initial list of accounts. NULL to create a new one.
+ * Accounts found in the @address will be appended to this list.
+ * @address: Email address string.
+ *
+ * Find all the mail (not news) accounts within the specified address.
+ *
+ * Return value: the original accounts list with the found accounts appended.
+ */
+GList *account_find_all_from_address(GList *ac_list, const gchar *address)
+{
+       GList *cur;
+       PrefsAccount *ac;
+
+       if (address == NULL)
+               return ac_list;
+
+       for (cur = account_list; cur != NULL; cur = cur->next) {
+               ac = (PrefsAccount *)cur->data;
+               if (ac->protocol != A_NNTP && ac->address &&
+                   strcasestr(address, ac->address) != NULL)
+                       ac_list = g_list_append(ac_list, ac);
+       }
+       return ac_list;
+}
+       
 PrefsAccount *account_find_from_smtp_server(const gchar *address,
                                            const gchar *smtp_server)
 {
@@ -227,33 +254,29 @@ PrefsAccount *account_find_from_id(gint id)
        return NULL;
 }
 
-/*
- * account_find_all_from_address:
- * @ac_list: initial list of accounts. NULL to create a new one.
- * Accounts found in the @address will be appended to this list.
- * @address: Email address string.
- *
- * Find all the mail (not news) accounts within the specified address.
- *
- * Return value: the original accounts list with the found accounts appended.
- */
-GList *account_find_all_from_address(GList *ac_list, const gchar *address)
+PrefsAccount *account_find_from_item(FolderItem *item)
 {
-       GList *cur;
        PrefsAccount *ac;
 
-       if (address == NULL)
-               return ac_list;
-
-       for (cur = account_list; cur != NULL; cur = cur->next) {
-               ac = (PrefsAccount *)cur->data;
-               if (ac->protocol != A_NNTP && ac->address &&
-                   strcasestr(address, ac->address) != NULL)
-                       ac_list = g_list_append(ac_list, ac);
+       g_return_val_if_fail(item != NULL, NULL);
+
+       ac = item->account;
+       if (!ac) {
+               FolderItem *cur_item = item->parent;
+               while (cur_item != NULL) {
+                       if (cur_item->account && cur_item->apply_sub) {
+                               ac = cur_item->account;
+                               break;
+                       }                               
+                       cur_item = cur_item->parent;
+               }
        }
-       return ac_list;
+       if (!ac)
+               ac = item->folder->account;
+
+       return ac;
 }
-       
+
 void account_set_menu(void)
 {
        main_window_set_account_menu(account_list);
index 9c3d8f4..47d157d 100644 (file)
@@ -34,12 +34,13 @@ extern PrefsAccount *cur_account;
 void         account_read_config_all   (void);
 void         account_save_config_all   (void);
 
+GList        *account_find_all_from_address    (GList          *ac_list,
+                                                const gchar    *address);
 PrefsAccount *account_find_from_smtp_server    (const gchar    *address,
                                                 const gchar    *smtp_server);
 PrefsAccount *account_find_from_address                (const gchar    *address);
 PrefsAccount *account_find_from_id             (gint            id);
-GList        *account_find_all_from_address    (GList          *ac_list,
-                                                const gchar    *address);
+PrefsAccount *account_find_from_item           (FolderItem     *item);
 
 void         account_set_menu          (void);
 
index 8c8a7cf..84918a8 100644 (file)
@@ -206,7 +206,6 @@ FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path
        item->stype = F_NORMAL;
        item->name = g_strdup(name);
        item->path = g_strdup(path);
-       item->account = NULL;
        item->mtime = 0;
        item->new = 0;
        item->unread = 0;
@@ -221,6 +220,8 @@ FolderItem *folder_item_new(Folder *folder, const gchar *name, const gchar *path
        item->opened    = FALSE;
        item->parent = NULL;
        item->folder = NULL;
+       item->account = NULL;
+       item->apply_sub = FALSE;
        item->mark_queue = NULL;
        item->data = NULL;
 
@@ -1897,7 +1898,8 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        const gchar *path = NULL;
        PrefsAccount *account = NULL;
        gboolean no_sub = FALSE, no_select = FALSE, collapsed = FALSE, 
-                threaded = TRUE, ret_rcpt = FALSE, hidereadmsgs = FALSE;
+                threaded = TRUE, apply_sub = FALSE;
+       gboolean ret_rcpt = FALSE, hidereadmsgs = FALSE; /* CLAWS */
        FolderSortKey sort_key = SORT_BY_NONE;
        FolderSortType sort_type = SORT_ASCENDING;
        gint new = 0, unread = 0, total = 0;
@@ -1934,11 +1936,7 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
                        name = attr->value;
                else if (!strcmp(attr->name, "path"))
                        path = attr->value;
-               else if (!strcmp(attr->name, "account_id")) {
-                       account = account_find_from_id(atoi(attr->value));
-                       if (!account) g_warning("account_id: %s not found\n",
-                                               attr->value);
-               } else if (!strcmp(attr->name, "mtime"))
+               else if (!strcmp(attr->name, "mtime"))
                        mtime = strtoul(attr->value, NULL, 10);
                else if (!strcmp(attr->name, "new"))
                        new = atoi(attr->value);
@@ -1988,12 +1986,16 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
                                sort_type = SORT_ASCENDING;
                        else
                                sort_type = SORT_DESCENDING;
-               }
+               } else if (!strcmp(attr->name, "account_id")) {
+                       account = account_find_from_id(atoi(attr->value));
+                       if (!account) g_warning("account_id: %s not found\n",
+                                               attr->value);
+               } else if (!strcmp(attr->name, "apply_sub"))
+                       apply_sub = *attr->value == '1' ? TRUE : FALSE;
        }
 
        item = folder_item_new(folder, name, path);
        item->stype = stype;
-       item->account = account;
        item->mtime = mtime;
        item->new = new;
        item->unread = unread;
@@ -2016,7 +2018,8 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        case F_TRASH:  folder->trash  = item; break;
        default:       break;
        }
-
+       item->account = account;
+       item->apply_sub = apply_sub;
        prefs_folder_item_read_config(item);
 
        node->data = item;
@@ -2034,7 +2037,8 @@ static gboolean folder_read_folder_func(GNode *node, gpointer data)
        const gchar *name = NULL;
        const gchar *path = NULL;
        PrefsAccount *account = NULL;
-       gboolean collapsed = FALSE, threaded = TRUE, ret_rcpt = FALSE;
+       gboolean collapsed = FALSE, threaded = TRUE, apply_sub = FALSE;
+       gboolean ret_rcpt = FALSE; /* CLAWS */
 
        if (g_node_depth(node) != 2) return FALSE;
        g_return_val_if_fail(node->data != NULL, FALSE);
@@ -2065,14 +2069,16 @@ static gboolean folder_read_folder_func(GNode *node, gpointer data)
                        name = attr->value;
                else if (!strcmp(attr->name, "path"))
                        path = attr->value;
+               else if (!strcmp(attr->name, "collapsed"))
+                       collapsed = *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "threaded"))
+                       threaded = *attr->value == '1' ? TRUE : FALSE;
                else if (!strcmp(attr->name, "account_id")) {
                        account = account_find_from_id(atoi(attr->value));
                        if (!account) g_warning("account_id: %s not found\n",
                                                attr->value);
-               } else if (!strcmp(attr->name, "collapsed"))
-                       collapsed = *attr->value == '1' ? TRUE : FALSE;
-               else if (!strcmp(attr->name, "threaded"))
-                       threaded = *attr->value == '1' ? TRUE : FALSE;
+               } else if (!strcmp(attr->name, "apply_sub"))
+                       apply_sub = *attr->value == '1' ? TRUE : FALSE;
                else if (!strcmp(attr->name, "reqretrcpt"))
                        ret_rcpt = *attr->value == '1' ? TRUE : FALSE;
        }
@@ -2088,6 +2094,8 @@ static gboolean folder_read_folder_func(GNode *node, gpointer data)
        folder_add(folder);
        FOLDER_ITEM(node->data)->collapsed = collapsed;
        FOLDER_ITEM(node->data)->threaded  = threaded;
+       FOLDER_ITEM(node->data)->account   = account;
+       FOLDER_ITEM(node->data)->apply_sub = apply_sub;
        FOLDER_ITEM(node->data)->ret_rcpt  = ret_rcpt;
 
        g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
@@ -2143,11 +2151,13 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                                (fp, LOCAL_FOLDER(folder)->rootpath);
                        fputs("\"", fp);
                }
+               if (item->collapsed && node->children)
+                       fputs(" collapsed=\"1\"", fp);
                if (folder->account)
                        fprintf(fp, " account_id=\"%d\"",
                                folder->account->account_id);
-               if (item->collapsed && node->children)
-                       fputs(" collapsed=\"1\"", fp);
+               if (item->apply_sub)
+                       fputs(" apply_sub=\"1\"", fp);
                if (item->ret_rcpt) 
                        fputs(" reqretrcpt=\"1\"", fp);
        } else {
@@ -2163,9 +2173,7 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                        xml_file_put_escape_str(fp, item->path);
                        fputs("\"", fp);
                }
-               if (item->account)
-                       fprintf(fp, " account_id=\"%d\"",
-                               item->account->account_id);
+               
                if (item->no_sub)
                        fputs(" no_sub=\"1\"", fp);
                if (item->no_select)
@@ -2195,6 +2203,12 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                fprintf(fp,
                        " mtime=\"%lu\" new=\"%d\" unread=\"%d\" total=\"%d\"",
                        item->mtime, item->new, item->unread, item->total);
+                       
+               if (item->account)
+                       fprintf(fp, " account_id=\"%d\"",
+                               item->account->account_id);
+               if (item->apply_sub)
+                       fputs(" apply_sub=\"1\"", fp);
        }
 
        if (node->children) {
index 62e9076..d0862c2 100644 (file)
@@ -219,7 +219,6 @@ struct _FolderItem
 
        gchar *name;
        gchar *path;
-       PrefsAccount *account;
 
        time_t mtime;
 
@@ -250,6 +249,10 @@ struct _FolderItem
 
        Folder *folder;
 
+       PrefsAccount *account;
+
+       gboolean apply_sub;
+       
        GSList *mark_queue;
 
        gpointer data;
index 2536905..acdf385 100644 (file)
@@ -3101,28 +3101,35 @@ void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 void compose_mail_cb(MainWindow *mainwin, guint action,
                            GtkWidget *widget)
 {
-       PrefsAccount * ac;
-       GList * list;
-       GList * cur;
+       PrefsAccount *ac = NULL;
+       FolderItem *item = mainwin->summaryview->folder_item;   
+        GList * list;
+        GList * cur;
 
-       if (mainwin->summaryview->folder_item) {
-               ac = mainwin->summaryview->folder_item->folder->account;
+       if (item) {
+               ac = account_find_from_item(item);
                if (ac && ac->protocol != A_NNTP) {
-                       compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
+                       compose_new_with_folderitem(ac, item);          /* CLAWS */
                        return;
                }
        }
 
-       if(cur_account && (cur_account->protocol != A_NNTP)) {
-               compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
+       /*
+        * CLAWS - use current account
+        */
+       if (cur_account && (cur_account->protocol != A_NNTP)) {
+               compose_new_with_folderitem(cur_account, item);
                return;
        }
 
+       /*
+        * CLAWS - just get the first one
+        */
        list = account_get_list();
-       for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
+       for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
                ac = (PrefsAccount *) cur->data;
                if (ac->protocol != A_NNTP) {
-                       compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
+                       compose_new_with_folderitem(ac, item);
                        return;
                }
        }
index 1856e3a..1fe647f 100644 (file)
@@ -169,3 +169,29 @@ void menu_button_position(GtkMenu *menu, gint *x, gint *y, gpointer user_data)
        *x = xpos;
        *y = ypos;
 }
+
+gint menu_find_option_menu_index(GtkOptionMenu *optmenu, gpointer data,
+                                GCompareFunc func)
+{
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+       gpointer menu_data;
+       GList *cur;
+       gint n;
+
+       menu = gtk_option_menu_get_menu(optmenu);
+
+       for (cur = GTK_MENU_SHELL(menu)->children, n = 0;
+            cur != NULL; cur = cur->next, n++) {
+               menuitem = GTK_WIDGET(cur->data);
+               menu_data = gtk_object_get_user_data(GTK_OBJECT(menuitem));
+               if (func) {
+                       if (func(menu_data, data) == 0)
+                               return n;
+               } else if (menu_data == data)
+                       return n;
+       }
+
+       return -1;
+}
+
index fa92c6c..0ec4b38 100644 (file)
@@ -25,6 +25,7 @@
 #include <gtk/gtkitemfactory.h>
 #include <gtk/gtkmenu.h>
 #include <gtk/gtkmenushell.h>
+#include <gtk/gtkoptionmenu.h>
 
 #define MENUITEM_ADD(menu, menuitem, label, data) \
 { \
@@ -70,4 +71,8 @@ void menu_button_position     (GtkMenu                *menu,
                                 gint                   *y,
                                 gpointer                user_data);
 
+gint menu_find_option_menu_index(GtkOptionMenu         *optmenu,
+                                gpointer                data,
+                                GCompareFunc            func);
+
 #endif /* __MENU_H__ */
index ba2a84c..7a210ba 100644 (file)
@@ -4092,30 +4092,20 @@ static void prefs_common_charset_set_data_from_optmenu(PrefParam *pparam)
 
 static void prefs_common_charset_set_optmenu(PrefParam *pparam)
 {
-       GList *cur;
        GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
-       GtkWidget *menu;
-       GtkWidget *menuitem;
-       gchar *charset;
-       gint n = 0;
+       gint index;
 
        g_return_if_fail(optmenu != NULL);
        g_return_if_fail(*((gchar **)pparam->data) != NULL);
 
-       menu = gtk_option_menu_get_menu(optmenu);
-       for (cur = GTK_MENU_SHELL(menu)->children;
-            cur != NULL; cur = cur->next) {
-               menuitem = GTK_WIDGET(cur->data);
-               charset = gtk_object_get_user_data(GTK_OBJECT(menuitem));
-               if (!strcmp(charset, *((gchar **)pparam->data))) {
-                       gtk_option_menu_set_history(optmenu, n);
-                       return;
-               }
-               n++;
+       index = menu_find_option_menu_index(optmenu, *((gchar **)pparam->data),
+                                           (GCompareFunc)strcmp);
+       if (index >= 0)
+               gtk_option_menu_set_history(optmenu, index);
+       else {
+               gtk_option_menu_set_history(optmenu, 0);
+               prefs_common_charset_set_data_from_optmenu(pparam);
        }
-
-       gtk_option_menu_set_history(optmenu, 0);
-       prefs_common_charset_set_data_from_optmenu(pparam);
 }
 
 static void prefs_common_recv_dialog_set_data_from_optmenu(PrefParam *pparam)