2008-07-19 [ticho] 3.5.0cvs26
authorAndrej Kacian <ticho@claws-mail.org>
Sat, 19 Jul 2008 16:38:57 +0000 (16:38 +0000)
committerAndrej Kacian <ticho@claws-mail.org>
Sat, 19 Jul 2008 16:38:57 +0000 (16:38 +0000)
* src/edittags.c
* src/main.c
* src/mimeview.c
* src/mimeview.h
* src/gtk/gtkutils.c
* src/gtk/gtkutils.h
* src/gtk/menu.c
* src/gtk/menu.h
Use GtkUIManager for mimeview and tag edit dialog popup menus,
instead of deprecated GtkItemFactory.

ChangeLog
PATCHSETS
configure.ac
src/edittags.c
src/gtk/gtkutils.c
src/gtk/gtkutils.h
src/gtk/menu.c
src/gtk/menu.h
src/main.c
src/mimeview.c
src/mimeview.h

index f641c46..62a83a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-07-19 [ticho]     3.5.0cvs26
+
+       * src/edittags.c
+       * src/main.c
+       * src/mimeview.c
+       * src/mimeview.h
+       * src/gtk/gtkutils.c
+       * src/gtk/gtkutils.h
+       * src/gtk/menu.c
+       * src/gtk/menu.h
+               Use GtkUIManager for mimeview and tag edit dialog popup menus,
+               instead of deprecated GtkItemFactory.
+
 2008-07-19 [colin]     3.5.0cvs25
 
        * src/account.c
index 03f3928..0ef17ed 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.455 -r 1.382.2.456 src/compose.c;  ) > 3.5.0cvs23.patchset
 ( cvs diff -u -r 1.274.2.252 -r 1.274.2.253 src/mainwindow.c;  ) > 3.5.0cvs24.patchset
 ( cvs diff -u -r 1.61.2.79 -r 1.61.2.80 src/account.c;  cvs diff -u -r 1.5.10.21 -r 1.5.10.22 src/addrgather.c;  cvs diff -u -r 1.382.2.456 -r 1.382.2.457 src/compose.c;  cvs diff -u -r 1.8.2.30 -r 1.8.2.31 src/editldap.c;  cvs diff -u -r 1.1.4.28 -r 1.1.4.29 src/expldifdlg.c;  cvs diff -u -r 1.14.2.17 -r 1.14.2.18 src/importldif.c;  cvs diff -u -r 1.115.2.198 -r 1.115.2.199 src/main.c;  cvs diff -u -r 1.274.2.253 -r 1.274.2.254 src/mainwindow.c;  cvs diff -u -r 1.83.2.133 -r 1.83.2.134 src/mimeview.c;  cvs diff -u -r 1.5.2.17 -r 1.5.2.18 src/noticeview.c;  cvs diff -u -r 1.105.2.137 -r 1.105.2.138 src/prefs_account.c;  cvs diff -u -r 1.60.2.58 -r 1.60.2.59 src/prefs_actions.c;  cvs diff -u -r 1.3.2.19 -r 1.3.2.20 src/prefs_ext_prog.c;  cvs diff -u -r 1.59.2.69 -r 1.59.2.70 src/prefs_filtering.c;  cvs diff -u -r 1.52.2.64 -r 1.52.2.65 src/prefs_folder_item.c;  cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/prefs_image_viewer.c;  cvs diff -u -r 1.1.2.13 -r 1.1.2.14 src/prefs_logging.c;  cvs diff -u -r 1.1.2.36 -r 1.1.2.37 src/prefs_msg_colors.c;  cvs diff -u -r 1.1.2.29 -r 1.1.2.30 src/prefs_other.c;  cvs diff -u -r 1.1.2.22 -r 1.1.2.23 src/prefs_send.c;  cvs diff -u -r 1.5.2.35 -r 1.5.2.36 src/prefs_spelling.c;  cvs diff -u -r 1.1.2.55 -r 1.1.2.56 src/prefs_summaries.c;  cvs diff -u -r 1.12.2.63 -r 1.12.2.64 src/prefs_template.c;  cvs diff -u -r 1.1.2.13 -r 1.1.2.14 src/printing.c;  cvs diff -u -r 1.8.2.35 -r 1.8.2.36 src/quote_fmt.c;  cvs diff -u -r 1.15.2.53 -r 1.15.2.54 src/summary_search.c;  cvs diff -u -r 1.395.2.373 -r 1.395.2.374 src/summaryview.c;  cvs diff -u -r 1.43.2.101 -r 1.43.2.102 src/toolbar.c;  cvs diff -u -r 1.1.2.70 -r 1.1.2.71 src/wizard.c;  cvs diff -u -r 1.24.2.16 -r 1.24.2.17 src/common/Makefile.am;  cvs diff -u -r 1.1.4.45 -r 1.1.4.46 src/gtk/gtksctree.c;  cvs diff -u -r 1.4.2.40 -r 1.4.2.41 src/gtk/gtkutils.h;  cvs diff -u -r 1.5.2.51 -r 1.5.2.52 src/gtk/pluginwindow.c;  cvs diff -u -r 1.1.2.82 -r 1.1.2.83 src/gtk/quicksearch.c;  cvs diff -u -r 1.1.2.32 -r 1.1.2.33 src/plugins/bogofilter/bogofilter_gtk.c;  cvs diff -u -r 1.5.2.22 -r 1.5.2.23 src/plugins/dillo_viewer/dillo_prefs.c;  cvs diff -u -r 1.1.2.30 -r 1.1.2.31 src/plugins/pgpcore/prefs_gpg.c;  cvs diff -u -r 1.23.2.48 -r 1.23.2.49 src/plugins/spamassassin/spamassassin_gtk.c;  cvs diff -u -r 1.14.2.63 -r 1.14.2.64 src/plugins/trayicon/trayicon.c;  cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/plugins/trayicon/trayicon_prefs.c;  ) > 3.5.0cvs25.patchset
