2008-07-30 [colin] 3.5.0cvs39
authorColin Leroy <colin@colino.net>
Wed, 30 Jul 2008 15:59:34 +0000 (15:59 +0000)
committerColin Leroy <colin@colino.net>
Wed, 30 Jul 2008 15:59:34 +0000 (15:59 +0000)
* src/folderview.c
* src/folderview.h
* src/imap_gtk.c
* src/mh_gtk.c
* src/news_gtk.c
Move the folderview popup menu to GtkUIManager

ChangeLog
PATCHSETS
configure.ac
src/folderview.c
src/folderview.h
src/imap_gtk.c
src/mh_gtk.c
src/news_gtk.c

index 7f00dfa8ebf770111c985a3c020770aa51fb4161..cef1a64a0c7080d20168dfa7939e529b55af33fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-07-30 [colin]     3.5.0cvs39
+
+       * src/folderview.c
+       * src/folderview.h
+       * src/imap_gtk.c
+       * src/mh_gtk.c
+       * src/news_gtk.c
+               Move the folderview popup menu to GtkUIManager
+
 2008-07-29 [colin]     3.5.0cvs38
 
        * src/account.c
index 795f83ef07644db2cd1a9b89b54e1a9f9bdb3b0a..19e8454f1dafcb06df563cf19c63a342d1c0d654 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.12.2.50 -r 1.12.2.51 src/action.c;  cvs diff -u -r 1.3.2.8 -r 1.3.2.9 src/action.h;  cvs diff -u -r 1.60.2.120 -r 1.60.2.121 src/addressbook.c;  cvs diff -u -r 1.5.2.8 -r 1.5.2.9 src/addressitem.h;  cvs diff -u -r 1.382.2.458 -r 1.382.2.459 src/compose.c;  cvs diff -u -r 1.50.2.47 -r 1.50.2.48 src/compose.h;  cvs diff -u -r 1.94.2.181 -r 1.94.2.182 src/messageview.c;  cvs diff -u -r 1.19.2.19 -r 1.19.2.20 src/messageview.h;  cvs diff -u -r 1.395.2.376 -r 1.395.2.377 src/summaryview.c;  cvs diff -u -r 1.5.2.31 -r 1.5.2.32 src/gtk/menu.c;  cvs diff -u -r 1.4.2.16 -r 1.4.2.17 src/gtk/menu.h;  ) > 3.5.0cvs36.patchset
 ( cvs diff -u -r 1.101.2.52 -r 1.101.2.53 src/news.c;  ) > 3.5.0cvs37.patchset
 ( cvs diff -u -r 1.61.2.80 -r 1.61.2.81 src/account.c;  cvs diff -u -r 1.11.2.10 -r 1.11.2.11 src/account.h;  cvs diff -u -r 1.12.2.51 -r 1.12.2.52 src/action.c;  cvs diff -u -r 1.3.2.9 -r 1.3.2.10 src/action.h;  cvs diff -u -r 1.5.2.9 -r 1.5.2.10 src/addressitem.h;  cvs diff -u -r 1.382.2.459 -r 1.382.2.460 src/compose.c;  cvs diff -u -r 1.1.2.18 -r 1.1.2.19 src/edittags.c;  cvs diff -u -r 1.274.2.257 -r 1.274.2.258 src/mainwindow.c;  cvs diff -u -r 1.39.2.49 -r 1.39.2.50 src/mainwindow.h;  cvs diff -u -r 1.83.2.137 -r 1.83.2.138 src/mimeview.c;  cvs diff -u -r 1.395.2.377 -r 1.395.2.378 src/summaryview.c;  cvs diff -u -r 1.5.2.32 -r 1.5.2.33 src/gtk/menu.c;  cvs diff -u -r 1.4.2.17 -r 1.4.2.18 src/gtk/menu.h;  ) > 3.5.0cvs38.patchset
+( cvs diff -u -r 1.207.2.203 -r 1.207.2.204 src/folderview.c;  cvs diff -u -r 1.20.2.22 -r 1.20.2.23 src/folderview.h;  cvs diff -u -r 1.1.2.59 -r 1.1.2.60 src/imap_gtk.c;  cvs diff -u -r 1.2.2.32 -r 1.2.2.33 src/mh_gtk.c;  cvs diff -u -r 1.2.2.27 -r 1.2.2.28 src/news_gtk.c;  ) > 3.5.0cvs39.patchset
index e61f955e28438edbc024d063144cb67c72e4a6cf..207f627e8a317fe845eb32ef8aa8487bc73bdaed 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=5
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=38
+EXTRA_VERSION=39
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 16bb6d3ee03f96f1e4d15f119a3f706370d70892..e33d19ba2c698850a2046d761cf51282a98042d4 100644 (file)
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtkctree.h>
-#include <gtk/gtkcontainer.h>
-#include <gtk/gtkclist.h>
-#include <gtk/gtkstyle.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkstatusbar.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkitemfactory.h>
+#include <gtk/gtk.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -222,28 +211,22 @@ static void folderview_col_resized        (GtkCList       *clist,
                                         gint            width,
                                         FolderView     *folderview);
 
-static void mark_all_read_cb            (FolderView    *folderview,
-                                         guint           action,
-                                         GtkWidget      *widget);
+static void mark_all_read_cb            (GtkAction     *action,
+                                        gpointer        data);
 
-static void folderview_empty_trash_cb  (FolderView     *folderview,
-                                        guint           action,
-                                        GtkWidget      *widget);
+static void folderview_empty_trash_cb  (GtkAction      *action,
+                                        gpointer        data);
 
-static void folderview_send_queue_cb   (FolderView     *folderview,
-                                        guint           action,
-                                        GtkWidget      *widget);
+static void folderview_send_queue_cb   (GtkAction      *action,
+                                        gpointer        data);
 
-static void folderview_search_cb       (FolderView     *folderview,
-                                        guint           action,
-                                        GtkWidget      *widget);
-static void folderview_run_processing_cb(FolderView    *folderview,
-                                        guint           action,
-                                        GtkWidget      *widget);
+static void folderview_search_cb       (GtkAction      *action,
+                                        gpointer        data);
+static void folderview_run_processing_cb(GtkAction     *action,
+                                        gpointer        data);
 
-static void folderview_property_cb     (FolderView     *folderview,
-                                        guint           action,
-                                        GtkWidget      *widget);
+static void folderview_property_cb     (GtkAction      *action,
+                                        gpointer        data);
 
 static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
                                          GdkDragContext *context,
@@ -283,34 +266,26 @@ static gboolean folderview_update_folder   (gpointer          source,
                                          gpointer          userdata);
 static gboolean folderview_update_item_claws    (gpointer          source,
                                          gpointer          data);
-static void folderview_processing_cb(FolderView *folderview, guint action,
-                                    GtkWidget *widget);
+static void folderview_processing_cb(GtkAction *action, gpointer data);
 static void folderview_set_sens_and_popup_menu(FolderView *folderview, gint row, 
                                GdkEventButton *event);
 
 GHashTable *folderview_popups;
 
