From: Colin Leroy Date: Fri, 25 Jul 2008 21:01:45 +0000 (+0000) Subject: 2008-07-25 [colin] 3.5.0cvs34 X-Git-Tag: rel_3_6_0~123 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=4afbb72b2a8276484111caf7d49a8c8dc0205a61 2008-07-25 [colin] 3.5.0cvs34 * src/addrcustomattr.c * src/addressbook.c * src/compose.c * src/editaddress.c * src/editaddress_other_attributes_ldap.h * src/edittags.c * src/mainwindow.c * src/mimeview.c * src/prefs_actions.c * src/prefs_filtering.c * src/prefs_template.c * src/summaryview.c * src/textview.c * src/textview.h * src/toolbar.c * src/gtk/about.c * src/gtk/menu.c * src/gtk/menu.h * src/plugins/trayicon/trayicon.c More changes from GtkItemFactory to GtkUIManager --- diff --git a/ChangeLog b/ChangeLog index 1ca84edb8..936138505 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2008-07-25 [colin] 3.5.0cvs34 + + * src/addrcustomattr.c + * src/addressbook.c + * src/compose.c + * src/editaddress.c + * src/editaddress_other_attributes_ldap.h + * src/edittags.c + * src/mainwindow.c + * src/mimeview.c + * src/prefs_actions.c + * src/prefs_filtering.c + * src/prefs_template.c + * src/summaryview.c + * src/textview.c + * src/textview.h + * src/toolbar.c + * src/gtk/about.c + * src/gtk/menu.c + * src/gtk/menu.h + * src/plugins/trayicon/trayicon.c + More changes from GtkItemFactory to GtkUIManager + 2008-07-25 [colin] 3.5.0cvs33 * src/gtk/menu.h diff --git a/PATCHSETS b/PATCHSETS index ddebe07a9..b611ec365 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -3445,3 +3445,4 @@ ( cvs diff -u -r 1.1.2.13 -r 1.1.2.14 src/plugins/pgpcore/pgp_viewer.c; cvs diff -u -r 1.1.2.51 -r 1.1.2.52 src/plugins/pgpcore/sgpgme.c; ) > 3.5.0cvs31.patchset ( cvs diff -u -r 1.274.2.255 -r 1.274.2.256 src/mainwindow.c; cvs diff -u -r 1.83.2.135 -r 1.83.2.136 src/mimeview.c; cvs diff -u -r 1.395.2.374 -r 1.395.2.375 src/summaryview.c; cvs diff -u -r 1.68.2.47 -r 1.68.2.48 src/summaryview.h; ) > 3.5.0cvs32.patchset ( cvs diff -u -r 1.4.2.13 -r 1.4.2.14 src/gtk/menu.h; ) > 3.5.0cvs33.patchset +( cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/addrcustomattr.c; cvs diff -u -r 1.60.2.119 -r 1.60.2.120 src/addressbook.c; cvs diff -u -r 1.382.2.457 -r 1.382.2.458 src/compose.c; cvs diff -u -r 1.14.2.50 -r 1.14.2.51 src/editaddress.c; cvs diff -u -r 1.1.2.7 -r 1.1.2.8 src/editaddress_other_attributes_ldap.h; cvs diff -u -r 1.1.2.17 -r 1.1.2.18 src/edittags.c; cvs diff -u -r 1.274.2.256 -r 1.274.2.257 src/mainwindow.c; cvs diff -u -r 1.83.2.136 -r 1.83.2.137 src/mimeview.c; cvs diff -u -r 1.60.2.59 -r 1.60.2.60 src/prefs_actions.c; cvs diff -u -r 1.59.2.70 -r 1.59.2.71 src/prefs_filtering.c; cvs diff -u -r 1.12.2.64 -r 1.12.2.65 src/prefs_template.c; cvs diff -u -r 1.395.2.375 -r 1.395.2.376 src/summaryview.c; cvs diff -u -r 1.96.2.202 -r 1.96.2.203 src/textview.c; cvs diff -u -r 1.12.2.22 -r 1.12.2.23 src/textview.h; cvs diff -u -r 1.43.2.102 -r 1.43.2.103 src/toolbar.c; cvs diff -u -r 1.4.2.64 -r 1.4.2.65 src/gtk/about.c; cvs diff -u -r 1.5.2.29 -r 1.5.2.30 src/gtk/menu.c; cvs diff -u -r 1.4.2.14 -r 1.4.2.15 src/gtk/menu.h; cvs diff -u -r 1.14.2.64 -r 1.14.2.65 src/plugins/trayicon/trayicon.c; ) > 3.5.0cvs34.patchset diff --git a/configure.ac b/configure.ac index f2a76fac3..b9f75a8e7 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=5 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=33 +EXTRA_VERSION=34 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/addrcustomattr.c b/src/addrcustomattr.c index 828a600a0..6a77a7f58 100644 --- a/src/addrcustomattr.c +++ b/src/addrcustomattr.c @@ -38,7 +38,7 @@ #include "addrbook.h" #include "editaddress.h" -static GtkItemFactory *custom_attr_popup_factory = NULL; +static GtkActionGroup *custom_attr_popup_action = NULL; static GtkWidget *custom_attr_popup_menu = NULL; static struct CustomAttrWindow @@ -162,12 +162,12 @@ static void custom_attr_window_list_view_clear_list(GtkWidget *list_view, gboole } } -static void custom_attr_popup_clear_list (void *obj, guint action, void *data) +static void custom_attr_popup_clear_list (void *obj, void *data) { custom_attr_window_list_view_clear_list(custom_attr_window.attr_list, TRUE); } -static void custom_attr_popup_delete (void *obj, guint action, void *data) +static void custom_attr_popup_delete (void *obj, void *data) { GtkTreeIter sel; GtkTreeModel *model; @@ -185,7 +185,7 @@ static void custom_attr_popup_delete (void *obj, guint action, void *data) } } -static void custom_attr_popup_factory_defaults (void *obj, guint action, void *data) +static void custom_attr_popup_factory_defaults (void *obj, void *data) { if (alertpanel(_("Reset to default"), _("Do you really want to replace all attribute names\nwith the default set?"), @@ -205,11 +205,12 @@ static void custom_attr_popup_factory_defaults (void *obj, guint action, void *d } } -static GtkItemFactoryEntry custom_attr_popup_entries[] = +static GtkActionEntry custom_attr_popup_entries[] = { - {N_("/_Delete"), NULL, custom_attr_popup_delete, 0, NULL, NULL}, - {N_("/Delete _all"), NULL, custom_attr_popup_clear_list, 0, NULL, NULL}, - {N_("/_Reset to default"), NULL, custom_attr_popup_factory_defaults, 0, NULL, NULL}, + {"CustomAttrPopup", NULL, "CustomAttrPopup" }, + {"CustomAttrPopup/Delete", NULL, N_("_Delete"), NULL, NULL, G_CALLBACK(custom_attr_popup_delete) }, + {"CustomAttrPopup/DeleteAll", NULL, N_("Delete _all"), NULL, NULL, G_CALLBACK(custom_attr_popup_clear_list) }, + {"CustomAttrPopup/Reset", NULL, N_("_Reset to default"), NULL, NULL, G_CALLBACK(custom_attr_popup_factory_defaults) }, }; static gint custom_attr_list_btn_pressed(GtkWidget *widget, GdkEventButton *event, @@ -221,17 +222,20 @@ static gint custom_attr_list_btn_pressed(GtkWidget *widget, GdkEventButton *even gboolean non_empty; if (!custom_attr_popup_menu) { - gint n_entries = sizeof(custom_attr_popup_entries) / - sizeof(custom_attr_popup_entries[0]); - custom_attr_popup_menu = menu_create_items(custom_attr_popup_entries, - n_entries, "", - &custom_attr_popup_factory, list_view); + custom_attr_popup_action = cm_menu_create_action_group("CustomAttrPopup", custom_attr_popup_entries, + G_N_ELEMENTS(custom_attr_popup_entries), (gpointer)list_view); + MENUITEM_ADDUI("/Menus", "CustomAttrPopup", "CustomAttrPopup", GTK_UI_MANAGER_MENU) + MENUITEM_ADDUI("/Menus/CustomAttrPopup", "Delete", "CustomAttrPopup/Delete", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/CustomAttrPopup", "DeleteAll", "CustomAttrPopup/DeleteAll", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/CustomAttrPopup", "Reset", "CustomAttrPopup/Reset", GTK_UI_MANAGER_MENUITEM) + custom_attr_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/CustomAttrPopup")) ); } /* grey out popup menu items if list is empty */ non_empty = gtk_tree_model_get_iter_first(model, &iter); - menu_set_sensitive(custom_attr_popup_factory, "/Delete", non_empty); - menu_set_sensitive(custom_attr_popup_factory, "/Delete all", non_empty); + cm_menu_set_sensitive("CustomAttrPopup/Delete", non_empty); + cm_menu_set_sensitive("CustomAttrPopup/DeleteAll", non_empty); gtk_menu_popup(GTK_MENU(custom_attr_popup_menu), NULL, NULL, NULL, NULL, @@ -421,7 +425,7 @@ static void custom_attr_window_add_attr_cb(GtkWidget *widget, static void custom_attr_window_del_attr_cb(GtkWidget *widget, gpointer data) { - custom_attr_popup_delete(NULL, 0, NULL); + custom_attr_popup_delete(NULL, NULL); gtk_widget_grab_focus(custom_attr_window.attr_list); } @@ -431,7 +435,7 @@ static gboolean custom_attr_window_key_pressed(GtkWidget *widget, if (event && event->keyval == GDK_Escape) custom_attr_window_close(); else if (event && event->keyval == GDK_Delete) - custom_attr_popup_delete(NULL, 0, NULL); + custom_attr_popup_delete(NULL, NULL); return FALSE; } diff --git a/src/addressbook.c b/src/addressbook.c index dace2a45c..0262d18f0 100644 --- a/src/addressbook.c +++ b/src/addressbook.c @@ -26,22 +26,7 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include diff --git a/src/compose.c b/src/compose.c index 9db7041e8..52c841d6d 100644 --- a/src/compose.c +++ b/src/compose.c @@ -30,33 +30,8 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include + #include #include #include diff --git a/src/editaddress.c b/src/editaddress.c index a23a63832..1c782d8e3 100644 --- a/src/editaddress.c +++ b/src/editaddress.c @@ -815,8 +815,7 @@ static void addressbook_edit_person_set_picture(void) return; } personeditdlg.picture_set = TRUE; - menu_set_sensitive(personeditdlg.editaddr_popupfactory, - "/Unset picture", personeditdlg.picture_set); + cm_menu_set_sensitive("EditAddressPopup/UnsetPicture", personeditdlg.picture_set); g_free(filename); gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf); g_object_unref(pixbuf); @@ -829,25 +828,26 @@ static void addressbook_edit_person_clear_picture(void) stock_pixbuf_gdk(NULL, STOCK_PIXMAP_ANONYMOUS, &pixbuf); personeditdlg.picture_set = FALSE; - menu_set_sensitive(personeditdlg.editaddr_popupfactory, - "/Unset picture", personeditdlg.picture_set); + cm_menu_set_sensitive("EditAddressPopup/UnsetPicture", personeditdlg.picture_set); gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf); } -static void addressbook_edit_person_set_picture_menu_cb (void *obj, guint action, void *data) +static void addressbook_edit_person_set_picture_menu_cb (GtkAction *action, gpointer data) { addressbook_edit_person_set_picture(); } -static void addressbook_edit_person_unset_picture_menu_cb (void *obj, guint action, void *data) +static void addressbook_edit_person_unset_picture_menu_cb (GtkAction *action, gpointer data) { addressbook_edit_person_clear_picture(); } -static GtkItemFactoryEntry editaddr_popup_entries[] = +static GtkWidget *editaddr_popup_menu = NULL; +static GtkActionEntry editaddr_popup_entries[] = { - {N_("/_Set picture"), NULL, addressbook_edit_person_set_picture_menu_cb, 0, NULL, NULL}, - {N_("/_Unset picture"), NULL, addressbook_edit_person_unset_picture_menu_cb, 0, NULL, NULL}, + {"EditAddressPopup", NULL, "EditAddressPopup" }, + {"EditAddressPopup/SetPicture", NULL, N_("_Set picture"), NULL, NULL, G_CALLBACK(addressbook_edit_person_set_picture_menu_cb) }, + {"EditAddressPopup/UnsetPicture", NULL, N_("_Unset picture"), NULL, NULL, G_CALLBACK(addressbook_edit_person_unset_picture_menu_cb) }, }; static void addressbook_edit_person_set_picture_cb(GtkWidget *widget, @@ -856,7 +856,7 @@ static void addressbook_edit_person_set_picture_cb(GtkWidget *widget, if (event->button == 1) { addressbook_edit_person_set_picture(); } else { - gtk_menu_popup(GTK_MENU(personeditdlg.editaddr_popupmenu), + gtk_menu_popup(GTK_MENU(editaddr_popup_menu), NULL, NULL, NULL, NULL, event->button, event->time); } @@ -887,19 +887,23 @@ static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) { GtkWidget *entry_nn; const gchar *locale; gint top = 0; - gint n_entries; + GtkActionGroup *action_group; + vbox = gtk_vbox_new( FALSE, 20 ); hbox = gtk_hbox_new( FALSE, 8 ); gtk_widget_show( vbox ); - /* set up picture context menu before we call addressbook_edit_person_clear_picture() */ - n_entries = sizeof(editaddr_popup_entries) / - sizeof(editaddr_popup_entries[0]); - personeditdlg.editaddr_popupmenu = menu_create_items(editaddr_popup_entries, n_entries, - "", &personeditdlg.editaddr_popupfactory, - NULL); + if (!editaddr_popup_menu) { + action_group = cm_menu_create_action_group("EditAddressPopup", editaddr_popup_entries, + G_N_ELEMENTS(editaddr_popup_entries), (gpointer)NULL); + MENUITEM_ADDUI("/Menus", "EditAddressPopup", "EditAddressPopup", GTK_UI_MANAGER_MENU) + MENUITEM_ADDUI("/Menus/EditAddressPopup", "SetPicture", "EditAddressPopup/SetPicture", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/EditAddressPopup", "UnsetPicture", "EditAddressPopup/UnsetPicture", GTK_UI_MANAGER_MENUITEM) + editaddr_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/EditAddressPopup")) ); + } /* User's picture */ ebox_picture = gtk_event_box_new(); frame_picture = gtk_frame_new(_("Photo")); @@ -1677,10 +1681,8 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo if( ADDRITEM_NAME(current_person) ) gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_name), ADDRITEM_NAME(person) ); - menu_set_sensitive(personeditdlg.editaddr_popupfactory, - "/Set picture", !personeditdlg.ldap); - menu_set_sensitive(personeditdlg.editaddr_popupfactory, - "/Unset picture", !personeditdlg.ldap); + cm_menu_set_sensitive("EditAddressPopup/SetPicture", !personeditdlg.ldap); + cm_menu_set_sensitive("EditAddressPopup/UnsetPicture", !personeditdlg.ldap); if( current_person->picture ) { filename = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S, current_person->picture, ".png", NULL ); @@ -1693,8 +1695,7 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo goto no_img; } personeditdlg.picture_set = TRUE; - menu_set_sensitive(personeditdlg.editaddr_popupfactory, - "/Unset picture", !personeditdlg.ldap && personeditdlg.picture_set); + cm_menu_set_sensitive("EditAddressPopup/UnsetPicture", !personeditdlg.ldap && personeditdlg.picture_set); } else { goto no_img; } diff --git a/src/editaddress_other_attributes_ldap.h b/src/editaddress_other_attributes_ldap.h index ed84371de..26d3d2a06 100644 --- a/src/editaddress_other_attributes_ldap.h +++ b/src/editaddress_other_attributes_ldap.h @@ -77,8 +77,6 @@ struct _PersonEdit_dlg { gboolean editNew; gboolean read_only; gboolean ldap; - GtkItemFactory *editaddr_popupfactory; - GtkWidget *editaddr_popupmenu; }; #ifdef USE_LDAP diff --git a/src/edittags.c b/src/edittags.c index 117fe8a74..f9535a5d8 100644 --- a/src/edittags.c +++ b/src/edittags.c @@ -285,10 +285,8 @@ static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event, gboolean non_empty; if (!apply_popup_menu) { - actions = gtk_action_group_new("EditTags"); - gtk_action_group_add_actions(actions, apply_popup_actions, + actions = cm_menu_create_action_group("EditTags", 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", diff --git a/src/gtk/about.c b/src/gtk/about.c index 034eabbdc..501bef7fb 100644 --- a/src/gtk/about.c +++ b/src/gtk/about.c @@ -64,8 +64,6 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event); static gboolean about_textview_uri_clicked(GtkTextTag *tag, GObject *obj, GdkEvent *event, GtkTextIter *iter, GtkWidget *textview); -static void about_open_link_cb(GtkWidget *widget, guint action, void *data); -static void about_copy_link_cb(GtkWidget *widget, guint action, void *data); static gboolean about_textview_motion_notify(GtkWidget *widget, GdkEventMotion *event, GtkWidget *textview); @@ -74,12 +72,6 @@ static gboolean about_textview_leave_notify(GtkWidget *widget, GtkWidget *textview); static void about_textview_uri_update(GtkWidget *textview, gint x, gint y); -static GtkItemFactoryEntry textview_link_popup_entries[] = -{ - {N_("/_Open with Web browser"), NULL, about_open_link_cb, 0, NULL}, - {N_("/Copy this _link"), NULL, about_copy_link_cb, 0, NULL}, -}; - static GtkWidget *link_popupmenu; @@ -862,19 +854,12 @@ static gboolean about_textview_uri_clicked(GtkTextTag *tag, GObject *obj, } else { if (bevent->button == 3 && event->type == GDK_BUTTON_PRESS) { - GtkItemFactory *link_popupfactory; - gint n_entries; - - n_entries = sizeof(textview_link_popup_entries) / - sizeof(textview_link_popup_entries[0]); - link_popupmenu = menu_create_items( - textview_link_popup_entries, n_entries, - "", &link_popupfactory, - textview); + link_popupmenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TextviewPopupLink"))); g_object_set_data( G_OBJECT(link_popupmenu), - "menu_button", link); + "raw_url", link); gtk_menu_popup(GTK_MENU(link_popupmenu), NULL, NULL, NULL, NULL, bevent->button, bevent->time); @@ -885,34 +870,6 @@ static gboolean about_textview_uri_clicked(GtkTextTag *tag, GObject *obj, return FALSE; } -static void about_open_link_cb(GtkWidget *widget, guint action, void *data) -{ - gchar *link = g_object_get_data(G_OBJECT(link_popupmenu), - "menu_button"); - - if (link == NULL) { - return; - } - - open_uri(link, prefs_common_get_uri_cmd()); - g_object_set_data(G_OBJECT(link_popupmenu), "menu_button", - NULL); -} - -static void about_copy_link_cb(GtkWidget *widget, guint action, void *data) -{ - gchar *link = g_object_get_data(G_OBJECT(link_popupmenu), - "menu_button"); - - if (link == NULL) { - return; - } - - gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), link, -1); - gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), link, -1); - g_object_set_data(G_OBJECT(link_popupmenu), "menu_button", NULL); -} - static gboolean about_textview_motion_notify(GtkWidget *widget, GdkEventMotion *event, GtkWidget *textview) diff --git a/src/gtk/menu.c b/src/gtk/menu.c index 7bcbed5e8..a3f33a095 100644 --- a/src/gtk/menu.c +++ b/src/gtk/menu.c @@ -84,6 +84,16 @@ GtkWidget *menu_create_items(GtkItemFactoryEntry *entries, return gtk_item_factory_get_widget(*factory, path); } +GtkActionGroup *cm_menu_create_action_group(const gchar *name, GtkActionEntry **entries, + gint num_entries, gpointer data) +{ + GtkActionGroup *group = gtk_action_group_new(name); + gtk_action_group_set_translate_func(group, menu_translate, NULL, NULL); + gtk_action_group_add_actions(group, entries, num_entries, data); + gtk_ui_manager_insert_action_group(gtkut_ui_manager(), group, 0); + return group; +} + gchar *menu_translate(const gchar *path, gpointer data) { gchar *retval; @@ -125,6 +135,25 @@ void cm_menu_set_sensitive(gchar *menu, gboolean sensitive) g_free(path); } +void cm_toggle_menu_set_active(gchar *menu, gboolean active) +{ + 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_CHECK_MENU_ITEM(widget) ) { + g_message("Blah, '%s' is not a check menu item.\n", path); + } + + gtk_check_menu_item_set_active(widget, active); + g_free(path); +} + void menu_set_sensitive_all(GtkMenuShell *menu_shell, gboolean sensitive) { GList *cur; diff --git a/src/gtk/menu.h b/src/gtk/menu.h index 512895e9f..7fda1aa2d 100644 --- a/src/gtk/menu.h +++ b/src/gtk/menu.h @@ -48,7 +48,7 @@ #define MENUITEM_ADDUI(path, name, action, type) \ gtk_ui_manager_add_ui(gtkut_ui_manager(), \ - gtk_ui_manager_new_merge_id(gui_manager),\ + gtk_ui_manager_new_merge_id(gtkut_ui_manager()),\ path, name, action, type, FALSE); #define MENUITEM_ADDUI_ID(path, name, action, type,id) \ @@ -82,7 +82,10 @@ void menu_set_sensitive (GtkItemFactory *ifactory, const gchar *path, gboolean sensitive); +GtkActionGroup *cm_menu_create_action_group(const gchar *name, GtkActionEntry **entries, + gint num_entries, gpointer data); void cm_menu_set_sensitive(gchar *menu, gboolean sensitive); +void cm_toggle_menu_set_active(gchar *menu, gboolean active); void menu_set_active (GtkItemFactory *ifactory, const gchar *path, diff --git a/src/mainwindow.c b/src/mainwindow.c index 81757acc1..a97605635 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -1914,16 +1914,15 @@ MainWindow *main_window_create() #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \ gtk_window_add_accel_group \ (GTK_WINDOW(win), \ - gtk_item_factory_from_widget(menu)->accel_group); \ - g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \ + gtk_ui_manager_get_accel_group(gtkut_ui_manager())); \ + g_signal_connect(G_OBJECT(gtk_ui_manager_get_accel_group(gtkut_ui_manager())), \ "accel_activate", \ G_CALLBACK(main_window_accel_activate), mainwin); - - -/* ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window); + + ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window); - menu_connect_identical_items(); -*/ +/* FIXME menu_connect_identical_items(); */ + #ifndef GENERIC_UMPC gtk_window_iconify(GTK_WINDOW(mainwin->window)); #endif diff --git a/src/mimeview.c b/src/mimeview.c index f2e3b6d5c..9468b1f9f 100644 --- a/src/mimeview.c +++ b/src/mimeview.c @@ -347,10 +347,8 @@ MimeView *mimeview_create(MainWindow *mainwin) ctree_mainbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(ctree_mainbox), scrolledwin, TRUE, TRUE, 0); - actions = gtk_action_group_new("MimeView"); - gtk_action_group_add_actions(actions, mimeview_menu_actions, + actions = cm_menu_create_action_group("MimeView", 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", diff --git a/src/plugins/trayicon/trayicon.c b/src/plugins/trayicon/trayicon.c index 2081e3845..ae7464fb4 100644 --- a/src/plugins/trayicon/trayicon.c +++ b/src/plugins/trayicon/trayicon.c @@ -78,7 +78,6 @@ static GtkWidget *image = NULL; static GtkTooltips *tooltips; #endif static GtkWidget *traymenu_popup; -static GtkItemFactory *traymenu_factory; static gboolean updating_menu = FALSE; guint destroy_signal_id; @@ -92,48 +91,44 @@ typedef enum TRAYICON_NOTHING } TrayIconType; -static void trayicon_get_all_cb (gpointer data, guint action, GtkWidget *widget); -static void trayicon_compose_cb (gpointer data, guint action, GtkWidget *widget); +static void trayicon_get_all_cb (GtkAction *action, gpointer data); +static void trayicon_compose_cb (GtkAction *action, gpointer data); static void trayicon_compose_acc_cb (GtkMenuItem *menuitem, gpointer data ); -static void trayicon_addressbook_cb (gpointer data, guint action, GtkWidget *widget); -static void trayicon_exit_cb (gpointer data, guint action, GtkWidget *widget); -static void trayicon_toggle_offline_cb (gpointer data, guint action, GtkWidget *widget); +static void trayicon_addressbook_cb (GtkAction *action, gpointer data); +static void trayicon_exit_cb (GtkAction *action, gpointer data); +static void trayicon_toggle_offline_cb (GtkAction *action, gpointer data); static void resize_cb (GtkWidget *widget, GtkRequisition *req, gpointer user_data); -static GtkItemFactoryEntry trayicon_popup_menu_entries[] = -{ - {N_("/_Get Mail"), NULL, trayicon_get_all_cb, 0, NULL}, - {"/---", NULL, NULL, 0, ""}, - {N_("/_Email"), NULL, trayicon_compose_cb, 0, NULL}, - {N_("/_Email from account"), NULL, NULL, 0, ""}, - {"/---", NULL, NULL, 0, ""}, - {N_("/Open A_ddressbook"), NULL, trayicon_addressbook_cb, 0, NULL}, - {"/---", NULL, NULL, 0, ""}, - {N_("/_Work Offline"), NULL, trayicon_toggle_offline_cb, 0, ""}, - {"/---", NULL, NULL, 0, ""}, - {N_("/E_xit Claws Mail"), NULL, trayicon_exit_cb, 0, NULL} +static GtkActionEntry trayicon_popup_menu_entries[] = +{ + {"TrayiconPopup", NULL, "TrayiconPopup" }, + {"TrayiconPopup/GetMail", NULL, N_("_Get Mail"), NULL, NULL, G_CALLBACK(trayicon_get_all_cb) }, + {"TrayiconPopup/---", NULL, "---", NULL, NULL, G_CALLBACK(trayicon_compose_cb) }, + {"TrayiconPopup/Email", NULL, N_("_Email"), NULL, NULL, G_CALLBACK(trayicon_compose_cb) }, + {"TrayiconPopup/EmailAcc", NULL, N_("E_mail from account"), NULL, NULL, NULL }, + {"TrayiconPopup/OpenAB", NULL, N_("Open A_ddressbook"), NULL, NULL, G_CALLBACK(trayicon_addressbook_cb) }, + {"TrayiconPopup/Exit", NULL, N_("E_xit Claws Mail"), NULL, NULL, G_CALLBACK(trayicon_exit_cb) }, +}; + +static GtkToggleActionEntry trayicon_popup_toggle_menu_entries[] = +{ + {"TrayiconPopup/ToggleOffline", NULL, N_("_Work Offline"), NULL, NULL, G_CALLBACK(trayicon_toggle_offline_cb) }, }; static gboolean trayicon_set_accounts_hook(gpointer source, gpointer data) { - GList *cur_ac, *cur_item = NULL; - GtkWidget *menu; + GList *cur_ac; + GtkWidget *menu, *submenu; GtkWidget *menuitem; PrefsAccount *ac_prefs; GList *account_list = account_get_list(); - menu = gtk_item_factory_get_widget(traymenu_factory, - "/Email from account"); - - /* 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_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TrayiconPopup/EmailAcc"); + gtk_widget_show(menu); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu), NULL); + submenu = gtk_menu_new(); for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) { ac_prefs = (PrefsAccount *)cur_ac->data; @@ -141,11 +136,13 @@ static gboolean trayicon_set_accounts_hook(gpointer source, gpointer data) (ac_prefs->account_name ? ac_prefs->account_name : _("Untitled")); gtk_widget_show(menuitem); - gtk_menu_append(GTK_MENU(menu), menuitem); + gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(trayicon_compose_acc_cb), ac_prefs); } + gtk_widget_show(submenu); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu), submenu); return FALSE; } @@ -331,12 +328,8 @@ static gboolean click_cb(GtkWidget * widget, /* tell callbacks to skip any event */ updating_menu = TRUE; /* initialize checkitem according to current offline state */ - gtk_check_menu_item_set_active( - GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(traymenu_factory, - "/Work Offline")), prefs_common.work_offline); - gtk_widget_set_sensitive( - GTK_WIDGET(gtk_item_factory_get_item(traymenu_factory, - "/Get Mail")), mainwin->lock_count == 0); + cm_toggle_menu_set_active("TrayiconPopup/ToggleOffline", prefs_common.work_offline); + cm_menu_set_sensitive("TrayiconPopup/GetMail", mainwin->lock_count == 0); updating_menu = FALSE; gtk_menu_popup( GTK_MENU(traymenu_popup), NULL, NULL, NULL, NULL, @@ -379,8 +372,7 @@ static gboolean trayicon_update_theme(gpointer source, gpointer data) static void create_trayicon() { - gint n_entries = 0; - + GtkActionGroup *action_group; trayicon = egg_tray_icon_new("Claws Mail"); gtk_widget_realize(GTK_WIDGET(trayicon)); gtk_window_set_default_size(GTK_WINDOW(trayicon), 16, 16); @@ -407,11 +399,26 @@ static void create_trayicon() tooltips = gtk_tooltips_new(); gtk_tooltips_enable(tooltips); #endif - n_entries = sizeof(trayicon_popup_menu_entries) / - sizeof(trayicon_popup_menu_entries[0]); - traymenu_popup = menu_create_items(trayicon_popup_menu_entries, - n_entries, "", &traymenu_factory, - NULL); + + action_group = cm_menu_create_action_group("TrayiconPopup", trayicon_popup_menu_entries, + G_N_ELEMENTS(trayicon_popup_menu_entries), (gpointer)NULL); + gtk_action_group_add_toggle_actions(action_group, trayicon_popup_toggle_menu_entries, + G_N_ELEMENTS(trayicon_popup_toggle_menu_entries), (gpointer)NULL); + + MENUITEM_ADDUI("/Menus", "TrayiconPopup", "TrayiconPopup", GTK_UI_MANAGER_MENU) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "GetMail", "TrayiconPopup/GetMail", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "Separator1", "TrayiconPopup/---", GTK_UI_MANAGER_SEPARATOR) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "Email", "TrayiconPopup/Email", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "EmailAcc", "TrayiconPopup/EmailAcc", GTK_UI_MANAGER_MENU) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "Separator2", "TrayiconPopup/---", GTK_UI_MANAGER_SEPARATOR) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "OpenAB", "TrayiconPopup/OpenAB", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "Separator3", "TrayiconPopup/---", GTK_UI_MANAGER_SEPARATOR) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "ToggleOffline", "TrayiconPopup/ToggleOffline", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "Separator4", "TrayiconPopup/---", GTK_UI_MANAGER_SEPARATOR) + MENUITEM_ADDUI("/Menus/TrayiconPopup", "Exit", "TrayiconPopup/Exit", GTK_UI_MANAGER_MENUITEM) + + traymenu_popup = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TrayiconPopup")) ); gtk_widget_show_all(GTK_WIDGET(trayicon)); @@ -554,13 +561,13 @@ const gchar *plugin_version(void) /* popup menu callbacks */ -static void trayicon_get_all_cb( gpointer data, guint action, GtkWidget *widget ) +static void trayicon_get_all_cb( GtkAction *action, gpointer data ) { MainWindow *mainwin = mainwindow_get_mainwindow(); inc_all_account_mail_cb(mainwin, 0, NULL); } -static void trayicon_compose_cb( gpointer data, guint action, GtkWidget *widget ) +static void trayicon_compose_cb( GtkAction *action, gpointer data ) { MainWindow *mainwin = mainwindow_get_mainwindow(); compose_mail_cb(mainwin, 0, NULL); @@ -571,12 +578,12 @@ static void trayicon_compose_acc_cb( GtkMenuItem *menuitem, gpointer data ) compose_new((PrefsAccount *)data, NULL, NULL); } -static void trayicon_addressbook_cb( gpointer data, guint action, GtkWidget *widget ) +static void trayicon_addressbook_cb( GtkAction *action, gpointer data ) { addressbook_open(NULL); } -static void trayicon_toggle_offline_cb( gpointer data, guint action, GtkWidget *widget ) +static void trayicon_toggle_offline_cb( GtkAction *action, gpointer data ) { /* toggle offline mode if menu checkitem has been clicked */ if (!updating_menu) { @@ -599,7 +606,7 @@ static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget) app_will_exit(NULL, mainwin); } -static void trayicon_exit_cb( gpointer data, guint action, GtkWidget *widget ) +static void trayicon_exit_cb( GtkAction *action, gpointer data ) { MainWindow *mainwin = mainwindow_get_mainwindow(); diff --git a/src/prefs_actions.c b/src/prefs_actions.c index f5c7e3749..18683ffa6 100644 --- a/src/prefs_actions.c +++ b/src/prefs_actions.c @@ -91,13 +91,10 @@ static void prefs_actions_register_cb (GtkWidget *w, gpointer data); static void prefs_actions_substitute_cb (GtkWidget *w, gpointer data); -static void prefs_actions_delete_cb (GtkWidget *w, - gpointer data); -static void prefs_actions_delete_all_cb (GtkWidget *w, - gpointer data); -static void prefs_actions_clear_cb (void); -static void prefs_actions_duplicate_cb (GtkWidget *w, - gpointer data); +static void prefs_actions_delete_cb (gpointer gtk_action, gpointer data); +static void prefs_actions_delete_all_cb (gpointer gtk_action, gpointer data); +static void prefs_actions_clear_cb (gpointer gtk_action, gpointer data); +static void prefs_actions_duplicate_cb (gpointer gtk_action, gpointer data); static void prefs_actions_up (GtkWidget *w, gpointer data); static void prefs_actions_down (GtkWidget *w, @@ -697,7 +694,7 @@ static void prefs_actions_substitute_cb(GtkWidget *w, gpointer data) modified_list = TRUE; } -static void prefs_actions_delete_cb(GtkWidget *w, gpointer data) +static void prefs_actions_delete_cb(gpointer gtk_action, gpointer data) { GtkTreeIter sel; GtkTreeModel *model; @@ -730,7 +727,7 @@ static void prefs_actions_delete_cb(GtkWidget *w, gpointer data) modified_list = TRUE; } -static void prefs_actions_delete_all_cb(GtkWidget *w, gpointer data) +static void prefs_actions_delete_all_cb(gpointer gtk_action, gpointer data) { GtkListStore *list_store; @@ -747,7 +744,7 @@ static void prefs_actions_delete_all_cb(GtkWidget *w, gpointer data) modified_list = TRUE; } -static void prefs_actions_clear_cb(void) +static void prefs_actions_clear_cb(gpointer gtk_action, gpointer data) { gint row; @@ -759,7 +756,7 @@ static void prefs_actions_clear_cb(void) modified = TRUE; } -static void prefs_actions_duplicate_cb(GtkWidget *w, gpointer data) +static void prefs_actions_duplicate_cb(gpointer gtk_action, gpointer data) { gint row; @@ -1056,14 +1053,15 @@ static void prefs_actions_list_view_insert_action(GtkWidget *list_view, } } -static GtkItemFactory *prefs_actions_popup_factory = NULL; +static GtkActionGroup *prefs_actions_popup_action = NULL; static GtkWidget *prefs_actions_popup_menu = NULL; -static GtkItemFactoryEntry prefs_actions_popup_entries[] = +static GtkActionEntry prefs_actions_popup_entries[] = { - {N_("/_Delete"), NULL, prefs_actions_delete_cb, 0, NULL, NULL}, - {N_("/Delete _all"), NULL, prefs_actions_delete_all_cb, 0, NULL, NULL}, - {N_("/D_uplicate"), NULL, prefs_actions_duplicate_cb, 0, NULL, NULL}, + {"PrefsActionsPopup", NULL, "PrefsActionsPopup" }, + {"PrefsActionsPopup/Delete", NULL, N_("_Delete"), NULL, NULL, G_CALLBACK(prefs_actions_delete_cb) }, + {"PrefsActionsPopup/DeleteAll", NULL, N_("Delete _all"), NULL, NULL, G_CALLBACK(prefs_actions_delete_all_cb) }, + {"PrefsActionsPopup/Duplicate", NULL, N_("D_uplicate"), NULL, NULL, G_CALLBACK(prefs_actions_duplicate_cb) }, }; static gint prefs_actions_list_btn_pressed(GtkWidget *widget, GdkEventButton *event, @@ -1089,24 +1087,27 @@ static gint prefs_actions_list_btn_pressed(GtkWidget *widget, GdkEventButton *ev gint row; if (!prefs_actions_popup_menu) { - gint n_entries = sizeof(prefs_actions_popup_entries) / - sizeof(prefs_actions_popup_entries[0]); - prefs_actions_popup_menu = menu_create_items(prefs_actions_popup_entries, - n_entries, "", - &prefs_actions_popup_factory, list_view); + prefs_actions_popup_action = cm_menu_create_action_group("PrefsActionsPopup", prefs_actions_popup_entries, + G_N_ELEMENTS(prefs_actions_popup_entries), (gpointer)list_view); + MENUITEM_ADDUI("/Menus", "PrefsActionsPopup", "PrefsActionsPopup", GTK_UI_MANAGER_MENU) + MENUITEM_ADDUI("/Menus/PrefsActionsPopup", "Delete", "PrefsActionsPopup/Delete", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/PrefsActionsPopup", "DeleteAll", "PrefsActionsPopup/DeleteAll", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/PrefsActionsPopup", "Duplicate", "PrefsActionsPopup/Duplicate", GTK_UI_MANAGER_MENUITEM) + prefs_actions_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/PrefsActionsPopup")) ); } /* grey out some popup menu items if there is no selected row */ row = gtkut_list_view_get_selected_row(GTK_WIDGET(list_view)); - menu_set_sensitive(prefs_actions_popup_factory, "/Delete", (row > 0)); - menu_set_sensitive(prefs_actions_popup_factory, "/Duplicate", (row > 0)); + cm_menu_set_sensitive("PrefsActionsPopup/Delete", (row > 0)); + cm_menu_set_sensitive("PrefsActionsPopup/Duplicate", (row > 0)); /* grey out seom popup menu items if there is no row (not counting the (New) one at row 0) */ non_empty = gtk_tree_model_get_iter_first(model, &iter); if (non_empty) non_empty = gtk_tree_model_iter_next(model, &iter); - menu_set_sensitive(prefs_actions_popup_factory, "/Delete all", non_empty); + cm_menu_set_sensitive("PrefsActionsPopup/DeleteAll", non_empty); gtk_menu_popup(GTK_MENU(prefs_actions_popup_menu), NULL, NULL, NULL, NULL, diff --git a/src/prefs_filtering.c b/src/prefs_filtering.c index 34822a4df..1d7b7a1e7 100644 --- a/src/prefs_filtering.c +++ b/src/prefs_filtering.c @@ -100,29 +100,29 @@ static void prefs_filtering_set_list (void); static gboolean prefs_filtering_search_func_cb (GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data); -static void prefs_filtering_register_cb (void); -static void prefs_filtering_substitute_cb (void); -static void prefs_filtering_delete_cb (void); -static void prefs_filtering_delete_all_cb(void); -static void prefs_filtering_clear_cb(void); -static void prefs_filtering_duplicate_cb(void); -static void prefs_filtering_top (void); -static void prefs_filtering_page_up(void); -static void prefs_filtering_up (void); -static void prefs_filtering_down (void); -static void prefs_filtering_page_down(void); -static void prefs_filtering_bottom (void); +static void prefs_filtering_register_cb (gpointer action, gpointer data); +static void prefs_filtering_substitute_cb (gpointer action, gpointer data); +static void prefs_filtering_delete_cb (gpointer action, gpointer data); +static void prefs_filtering_delete_all_cb(gpointer action, gpointer data); +static void prefs_filtering_clear_cb(gpointer action, gpointer data); +static void prefs_filtering_duplicate_cb(gpointer action, gpointer data); +static void prefs_filtering_top (gpointer action, gpointer data); +static void prefs_filtering_page_up (gpointer action, gpointer data); +static void prefs_filtering_up (gpointer action, gpointer data); +static void prefs_filtering_down (gpointer action, gpointer data); +static void prefs_filtering_page_down (gpointer action, gpointer data); +static void prefs_filtering_bottom (gpointer action, gpointer data); static gint prefs_filtering_deleted (GtkWidget *widget, GdkEventAny *event, gpointer data); static gboolean prefs_filtering_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data); -static void prefs_filtering_cancel (void); -static void prefs_filtering_ok (void); +static void prefs_filtering_cancel (gpointer action, gpointer data); +static void prefs_filtering_ok (gpointer action, gpointer data); -static void prefs_filtering_condition_define (void); -static void prefs_filtering_action_define(void); +static void prefs_filtering_condition_define (gpointer action, gpointer data); +static void prefs_filtering_action_define (gpointer action, gpointer data); static gint prefs_filtering_list_view_set_row (gint row, FilteringProp * prop); static void prefs_filtering_reset_dialog (void); @@ -1083,7 +1083,7 @@ static void prefs_filtering_condition_define_done(MatcherList * matchers) } } -static void prefs_filtering_condition_define(void) +static void prefs_filtering_condition_define(gpointer action, gpointer data) { gchar * cond_str; MatcherList * matchers = NULL; @@ -1119,7 +1119,7 @@ static void prefs_filtering_action_define_done(GSList * action_list) } } -static void prefs_filtering_action_define(void) +static void prefs_filtering_action_define(gpointer action, gpointer data) { gchar * action_str; GSList * action_list = NULL; @@ -1200,7 +1200,7 @@ fail: return prop; } -static void prefs_filtering_register_cb(void) +static void prefs_filtering_register_cb(gpointer action, gpointer data) { FilteringProp *prop; @@ -1215,7 +1215,7 @@ static void prefs_filtering_register_cb(void) modified = TRUE; } -static void prefs_filtering_substitute_cb(void) +static void prefs_filtering_substitute_cb(gpointer action, gpointer data) { gint selected_row = gtkut_list_view_get_selected_row (filtering.cond_list_view); @@ -1247,7 +1247,7 @@ static void prefs_filtering_substitute_cb(void) modified = TRUE; } -static void prefs_filtering_delete_cb(void) +static void prefs_filtering_delete_cb(gpointer action, gpointer data) { GtkTreeView *list_view = GTK_TREE_VIEW(filtering.cond_list_view); GtkTreeModel *model; @@ -1273,7 +1273,7 @@ static void prefs_filtering_delete_cb(void) modified = TRUE; } -static void prefs_filtering_delete_all_cb(void) +static void prefs_filtering_delete_all_cb(gpointer action, gpointer data) { GtkListStore *list_store; @@ -1289,12 +1289,12 @@ static void prefs_filtering_delete_all_cb(void) modified = TRUE; } -static void prefs_filtering_clear_cb(void) +static void prefs_filtering_clear_cb(gpointer action, gpointer data) { prefs_filtering_reset_dialog(); } -static void prefs_filtering_duplicate_cb(void) +static void prefs_filtering_duplicate_cb(gpointer action, gpointer data) { gint selected_row = gtkut_list_view_get_selected_row (filtering.cond_list_view); @@ -1325,7 +1325,7 @@ static void prefs_filtering_duplicate_cb(void) modified = TRUE; } -static void prefs_filtering_top(void) +static void prefs_filtering_top(gpointer action, gpointer data) { gint row; GtkTreeIter top, sel; @@ -1346,7 +1346,7 @@ static void prefs_filtering_top(void) modified = TRUE; } -static void prefs_filtering_page_up(void) +static void prefs_filtering_page_up(gpointer action, gpointer data) { gint row, target_row, n_rows; GtkTreeIter selected, target; @@ -1378,7 +1378,7 @@ static void prefs_filtering_page_up(void) gtkut_list_view_select_row(filtering.cond_list_view, target_row); modified = TRUE; } -static void prefs_filtering_up(void) +static void prefs_filtering_up(gpointer action, gpointer data) { gint row; GtkTreeIter top, sel; @@ -1399,7 +1399,7 @@ static void prefs_filtering_up(void) modified = TRUE; } -static void prefs_filtering_down(void) +static void prefs_filtering_down(gpointer action, gpointer data) { gint row, n_rows; GtkTreeIter top, sel; @@ -1420,7 +1420,7 @@ static void prefs_filtering_down(void) modified = TRUE; } -static void prefs_filtering_page_down(void) +static void prefs_filtering_page_down(gpointer action, gpointer data) { gint row, target_row, n_rows; GtkTreeIter selected, target; @@ -1453,7 +1453,7 @@ static void prefs_filtering_page_down(void) modified = TRUE; } -static void prefs_filtering_bottom(void) +static void prefs_filtering_bottom(gpointer action, gpointer data) { gint row, n_rows; GtkTreeIter top, sel; @@ -1506,7 +1506,7 @@ static void prefs_filtering_select_set(FilteringProp *prop) static gint prefs_filtering_deleted(GtkWidget *widget, GdkEventAny *event, gpointer data) { - prefs_filtering_cancel(); + prefs_filtering_cancel(NULL, NULL); return TRUE; } @@ -1514,7 +1514,7 @@ static gboolean prefs_filtering_key_pressed(GtkWidget *widget, GdkEventKey *even gpointer data) { if (event && event->keyval == GDK_Escape) { - prefs_filtering_cancel(); + prefs_filtering_cancel(NULL, NULL); return TRUE; } return FALSE; @@ -1592,7 +1592,7 @@ static gboolean prefs_filtering_check_mod(gboolean check_changed_list) return FALSE; } -static void prefs_filtering_ok(void) +static void prefs_filtering_ok(gpointer action, gpointer data) { if (prefs_filtering_check_mod(FALSE)) return; @@ -1602,7 +1602,7 @@ static void prefs_filtering_ok(void) prefs_filtering_close(); } -static void prefs_filtering_cancel(void) +static void prefs_filtering_cancel(gpointer action, gpointer data) { if (prefs_filtering_check_mod(TRUE)) return; @@ -1743,18 +1743,19 @@ static void prefs_filtering_list_view_get_rule_info(GtkWidget *list, gint row, } } -static GtkItemFactory *prefs_filtering_popup_factory = NULL; +static GtkActionGroup *prefs_filtering_popup_action = NULL; static GtkWidget *prefs_filtering_popup_menu = NULL; -static GtkItemFactoryEntry prefs_filtering_popup_entries[] = +static GtkActionEntry prefs_filtering_popup_entries[] = { - {N_("/_Delete"), NULL, prefs_filtering_delete_cb, 0, NULL, NULL}, - {N_("/Delete _all"), NULL, prefs_filtering_delete_all_cb, 0, NULL, NULL}, - {N_("/D_uplicate"), NULL, prefs_filtering_duplicate_cb, 0, NULL, NULL}, + {"PrefsFilteringPopup", NULL, "PrefsFilteringPopup" }, + {"PrefsFilteringPopup/Delete", NULL, N_("_Delete"), NULL, NULL, G_CALLBACK(prefs_filtering_delete_cb) }, + {"PrefsFilteringPopup/DeleteAll", NULL, N_("Delete _all"), NULL, NULL, G_CALLBACK(prefs_filtering_delete_all_cb) }, + {"PrefsFilteringPopup/Duplicate", NULL, N_("D_uplicate"), NULL, NULL, G_CALLBACK(prefs_filtering_duplicate_cb) }, #ifdef GENERIC_UMPC - {N_("/---"), NULL, NULL, 0, "", NULL}, - {N_("/Move one page up"), NULL, prefs_filtering_page_up, 0, NULL, NULL}, - {N_("/Move one page down"), NULL, prefs_filtering_page_down, 0, NULL, NULL}, + {"PrefsFilteringPopup/---", NULL, "---", NULL, NULL, NULL }, + {"PrefsFilteringPopup/PageUp", NULL, N_("Move one page up"), NULL, NULL, G_CALLBACK(prefs_filtering_page_up) }, + {"PrefsFilteringPopup/PageDown", NULL, N_("Move one page down"), NULL, NULL, G_CALLBACK(prefs_filtering_page_down) }, #endif }; @@ -1782,24 +1783,32 @@ static gint prefs_filtering_list_btn_pressed(GtkWidget *widget, GdkEventButton * gint row; if (!prefs_filtering_popup_menu) { - gint n_entries = sizeof(prefs_filtering_popup_entries) / - sizeof(prefs_filtering_popup_entries[0]); - prefs_filtering_popup_menu = menu_create_items(prefs_filtering_popup_entries, - n_entries, "", - &prefs_filtering_popup_factory, list_view); + prefs_filtering_popup_action = cm_menu_create_action_group("PrefsFilteringPopup", prefs_filtering_popup_entries, + G_N_ELEMENTS(prefs_filtering_popup_entries), (gpointer)list_view); + MENUITEM_ADDUI("/Menus", "PrefsFilteringPopup", "PrefsFilteringPopup", GTK_UI_MANAGER_MENU) + MENUITEM_ADDUI("/Menus/PrefsFilteringPopup", "Delete", "PrefsFilteringPopup/Delete", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/PrefsFilteringPopup", "DeleteAll", "PrefsFilteringPopup/DeleteAll", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/PrefsFilteringPopup", "Duplicate", "PrefsFilteringPopup/Duplicate", GTK_UI_MANAGER_MENUITEM) +#ifdef GENERIC_UMPC + MENUITEM_ADDUI("/Menus/PrefsFilteringPopup", "Separator1", "PrefsFilteringPopup/---", GTK_UI_MANAGER_SEPARATOR) + MENUITEM_ADDUI("/Menus/PrefsFilteringPopup", "PageUp", "PrefsFilteringPopup/PageUp", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/PrefsFilteringPopup", "PageDown", "PrefsFilteringPopup/PageDown", GTK_UI_MANAGER_MENUITEM) +#endif + prefs_filtering_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/PrefsFilteringPopup")) ); } /* grey out some popup menu items if there is no selected row */ row = gtkut_list_view_get_selected_row(GTK_WIDGET(list_view)); - menu_set_sensitive(prefs_filtering_popup_factory, "/Delete", (row > 0)); - menu_set_sensitive(prefs_filtering_popup_factory, "/Duplicate", (row > 0)); + cm_menu_set_sensitive("PrefsFilteringPopup/Delete", (row > 0)); + cm_menu_set_sensitive("PrefsFilteringPopup/Duplicate", (row > 0)); /* grey out seom popup menu items if there is no row (not counting the (New) one at row 0) */ non_empty = gtk_tree_model_get_iter_first(model, &iter); if (non_empty) non_empty = gtk_tree_model_iter_next(model, &iter); - menu_set_sensitive(prefs_filtering_popup_factory, "/Delete all", non_empty); + cm_menu_set_sensitive("PrefsFilteringPopup/DeleteAll", non_empty); gtk_menu_popup(GTK_MENU(prefs_filtering_popup_menu), NULL, NULL, NULL, NULL, diff --git a/src/prefs_template.c b/src/prefs_template.c index 86d4e6334..44739dfde 100644 --- a/src/prefs_template.c +++ b/src/prefs_template.c @@ -99,18 +99,18 @@ static gint prefs_template_deleted_cb (GtkWidget *widget, static gboolean prefs_template_key_pressed_cb (GtkWidget *widget, GdkEventKey *event, gpointer data); -static void prefs_template_cancel_cb (void); -static void prefs_template_ok_cb (void); -static void prefs_template_register_cb (void); -static void prefs_template_substitute_cb (void); -static void prefs_template_delete_cb (void); -static void prefs_template_delete_all_cb (void); -static void prefs_template_clear_cb (void); -static void prefs_template_duplicate_cb (void); -static void prefs_template_top_cb (void); -static void prefs_template_up_cb (void); -static void prefs_template_down_cb (void); -static void prefs_template_bottom_cb (void); +static void prefs_template_cancel_cb (gpointer action, gpointer data); +static void prefs_template_ok_cb (gpointer action, gpointer data); +static void prefs_template_register_cb (gpointer action, gpointer data); +static void prefs_template_substitute_cb (gpointer action, gpointer data); +static void prefs_template_delete_cb (gpointer action, gpointer data); +static void prefs_template_delete_all_cb (gpointer action, gpointer data); +static void prefs_template_clear_cb (gpointer action, gpointer data); +static void prefs_template_duplicate_cb (gpointer action, gpointer data); +static void prefs_template_top_cb (gpointer action, gpointer data); +static void prefs_template_up_cb (gpointer action, gpointer data); +static void prefs_template_down_cb (gpointer action, gpointer data); +static void prefs_template_bottom_cb (gpointer action, gpointer data); static GtkListStore* prefs_template_create_data_store (void); static void prefs_template_list_view_insert_template (GtkWidget *list_view, @@ -238,10 +238,6 @@ static void prefs_template_window_create(void) (GtkAttachOptions) 0, 0, 0); CLAWS_SET_TIP(*(widgets_table[i].entry), widgets_table[i].tooltips); - - if (widgets_table[i].compl) - address_completion_register_entry( - GTK_ENTRY(*(widgets_table[i].entry)), TRUE); } /* template content */ @@ -423,8 +419,6 @@ static void prefs_template_window_create(void) G_CALLBACK(manual_open_with_anchor_cb), MANUAL_ANCHOR_TEMPLATES); - address_completion_start(window); - if (!geometry.min_height) { geometry.min_width = 500; geometry.min_height = 540; @@ -474,6 +468,7 @@ static void prefs_template_window_setup(void) GSList *tmpl_list; GSList *cur; Template *tmpl; + int i; manage_window_set_transient(GTK_WINDOW(templates.window)); gtk_widget_grab_focus(templates.ok_btn); @@ -482,6 +477,14 @@ static void prefs_template_window_setup(void) tmpl_list = template_read_config(); + address_completion_start(templates.window); + + for (i=0; widgets_table[i].label; i++) { + if (widgets_table[i].compl) + address_completion_register_entry( + GTK_ENTRY(*(widgets_table[i].entry)), TRUE); + } + for (cur = tmpl_list; cur != NULL; cur = cur->next) { tmpl = (Template *)cur->data; prefs_template_list_view_insert_template(templates.list_view, @@ -497,7 +500,7 @@ static void prefs_template_window_setup(void) static gint prefs_template_deleted_cb(GtkWidget *widget, GdkEventAny *event, gpointer data) { - prefs_template_cancel_cb(); + prefs_template_cancel_cb(NULL, NULL); return TRUE; } @@ -505,7 +508,7 @@ static gboolean prefs_template_key_pressed_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) { if (event && event->keyval == GDK_Escape) - prefs_template_cancel_cb(); + prefs_template_cancel_cb(NULL, NULL); else { GtkWidget *focused = gtkut_get_focused_child( GTK_CONTAINER(widget)); @@ -528,7 +531,7 @@ static void prefs_template_address_completion_end(void) address_completion_end(templates.window); } -static void prefs_template_ok_cb(void) +static void prefs_template_ok_cb(gpointer action, gpointer data) { GSList *tmpl_list; GtkListStore *store; @@ -554,7 +557,7 @@ static void prefs_template_ok_cb(void) inc_unlock(); } -static void prefs_template_cancel_cb(void) +static void prefs_template_cancel_cb(gpointer action, gpointer data) { GtkListStore *store; @@ -799,13 +802,13 @@ static gboolean prefs_template_list_view_set_row(gint row) return TRUE; } -static void prefs_template_register_cb(void) +static void prefs_template_register_cb(gpointer action, gpointer data) { modified = !prefs_template_list_view_set_row(-1); modified_list = TRUE; } -static void prefs_template_substitute_cb(void) +static void prefs_template_substitute_cb(gpointer action, gpointer data) { Template *tmpl; gint row; @@ -828,7 +831,7 @@ static void prefs_template_substitute_cb(void) modified_list = TRUE; } -static void prefs_template_delete_cb(void) +static void prefs_template_delete_cb(gpointer action, gpointer data) { Template *tmpl; gint row; @@ -857,7 +860,7 @@ static void prefs_template_delete_cb(void) modified_list = TRUE; } -static void prefs_template_delete_all_cb(void) +static void prefs_template_delete_all_cb(gpointer action, gpointer data) { GtkListStore *list_store; @@ -874,7 +877,7 @@ static void prefs_template_delete_all_cb(void) modified_list = TRUE; } -static void prefs_template_duplicate_cb(void) +static void prefs_template_duplicate_cb(gpointer action, gpointer data) { Template *tmpl; gint row; @@ -896,12 +899,12 @@ static void prefs_template_duplicate_cb(void) modified_list = !prefs_template_list_view_set_row(-row-2); } -static void prefs_template_clear_cb(void) +static void prefs_template_clear_cb(gpointer action, gpointer data) { prefs_template_reset_dialog(); } -static void prefs_template_top_cb(void) +static void prefs_template_top_cb(gpointer action, gpointer data) { gint row; GtkTreeIter top, sel; @@ -922,7 +925,7 @@ static void prefs_template_top_cb(void) modified_list = TRUE; } -static void prefs_template_up_cb(void) +static void prefs_template_up_cb(gpointer action, gpointer data) { gint row; GtkTreeIter top, sel; @@ -943,7 +946,7 @@ static void prefs_template_up_cb(void) modified_list = TRUE; } -static void prefs_template_down_cb(void) +static void prefs_template_down_cb(gpointer action, gpointer data) { gint row, n_rows; GtkTreeIter top, sel; @@ -964,7 +967,7 @@ static void prefs_template_down_cb(void) modified_list = TRUE; } -static void prefs_template_bottom_cb(void) +static void prefs_template_bottom_cb(gpointer action, gpointer data) { gint row, n_rows; GtkTreeIter top, sel; @@ -1050,14 +1053,15 @@ static void prefs_template_list_view_insert_template(GtkWidget *list_view, } } -static GtkItemFactory *prefs_template_popup_factory = NULL; +static GtkActionGroup *prefs_template_popup_action = NULL; static GtkWidget *prefs_template_popup_menu = NULL; -static GtkItemFactoryEntry prefs_template_popup_entries[] = +static GtkActionEntry prefs_template_popup_entries[] = { - {N_("/_Delete"), NULL, prefs_template_delete_cb, 0, NULL, NULL}, - {N_("/Delete _all"), NULL, prefs_template_delete_all_cb, 0, NULL, NULL}, - {N_("/D_uplicate"), NULL, prefs_template_duplicate_cb, 0, NULL, NULL}, + {"PrefsTemplatePopup", NULL, "PrefsTemplatePopup" }, + {"PrefsTemplatePopup/Delete", NULL, N_("_Delete"), NULL, NULL, G_CALLBACK(prefs_template_delete_cb) }, + {"PrefsTemplatePopup/DeleteAll", NULL, N_("Delete _all"), NULL, NULL, G_CALLBACK(prefs_template_delete_all_cb) }, + {"PrefsTemplatePopup/Duplicate", NULL, N_("D_uplicate"), NULL, NULL, G_CALLBACK(prefs_template_duplicate_cb) }, }; static gint prefs_template_list_btn_pressed(GtkWidget *widget, GdkEventButton *event, @@ -1083,24 +1087,27 @@ static gint prefs_template_list_btn_pressed(GtkWidget *widget, GdkEventButton *e gint row; if (!prefs_template_popup_menu) { - gint n_entries = sizeof(prefs_template_popup_entries) / - sizeof(prefs_template_popup_entries[0]); - prefs_template_popup_menu = menu_create_items(prefs_template_popup_entries, - n_entries, "", - &prefs_template_popup_factory, list_view); + prefs_template_popup_action = cm_menu_create_action_group("PrefsTemplatePopup", prefs_template_popup_entries, + G_N_ELEMENTS(prefs_template_popup_entries), (gpointer)list_view); + MENUITEM_ADDUI("/Menus", "PrefsTemplatePopup", "PrefsTemplatePopup", GTK_UI_MANAGER_MENU) + MENUITEM_ADDUI("/Menus/PrefsTemplatePopup", "Delete", "PrefsTemplatePopup/Delete", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/PrefsTemplatePopup", "DeleteAll", "PrefsTemplatePopup/DeleteAll", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/PrefsTemplatePopup", "Duplicate", "PrefsTemplatePopup/Duplicate", GTK_UI_MANAGER_MENUITEM) + prefs_template_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/PrefsTemplatePopup")) ); } /* grey out some popup menu items if there is no selected row */ row = gtkut_list_view_get_selected_row(GTK_WIDGET(list_view)); - menu_set_sensitive(prefs_template_popup_factory, "/Delete", (row > 0)); - menu_set_sensitive(prefs_template_popup_factory, "/Duplicate", (row > 0)); + cm_menu_set_sensitive("PrefsTemplatePopup/Delete", (row > 0)); + cm_menu_set_sensitive("PrefsTemplatePopup/Duplicate", (row > 0)); /* grey out seom popup menu items if there is no row (not counting the (New) one at row 0) */ non_empty = gtk_tree_model_get_iter_first(model, &iter); if (non_empty) non_empty = gtk_tree_model_iter_next(model, &iter); - menu_set_sensitive(prefs_template_popup_factory, "/Delete all", non_empty); + cm_menu_set_sensitive("PrefsTemplatePopup/DeleteAll", non_empty); gtk_menu_popup(GTK_MENU(prefs_template_popup_menu), NULL, NULL, NULL, NULL, diff --git a/src/summaryview.c b/src/summaryview.c index 05cf06f08..25116b9e2 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -802,14 +802,12 @@ SummaryView *summary_create(void) G_CALLBACK(tog_searchbar_cb), summaryview); /* create popup menu */ - summaryview->action_group = gtk_action_group_new("SummaryViewPopup"); - gtk_action_group_add_actions(summaryview->action_group, summary_popup_entries, + summaryview->action_group = cm_menu_create_action_group("SummaryViewPopup", summary_popup_entries, G_N_ELEMENTS(summary_popup_entries), (gpointer)summaryview); #ifndef GENERIC_UMPC gtk_action_group_add_toggle_actions(summaryview->action_group, summary_popup_toggleentries, G_N_ELEMENTS(summary_popup_toggleentries), (gpointer)summaryview); #endif - gtk_ui_manager_insert_action_group(gtkut_ui_manager(), summaryview->action_group, 0); MENUITEM_ADDUI("/Menus", "SummaryViewPopup", "SummaryViewPopup", GTK_UI_MANAGER_MENU) MENUITEM_ADDUI("/Menus/SummaryViewPopup", "Reply", "SummaryViewPopup/Reply", GTK_UI_MANAGER_MENUITEM) @@ -1771,9 +1769,6 @@ void summary_set_menu_sensitive(SummaryView *summaryview) { SensitiveCond state; gboolean sensitive; -#ifndef GENERIC_UMPC - GtkWidget *menuitem; -#endif gint i; static const struct { @@ -1850,13 +1845,11 @@ void summary_set_menu_sensitive(SummaryView *summaryview) summary_lock(summaryview); #ifndef GENERIC_UMPC - menuitem = gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/SummaryViewPopup/View/AllHeaders"); if (summaryview->messageview && summaryview->messageview->mimeview && summaryview->messageview->mimeview->textview) - gtk_check_menu_item_set_active - (GTK_CHECK_MENU_ITEM(menuitem), - summaryview->messageview->mimeview->textview->show_all_headers); + cm_toggle_menu_set_active("SummaryViewPopup/View/AllHeaders", + summaryview->messageview->mimeview->textview->show_all_headers); #endif summary_unlock(summaryview); } diff --git a/src/textview.c b/src/textview.c index f64a3f7b7..0cb5542cd 100644 --- a/src/textview.c +++ b/src/textview.c @@ -187,46 +187,42 @@ static void textview_toggle_quote (TextView *textview, ClickableText *uri, gboolean expand_only); -static void open_uri_cb (TextView *textview, - guint action, - void *data); -static void copy_uri_cb (TextView *textview, - guint action, - void *data); -static void add_uri_to_addrbook_cb (TextView *textview, - guint action, - void *data); -static void mail_to_uri_cb (TextView *textview, - guint action, - void *data); -static void copy_mail_to_uri_cb (TextView *textview, - guint action, - void *data); -static void save_file_cb (TextView *textview, - guint action, - void *data); -static void open_image_cb (TextView *textview, - guint action, - void *data); +static void open_uri_cb (GtkAction *action, + TextView *textview); +static void copy_uri_cb (GtkAction *action, + TextView *textview); +static void add_uri_to_addrbook_cb (GtkAction *action, + TextView *textview); +static void mail_to_uri_cb (GtkAction *action, + TextView *textview); +static void copy_mail_to_uri_cb (GtkAction *action, + TextView *textview); +static void save_file_cb (GtkAction *action, + TextView *textview); +static void open_image_cb (GtkAction *action, + TextView *textview); static void textview_show_tags(TextView *textview); -static GtkItemFactoryEntry textview_link_popup_entries[] = +static GtkActionEntry textview_link_popup_entries[] = { - {N_("/_Open with Web browser"), NULL, open_uri_cb, 0, NULL}, - {N_("/Copy this _link"), NULL, copy_uri_cb, 0, NULL}, + {"TextviewPopupLink", NULL, "TextviewPopupLink" }, + {"TextviewPopupLink/Open", NULL, N_("_Open in web browser"), NULL, NULL, G_CALLBACK(open_uri_cb) }, + {"TextviewPopupLink/Copy", NULL, N_("Copy this _link"), NULL, NULL, G_CALLBACK(copy_uri_cb) }, }; -static GtkItemFactoryEntry textview_mail_popup_entries[] = +static GtkActionEntry textview_mail_popup_entries[] = { - {N_("/Compose _new message"), NULL, mail_to_uri_cb, 0, NULL}, - {N_("/Add to _address book"), NULL, add_uri_to_addrbook_cb, 0, NULL}, - {N_("/Copy this add_ress"), NULL, copy_mail_to_uri_cb, 0, NULL}, + {"TextviewPopupMail", NULL, "TextviewPopupMail" }, + {"TextviewPopupMail/Compose", NULL, N_("Compose _new message"), NULL, NULL, G_CALLBACK(mail_to_uri_cb) }, + {"TextviewPopupMail/AddAB", NULL, N_("Add to _Address book"), NULL, NULL, G_CALLBACK(add_uri_to_addrbook_cb) }, + {"TextviewPopupMail/Copy", NULL, N_("Copy this add_ress"), NULL, NULL, G_CALLBACK(copy_mail_to_uri_cb) }, }; -static GtkItemFactoryEntry textview_file_popup_entries[] = +static GtkActionEntry textview_file_popup_entries[] = { - {N_("/_Open image"), NULL, open_image_cb, 0, NULL}, - {N_("/_Save image..."), NULL, save_file_cb, 0, NULL}, + {"TextviewPopupFile", NULL, "TextviewPopupFile" }, + {"TextviewPopupFile/Open", NULL, N_("_Open image"), NULL, NULL, G_CALLBACK(open_image_cb) }, + {"TextviewPopupFile/Save", NULL, N_("_Save image..."), NULL, NULL, G_CALLBACK(save_file_cb) }, }; static void scrolled_cb (GtkAdjustment *adj, TextView *textview) @@ -261,10 +257,7 @@ TextView *textview_create(void) GtkWidget *text; GtkTextBuffer *buffer; GtkClipboard *clipboard; - GtkItemFactory *link_popupfactory, *mail_popupfactory, *file_popupfactory; - GtkWidget *link_popupmenu, *mail_popupmenu, *file_popupmenu; GtkAdjustment *adj; - gint n_entries; debug_print("Creating text view...\n"); textview = g_new0(TextView, 1); @@ -322,23 +315,35 @@ TextView *textview_create(void) gtk_widget_show(vbox); - n_entries = sizeof(textview_link_popup_entries) / - sizeof(textview_link_popup_entries[0]); - link_popupmenu = menu_create_items(textview_link_popup_entries, n_entries, - "", &link_popupfactory, - textview); - - n_entries = sizeof(textview_mail_popup_entries) / - sizeof(textview_mail_popup_entries[0]); - mail_popupmenu = menu_create_items(textview_mail_popup_entries, n_entries, - "", &mail_popupfactory, - textview); - - n_entries = sizeof(textview_file_popup_entries) / - sizeof(textview_file_popup_entries[0]); - file_popupmenu = menu_create_items(textview_file_popup_entries, n_entries, - "", &file_popupfactory, - textview); + + textview->link_action_group = cm_menu_create_action_group("TextviewPopupLink", + textview_link_popup_entries, + G_N_ELEMENTS(textview_link_popup_entries), (gpointer)textview); + textview->mail_action_group = cm_menu_create_action_group("TextviewPopupMail", + textview_mail_popup_entries, + G_N_ELEMENTS(textview_mail_popup_entries), (gpointer)textview); + textview->file_action_group = cm_menu_create_action_group("TextviewPopupFile", + textview_file_popup_entries, + G_N_ELEMENTS(textview_file_popup_entries), (gpointer)textview); + + MENUITEM_ADDUI("/Menus", "TextviewPopupLink", "TextviewPopupLink", GTK_UI_MANAGER_MENU) + MENUITEM_ADDUI("/Menus", "TextviewPopupMail", "TextviewPopupMail", GTK_UI_MANAGER_MENU) + MENUITEM_ADDUI("/Menus", "TextviewPopupFile", "TextviewPopupFile", GTK_UI_MANAGER_MENU) + + MENUITEM_ADDUI("/Menus/TextviewPopupLink", "Open", "TextviewPopupLink/Open", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TextviewPopupLink", "Copy", "TextviewPopupLink/Copy", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TextviewPopupMail", "Compose", "TextviewPopupMail/Compose", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TextviewPopupMail", "AddAB", "TextviewPopupMail/AddAB", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TextviewPopupMail", "Copy", "TextviewPopupMail/Copy", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TextviewPopupFile", "Open", "TextviewPopupFile/Open", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI("/Menus/TextviewPopupFile", "Save", "TextviewPopupFile/Save", GTK_UI_MANAGER_MENUITEM) + + textview->link_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TextviewPopupLink")) ); + textview->mail_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TextviewPopupMail")) ); + textview->file_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM( + gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TextviewPopupFile")) ); textview->vbox = vbox; textview->scrolledwin = scrolledwin; @@ -347,12 +352,6 @@ TextView *textview_create(void) textview->body_pos = 0; textview->show_all_headers = FALSE; textview->last_buttonpress = GDK_NOTHING; - textview->link_popup_menu = link_popupmenu; - textview->link_popup_factory = link_popupfactory; - textview->mail_popup_menu = mail_popupmenu; - textview->mail_popup_factory = mail_popupfactory; - textview->file_popup_menu = file_popupmenu; - textview->file_popup_factory = file_popupfactory; textview->image = NULL; return textview; } @@ -2806,21 +2805,28 @@ static void textview_uri_list_remove_all(GSList *uri_list) g_slist_free(uri_list); } -static void open_uri_cb (TextView *textview, guint action, void *data) +static void open_uri_cb (GtkAction *action, TextView *textview) { ClickableText *uri = g_object_get_data(G_OBJECT(textview->link_popup_menu), "menu_button"); - if (uri == NULL) - return; + const gchar *raw_url = g_object_get_data(G_OBJECT(textview->link_popup_menu), + "raw_url"); - if (textview_uri_security_check(textview, uri) == TRUE) - open_uri(uri->uri, - prefs_common_get_uri_cmd()); - g_object_set_data(G_OBJECT(textview->link_popup_menu), "menu_button", - NULL); + if (uri) { + if (textview_uri_security_check(textview, uri) == TRUE) + open_uri(uri->uri, + prefs_common_get_uri_cmd()); + g_object_set_data(G_OBJECT(textview->link_popup_menu), "menu_button", + NULL); + } + if (raw_url) { + open_uri(raw_url, prefs_common_get_uri_cmd()); + g_object_set_data(G_OBJECT(textview->link_popup_menu), "raw_url", + NULL); + } } -static void open_image_cb (TextView *textview, guint action, void *data) +static void open_image_cb (GtkAction *action, TextView *textview) { ClickableText *uri = g_object_get_data(G_OBJECT(textview->file_popup_menu), "menu_button"); @@ -2882,7 +2888,7 @@ static void open_image_cb (TextView *textview, guint action, void *data) NULL); } -static void save_file_cb (TextView *textview, guint action, void *data) +static void save_file_cb (GtkAction *action, TextView *textview) { ClickableText *uri = g_object_get_data(G_OBJECT(textview->file_popup_menu), "menu_button"); @@ -2950,20 +2956,27 @@ static void save_file_cb (TextView *textview, guint action, void *data) NULL); } -static void copy_uri_cb (TextView *textview, guint action, void *data) +static void copy_uri_cb (GtkAction *action, TextView *textview) { ClickableText *uri = g_object_get_data(G_OBJECT(textview->link_popup_menu), "menu_button"); - if (uri == NULL) - return; - - gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), uri->uri, -1); - gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), uri->uri, -1); - g_object_set_data(G_OBJECT(textview->link_popup_menu), "menu_button", + const gchar *raw_url = g_object_get_data(G_OBJECT(textview->link_popup_menu), + "raw_url"); + if (uri) { + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), uri->uri, -1); + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), uri->uri, -1); + g_object_set_data(G_OBJECT(textview->link_popup_menu), "menu_button", NULL); + } + if (raw_url) { + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), raw_url, -1); + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), raw_url, -1); + g_object_set_data(G_OBJECT(textview->link_popup_menu), "raw_url", + NULL); + } } -static void add_uri_to_addrbook_cb (TextView *textview, guint action, void *data) +static void add_uri_to_addrbook_cb (GtkAction *action, TextView *textview) { gchar *fromname, *fromaddress; ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu), @@ -3009,7 +3022,7 @@ static void add_uri_to_addrbook_cb (TextView *textview, guint action, void *data g_free(fromname); } -static void mail_to_uri_cb (TextView *textview, guint action, void *data) +static void mail_to_uri_cb (GtkAction *action, TextView *textview) { PrefsAccount *account = NULL; ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu), @@ -3031,7 +3044,7 @@ static void mail_to_uri_cb (TextView *textview, guint action, void *data) } } -static void copy_mail_to_uri_cb (TextView *textview, guint action, void *data) +static void copy_mail_to_uri_cb (GtkAction *action, TextView *textview) { ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu), "menu_button"); diff --git a/src/textview.h b/src/textview.h index c4534135b..3c5e15d77 100644 --- a/src/textview.h +++ b/src/textview.h @@ -57,12 +57,12 @@ struct _TextView GtkWidget *scrolledwin; GtkWidget *text; + GtkActionGroup *link_action_group; GtkWidget *link_popup_menu; - GtkItemFactory *link_popup_factory; + GtkActionGroup *mail_action_group; GtkWidget *mail_popup_menu; - GtkItemFactory *mail_popup_factory; + GtkActionGroup *file_action_group; GtkWidget *file_popup_menu; - GtkItemFactory *file_popup_factory; gboolean default_text; gboolean is_in_signature; diff --git a/src/toolbar.c b/src/toolbar.c index 3ff47cb83..be79107b1 100644 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -91,9 +91,9 @@ static void activate_compose_button (Toolbar *toolbar, /* toolbar callbacks */ static void toolbar_reply (gpointer data, - guint action); + guint action); static void toolbar_learn (gpointer data, - guint action); + guint action); static void toolbar_delete_cb (GtkWidget *widget, gpointer data); static void toolbar_trash_cb (GtkWidget *widget, @@ -230,40 +230,6 @@ struct { { "toolbar_compose.xml", NULL}, { "toolbar_msgview.xml", NULL} }; -#ifndef GENERIC_UMPC -static GtkItemFactoryEntry reply_entries[] = -{ - {N_("/Reply with _quote"), NULL, toolbar_reply, COMPOSE_REPLY_WITH_QUOTE, NULL}, - {N_("/_Reply without quote"), NULL, toolbar_reply, COMPOSE_REPLY_WITHOUT_QUOTE, NULL} -}; -static GtkItemFactoryEntry replyall_entries[] = -{ - {N_("/Reply to all with _quote"), "A", toolbar_reply, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL}, - {N_("/_Reply to all without quote"), "a", toolbar_reply, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL} -}; -static GtkItemFactoryEntry replylist_entries[] = -{ - {N_("/Reply to list with _quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL}, - {N_("/_Reply to list without quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL} -}; -static GtkItemFactoryEntry replysender_entries[] = -{ - {N_("/Reply to sender with _quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL}, - {N_("/_Reply to sender without quote"), NULL, toolbar_reply, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL} -}; -static GtkItemFactoryEntry forward_entries[] = -{ - {N_("/_Forward"), "f", toolbar_reply, COMPOSE_FORWARD_INLINE, NULL}, - {N_("/For_ward as attachment"), "F", toolbar_reply, COMPOSE_FORWARD_AS_ATTACH, NULL}, - {N_("/Redirec_t"), NULL, toolbar_reply, COMPOSE_REDIRECT, NULL} -}; -#endif -static GtkItemFactoryEntry learn_entries[] = -{ - {N_("/Learn as _Spam"), NULL, toolbar_learn, TRUE, NULL}, - {N_("/Learn as _Ham"), NULL, toolbar_learn, FALSE, NULL} -}; - gint toolbar_ret_val_from_descr(const gchar *descr) { @@ -1273,8 +1239,8 @@ static void toolbar_learn_cb(GtkWidget *widget, gpointer data) */ static void toolbar_reply_cb(GtkWidget *widget, gpointer data) { - toolbar_reply(data, prefs_common.reply_with_quote ? - COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE); + toolbar_reply(data, (prefs_common.reply_with_quote ? + COMPOSE_REPLY_WITH_QUOTE : COMPOSE_REPLY_WITHOUT_QUOTE)); } @@ -1284,8 +1250,8 @@ static void toolbar_reply_cb(GtkWidget *widget, gpointer data) static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data) { toolbar_reply(data, - prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE - : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE); + (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE + : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE)); } @@ -1295,8 +1261,8 @@ static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data) static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data) { toolbar_reply(data, - prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE - : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE); + (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE + : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE)); } @@ -1306,8 +1272,8 @@ static void toolbar_reply_to_list_cb(GtkWidget *widget, gpointer data) static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data) { toolbar_reply(data, - prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE - : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE); + (prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE + : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE)); } /* @@ -1340,7 +1306,7 @@ static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data) */ static void toolbar_forward_cb(GtkWidget *widget, gpointer data) { - toolbar_reply(data, COMPOSE_FORWARD); + toolbar_reply(data, (COMPOSE_FORWARD)); } /* @@ -1816,11 +1782,30 @@ static void toolbar_buttons_cb(GtkWidget *widget, } #endif -#define MAKE_MENU(entries,path,btn) { \ - n_menu_entries = sizeof(entries) / \ - sizeof(entries[0]); \ - menu = menu_create_items(entries, n_menu_entries, path, &factory, toolbar_item); \ - gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(btn), menu); \ +#define ADD_MENU_ITEM(name,cb,data) { \ + item = gtk_menu_item_new_with_mnemonic(name); \ + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); \ + g_signal_connect(G_OBJECT(item), "activate", \ + G_CALLBACK(cb), \ + toolbar_item); \ + g_object_set_data(G_OBJECT(item), "int-value", GINT_TO_POINTER(data)); \ + gtk_widget_show(item); \ +} + +static void toolbar_reply_menu_cb(GtkWidget *widget, gpointer data) +{ + gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value"); + ToolbarItem *toolbar_item = (ToolbarItem *)data; + + toolbar_reply(toolbar_item, GPOINTER_TO_INT(int_value)); +} + +static void toolbar_learn_menu_cb(GtkWidget *widget, gpointer data) +{ + gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value"); + ToolbarItem *toolbar_item = (ToolbarItem *)data; + + toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value)); } /** @@ -1839,13 +1824,11 @@ Toolbar *toolbar_create(ToolbarType type, GtkWidget *icon_news; GtkWidget *icon_ham; GtkWidget *item; - GtkWidget *menu; - guint n_menu_entries; - GtkItemFactory *factory; ToolbarClawsActions *action_item; GSList *cur; GSList *toolbar_list; Toolbar *toolbar_data; + GtkWidget *menu; #ifndef GENERIC_UMPC #if !(GTK_CHECK_VERSION(2,12,0)) GtkTooltips *toolbar_tips = gtk_tooltips_new(); @@ -1948,7 +1931,10 @@ Toolbar *toolbar_create(ToolbarType type, toolbar_data->learn_ham_icon = icon_ham; g_object_ref(toolbar_data->learn_ham_icon); - MAKE_MENU(learn_entries,"",toolbar_data->learn_spam_btn); + menu = gtk_menu_new(); + ADD_MENU_ITEM(_("Learn as _Spam"), toolbar_learn_menu_cb, TRUE); + ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE); + gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu); break; case A_REPLY_MESSAGE: #ifndef GENERIC_UMPC @@ -1957,7 +1943,10 @@ Toolbar *toolbar_create(ToolbarType type, _("Reply to Message options")); toolbar_data->reply_btn = item; - MAKE_MENU(reply_entries,"",toolbar_data->reply_btn); + menu = gtk_menu_new(); + ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITH_QUOTE); + ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_WITHOUT_QUOTE); + gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->reply_btn), menu); #else TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Reply to Message")); @@ -1971,7 +1960,10 @@ Toolbar *toolbar_create(ToolbarType type, _("Reply to Sender options")); toolbar_data->replysender_btn = item; - MAKE_MENU(replysender_entries,"",toolbar_data->replysender_btn); + menu = gtk_menu_new(); + ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE); + ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE); + gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replysender_btn), menu); #else TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Reply to Sender")); @@ -1985,7 +1977,10 @@ Toolbar *toolbar_create(ToolbarType type, _("Reply to All options")); toolbar_data->replyall_btn = item; - MAKE_MENU(replyall_entries,"",toolbar_data->replyall_btn); + menu = gtk_menu_new(); + ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE); + ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE); + gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replyall_btn), menu); #else TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Reply to All")); @@ -1999,7 +1994,10 @@ Toolbar *toolbar_create(ToolbarType type, _("Reply to Mailing-list options")); toolbar_data->replylist_btn = item; - MAKE_MENU(replylist_entries,"",toolbar_data->replylist_btn); + menu = gtk_menu_new(); + ADD_MENU_ITEM(_("_Reply with quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE); + ADD_MENU_ITEM(_("Reply without _quote"), toolbar_reply_menu_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE); + gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->replylist_btn), menu); #else TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Reply to Mailing-list")); @@ -2013,7 +2011,11 @@ Toolbar *toolbar_create(ToolbarType type, _("Forward Message options")); toolbar_data->fwd_btn = item; - MAKE_MENU(forward_entries,"",toolbar_data->fwd_btn); + menu = gtk_menu_new(); + ADD_MENU_ITEM(_("_Forward"), toolbar_reply_menu_cb, COMPOSE_FORWARD_INLINE); + ADD_MENU_ITEM(_("For_ward as attachment"), toolbar_reply_menu_cb, COMPOSE_FORWARD_AS_ATTACH); + ADD_MENU_ITEM(_("Redirec_t"), toolbar_reply_menu_cb, COMPOSE_REDIRECT); + gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->fwd_btn), menu); #else TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Forward Message"));