diff options
author | Michael Zucci <zucchi@src.gnome.org> | 2004-09-20 13:59:55 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-09-20 13:59:55 +0800 |
commit | ef6a3af717132e0750f226fa8a0ee0f3c98e19f0 (patch) | |
tree | f4ed25f7a247a8ccb855a8d940777e7a3d21a3e3 /mail/em-folder-tree.c | |
parent | 96111b1f1487ca3fe454b340a73ba927cc6bfb83 (diff) | |
download | gsoc2013-evolution-ef6a3af717132e0750f226fa8a0ee0f3c98e19f0.tar.gz gsoc2013-evolution-ef6a3af717132e0750f226fa8a0ee0f3c98e19f0.tar.zst gsoc2013-evolution-ef6a3af717132e0750f226fa8a0ee0f3c98e19f0.zip |
Merged notzed-eplugin-2-branch to head.
svn path=/trunk/; revision=27300
Diffstat (limited to 'mail/em-folder-tree.c')
-rw-r--r-- | mail/em-folder-tree.c | 108 |
1 files changed, 64 insertions, 44 deletions
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 5d8005ed40..5c8c384af8 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -37,6 +37,7 @@ #include <gtk/gtk.h> #include <gdk-pixbuf/gdk-pixbuf.h> +#include <libgnome/gnome-i18n.h> #include <camel/camel-session.h> #include <camel/camel-store.h> @@ -987,36 +988,48 @@ tree_drag_data_action(struct _DragDataReceivedAsync *m) } static void -emft_drop_popup_copy(GtkWidget *item, struct _DragDataReceivedAsync *m) +emft_drop_popup_copy(EPopup *ep, EPopupItem *item, void *data) { + struct _DragDataReceivedAsync *m = data; + m->action = GDK_ACTION_COPY; tree_drag_data_action(m); } static void -emft_drop_popup_move(GtkWidget *item, struct _DragDataReceivedAsync *m) +emft_drop_popup_move(EPopup *ep, EPopupItem *item, void *data) { + struct _DragDataReceivedAsync *m = data; + m->action = GDK_ACTION_MOVE; tree_drag_data_action(m); } static void -emft_drop_popup_cancel(GtkWidget *item, struct _DragDataReceivedAsync *m) +emft_drop_popup_cancel(EPopup *ep, EPopupItem *item, void *data) { + struct _DragDataReceivedAsync *m = data; + m->aborted = TRUE; mail_msg_free(&m->msg); } -static EMPopupItem emft_drop_popup_menu[] = { - { EM_POPUP_ITEM, "00.emc.00", N_("_Copy to Folder"), G_CALLBACK (emft_drop_popup_copy), NULL, NULL, 1 }, - { EM_POPUP_ITEM, "00.emc.01", N_("_Move to Folder"), G_CALLBACK (emft_drop_popup_move), NULL, NULL, 1 }, - { EM_POPUP_ITEM, "00.emc.02", N_("_Copy"), G_CALLBACK (emft_drop_popup_copy), NULL, "stock_folder-copy", 2 }, - { EM_POPUP_ITEM, "00.emc.03", N_("_Move"), G_CALLBACK (emft_drop_popup_move), NULL, "stock_folder-move", 2 }, - { EM_POPUP_BAR, "10.emc" }, - { EM_POPUP_ITEM, "99.emc.00", N_("Cancel _Drag"), G_CALLBACK (emft_drop_popup_cancel), NULL, "stock_cancel", 0 }, +static EPopupItem emft_drop_popup_menu[] = { + { E_POPUP_ITEM, "00.emc.00", N_("_Copy to Folder"), emft_drop_popup_copy, NULL, NULL, 1 }, + { E_POPUP_ITEM, "00.emc.01", N_("_Move to Folder"), emft_drop_popup_move, NULL, NULL, 1 }, + { E_POPUP_ITEM, "00.emc.02", N_("_Copy"), emft_drop_popup_copy, NULL, "stock_folder-copy", 2 }, + { E_POPUP_ITEM, "00.emc.03", N_("_Move"), emft_drop_popup_move, NULL, "stock_folder-move", 2 }, + { E_POPUP_BAR, "10.emc" }, + { E_POPUP_ITEM, "99.emc.00", N_("Cancel _Drag"), emft_drop_popup_cancel, NULL, "stock_cancel", 0 }, }; static void +emft_drop_popup_free(EPopup *ep, GSList *items, void *data) +{ + g_slist_free(items); +} + +static void tree_drag_data_received(GtkWidget *widget, GdkDragContext *context, int x, int y, GtkSelectionData *selection, guint info, guint time, EMFolderTree *emft) { struct _EMFolderTreePrivate *priv = emft->priv; @@ -1082,15 +1095,13 @@ tree_drag_data_received(GtkWidget *widget, GdkDragContext *context, int x, int y mask = ~2; for (i=0;i<sizeof(emft_drop_popup_menu)/sizeof(emft_drop_popup_menu[0]);i++) { - EMPopupItem *item = &emft_drop_popup_menu[i]; + EPopupItem *item = &emft_drop_popup_menu[i]; - if ((item->mask & mask) == 0) { - item->activate_data = m; + if ((item->visible & mask) == 0) menus = g_slist_append(menus, item); - } } - em_popup_add_items(emp, menus, (GDestroyNotify)g_slist_free); - menu = em_popup_create_menu_once(emp, NULL, mask, mask); + e_popup_add_items((EPopup *)emp, menus, emft_drop_popup_free, m); + menu = e_popup_create_menu_once((EPopup *)emp, NULL, mask, mask); gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time()); } else { tree_drag_data_action(m); @@ -2192,8 +2203,9 @@ fail: } static void -emft_popup_copy (GtkWidget *item, EMFolderTree *emft) +emft_popup_copy(EPopup *ep, EPopupItem *item, void *data) { + EMFolderTree *emft = data; struct _copy_folder_data *cfd; cfd = g_malloc (sizeof (*cfd)); @@ -2205,8 +2217,9 @@ emft_popup_copy (GtkWidget *item, EMFolderTree *emft) } static void -emft_popup_move (GtkWidget *item, EMFolderTree *emft) +emft_popup_move(EPopup *ep, EPopupItem *item, void *data) { + EMFolderTree *emft = data; struct _copy_folder_data *cfd; cfd = g_malloc (sizeof (*cfd)); @@ -2419,8 +2432,10 @@ emft_popup_new_folder_response (EMFolderSelector *emfs, int response, EMFolderTr } static void -emft_popup_new_folder (GtkWidget *item, EMFolderTree *emft) +emft_popup_new_folder (EPopup *ep, EPopupItem *pitem, void *data) { + EMFolderTree *emft = data; + EMFolderTree *folder_tree; GtkWidget *dialog; char *uri; @@ -2545,8 +2560,9 @@ emft_popup_delete_response (GtkWidget *dialog, int response, EMFolderTree *emft) } static void -emft_popup_delete_folder (GtkWidget *item, EMFolderTree *emft) +emft_popup_delete_folder (EPopup *ep, EPopupItem *pitem, void *data) { + EMFolderTree *emft = data; struct _EMFolderTreePrivate *priv = emft->priv; GtkTreeSelection *selection; CamelStore *local, *store; @@ -2580,8 +2596,9 @@ emft_popup_delete_folder (GtkWidget *item, EMFolderTree *emft) } static void -emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft) +emft_popup_rename_folder (EPopup *ep, EPopupItem *pitem, void *data) { + EMFolderTree *emft = data; struct _EMFolderTreePrivate *priv = emft->priv; char *prompt, *full_name, *name, *new_name, *uri; GtkTreeSelection *selection; @@ -2676,8 +2693,9 @@ emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft) static void -emft_popup_properties (GtkWidget *item, EMFolderTree *emft) +emft_popup_properties (EPopup *ep, EPopupItem *pitem, void *data) { + EMFolderTree *emft = data; struct _EMFolderTreePrivate *priv = emft->priv; GtkTreeSelection *selection; GtkTreeModel *model; @@ -2693,33 +2711,39 @@ emft_popup_properties (GtkWidget *item, EMFolderTree *emft) g_free (uri); } -static EMPopupItem emft_popup_menu[] = { +static EPopupItem emft_popup_menu[] = { #if 0 - { EM_POPUP_ITEM, "00.emc.00", N_("_View"), G_CALLBACK (emft_popup_view), NULL, NULL, EM_POPUP_FOLDER_SELECT }, - { EM_POPUP_ITEM, "00.emc.01", N_("Open in _New Window"), G_CALLBACK (emft_popup_open_new), NULL, NULL, EM_POPUP_FOLDER_SELECT }, + { E_POPUP_ITEM, "00.emc.00", N_("_View"), emft_popup_view, NULL, NULL, EM_POPUP_FOLDER_SELECT }, + { E_POPUP_ITEM, "00.emc.01", N_("Open in _New Window"), emft_popup_open_new, NULL, NULL, EM_POPUP_FOLDER_SELECT }, - { EM_POPUP_BAR, "10.emc" }, + { E_POPUP_BAR, "10.emc" }, #endif - { EM_POPUP_ITEM, "10.emc.00", N_("_Copy..."), G_CALLBACK (emft_popup_copy), NULL, "stock_folder-copy", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT }, - { EM_POPUP_ITEM, "10.emc.01", N_("_Move..."), G_CALLBACK (emft_popup_move), NULL, "stock_folder-move", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE }, + { E_POPUP_ITEM, "10.emc.00", N_("_Copy..."), emft_popup_copy, NULL, "stock_folder-copy", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT }, + { E_POPUP_ITEM, "10.emc.01", N_("_Move..."), emft_popup_move, NULL, "stock_folder-move", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE }, - { EM_POPUP_BAR, "20.emc" }, + { E_POPUP_BAR, "20.emc" }, /* FIXME: need to disable for nochildren folders */ - { EM_POPUP_ITEM, "20.emc.00", N_("_New Folder..."), G_CALLBACK (emft_popup_new_folder), NULL, "stock_folder", EM_POPUP_FOLDER_INFERIORS }, + { E_POPUP_ITEM, "20.emc.00", N_("_New Folder..."), emft_popup_new_folder, NULL, "stock_folder", EM_POPUP_FOLDER_INFERIORS }, /* FIXME: need to disable for undeletable folders */ - { EM_POPUP_ITEM, "20.emc.01", N_("_Delete"), G_CALLBACK (emft_popup_delete_folder), NULL, "stock_delete", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE }, - { EM_POPUP_ITEM, "20.emc.01", N_("_Rename..."), G_CALLBACK (emft_popup_rename_folder), NULL, NULL, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE }, + { E_POPUP_ITEM, "20.emc.01", N_("_Delete"), emft_popup_delete_folder, NULL, "stock_delete", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE }, + { E_POPUP_ITEM, "20.emc.01", N_("_Rename..."), emft_popup_rename_folder, NULL, NULL, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE }, - { EM_POPUP_BAR, "80.emc" }, - { EM_POPUP_ITEM, "80.emc.00", N_("_Properties"), G_CALLBACK (emft_popup_properties), NULL, "stock_folder-properties", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT } + { E_POPUP_BAR, "80.emc" }, + { E_POPUP_ITEM, "80.emc.00", N_("_Properties"), emft_popup_properties, NULL, "stock_folder-properties", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT } }; +static void +emft_popup_free(EPopup *ep, GSList *items, void *data) +{ + g_slist_free(items); +} + static gboolean emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTree *emft) { GtkTreeSelection *selection; CamelStore *local, *store; - EMPopupTarget *target; + EMPopupTargetFolder *target; GtkTreePath *tree_path; GtkTreeModel *model; GtkTreeIter iter; @@ -2789,18 +2813,14 @@ emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTr emp = em_popup_new ("com.ximian.mail.storageset.popup.select"); /* FIXME: pass valid fi->flags here */ - target = em_popup_target_new_folder (uri, info_flags, flags); + target = em_popup_target_new_folder (emp, uri, info_flags, flags); - for (i = 0; i < sizeof (emft_popup_menu) / sizeof (emft_popup_menu[0]); i++) { - EMPopupItem *item = &emft_popup_menu[i]; - - item->activate_data = emft; - menus = g_slist_prepend (menus, item); - } + for (i = 0; i < sizeof (emft_popup_menu) / sizeof (emft_popup_menu[0]); i++) + menus = g_slist_prepend (menus, &emft_popup_menu[i]); - em_popup_add_items (emp, menus, (GDestroyNotify) g_slist_free); + e_popup_add_items ((EPopup *)emp, menus, emft_popup_free, emft); - menu = em_popup_create_menu_once (emp, target, 0, target->mask); + menu = e_popup_create_menu_once ((EPopup *)emp, (EPopupTarget *)target, 0, target->target.mask); if (event == NULL || event->type == GDK_KEY_PRESS) { /* FIXME: menu pos function */ |