-static GtkItemFactoryEntry folderview_common_popup_entries[] =
-{
-       {N_("/Mark all re_ad"),         NULL, mark_all_read_cb, 0, NULL},
-       {"/---",                        NULL, NULL, 0, "<Separator>"},
-       {N_("/R_un processing rules"),  NULL, folderview_run_processing_cb, 0, NULL},
-       {N_("/_Search folder..."),      NULL, folderview_search_cb, 0, NULL},
-       {N_("/_Properties..."),         NULL, folderview_property_cb, 0, NULL},
-       {N_("/Process_ing..."),         NULL, folderview_processing_cb, 0, NULL},
-};
-
-static GtkItemFactoryEntry folder_view_trash_popup_entries[] = {
-       {"/------trashsep",             NULL, NULL, 0, "<Separator>"},
-       {N_("/Empty _trash..."),        NULL, folderview_empty_trash_cb, 0, NULL},
-};
-
-static GtkItemFactoryEntry folder_view_queue_popup_entries[] = {
-       {"/------queuesep",     NULL, NULL, 0, "<Separator>"},
-       {N_("/Send _queue..."), NULL, folderview_send_queue_cb, 0, NULL},
+static GtkActionEntry folderview_common_popup_entries[] = 
+{
+       {"FolderViewPopup",                     NULL, "FolderViewPopup" },
+       {"FolderViewPopup/MarkAllRead",         NULL, N_("Mark all re_ad"), NULL, NULL, G_CALLBACK(mark_all_read_cb) },
+       {"FolderViewPopup/---",                 NULL, "---" },
+       {"FolderViewPopup/RunProcessing",       NULL, N_("R_un processing rules"), NULL, NULL, G_CALLBACK(folderview_run_processing_cb) },
+       {"FolderViewPopup/SearchFolder",        NULL, N_("_Search folder..."), NULL, NULL, G_CALLBACK(folderview_search_cb) },
+       {"FolderViewPopup/Properties",          NULL, N_("_Properties..."), NULL, NULL, G_CALLBACK(folderview_property_cb) },
+       {"FolderViewPopup/Processing",          NULL, N_("Process_ing..."), NULL, NULL, G_CALLBACK(folderview_processing_cb) },
+       {"FolderViewPopup/EmptyTrash",          NULL, N_("Empty _trash..."), NULL, NULL, G_CALLBACK(folderview_empty_trash_cb) },
+       {"FolderViewPopup/SendQueue",           NULL, N_("Send _queue..."), NULL, NULL, G_CALLBACK(folderview_send_queue_cb) },
+       
 };
 
-
 GtkTargetEntry folderview_drag_types[] =
 {
        {"claws-mail/internal", GTK_TARGET_SAME_APP, TARGET_DUMMY},
@@ -320,60 +295,66 @@ GtkTargetEntry folderview_drag_types[] =
 void folderview_initialize(void)
 {
        FolderViewPopup *fpopup;
-       guint i, n_entries;
-       GSList *entries = NULL;
 
        fpopup = g_new0(FolderViewPopup, 1);
 
-       n_entries = sizeof(folderview_common_popup_entries) /
-               sizeof(folderview_common_popup_entries[0]);
-       for (i = 0; i < n_entries; i++)
-               entries = g_slist_append(entries, &folderview_common_popup_entries[i]);
-
        fpopup->klass = "common";
        fpopup->path = "<CommonFolder>";
-       fpopup->entries = entries;
+       fpopup->entries = folderview_common_popup_entries;
+       fpopup->n_entries = G_N_ELEMENTS(folderview_common_popup_entries);
        fpopup->set_sensitivity = NULL;
 
        folderview_popups = g_hash_table_new(g_str_hash, g_str_equal);
        g_hash_table_insert(folderview_popups, "common", fpopup);
 }
 
-static GtkItemFactory *create_ifactory(FolderView *folderview, FolderViewPopup *fpopup)
+static GtkActionGroup *create_action_group(FolderView *folderview, FolderViewPopup *fpopup)
 {
-       GSList *entries;
-       GtkItemFactory *factory;
        FolderViewPopup *fpopup_common;
-       GtkWidget *popup;
-
-       factory = gtk_item_factory_new(GTK_TYPE_MENU, fpopup->path, NULL);
-       gtk_item_factory_set_translate_func(factory, menu_translate,
-                                           NULL, NULL);
-
-       for (entries = fpopup->entries; entries != NULL; entries = g_slist_next(entries))
-               gtk_item_factory_create_item(factory, entries->data, folderview, 1);
+       GtkActionGroup *action_group;
+       
+       action_group = cm_menu_create_action_group(
+                               fpopup->path, 
+                               fpopup->entries, fpopup->n_entries, 
+                               (gpointer)folderview);
+
+       if (fpopup->toggle_entries)
+               gtk_action_group_add_toggle_actions(action_group, fpopup->toggle_entries,
+                               fpopup->n_toggle_entries,
+                               (gpointer)folderview);
+       if (fpopup->radio_entries)
+               gtk_action_group_add_radio_actions(action_group, fpopup->radio_entries,
+                               fpopup->n_radio_entries, fpopup->radio_default, 
+                               G_CALLBACK(fpopup->radio_callback), 
+                               (gpointer)folderview);
 
        fpopup_common = g_hash_table_lookup(folderview_popups, "common");
-       if (fpopup_common != fpopup)
-               for (entries = fpopup_common->entries; entries != NULL; entries = g_slist_next(entries))
-                       gtk_item_factory_create_item(factory, entries->data, folderview, 1);
-
-       popup = gtk_item_factory_get_widget(factory, fpopup->path);
-        g_signal_connect(G_OBJECT(popup), "selection_done",
-                         G_CALLBACK(folderview_popup_close),
-                         folderview);
+       if (fpopup_common != fpopup) {
+               gtk_action_group_add_actions(action_group, fpopup_common->entries,
+                               fpopup_common->n_entries,
+                               (gpointer)folderview);
+               if (fpopup_common->toggle_entries)
+                       gtk_action_group_add_toggle_actions(action_group, fpopup_common->toggle_entries,
+                                       fpopup_common->n_toggle_entries,
+                                       (gpointer)folderview);
+               if (fpopup_common->radio_entries)
+                       gtk_action_group_add_radio_actions(action_group, fpopup_common->radio_entries,
+                                       fpopup_common->n_radio_entries, fpopup_common->radio_default, 
+                                       G_CALLBACK(fpopup_common->radio_callback), 
+                                       (gpointer)folderview);
+       }
 
-       return factory;
+       return action_group;
 }
 
-static void create_ifactories(gpointer key, gpointer value, gpointer data)
+static void create_action_groups(gpointer key, gpointer value, gpointer data)
 {
        FolderView *folderview = data;
        FolderViewPopup *fpopup = value;
-       GtkItemFactory *factory;
+       GtkActionGroup *group;
 
-       factory = create_ifactory(folderview, fpopup);
-       g_hash_table_insert(folderview->popups, fpopup->klass, factory);
+       group = create_action_group(folderview, fpopup);
+       g_hash_table_insert(folderview->popups, fpopup->klass, group);
 }
 
 static void folderview_column_set_titles(FolderView *folderview)
@@ -658,7 +639,7 @@ FolderView *folderview_create(void)
        
        /* create popup factories */
        folderview->popups = g_hash_table_new(g_str_hash, g_str_equal);
-       g_hash_table_foreach(folderview_popups, create_ifactories, folderview);
+       g_hash_table_foreach(folderview_popups, create_action_groups, folderview);
 
        folderview->ctree        = ctree;
 
@@ -856,9 +837,9 @@ void folderview_select(FolderView *folderview, FolderItem *item)
                folder_update_op_count();
 }
 
-static void mark_all_read_cb(FolderView *folderview, guint action,
-                             GtkWidget *widget)
+static void mark_all_read_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
        AlertValue val;
        
@@ -1906,11 +1887,16 @@ static void folderview_set_sens_and_popup_menu(FolderView *folderview, gint row,
        FolderItem *item;
        Folder *folder;
        FolderViewPopup *fpopup;
-       GtkItemFactory *fpopup_factory;
+       GtkActionGroup *action_group;
        GtkWidget *popup;
        FolderItem *special_trash = NULL, *special_queue = NULL;
        PrefsAccount *ac;
+       GtkUIManager *ui_manager = gtk_ui_manager_new();
+       
+       if (folderview->ui_manager)
+               g_object_unref(folderview->ui_manager);
 
+       folderview->ui_manager = ui_manager;
        item = folderview_get_selected_item(folderview);
 
        g_return_if_fail(item != NULL);
@@ -1918,15 +1904,30 @@ static void folderview_set_sens_and_popup_menu(FolderView *folderview, gint row,
        folder = item->folder;
 
        fpopup = g_hash_table_lookup(folderview_popups, folder->klass->idstr);
+
        if (fpopup != NULL)
-               fpopup_factory = g_hash_table_lookup(folderview->popups, folder->klass->idstr);
+               action_group = g_hash_table_lookup(folderview->popups, folder->klass->idstr);
        else {
                fpopup = g_hash_table_lookup(folderview_popups, "common");
-               fpopup_factory = g_hash_table_lookup(folderview->popups, "common");
+               action_group = g_hash_table_lookup(folderview->popups, "common");
        }
+       
+       gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/", "Popup", "Popup", GTK_UI_MANAGER_MENUBAR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup", "FolderViewPopup", "FolderViewPopup", GTK_UI_MANAGER_MENU)
+       
+       if (fpopup->add_menuitems)      
+               fpopup->add_menuitems(ui_manager, item);
+
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "MarkAllRead", "FolderViewPopup/MarkAllRead", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Separator1", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RunProcessing", "FolderViewPopup/RunProcessing", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SearchFolder", "FolderViewPopup/SearchFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Properties", "FolderViewPopup/Properties", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Processing", "FolderViewPopup/Processing", GTK_UI_MANAGER_MENUITEM)
 
        if (fpopup->set_sensitivity != NULL)
-               fpopup->set_sensitivity(fpopup_factory, item);
+               fpopup->set_sensitivity(ui_manager, item);
 
        if (NULL != (ac = account_find_from_item(item))) {
                special_trash = account_get_special_folder(ac, F_TRASH);
@@ -1934,55 +1935,49 @@ static void folderview_set_sens_and_popup_menu(FolderView *folderview, gint row,
        }
        
        if ((item == folder->trash || item == special_trash
-            || folder_has_parent_of_type(item, F_TRASH)) &&
-           gtk_item_factory_get_item(fpopup_factory, "/Empty trash...") == NULL) {
-               gtk_item_factory_create_item(fpopup_factory, &folder_view_trash_popup_entries[0], folderview, 1);
-               gtk_item_factory_create_item(fpopup_factory, &folder_view_trash_popup_entries[1], folderview, 1);
-       } else if (item != folder->trash && (special_trash == NULL || item != special_trash)
-               && !folder_has_parent_of_type(item, F_TRASH)) {
-               gtk_item_factory_delete_entry(fpopup_factory, &folder_view_trash_popup_entries[0]);
-               gtk_item_factory_delete_entry(fpopup_factory, &folder_view_trash_popup_entries[1]);
-       }
+            || folder_has_parent_of_type(item, F_TRASH))) {
+               MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorTrash", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+               MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "EmptyTrash", "FolderViewPopup/EmptyTrash", GTK_UI_MANAGER_MENUITEM)
+       } 
        
        if ((item == folder->queue || item == special_queue
-            || folder_has_parent_of_type(item, F_QUEUE)) &&
-           gtk_item_factory_get_item(fpopup_factory, "/Send queue...") == NULL) {
-               gtk_item_factory_create_item(fpopup_factory, &folder_view_queue_popup_entries[0], folderview, 1);
-               gtk_item_factory_create_item(fpopup_factory, &folder_view_queue_popup_entries[1], folderview, 1);
-       } else if (item != folder->queue && (special_queue == NULL || item != special_queue)
-               && !folder_has_parent_of_type(item, F_QUEUE)) {
-               gtk_item_factory_delete_entry(fpopup_factory, &folder_view_queue_popup_entries[0]);
-               gtk_item_factory_delete_entry(fpopup_factory, &folder_view_queue_popup_entries[1]);
-       }
+            || folder_has_parent_of_type(item, F_QUEUE))) {
+               MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorQueue", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+               MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SendQueue", "FolderViewPopup/SendQueue", GTK_UI_MANAGER_MENUITEM)
+       } 
        
 #define SET_SENS(name, sens) \