+( cvs diff -u -r 1.1.2.16 -r 1.1.2.17 src/edittags.c;  cvs diff -u -r 1.115.2.199 -r 1.115.2.200 src/main.c;  cvs diff -u -r 1.83.2.134 -r 1.83.2.135 src/mimeview.c;  cvs diff -u -r 1.20.2.24 -r 1.20.2.25 src/mimeview.h;  cvs diff -u -r 1.5.2.75 -r 1.5.2.76 src/gtk/gtkutils.c;  cvs diff -u -r 1.4.2.41 -r 1.4.2.42 src/gtk/gtkutils.h;  cvs diff -u -r 1.5.2.28 -r 1.5.2.29 src/gtk/menu.c;  cvs diff -u -r 1.4.2.12 -r 1.4.2.13 src/gtk/menu.h;  ) > 3.5.0cvs26.patchset
index 3d9463f..1929186 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=5
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=25
+EXTRA_VERSION=26
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 7b42ff7..117fe8a 100644 (file)
@@ -197,10 +197,9 @@ static void apply_window_create_list_view_columns(GtkWidget *list_view)
 
 }
 
-static GtkItemFactory *apply_popup_factory = NULL;
 static GtkWidget *apply_popup_menu = NULL;
 
-static void apply_popup_delete (void *obj, guint action, void *data)
+static void apply_popup_delete (GtkAction *action, gpointer data)
 {
        GtkTreeIter sel;
        GtkTreeModel *model;
@@ -234,7 +233,7 @@ static void apply_popup_delete (void *obj, guint action, void *data)
        APPLYWINDOW_UNLOCK();
 }
 
-static void apply_popup_delete_all (void *obj, guint action, void *data)
+static void apply_popup_delete_all (GtkAction *action, gpointer data)
 {
        GSList *cur;
        GtkTreeModel *model;
@@ -264,15 +263,19 @@ static void apply_popup_delete_all (void *obj, guint action, void *data)
        APPLYWINDOW_UNLOCK();
 }
 
