2007-07-15 [colin] 2.10.0cvs28
[claws.git] / src / mainwindow.c
index a025a84fdaa06d514bb53e9d2392006f93a16d64..6fa82e6cec9708625dff4aac483678b9b82ef63c 100644 (file)
@@ -1,20 +1,19 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+   Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+   Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "defs.h"
@@ -191,10 +190,11 @@ static void toggle_toolbar_cb      (MainWindow    *mainwin,
 static void toggle_statusbar_cb         (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
+#ifndef MAEMO
 static void set_layout_cb       (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
-
+#endif
 static void addressbook_open_cb        (MainWindow     *mainwin,
                                 guint           action,
                                 GtkWidget      *widget);
@@ -565,6 +565,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
 
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
+#ifndef MAEMO
        {N_("/_View/La_yout"),                  NULL, NULL, 0, "<Branch>"},
        {N_("/_View/Layout/_Standard"),         NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
        {N_("/_View/Layout/_Three columns"),    NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
@@ -572,6 +573,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
        {N_("/_View/Layout/S_mall screen"),     NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
+#endif
        {N_("/_View/_Sort"),                    NULL, NULL, 0, "<Branch>"},
        {N_("/_View/_Sort/by _number"),         NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
        {N_("/_View/_Sort/by S_ize"),           NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
@@ -580,10 +582,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/_Sort/by _From"),           NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
        {N_("/_View/_Sort/by _To"),             NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
        {N_("/_View/_Sort/by S_ubject"),        NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
-       {N_("/_View/_Sort/by _color label"),
-                                               NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
-       {N_("/_View/_Sort/by tag"),
-                                               NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
+       {N_("/_View/_Sort/by _color label"),    NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
+       {N_("/_View/_Sort/by tag"),             NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
        {N_("/_View/_Sort/by _mark"),           NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
        {N_("/_View/_Sort/by _status"),         NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
        {N_("/_View/_Sort/by a_ttachment"),
@@ -1322,7 +1322,9 @@ MainWindow *main_window_create()
        window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow");
        gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
-
+#ifdef MAEMO
+       prefs_common.layout_mode = SMALL_LAYOUT;
+#endif
        if (!geometry.min_height) {
                geometry.min_width = 320;
                geometry.min_height = 200;
@@ -1354,7 +1356,11 @@ MainWindow *main_window_create()
        menubar = menubar_create(window, mainwin_entries, 
                                 n_menu_entries, "<Main>", mainwin);
        gtk_widget_show(menubar);
+
+#ifndef MAEMO
        gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
+#endif
+
        ifactory = gtk_item_factory_from_widget(menubar);
 
 /*     gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
@@ -1377,11 +1383,17 @@ MainWindow *main_window_create()
        }
        /* link window to mainwin->window to avoid gdk warnings */
        mainwin->window       = window;
+       mainwin_list = g_list_append(mainwin_list, mainwin);
        
-       /* create toolbar */
+#ifdef MAEMO
+       mainwin->toolbar = toolbar_create(TOOLBAR_MAIN, 
+                                         window, 
+                                         (gpointer)mainwin);
+#else
        mainwin->toolbar = toolbar_create(TOOLBAR_MAIN, 
                                          handlebox, 
                                          (gpointer)mainwin);
+#endif
        toolbar_set_learn_button
                (mainwin->toolbar,
                 LEARN_SPAM);
@@ -1425,10 +1437,11 @@ MainWindow *main_window_create()
        statusbar = statusbar_create();
        gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
 
+#ifndef MAEMO
        progressbar = gtk_progress_bar_new();
        gtk_widget_set_size_request(progressbar, 120, 1);
        gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
-
+#endif
        online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
        offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
        online_switch = gtk_button_new ();
@@ -1516,7 +1529,9 @@ MainWindow *main_window_create()
        mainwin->vbox_body      = vbox_body;
        mainwin->hbox_stat      = hbox_stat;
        mainwin->statusbar      = statusbar;
+#ifndef MAEMO
        mainwin->progressbar    = progressbar;
+#endif
        mainwin->statuslabel    = statuslabel;
        mainwin->online_switch  = online_switch;
        mainwin->online_pixmap  = online_pixmap;
@@ -1639,7 +1654,9 @@ MainWindow *main_window_create()
           menu items in different menus             */
        menu_connect_identical_items();
 
+#ifndef MAEMO
        gtk_window_iconify(GTK_WINDOW(mainwin->window));
+#endif
 
        g_signal_connect(G_OBJECT(window), "window_state_event",
                         G_CALLBACK(mainwindow_state_event_cb), mainwin);
@@ -1674,8 +1691,6 @@ MainWindow *main_window_create()
        if (!hand_cursor)
                hand_cursor = gdk_cursor_new(GDK_HAND2);
 
-       mainwin_list = g_list_append(mainwin_list, mainwin);
-
        /* init work_offline */
        if (prefs_common.work_offline)
                online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
@@ -1960,24 +1975,18 @@ static void main_window_set_account_receive_menu(MainWindow *mainwin,
 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
                                                       GList *account_list)
 {
-       GList *cur_ac, *cur_item;
+       GList *cur_ac;
        GtkWidget *menuitem;
        PrefsAccount *ac_prefs;
        GtkWidget *menu = NULL;
 
-       if (mainwin->toolbar->getall_btn == NULL
-       ||  mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
+       if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
                return;
 
-       menu = mainwin->toolbar->getall_combo->menu;
-
-       /* destroy all previous menu item */
-       cur_item = GTK_MENU_SHELL(menu)->children;
-       while (cur_item != NULL) {
-               GList *next = cur_item->next;
-               gtk_widget_destroy(GTK_WIDGET(cur_item->data));
-               cur_item = next;
-       }
+       menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
+       if (menu)
+               gtk_widget_destroy(menu);
+       menu = gtk_menu_new();
 
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
                ac_prefs = (PrefsAccount *)cur_ac->data;
@@ -1991,29 +2000,43 @@ static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
                                 G_CALLBACK(account_receive_menu_cb),
                                 ac_prefs);
        }
+       gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
 }
 
 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
                                                       GList *account_list)
 {
-       GList *cur_ac, *cur_item;
+#ifndef MAEMO
+       GList *cur_ac;
        GtkWidget *menuitem;
        PrefsAccount *ac_prefs;
        GtkWidget *menu = NULL;
 
-       if (mainwin->toolbar->compose_mail_btn == NULL
-       ||  mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
+       if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
                return;
 
-       menu = mainwin->toolbar->compose_combo->menu;
+       menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
+       if (menu)
+               gtk_widget_destroy(menu);
+       menu = gtk_menu_new();
 
-       /* destroy all previous menu item */
-       cur_item = GTK_MENU_SHELL(menu)->children;
-       while (cur_item != NULL) {
-               GList *next = cur_item->next;
-               gtk_widget_destroy(GTK_WIDGET(cur_item->data));
-               cur_item = next;
+       for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
+               ac_prefs = (PrefsAccount *)cur_ac->data;
+
+               menuitem = gtk_menu_item_new_with_label
+                       (ac_prefs->account_name
+                        ? ac_prefs->account_name : _("Untitled"));
+               gtk_widget_show(menuitem);
+               gtk_menu_append(GTK_MENU(menu), menuitem);
+               g_signal_connect(G_OBJECT(menuitem), "activate",
+                                G_CALLBACK(account_compose_menu_cb),
+                                ac_prefs);
        }
+       gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
+       menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_news_btn));
+       if (menu)
+               gtk_widget_destroy(menu);
+       menu = gtk_menu_new();
 
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
                ac_prefs = (PrefsAccount *)cur_ac->data;
@@ -2027,6 +2050,8 @@ static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
                                 G_CALLBACK(account_compose_menu_cb),
                                 ac_prefs);
        }
+       gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_news_btn), menu);
+#endif
 }
 
 void main_window_set_account_menu(GList *account_list)
@@ -3097,6 +3122,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
 }
 
+#ifndef MAEMO
        switch (prefs_common.layout_mode) {
        case NORMAL_LAYOUT:
                SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
@@ -3114,6 +3140,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
                SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
                break;
        }
+#endif
 #undef SET_CHECK_MENU_ACTIVE
 
        if (folderwin) {
@@ -3357,6 +3384,7 @@ static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
        }
 }
 
+#ifndef MAEMO
 static void set_layout_cb(MainWindow *mainwin, guint action,
                               GtkWidget *widget)
 {
@@ -3390,6 +3418,7 @@ static void set_layout_cb(MainWindow *mainwin, guint action,
        summary_relayout(mainwin->summaryview); 
        summary_update_unread(mainwin->summaryview, NULL);
 }
+#endif
 
 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
                                        gboolean ask_sync)