-       menu_set_sensitive(fpopup_factory, name, sens)
+       cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens)
 
-       SET_SENS("/Mark all read", item->unread_msgs >= 1);
-       SET_SENS("/Search folder...", item->total_msgs >= 1 && 
+       SET_SENS("FolderViewPopup/MarkAllRead", item->unread_msgs >= 1);
+       SET_SENS("FolderViewPopup/SearchFolder", item->total_msgs >= 1 && 
                 folderview->selected == folderview->opened);
-       SET_SENS("/Properties...", TRUE);
+       SET_SENS("FolderViewPopup/Properties", TRUE);
 
-       SET_SENS("/Run processing rules", item->prefs->processing &&
+       SET_SENS("FolderViewPopup/RunProcessing", item->prefs->processing &&
                 item->total_msgs >= 1 && !item->processing_pending);
-       SET_SENS("/Processing...", item->node->parent != NULL && 
+       SET_SENS("FolderViewPopup/Processing", item->node->parent != NULL && 
                !item->no_select && !item->processing_pending);
 
        if (item == folder->trash || item == special_trash
            || folder_has_parent_of_type(item, F_TRASH)) {
                GSList *msglist = folder_item_get_msg_list(item);
-               SET_SENS("/Empty trash...", msglist != NULL);
+               SET_SENS("FolderViewPopup/EmptyTrash", msglist != NULL);
                procmsg_msg_list_free(msglist);
        }
        if (item == folder->queue || item == special_queue
            || folder_has_parent_of_type(item, F_QUEUE)) {
                GSList *msglist = folder_item_get_msg_list(item);
-               SET_SENS("/Send queue...", msglist != NULL);
+               SET_SENS("FolderViewPopup/SendQueue", msglist != NULL);
                procmsg_msg_list_free(msglist);
        }
 #undef SET_SENS
 
-       popup = gtk_item_factory_get_widget(fpopup_factory, fpopup->path);
+       popup = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
+                       gtk_ui_manager_get_widget(ui_manager, "/Popup/FolderViewPopup")) );
+        g_signal_connect(G_OBJECT(popup), "selection_done",
+                         G_CALLBACK(folderview_popup_close),
+                         folderview);
        gtk_menu_popup(GTK_MENU(popup), NULL, NULL, NULL, NULL,
                       event->button, event->time);
 }
@@ -2395,9 +2390,9 @@ static void folderview_create_folder_node(FolderView *folderview, FolderItem *it
        gtk_clist_thaw(GTK_CLIST(ctree));
 }
 
-static void folderview_empty_trash_cb(FolderView *folderview, guint action,
-                                     GtkWidget *widget)
+static void folderview_empty_trash_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
        GSList *mlist = NULL;
@@ -2439,9 +2434,9 @@ static void folderview_empty_trash_cb(FolderView *folderview, guint action,
        folder_item_remove_all_msg(item);
 }
 