-static GtkItemFactoryEntry apply_popup_entries[] =
+static const GtkActionEntry apply_popup_actions[] =
 {
-       {N_("/_Delete"),                NULL, apply_popup_delete, 0, NULL, NULL},
-       {N_("/Delete _all"),    NULL, apply_popup_delete_all, 0, NULL, NULL},
+       { "EditTags", NULL, "EditTags" },
+       { "EditTags/Delete", NULL, N_("_Delete"), NULL, "Delete tag", G_CALLBACK(apply_popup_delete) },
+       { "EditTags/DeleteAll", NULL, N_("Delete _all"), NULL, "Delete all tags", G_CALLBACK(apply_popup_delete_all) }
 };
 
 static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
                                    GtkTreeView *list_view)
 {
+       GtkActionGroup *actions;
+       GtkUIManager *gui_manager = gtkut_ui_manager();
+
        if (applywindow.busy)
                return FALSE;
 
@@ -282,17 +285,25 @@ static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
                gboolean non_empty;
 
                if (!apply_popup_menu) {
-                       gint n_entries = sizeof(apply_popup_entries) /
-                               sizeof(apply_popup_entries[0]);
-                       apply_popup_menu = menu_create_items(apply_popup_entries, n_entries,
-                                                     "<TagPopupMenu>", &apply_popup_factory,
-                                                     list_view);
+                       actions = gtk_action_group_new("EditTags");
+                       gtk_action_group_add_actions(actions, apply_popup_actions,
+                                       G_N_ELEMENTS(apply_popup_actions), (gpointer)list_view);
+                       gtk_ui_manager_insert_action_group(gui_manager, actions, 0);
+
+                       MENUITEM_ADDUI("/Menus", "EditTags", "EditTags", GTK_UI_MANAGER_MENU)
+                       MENUITEM_ADDUI("/Menus/EditTags", "Delete", "EditTags/Delete",
+                                       GTK_UI_MANAGER_MENUITEM)
+                       MENUITEM_ADDUI("/Menus/EditTags", "DeleteAll", "EditTags/DeleteAll",
+                                       GTK_UI_MANAGER_MENUITEM)
+
+                       apply_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
+                                               gtk_ui_manager_get_widget(gui_manager, "/Menus/EditTags")) );
                }
 
                /* grey out popup menu items if list is empty */
                non_empty = gtk_tree_model_get_iter_first(model, &iter);
-               menu_set_sensitive(apply_popup_factory, "/Delete", non_empty);
-               menu_set_sensitive(apply_popup_factory, "/Delete all", non_empty);
+               cm_menu_set_sensitive("EditTags/Delete", non_empty);
+               cm_menu_set_sensitive("EditTags/DeleteAll", non_empty);
 
                gtk_menu_popup(GTK_MENU(apply_popup_menu), 
                               NULL, NULL, NULL, NULL, 
@@ -464,7 +475,7 @@ static void apply_window_del_tag_cb(GtkWidget *widget,
 {
        if (applywindow.busy)
                return;
-       apply_popup_delete(NULL, 0, NULL);
+       apply_popup_delete(NULL, NULL);
        gtk_widget_grab_focus(applywindow.taglist);
 }
 
@@ -475,7 +486,7 @@ static gboolean apply_window_key_pressed(GtkWidget *widget, GdkEventKey *event,
        if (event && event->keyval == GDK_Escape)
                apply_window_close();
        else if (event && event->keyval == GDK_Delete)
-               apply_popup_delete(NULL, 0, NULL);
+               apply_popup_delete(NULL, NULL);
        return FALSE;
 }
 
index 2cf68ed..e891362 100644 (file)
@@ -1579,3 +1579,16 @@ gboolean gtkut_list_view_select_row(GtkWidget *list, gint row)
        return TRUE;
 }
 
+static GtkUIManager *gui_manager = NULL;
+
+GtkUIManager *gtkut_create_ui_manager(void)
+{
+       g_return_val_if_fail(gui_manager == NULL, gui_manager);
+       return (gui_manager = gtk_ui_manager_new());
+}
+
+GtkUIManager *gtkut_ui_manager(void)
+{
+       return gui_manager;
+}
+
index f63ca06..312a81f 100644 (file)
@@ -216,6 +216,9 @@ gboolean gtkut_tree_model_get_iter_last(GtkTreeModel *model,
 gint gtkut_list_view_get_selected_row(GtkWidget *list_view);
 gboolean gtkut_list_view_select_row(GtkWidget *list, gint row);
 
+GtkUIManager *gtkut_create_ui_manager(void);
+GtkUIManager *gtkut_ui_manager(void);
+
 #if GTK_CHECK_VERSION(2,12,0)
 #define CLAWS_TIP_DECL() {}
 #define CLAWS_SET_TIP(widget,tip) {                                    \
index 7039f93..7bcbed5 100644 (file)
 #include <gtk/gtkitemfactory.h>
 #include <gtk/gtkbutton.h>
 #include <gtk/gtkwindow.h>
+#include <gtk/gtkutils.h>
 
 #include "menu.h"
 #include "utils.h"
+#include "gtkutils.h"
 
 #ifdef MAEMO
 #ifdef CHINOOK
@@ -104,6 +106,25 @@ void menu_set_sensitive(GtkItemFactory *ifactory, const gchar *path,
        gtk_widget_set_sensitive(widget, sensitive);
 }
 
+void cm_menu_set_sensitive(gchar *menu, gboolean sensitive)
+{
+       GtkUIManager *gui_manager = gtkut_ui_manager();
+       GtkWidget *widget;
+       gchar *path = g_strdup_printf("/Menus/%s/", menu);
+
+       widget = gtk_ui_manager_get_widget(gui_manager, path);
+       if( !GTK_IS_WIDGET(widget) ) {
+               g_message("Blah, '%s' is not a widget.\n", path);
+       }
+
+       if( !GTK_IS_MENU_ITEM(widget) ) {
+               g_message("Blah, '%s' is not a menu item.\n", path);
+       }
+
+       gtk_widget_set_sensitive(widget, sensitive);
+       g_free(path);
+}
+
 void menu_set_sensitive_all(GtkMenuShell *menu_shell, gboolean sensitive)
 {
        GList *cur;
index ccdf66e..8da32e6 100644 (file)
                                  GINT_TO_POINTER(data));        \
 }
 
+#define MENUITEM_ADDUI(path, name, action, type)       \
+       gtk_ui_manager_add_ui(gui_manager,      \
+                       gtk_ui_manager_new_merge_id(gui_manager),       \
+                       path, name, action, type, FALSE);
+
 #define menu_set_insensitive_all(menu_shell) \
        menu_set_sensitive_all(menu_shell, FALSE);
 
@@ -65,6 +70,8 @@ void menu_set_sensitive               (GtkItemFactory         *ifactory,
                                 const gchar            *path,
                                 gboolean                sensitive);
 
+void cm_menu_set_sensitive(gchar *menu, gboolean sensitive);
+
 void menu_set_active           (GtkItemFactory         *ifactory,
                                 const gchar            *path,
                                 gboolean                is_active);
index c084e6e..94bd154 100644 (file)
@@ -112,6 +112,7 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
 #include "matcher.h"
 #include "tags.h"
 #include "hooks.h"
+#include "menu.h"
 
 #ifdef HAVE_LIBETPAN
 #include "imap-thread.h"
@@ -1043,6 +1044,7 @@ int main(int argc, char *argv[])
        gint num_folder_class = 0;
        gboolean asked_for_migration = FALSE;
        gboolean start_done = TRUE;
+       GtkUIManager *gui_manager = NULL;
        
        START_TIMING("startup");
 
@@ -1153,6 +1155,11 @@ int main(int argc, char *argv[])
        gtk_widget_set_default_colormap(gdk_rgb_get_colormap());
        gtk_widget_set_default_visual(gdk_rgb_get_visual());
 
+       gui_manager = gtkut_create_ui_manager();
+
+       /* Create container for all the menus we will be adding */
+       MENUITEM_ADDUI("/", "Menus", NULL, GTK_UI_MANAGER_MENUBAR);
+
        if (!g_thread_supported()) {
                g_error(_("g_thread is not supported by glib.\n"));
        }
index 60c3e63..bbd7781 100644 (file)
@@ -155,20 +155,47 @@ static void icon_scroll_size_allocate_cb(GtkWidget        *widget,
                                         MimeView       *mimeview);
 static MimeInfo *mimeview_get_part_to_use(MimeView *mimeview);
 
-static void mimeview_launch_cb(MimeView *mimeview)
+static void mimeview_launch_cb(GtkAction *action, gpointer data)
 {
+       MimeView *mimeview = (MimeView *)data;
        mimeview_launch(mimeview, mimeview_get_part_to_use(mimeview));
 }
-static GtkItemFactoryEntry mimeview_popup_entries[] =
+
+static void mimeview_open_with_cb(GtkAction *action, gpointer data)
+{
+       mimeview_open_with((MimeView *)data);
+}
+
+static void mimeview_display_as_text_cb(GtkAction *action, gpointer data)
+{
+       mimeview_display_as_text((MimeView *)data);
+}
+
+static void mimeview_save_as_cb(GtkAction *action, gpointer data)
+{
+       mimeview_save_as((MimeView *)data);
+}
+
+static void mimeview_save_all_cb(GtkAction *action, gpointer data)
+{
+       mimeview_save_all((MimeView *)data);
+}
+
+static void mimeview_select_next_part_cb(GtkAction *action, gpointer data)
 {
-       {N_("/_Open (l)"),                NULL, mimeview_launch_cb,       0, NULL},
+       mimeview_select_next_part((MimeView *)data);
+}
+
+static const GtkActionEntry mimeview_menu_actions[] = {
+       { "MimeView", NULL, "MimeView" },
+       { "MimeView/Open", NULL, N_("_Open (l)"), NULL, "Open MIME part", G_CALLBACK(mimeview_launch_cb) },
 #ifndef MAEMO
-       {N_("/Open _with (o)..."),        NULL, mimeview_open_with,       0, NULL},
+       { "MimeView/OpenWith", NULL, N_("Open _with (o)..."), NULL, "Open MIME part with...", G_CALLBACK(mimeview_open_with_cb) },
 #endif
-       {N_("/_Display as text (t)"),     NULL, mimeview_display_as_text, 0, NULL},
-       {N_("/_Save as (y)..."),          NULL, mimeview_save_as,         0, NULL},
-       {N_("/Save _all..."),             NULL, mimeview_save_all,        0, NULL},
-       {N_("/Next part (a)"),            NULL, mimeview_select_next_part,0, NULL},
+       { "MimeView/DisplayAsText", NULL, N_("_Display as text (t)"), NULL, "Display as text", G_CALLBACK(mimeview_display_as_text_cb) },
+       { "MimeView/SaveAs", NULL, N_("_Save as (y)..."), NULL, "Save as", G_CALLBACK(mimeview_save_as_cb) },
+       { "MimeView/SaveAll", NULL, N_("Save _all..."), NULL, "Save all parts", G_CALLBACK(mimeview_save_all_cb) },
+       { "MimeView/NextPart", NULL, N_("Next part (a)"), NULL, "Next part", G_CALLBACK(mimeview_select_next_part_cb) }
 };
 
 static GtkTargetEntry mimeview_mime_types[] =
@@ -223,10 +250,10 @@ MimeView *mimeview_create(MainWindow *mainwin)
        GtkWidget *arrow;
        GtkWidget *scrollbutton;
        GtkWidget *hbox;
-       GtkItemFactory *popupfactory;
+       GtkUIManager *gui_manager = gtkut_ui_manager();
+       GtkActionGroup *actions;
        NoticeView *siginfoview;
        gchar *titles[N_MIMEVIEW_COLS];
-       gint n_entries;
        gint i;
        CLAWS_TIP_DECL();
 
@@ -320,10 +347,31 @@ MimeView *mimeview_create(MainWindow *mainwin)
        ctree_mainbox = gtk_hbox_new(FALSE, 0); 
        gtk_box_pack_start(GTK_BOX(ctree_mainbox), scrolledwin, TRUE, TRUE, 0);
 
-       n_entries = sizeof(mimeview_popup_entries) /
-               sizeof(mimeview_popup_entries[0]);
-       popupmenu = menu_create_items(mimeview_popup_entries, n_entries,
-                                     "<MimeView>", &popupfactory, mimeview);
+       actions = gtk_action_group_new("MimeView");
+       gtk_action_group_add_actions(actions, mimeview_menu_actions,
+                       G_N_ELEMENTS(mimeview_menu_actions), (gpointer)mimeview);
+       gtk_ui_manager_insert_action_group(gui_manager, actions, 0);
+
+       MENUITEM_ADDUI("/Menus/", "MimeView", "MimeView", GTK_UI_MANAGER_MENU);
+       MENUITEM_ADDUI("/Menus/MimeView/", "Open", "MimeView/Open",
+                       GTK_UI_MANAGER_MENUITEM);
+#ifndef MAEMO
+       MENUITEM_ADDUI("/Menus/MimeView/", "OpenWith", "MimeView/OpenWith",
+                       GTK_UI_MANAGER_MENUITEM);
+#endif
+       MENUITEM_ADDUI("/Menus/MimeView/", "DisplayAsText", "MimeView/DisplayAsText",
+                       GTK_UI_MANAGER_MENUITEM);
+       MENUITEM_ADDUI("/Menus/MimeView/", "SaveAs", "MimeView/SaveAs",
+                       GTK_UI_MANAGER_MENUITEM);
+       MENUITEM_ADDUI("/Menus/MimeView/", "SaveAll", "MimeView/SaveAll",
+                       GTK_UI_MANAGER_MENUITEM);
+       MENUITEM_ADDUI("/Menus/MimeView/", "NextPart", "MimeView/NextPart",
+                       GTK_UI_MANAGER_MENUITEM);
+
+       popupmenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
+                               gtk_ui_manager_get_widget(gui_manager, "/Menus/MimeView")) );
+
+
        vbox = gtk_vbox_new(FALSE, 0);
        gtk_widget_show(vbox);
        siginfoview = noticeview_create(mainwin);