-static void folderview_send_queue_cb(FolderView *folderview, guint action,
-                                     GtkWidget *widget)
+static void folderview_send_queue_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
        FolderItem *special_queue = NULL;
@@ -2495,15 +2490,15 @@ static void folderview_send_queue_cb(FolderView *folderview, guint action,
        }
 }
 
-static void folderview_search_cb(FolderView *folderview, guint action,
-                                GtkWidget *widget)
+static void folderview_search_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        summary_search(folderview->summaryview);
 }
 
-static void folderview_run_processing_cb(FolderView *folderview, guint action,
-                                GtkWidget *widget)
+static void folderview_run_processing_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
 
@@ -2518,9 +2513,9 @@ static void folderview_run_processing_cb(FolderView *folderview, guint action,
        item->processing_pending = FALSE;
 }
 
-static void folderview_property_cb(FolderView *folderview, guint action,
-                                  GtkWidget *widget)
+static void folderview_property_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
 
@@ -2662,9 +2657,9 @@ static gint folderview_clist_compare(GtkCList *clist,
        return g_utf8_collate(item1->name, item2->name);
 }
 
-static void folderview_processing_cb(FolderView *folderview, guint action,
-                                    GtkWidget *widget)
+static void folderview_processing_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
        gchar *id, *title;
@@ -3159,9 +3154,9 @@ void folderview_register_popup(FolderViewPopup *fpopup)
 
        for (folderviews = folderview_list; folderviews != NULL; folderviews = g_list_next(folderviews)) {
                FolderView *folderview = folderviews->data;
-               GtkItemFactory *factory;
+               GtkActionGroup *factory;
 
-               factory = create_ifactory(folderview, fpopup);
+               factory = create_action_group(folderview, fpopup);
                g_hash_table_insert(folderview->popups, fpopup->klass, factory);
        }       
        g_hash_table_insert(folderview_popups, fpopup->klass, fpopup);
@@ -3171,6 +3166,7 @@ void folderview_unregister_popup(FolderViewPopup *fpopup)
 {
        GList *folderviews;
 
+
        for (folderviews = folderview_list; folderviews != NULL; folderviews = g_list_next(folderviews)) {
                FolderView *folderview = folderviews->data;
 
index cf13527571b1d3e96f0d439d906ea13aa886b912..af75e17c535783fd16abf870ac81c757629301ce 100644 (file)
@@ -80,14 +80,25 @@ struct _FolderView
        gint col_pos[N_FOLDER_COLS];
        gint deferred_refresh_id;
        Folder *scanning_folder;
+       GtkUIManager *ui_manager;
+       GtkActionGroup *popup_common_action_group;
+       GtkActionGroup *popup_specific_action_group;
 };
 
 struct _FolderViewPopup
 {
-       gchar            *klass;
-       gchar            *path;
-       GSList           *entries;
-       void            (*set_sensitivity)      (GtkItemFactory *menu, FolderItem *item);
+       gchar                    *klass;
+       gchar                    *path;
+       GtkActionEntry           *entries;
+       gint                      n_entries;
+       GtkToggleActionEntry     *toggle_entries;
+       gint                      n_toggle_entries;
+       GtkRadioActionEntry      *radio_entries;
+       gint                      n_radio_entries;
+       gint                      radio_default;
+       void                    (*radio_callback)       (GtkAction *action, GtkRadioAction *current, gpointer data);
+       void                    (*add_menuitems)        (GtkUIManager *ui_manager, FolderItem *item);
+       void                    (*set_sensitivity)      (GtkUIManager *ui_manager, FolderItem *item);
 };
 
 void folderview_initialize             (void);
index 973a6442e50029e417c0fe57a56d8094adf7baff..6146cf8545ef8ed7dca7628ddfb4bddec84f307f 100644 (file)
 #include "statusbar.h"
 #include "summaryview.h"
 
-static void new_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void rename_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void delete_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void update_tree_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void download_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void sync_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void subscribed_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void subscribe_cb(FolderView *folderview, guint action, GtkWidget *widget);
-
-static GtkItemFactoryEntry imap_popup_entries[] =
+static void new_folder_cb(GtkAction *action, gpointer data);
+static void rename_folder_cb(GtkAction *action, gpointer data);
+static void move_folder_cb(GtkAction *action, gpointer data);
+static void copy_folder_cb(GtkAction *action, gpointer data);
+static void delete_folder_cb(GtkAction *action, gpointer data);
+static void update_tree_cb(GtkAction *action, gpointer data);
+static void download_cb(GtkAction *action, gpointer data);
+static void sync_cb(GtkAction *action, gpointer data);
+static void subscribed_cb(GtkAction *action, gpointer data);
+static void subscribe_cb(GtkAction *action, gpointer data);
+static void unsubscribe_cb(GtkAction *action, gpointer data);
+
+static GtkActionEntry imap_popup_entries[] =
 {
-       {N_("/Create _new folder..."),   NULL, new_folder_cb,    0, NULL},
-       {"/---",                         NULL, NULL,             0, "<Separator>"},
-       {N_("/_Rename folder..."),       NULL, rename_folder_cb, 0, NULL},
-       {N_("/M_ove folder..."),         NULL, move_folder_cb,   0, NULL},
-       {N_("/Cop_y folder..."),         NULL, move_folder_cb,   1, NULL},
-       {"/---",                         NULL, NULL,             0, "<Separator>"},
-       {N_("/_Delete folder..."),       NULL, delete_folder_cb, 0, NULL},
-       {"/---",                         NULL, NULL,             0, "<Separator>"},
-       {N_("/_Synchronise"),            NULL, sync_cb,          0, NULL},
-       {N_("/Down_load messages"),      NULL, download_cb,      0, NULL},
-       {"/---",                         NULL, NULL,             0, "<Separator>"},
-       {N_("/S_ubscriptions"),          NULL, NULL,             0, "<Branch>"},
-       {N_("/Subscriptions/Show only subscribed _folders"),    
-                                        NULL, subscribed_cb,    0, "<ToggleItem>"},
-       {N_("/Subscriptions/---"),       NULL, NULL,             0, "<Separator>"},
-       {N_("/Subscriptions/_Subscribe..."),NULL, subscribe_cb,          1, NULL},
-       {N_("/Subscriptions/_Unsubscribe..."),    
-                                        NULL, subscribe_cb,     0, NULL},
-       {"/---",                         NULL, NULL,             0, "<Separator>"},
-       {N_("/_Check for new messages"), NULL, update_tree_cb,   0, NULL},
-       {N_("/C_heck for new folders"),  NULL, update_tree_cb,   1, NULL},
-       {N_("/R_ebuild folder tree"),    NULL, update_tree_cb,   2, NULL},
-       {"/---",                         NULL, NULL,             0, "<Separator>"},
+       {"FolderViewPopup/CreateNewFolder",     NULL, N_("Create _new folder..."), NULL, NULL, G_CALLBACK(new_folder_cb) },
+
+       {"FolderViewPopup/RenameFolder",        NULL, N_("_Rename folder..."), NULL, NULL, G_CALLBACK(rename_folder_cb) },
+       {"FolderViewPopup/MoveFolder",          NULL, N_("M_ove folder..."), NULL, NULL, G_CALLBACK(move_folder_cb) },
+       {"FolderViewPopup/CopyFolder",          NULL, N_("Cop_y folder..."), NULL, NULL, G_CALLBACK(copy_folder_cb) },
+
+       {"FolderViewPopup/DeleteFolder",        NULL, N_("_Delete folder..."), NULL, NULL, G_CALLBACK(delete_folder_cb) },
+
+       {"FolderViewPopup/Synchronise",         NULL, N_("Synchronise"), NULL, NULL, G_CALLBACK(sync_cb) },
+       {"FolderViewPopup/DownloadMessages",    NULL, N_("Down_load messages"), NULL, NULL, G_CALLBACK(download_cb) },
+
+
+       {"FolderViewPopup/Subscriptions",       NULL, N_("S_ubscriptions") },
+       {"FolderViewPopup/Subscriptions/---",   NULL, "---", NULL, NULL, NULL }, 
+       {"FolderViewPopup/Subscriptions/Subscribe",     NULL, N_("_Subscribe..."), NULL, NULL, G_CALLBACK(subscribe_cb) },
+       {"FolderViewPopup/Subscriptions/Unsubscribe",   NULL, N_("_Unsubscribe..."), NULL, NULL, G_CALLBACK(unsubscribe_cb) },
+
+       {"FolderViewPopup/CheckNewMessages",    NULL, N_("_Check for new messages"), NULL, NULL, G_CALLBACK(update_tree_cb) }, /*0*/
+       {"FolderViewPopup/CheckNewFolders",     NULL, N_("C_heck for new folders"), NULL, NULL, G_CALLBACK(update_tree_cb) }, /*1*/
+       {"FolderViewPopup/RebuildTree",         NULL, N_("R_ebuild folder tree"), NULL, NULL, G_CALLBACK(update_tree_cb) }, /*2*/
+};
+
+static GtkToggleActionEntry imap_toggle_popup_entries[] =
+{
+       {"FolderViewPopup/Subscriptions/ShowOnlySubs",  NULL, N_("Show only subscribed _folders"), NULL, NULL, G_CALLBACK(subscribed_cb) }, 
 };
 
-static void set_sensitivity(GtkItemFactory *factory, FolderItem *item);
+static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item);
+static void add_menuitems(GtkUIManager *ui_manager, FolderItem *item);
 
 static FolderViewPopup imap_popup =
 {
        "imap",
        "<IMAPFolder>",
-       NULL,
+       imap_popup_entries,
+       G_N_ELEMENTS(imap_popup_entries),
+       imap_toggle_popup_entries,
+       G_N_ELEMENTS(imap_toggle_popup_entries),
+       NULL, 0, 0, NULL,
+       add_menuitems,
        set_sensitivity
 };
 
 void imap_gtk_init(void)
 {
-       guint i, n_entries;
-
-       n_entries = sizeof(imap_popup_entries) /
-               sizeof(imap_popup_entries[0]);
-       for (i = 0; i < n_entries; i++)
-               imap_popup.entries = g_slist_append(imap_popup.entries, &imap_popup_entries[i]);
-
        folderview_register_popup(&imap_popup);
 }
 