@@ -353,7 +401,6 @@ MimeView *mimeview_create(MainWindow *mainwin)
        mimeview->ctree         = ctree;
        mimeview->mime_notebook = mime_notebook;
        mimeview->popupmenu     = popupmenu;
-       mimeview->popupfactory  = popupfactory;
        mimeview->type          = -1;
        mimeview->ctree_mainbox = ctree_mainbox;
        mimeview->icon_scroll   = icon_scroll;
@@ -1248,19 +1295,15 @@ static gboolean part_button_pressed(MimeView *mimeview, GdkEventButton *event,
                if (partinfo && (partinfo->type == MIMETYPE_MESSAGE ||
                                 partinfo->type == MIMETYPE_IMAGE ||
                                 partinfo->type == MIMETYPE_MULTIPART))
-                       menu_set_sensitive(mimeview->popupfactory,
-                                          "/Display as text (t)", FALSE);
+                       cm_menu_set_sensitive("MimeView/DisplayAsText", FALSE);
                else
-                       menu_set_sensitive(mimeview->popupfactory,
-                                          "/Display as text (t)", TRUE);
+                       cm_menu_set_sensitive("MimeView/DisplayAsText", TRUE);
                if (partinfo &&
                    partinfo->type == MIMETYPE_APPLICATION &&
                    !g_ascii_strcasecmp(partinfo->subtype, "octet-stream"))
-                       menu_set_sensitive(mimeview->popupfactory,
-                                          "/Open (l)", FALSE);
+                       cm_menu_set_sensitive("MimeView/Open", FALSE);
                else
-                       menu_set_sensitive(mimeview->popupfactory,
-                                          "/Open (l)", TRUE);
+                       cm_menu_set_sensitive("MimeView/Open", TRUE);
 
                g_object_set_data(G_OBJECT(mimeview->popupmenu),
                                  "pop_partinfo", partinfo);
index b11eda4..9deba16 100644 (file)
@@ -73,7 +73,6 @@ struct _MimeView
        gboolean ctree_mode;
 
        GtkWidget *popupmenu;
-       GtkItemFactory *popupfactory;
 
        GtkCTreeNode *opened;