-static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
+static void add_menuitems(GtkUIManager *ui_manager, FolderItem *item)
+{
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CreateNewFolder", "FolderViewPopup/CreateNewFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorIMAP1", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RenameFolder", "FolderViewPopup/RenameFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "MoveFolder", "FolderViewPopup/MoveFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CopyFolder", "FolderViewPopup/CopyFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorIMAP2", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "DeleteFolder", "FolderViewPopup/DeleteFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorIMAP3", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Synchronise", "FolderViewPopup/Synchronise", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "DownloadMessages", "FolderViewPopup/DownloadMessages", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorIMAP4", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Subscriptions", "FolderViewPopup/Subscriptions", GTK_UI_MANAGER_MENU)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup/Subscriptions", "ShowOnlySubs", "FolderViewPopup/Subscriptions/ShowOnlySubs", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup/Subscriptions", "SeparatorIMAP5", "FolderViewPopup/Subscriptions/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup/Subscriptions", "Subscribe", "FolderViewPopup/Subscriptions/Subscribe", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup/Subscriptions", "Unsubscribe", "FolderViewPopup/Subscriptions/Unsubscribe", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CheckNewMessages", "FolderViewPopup/CheckNewMessages", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CheckNewFolders", "FolderViewPopup/CheckNewFolders", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RebuildTree", "FolderViewPopup/RebuildTree", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorIMAP6", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+}
+
+static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item)
 {
        gboolean folder_is_normal = 
                        item != NULL &&
@@ -113,33 +140,39 @@ static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
                        !folder_has_parent_of_type(item, F_TRASH);
 
 #define SET_SENS(name, sens) \
-       menu_set_sensitive(factory, name, sens)
-
-       SET_SENS("/Create new folder...",   item->no_sub == FALSE);
-       SET_SENS("/Rename folder...",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
-       SET_SENS("/Move folder...",         folder_is_normal && folder_item_parent(item) != NULL);
-       SET_SENS("/Delete folder...",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
-
-       SET_SENS("/Synchronise",            item ? (folder_item_parent(item) == NULL && folder_want_synchronise(item->folder))
-                                               : FALSE);
-       SET_SENS("/Check for new messages", folder_item_parent(item) == NULL);
-       SET_SENS("/Check for new folders",  folder_item_parent(item) == NULL);
-       SET_SENS("/Rebuild folder tree",    folder_item_parent(item) == NULL);
-       SET_SENS("/Download messages",      !item->no_select);
+       cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens)
+
+       SET_SENS("FolderViewPopup/CreateNewFolder",   item->no_sub == FALSE);
+       SET_SENS("FolderViewPopup/RenameFolder",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/MoveFolder",      folder_is_normal && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/DeleteFolder",            item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+
+       SET_SENS("FolderViewPopup/CheckNewMessages", folder_item_parent(item) == NULL);
+       SET_SENS("FolderViewPopup/CheckNewFolders",  folder_item_parent(item) == NULL);
+       SET_SENS("FolderViewPopup/RebuildTree",    folder_item_parent(item) == NULL);
+
+       SET_SENS("FolderViewPopup/Synchronise",    
+                       item ? (folder_item_parent(item) != NULL
+                       && folder_want_synchronise(item->folder))
+                       : FALSE);
+       SET_SENS("FolderViewPopup/DownloadMessages", !item->no_select);
+
+       SET_SENS("FolderViewPopup/CheckNewMessages", folder_item_parent(item) == NULL);
+       SET_SENS("FolderViewPopup/CheckNewFolders",  folder_item_parent(item) == NULL);
+       SET_SENS("FolderViewPopup/RebuildTree",    folder_item_parent(item) == NULL);
        
-       SET_SENS("/Subscriptions/Unsubscribe...",    item->stype == F_NORMAL && folder_item_parent(item) != NULL);
-       SET_SENS("/Subscriptions/Subscribe...",    TRUE);
+       SET_SENS("FolderViewPopup/Subscriptions/Unsubscribe",    item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/Subscriptions/Subscribe",    TRUE);
        if (item->folder && item->folder->account)
-               menu_set_active(factory, 
-                       "/Subscriptions/Show only subscribed folders", 
+               cm_toggle_menu_set_active_full(ui_manager, "Popup/FolderViewPopup/Subscriptions/ShowOnlySubs",
                        item->folder->account->imap_subsonly);
 
 #undef SET_SENS
 }
 
-static void new_folder_cb(FolderView *folderview, guint action,
-                         GtkWidget *widget)
+static void new_folder_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
        FolderItem *new_item;
@@ -204,9 +237,9 @@ static void new_folder_cb(FolderView *folderview, guint action,
        folder_write_list();
 }
 
-static void rename_folder_cb(FolderView *folderview, guint action,
-                            GtkWidget *widget)
+static void rename_folder_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
        gchar *new_folder;
        gchar *name;
@@ -273,8 +306,25 @@ static void rename_folder_cb(FolderView *folderview, guint action,
        folder_write_list();
 }
 
-static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget)
+static void move_folder_cb(GtkAction *action, gpointer data)
+{
+       FolderView *folderview = (FolderView *)data;
+       FolderItem *from_folder = NULL, *to_folder = NULL;
+
+       from_folder = folderview_get_selected_item(folderview);
+       if (!from_folder || from_folder->folder->klass != imap_get_class())
+               return;
+
+       to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL, TRUE);
+       if (!to_folder)
+               return;
+       
+       folderview_move_folder(folderview, from_folder, to_folder, 0);
+}
+
+static void copy_folder_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *from_folder = NULL, *to_folder = NULL;
 
        from_folder = folderview_get_selected_item(folderview);
@@ -285,12 +335,12 @@ static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widg
        if (!to_folder)
                return;
        
-       folderview_move_folder(folderview, from_folder, to_folder, action);
+       folderview_move_folder(folderview, from_folder, to_folder, 1);
 }
 
-static void delete_folder_cb(FolderView *folderview, guint action,
-                            GtkWidget *widget)
+static void delete_folder_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
        gchar *message, *name;
@@ -342,10 +392,13 @@ static void delete_folder_cb(FolderView *folderview, guint action,
 
 }
 
-static void update_tree_cb(FolderView *folderview, guint action,
-                          GtkWidget *widget)
+#define DO_ACTION(name, act)   { if (!strcmp(a_name, name)) act; }
+
+static void update_tree_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
+       const gchar *a_name = gtk_action_get_name(action);
 
        item = folderview_get_selected_item(folderview);
        g_return_if_fail(item != NULL);
@@ -354,17 +407,14 @@ static void update_tree_cb(FolderView *folderview, guint action,
 
        g_return_if_fail(item->folder != NULL);
 
-       if (action == 0)
-               folderview_check_new(item->folder);
-       else if (action == 1)
-               folderview_rescan_tree(item->folder, FALSE);
-       else if (action == 2)
-               folderview_rescan_tree(item->folder, TRUE);
+       DO_ACTION("FolderViewPopup/CheckNewMessages", folderview_check_new(item->folder));
+       DO_ACTION("FolderViewPopup/CheckNewFolders", folderview_rescan_tree(item->folder, FALSE));
+       DO_ACTION("FolderViewPopup/RebuildTree", folderview_rescan_tree(item->folder, FALSE));
 }
 
-static void sync_cb(FolderView *folderview, guint action,
-                          GtkWidget *widget)
+static void sync_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
 
        item = folderview_get_selected_item(folderview);
@@ -433,8 +483,7 @@ static gboolean imap_gtk_subscribe_func(GNode *node, gpointer data)
        return FALSE;
 }
 
-static void subscribe_cb(FolderView *folderview, guint action,
-                          GtkWidget *widget)
+static void subscribe_cb_full(FolderView *folderview, guint action)
 {
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
@@ -550,15 +599,25 @@ static void subscribe_cb(FolderView *folderview, guint action,
                folderview_fast_rescan_tree(item->folder);
 }
 
-static void subscribed_cb(FolderView *folderview, guint action,
-                          GtkWidget *widget)
+static void subscribe_cb(GtkAction *action, gpointer data)
+{
+       subscribe_cb_full((FolderView *)data, 1);
+}
+
+static void unsubscribe_cb(GtkAction *action, gpointer data)
+{
+       subscribe_cb_full((FolderView *)data, 0);
+}
+
+static void subscribed_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
        
        if (!item || !item->folder || !item->folder->account)
                return;
-       if (item->folder->account->imap_subsonly == GTK_CHECK_MENU_ITEM(widget)->active)
+       if (item->folder->account->imap_subsonly == gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
                return;
 
        if (folderview->opened == folderview->selected ||
@@ -569,13 +628,13 @@ static void subscribed_cb(FolderView *folderview, guint action,
                folderview->opened = NULL;
        }
 
-       item->folder->account->imap_subsonly = GTK_CHECK_MENU_ITEM(widget)->active;
+       item->folder->account->imap_subsonly = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
        folderview_fast_rescan_tree(item->folder);
 }
 
-static void download_cb(FolderView *folderview, guint action,
-                       GtkWidget *widget)
+static void download_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
 
index 4fa3d209d84b88f21e0f39329ccbcc3b4249c9d3..fb4760da28e25911c74ceb25cc822ca1ada02dfc 100644 (file)
 #include "foldersel.h"
 #include "prefs_common.h"
 
-static void new_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void delete_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void rename_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void update_tree_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void remove_mailbox_cb(FolderView *folderview, guint action, GtkWidget *widget);
-
-static GtkItemFactoryEntry mh_popup_entries[] =
+static void new_folder_cb(GtkAction *action, gpointer data);
+static void delete_folder_cb(GtkAction *action, gpointer data);
+static void rename_folder_cb(GtkAction *action, gpointer data);
+static void move_folder_cb(GtkAction *action, gpointer data);
+static void copy_folder_cb(GtkAction *action, gpointer data);
+static void update_tree_cb(GtkAction *action, gpointer data);
+static void remove_mailbox_cb(GtkAction *action, gpointer data);
+
+static GtkActionEntry mh_popup_entries[] = 
 {
-       {N_("/Create _new folder..."),   NULL, new_folder_cb,     0, NULL},
-       {"/---",                         NULL, NULL,             0, "<Separator>"},
-       {N_("/_Rename folder..."),       NULL, rename_folder_cb,  0, NULL},
-       {N_("/M_ove folder..."),         NULL, move_folder_cb,    0, NULL},
-       {N_("/Cop_y folder..."),         NULL, move_folder_cb,    1, NULL},
-       {"/---",                         NULL, NULL,             0, "<Separator>"},
-       {N_("/_Delete folder..."),       NULL, delete_folder_cb,  0, NULL},
-       {"/---",                         NULL, NULL,              0, "<Separator>"},
-       {N_("/_Check for new messages"), NULL, update_tree_cb,    0, NULL},
-       {N_("/C_heck for new folders"),  NULL, update_tree_cb,    1, NULL},
-       {N_("/R_ebuild folder tree"),    NULL, update_tree_cb,    2, NULL},
-       {"/---",                         NULL, NULL,              0, "<Separator>"},
-       {N_("/Remove _mailbox..."),      NULL, remove_mailbox_cb, 0, NULL},
-       {"/---",                         NULL, NULL,              0, "<Separator>"},
-};
-
-static void set_sensitivity(GtkItemFactory *factory, FolderItem *item);
+       {"FolderViewPopup/CreateNewFolder",     NULL, N_("Create _new folder..."), NULL, NULL, G_CALLBACK(new_folder_cb) },
+       {"FolderViewPopup/RenameFolder",        NULL, N_("_Rename folder..."), NULL, NULL, G_CALLBACK(rename_folder_cb) },
+       {"FolderViewPopup/MoveFolder",          NULL, N_("M_ove folder..."), NULL, NULL, G_CALLBACK(move_folder_cb) },
+       {"FolderViewPopup/CopyFolder",          NULL, N_("Cop_y folder..."), NULL, NULL, G_CALLBACK(copy_folder_cb) },
+       {"FolderViewPopup/DeleteFolder",        NULL, N_("_Delete folder..."), NULL, NULL, G_CALLBACK(delete_folder_cb) },
+       {"FolderViewPopup/CheckNewMessages",    NULL, N_("_Check for new messages"), NULL, NULL, G_CALLBACK(update_tree_cb) }, /*0*/
+       {"FolderViewPopup/CheckNewFolders",     NULL, N_("C_heck for new folders"), NULL, NULL, G_CALLBACK(update_tree_cb) }, /*1*/
+       {"FolderViewPopup/RebuildTree",         NULL, N_("R_ebuild folder tree"), NULL, NULL, G_CALLBACK(update_tree_cb) }, /*2*/
+       {"FolderViewPopup/RemoveMailbox",       NULL, N_("Remove _mailbox..."), NULL, NULL, G_CALLBACK(remove_mailbox_cb) },
+};                     
+static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item);
+static void add_menuitems(GtkUIManager *ui_manager, FolderItem *item);
 
 static FolderViewPopup mh_popup =
 {
        "mh",
        "<MHFolder>",
-       NULL,
+       mh_popup_entries,
+       G_N_ELEMENTS(mh_popup_entries),
+       NULL, 0,
+       NULL, 0, 0, NULL,
+       add_menuitems,
        set_sensitivity
 };
 
 void mh_gtk_init(void)
 {
-       guint i, n_entries;
-
-       n_entries = sizeof(mh_popup_entries) /
-               sizeof(mh_popup_entries[0]);
-       for (i = 0; i < n_entries; i++)
-               mh_popup.entries = g_slist_append(mh_popup.entries, &mh_popup_entries[i]);
-
        folderview_register_popup(&mh_popup);
 }
 
-static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
+static void add_menuitems(GtkUIManager *ui_manager, FolderItem *item)
+{
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CreateNewFolder", "FolderViewPopup/CreateNewFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorMH1", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RenameFolder", "FolderViewPopup/RenameFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "MoveFolder", "FolderViewPopup/MoveFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CopyFolder", "FolderViewPopup/CopyFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorMH2", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "DeleteFolder", "FolderViewPopup/DeleteFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorMH3", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CheckNewMessages", "FolderViewPopup/CheckNewMessages", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CheckNewFolders", "FolderViewPopup/CheckNewFolders", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RebuildTree", "FolderViewPopup/RebuildTree", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorMH4", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RemoveMailbox", "FolderViewPopup/RemoveMailbox", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorMH5", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+}
+
+static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item)
 {
        gboolean folder_is_normal = 
                        item != NULL &&
@@ -96,25 +107,25 @@ static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
                        !folder_has_parent_of_type(item, F_QUEUE) &&
                        !folder_has_parent_of_type(item, F_TRASH);
 #define SET_SENS(name, sens) \
-       menu_set_sensitive(factory, name, sens)
+       cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens)
 
-       SET_SENS("/Create new folder...",   TRUE);
-       SET_SENS("/Rename folder...",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
-       SET_SENS("/Move folder...",         folder_is_normal && folder_item_parent(item) != NULL);
-       SET_SENS("/Delete folder...",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/CreateNewFolder",   TRUE);
+       SET_SENS("FolderViewPopup/RenameFolder",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/MoveFolder",      folder_is_normal && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/DeleteFolder",            item->stype == F_NORMAL && folder_item_parent(item) != NULL);
 
-       SET_SENS("/Check for new messages", folder_item_parent(item) == NULL);
-       SET_SENS("/Check for new folders",  folder_item_parent(item) == NULL);
-       SET_SENS("/Rebuild folder tree",    folder_item_parent(item) == NULL);
+       SET_SENS("FolderViewPopup/CheckNewMessages", folder_item_parent(item) == NULL);
+       SET_SENS("FolderViewPopup/CheckNewFolders",  folder_item_parent(item) == NULL);
+       SET_SENS("FolderViewPopup/RebuildTree",    folder_item_parent(item) == NULL);
 
-       SET_SENS("/Remove mailbox...",         folder_item_parent(item) == NULL);
+       SET_SENS("FolderViewPopup/RemoveMailbox",         folder_item_parent(item) == NULL);
 
 #undef SET_SENS
 }
 
-static void new_folder_cb(FolderView *folderview, guint action,
-                         GtkWidget *widget)
+static void new_folder_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
        FolderItem *new_item;
@@ -165,9 +176,9 @@ static void new_folder_cb(FolderView *folderview, guint action,
        folder_write_list();
 }
 
-static void delete_folder_cb(FolderView *folderview, guint action,
-                            GtkWidget *widget)
+static void delete_folder_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
        gchar *message, *name;
@@ -217,9 +228,9 @@ static void delete_folder_cb(FolderView *folderview, guint action,
 
 }
 
-static void rename_folder_cb(FolderView *folderview, guint action,
-                            GtkWidget *widget)
+static void rename_folder_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
        gchar *new_folder;
        gchar *name;
@@ -278,8 +289,9 @@ static void rename_folder_cb(FolderView *folderview, guint action,
        folder_write_list();
 }
 
-static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget)
+static void move_folder_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *from_folder = NULL, *to_folder = NULL;
 
        from_folder = folderview_get_selected_item(folderview);
@@ -290,13 +302,32 @@ static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widg
        if (!to_folder)
                return;
        
-       folderview_move_folder(folderview, from_folder, to_folder, action);
+       folderview_move_folder(folderview, from_folder, to_folder, 0);
 }
 
-static void update_tree_cb(FolderView *folderview, guint action,
-                          GtkWidget *widget)
+static void copy_folder_cb(GtkAction *action, gpointer data)
+{
+       FolderView *folderview = (FolderView *)data;
+       FolderItem *from_folder = NULL, *to_folder = NULL;
+
+       from_folder = folderview_get_selected_item(folderview);
+       if (!from_folder || from_folder->folder->klass != mh_get_class())
+               return;
+
+       to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL, TRUE);
+       if (!to_folder)
+               return;
+       
+       folderview_move_folder(folderview, from_folder, to_folder, 1);
+}
+
+#define DO_ACTION(name, act)   { if (!strcmp(a_name, name)) act; }
+
+static void update_tree_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
+       const gchar *a_name = gtk_action_get_name(action);
 
        item = folderview_get_selected_item(folderview);
        g_return_if_fail(item != NULL);
@@ -305,17 +336,14 @@ static void update_tree_cb(FolderView *folderview, guint action,
 
        g_return_if_fail(item->folder != NULL);
 
-       if (action == 0)
-               folderview_check_new(item->folder);
-       else if (action == 1)
-               folderview_rescan_tree(item->folder, FALSE);
-       else if (action == 2)
-               folderview_rescan_tree(item->folder, TRUE);
+       DO_ACTION("FolderViewPopup/CheckNewMessages", folderview_check_new(item->folder));
+       DO_ACTION("FolderViewPopup/CheckNewFolders", folderview_rescan_tree(item->folder, FALSE));
+       DO_ACTION("FolderViewPopup/RebuildTree", folderview_rescan_tree(item->folder, FALSE));
 }
 
-static void remove_mailbox_cb(FolderView *folderview, guint action,
-                             GtkWidget *widget)
+static void remove_mailbox_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
        gchar *name;
        gchar *message;
index 6b200f2e729481371421f91e230e6f2c8512f032..a0cb09831c48622e410ec01701082b8933ba6c19 100644 (file)
 #include "statusbar.h"
 #include "inputdialog.h"
 
-static void subscribe_newsgroup_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void unsubscribe_newsgroup_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void rename_newsgroup_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void update_tree_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void download_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void sync_cb(FolderView *folderview, guint action, GtkWidget *widget);
-
-static GtkItemFactoryEntry news_popup_entries[] =
+static void subscribe_newsgroup_cb(GtkAction *action, gpointer data);
+static void unsubscribe_newsgroup_cb(GtkAction *action, gpointer data);
+static void rename_newsgroup_cb(GtkAction *action, gpointer data);
+static void update_tree_cb(GtkAction *action, gpointer data);
+static void download_cb(GtkAction *action, gpointer data);
+static void sync_cb(GtkAction *action, gpointer data);
+
+static GtkActionEntry news_popup_entries[] =
 {
-       {N_("/_Subscribe to newsgroup..."),     NULL, subscribe_newsgroup_cb,    0, NULL},
-       {N_("/_Unsubscribe newsgroup"),         NULL, unsubscribe_newsgroup_cb,  0, NULL},
-       {"/---",                                NULL, NULL,                      0, "<Separator>"},
-       {N_("/Synchronise"),                    NULL, sync_cb,          0, NULL},
-       {N_("/Down_load messages"),             NULL, download_cb,               0, NULL},
-       {N_("/_Rename folder..."),              NULL, rename_newsgroup_cb,       0, NULL},
-       {"/---",                                NULL, NULL,                      0, "<Separator>"},
-       {N_("/_Check for new messages"),        NULL, update_tree_cb,            0, NULL},
-       {"/---",                                NULL, NULL,                      0, "<Separator>"},
+       {"FolderViewPopup/Subscribe",           NULL, N_("_Subscribe to newsgroup..."), NULL, NULL, G_CALLBACK(subscribe_newsgroup_cb) },
+       {"FolderViewPopup/Unsubscribe",         NULL, N_("_Unsubscribe newsgroup"), NULL, NULL, G_CALLBACK(unsubscribe_newsgroup_cb) },
+
+       {"FolderViewPopup/Synchronise",         NULL, N_("Synchronise"), NULL, NULL, G_CALLBACK(sync_cb) },
+       {"FolderViewPopup/DownloadMessages",    NULL, N_("Down_load messages"), NULL, NULL, G_CALLBACK(download_cb) },
+       {"FolderViewPopup/RenameFolder",        NULL, N_("_Rename folder..."), NULL, NULL, G_CALLBACK(rename_newsgroup_cb) },
+
+       {"FolderViewPopup/CheckNewMessages",    NULL, N_("_Check for new messages"), NULL, NULL, G_CALLBACK(update_tree_cb) },
+
 };
 
-static void set_sensitivity(GtkItemFactory *factory, FolderItem *item);
+static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item);
+static void add_menuitems(GtkUIManager *ui_manager, FolderItem *item);
 
 static FolderViewPopup news_popup =
 {
        "news",
        "<NewsFolder>",
-       NULL,
+       news_popup_entries,
+       G_N_ELEMENTS(news_popup_entries),
+       NULL, 0,
+       NULL, 0, 0, NULL,
+       add_menuitems,
        set_sensitivity
 };
 
 void news_gtk_init(void)
 {
-       guint i, n_entries;
-
-       n_entries = sizeof(news_popup_entries) /
-               sizeof(news_popup_entries[0]);
-       for (i = 0; i < n_entries; i++)
-               news_popup.entries = g_slist_append(news_popup.entries, &news_popup_entries[i]);
-
        folderview_register_popup(&news_popup);
 }
 
-static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
+static void add_menuitems(GtkUIManager *ui_manager, FolderItem *item)
+{
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Subscribe", "FolderViewPopup/Subscribe", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Unsubscribe", "FolderViewPopup/Unsubscribe", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorNews1", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Synchronise", "FolderViewPopup/Synchronise", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "DownloadMessages", "FolderViewPopup/DownloadMessages", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RenameFolder", "FolderViewPopup/RenameFolder", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorNews2", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CheckNewMessages", "FolderViewPopup/CheckNewMessages", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorNews3", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
+}
+       
+static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item)
 {
        MainWindow *mainwin = mainwindow_get_mainwindow();
        
 #define SET_SENS(name, sens) \
-       menu_set_sensitive(factory, name, sens)
+       cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens)
 
-       SET_SENS("/Subscribe to newsgroup...", 
+       SET_SENS("FolderViewPopup/Subscribe", 
                        folder_item_parent(item) == NULL 
                        && mainwin->lock_count == 0
                        && news_folder_locked(item->folder) == 0);
-       SET_SENS("/Unsubscribe newsgroup",     
+       SET_SENS("FolderViewPopup/Unsubscribe",     
                        folder_item_parent(item) != NULL 
                        && mainwin->lock_count == 0
                        && news_folder_locked(item->folder) == 0);
-       SET_SENS("/Check for new messages",    
+       SET_SENS("FolderViewPopup/CheckNewMessages",    
                        folder_item_parent(item) == NULL 
                        && mainwin->lock_count == 0
                        && news_folder_locked(item->folder) == 0);
-       SET_SENS("/Synchronise",    
+       SET_SENS("FolderViewPopup/Synchronise",    
                        item ? (folder_item_parent(item) != NULL
                        && folder_want_synchronise(item->folder))
                        : FALSE);
-       SET_SENS("/Download messages",
+       SET_SENS("FolderViewPopup/DownloadMessages",
                        item ? (folder_item_parent(item) != NULL
                        && !item->no_select)
                        : FALSE);
-       SET_SENS("/Rename folder...",
+       SET_SENS("FolderViewPopup/RenameFolder",
                        folder_item_parent(item) != NULL 
                        && mainwin->lock_count == 0
                        && news_folder_locked(item->folder) == 0);
 #undef SET_SENS
 }
 
-static void subscribe_newsgroup_cb(FolderView *folderview, guint action, GtkWidget *widget)
+static void subscribe_newsgroup_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        GtkCTreeNode *servernode, *node;
        Folder *folder;
@@ -209,9 +221,9 @@ static void subscribe_newsgroup_cb(FolderView *folderview, guint action, GtkWidg
        folder_write_list();
 }
 
-static void unsubscribe_newsgroup_cb(FolderView *folderview, guint action,
-                                    GtkWidget *widget)
+static void unsubscribe_newsgroup_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;
        gchar *name;
@@ -276,9 +288,9 @@ static FolderItem *find_child_by_name(FolderItem *item, const gchar *name)
        return NULL;
 }
 
-static void rename_newsgroup_cb(FolderView *folderview, guint action,
-                               GtkWidget *widget)
+static void rename_newsgroup_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
        gchar *new_folder;
        gchar *name;
@@ -320,9 +332,9 @@ static void rename_newsgroup_cb(FolderView *folderview, guint action,
        folder_write_list();
 }
 
-static void update_tree_cb(FolderView *folderview, guint action,
-                          GtkWidget *widget)
+static void update_tree_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
        MainWindow *mainwin = mainwindow_get_mainwindow();
        
@@ -339,9 +351,9 @@ static void update_tree_cb(FolderView *folderview, guint action,
        folderview_check_new(item->folder);
 }
 
-static void sync_cb(FolderView *folderview, guint action,
-                          GtkWidget *widget)
+static void sync_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        FolderItem *item;
 
        item = folderview_get_selected_item(folderview);
@@ -395,9 +407,9 @@ void news_gtk_synchronise(FolderItem *item, gint days)
        main_window_cursor_normal(mainwin);
 }
 
-static void download_cb(FolderView *folderview, guint action,
-                       GtkWidget *widget)
+static void download_cb(GtkAction *action, gpointer data)
 {
+       FolderView *folderview = (FolderView *)data;
        GtkCTree *ctree = GTK_CTREE(folderview->ctree);
        FolderItem *item;