aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog8
-rw-r--r--mail/em-folder-tree.c81
-rw-r--r--mail/em-folder-view.c26
3 files changed, 79 insertions, 36 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index f7a87f5626..d0a57ac3d3 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,11 @@
+2004-10-08 Harry Lu <harry.lu@sun.com>
+
+ * em-folder-tree.c: (em_folder_tree_class_init), (real_popup_menu),
+ (emft_popup_menu), (emft_tree_button_press): implement popup_menu
+ so that popup menu can be shown with Shift+F10 on folder tree.
+ * em-folder-view.c: (emfv_popup), (emfv_list_key_press):
+ same as above.
+
2004-10-07 Not Zed <NotZed@Ximian.com>
* mail-component.c (mc_startup): dont init the base plugin system
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 7cd4a2a07d..c326e8daa4 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -163,6 +163,7 @@ static void emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, Gt
static gboolean emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTree *emft);
static void emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft);
static gboolean emft_tree_user_event (GtkTreeView *treeview, GdkEvent *e, EMFolderTree *emft);
+static gboolean emft_popup_menu (GtkWidget *widget);
struct _emft_selection_data {
GtkTreeModel *model;
@@ -201,11 +202,14 @@ em_folder_tree_class_init (EMFolderTreeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_ref (GTK_TYPE_VBOX);
object_class->finalize = em_folder_tree_finalize;
gtk_object_class->destroy = em_folder_tree_destroy;
+
+ widget_class->popup_menu = emft_popup_menu;
signals[FOLDER_SELECTED] =
g_signal_new ("folder-selected",
@@ -2721,7 +2725,7 @@ emft_popup_properties (EPopup *ep, EPopupItem *pitem, void *data)
g_free (uri);
}
-static EPopupItem emft_popup_menu[] = {
+static EPopupItem emft_popup_items[] = {
#if 0
{ 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 },
@@ -2749,12 +2753,12 @@ emft_popup_free(EPopup *ep, GSList *items, void *data)
}
static gboolean
-emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTree *emft)
+emft_popup (EMFolderTree *emft, GdkEvent *event)
{
+ GtkTreeView *treeview;
GtkTreeSelection *selection;
CamelStore *local, *store;
EMPopupTargetFolder *target;
- GtkTreePath *tree_path;
GtkTreeModel *model;
GtkTreeIter iter;
GSList *menus = NULL;
@@ -2766,29 +2770,13 @@ emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTr
EMPopup *emp;
int i;
+ treeview = emft->priv->treeview;
+
/* this centralises working out when the user's done something */
emft_tree_user_event(treeview, (GdkEvent *)event, emft);
-
- if (event->button != 3 && !(event->button == 1 && event->type == GDK_2BUTTON_PRESS))
- return FALSE;
-
- if (!gtk_tree_view_get_path_at_pos (treeview, (int) event->x, (int) event->y, &tree_path, NULL, NULL, NULL))
- return FALSE;
-
- /* select/focus the row that was right-clicked or double-clicked */
- selection = gtk_tree_view_get_selection (treeview);
- gtk_tree_selection_select_path(selection, tree_path);
- gtk_tree_view_set_cursor (treeview, tree_path, NULL, FALSE);
-
- if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
- emft_tree_row_activated (treeview, tree_path, NULL, emft);
- gtk_tree_path_free (tree_path);
- return TRUE;
- }
-
- gtk_tree_path_free (tree_path);
-
+
/* FIXME: we really need the folderinfo to build a proper menu */
+ selection = gtk_tree_view_get_selection (treeview);
if (!emft_selection_get_selected (selection, &model, &iter))
return FALSE;
@@ -2826,8 +2814,8 @@ emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTr
/* FIXME: pass valid fi->flags here */
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++)
- menus = g_slist_prepend (menus, &emft_popup_menu[i]);
+ for (i = 0; i < sizeof (emft_popup_items) / sizeof (emft_popup_items[0]); i++)
+ menus = g_slist_prepend (menus, &emft_popup_items[i]);
e_popup_add_items ((EPopup *)emp, menus, emft_popup_free, emft);
@@ -2835,17 +2823,54 @@ emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTr
if (event == NULL || event->type == GDK_KEY_PRESS) {
/* FIXME: menu pos function */
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, event->time);
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
} else {
- gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button.button, event->button.time);
}
g_free (full_name);
g_free (uri);
-
+
return TRUE;
}
+static gboolean
+emft_popup_menu (GtkWidget *widget)
+{
+ return emft_popup (EM_FOLDER_TREE (widget), NULL);
+}
+
+static gboolean
+emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTree *emft)
+{
+ GtkTreeSelection *selection;
+ GtkTreePath *tree_path;
+
+ /* this centralises working out when the user's done something */
+ emft_tree_user_event(treeview, (GdkEvent *)event, emft);
+
+ if (event->button != 3 && !(event->button == 1 && event->type == GDK_2BUTTON_PRESS))
+ return FALSE;
+
+ if (!gtk_tree_view_get_path_at_pos (treeview, (int) event->x, (int) event->y, &tree_path, NULL, NULL, NULL))
+ return FALSE;
+
+ /* select/focus the row that was right-clicked or double-clicked */
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_select_path(selection, tree_path);
+ gtk_tree_view_set_cursor (treeview, tree_path, NULL, FALSE);
+
+ if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
+ emft_tree_row_activated (treeview, tree_path, NULL, emft);
+ gtk_tree_path_free (tree_path);
+ return TRUE;
+ }
+
+ gtk_tree_path_free (tree_path);
+
+ return emft_popup (emft, (GdkEvent *)event);
+}
+
/* This is called for keyboard and mouse events, it seems the only way
* we know the user has done something to the selection as opposed to
* code or initialisation processes */
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c
index b59fb0ff5c..ab3de6d597 100644
--- a/mail/em-folder-view.c
+++ b/mail/em-folder-view.c
@@ -121,6 +121,8 @@ static void emfv_setting_setup(EMFolderView *emfv);
static void emfv_on_url_cb(GObject *emitter, const char *url, EMFolderView *emfv);
static void emfv_on_url(EMFolderView *emfv, const char *uri, const char *nice_uri);
+static gboolean emfv_popup_menu (GtkWidget *widget);
+
static const EMFolderViewEnable emfv_enable_map[];
struct _EMFolderViewPrivate {
@@ -266,6 +268,8 @@ emfv_class_init(GObjectClass *klass)
((GtkObjectClass *) klass)->destroy = emfv_destroy;
+ ((GtkWidgetClass *) klass)->popup_menu = emfv_popup_menu;
+
((EMFolderViewClass *) klass)->update_message_style = TRUE;
((EMFolderViewClass *)klass)->set_folder = emfv_set_folder;
@@ -917,7 +921,7 @@ EMFV_POPUP_AUTO_TYPE(filter_type_current, emfv_popup_filter_mlist, AUTO_MLIST)
/* TODO: Move some of these to be 'standard' menu's */
-static EPopupItem emfv_popup_menu[] = {
+static EPopupItem emfv_popup_items[] = {
{ E_POPUP_ITEM, "00.emfv.00", N_("_Open"), emfv_popup_open, NULL, NULL, 0 },
{ E_POPUP_ITEM, "00.emfv.01", N_("_Edit as New Message..."), emfv_popup_edit, NULL, NULL, EM_POPUP_SELECT_EDIT },
{ E_POPUP_ITEM, "00.emfv.02", N_("_Save As..."), emfv_popup_saveas, NULL, "stock_save-as", 0 },
@@ -1011,8 +1015,8 @@ emfv_popup(EMFolderView *emfv, GdkEvent *event)
emp = em_popup_new("com.ximian.mail.folderview.popup.select");
target = em_folder_view_get_popup_target(emfv, emp);
- for (i=0;i<sizeof(emfv_popup_menu)/sizeof(emfv_popup_menu[0]);i++)
- menus = g_slist_prepend(menus, &emfv_popup_menu[i]);
+ for (i=0;i<sizeof(emfv_popup_items)/sizeof(emfv_popup_items[0]);i++)
+ menus = g_slist_prepend(menus, &emfv_popup_items[i]);
e_popup_add_items((EPopup *)emp, menus, emfv_popup_items_free, emfv);
@@ -1052,7 +1056,7 @@ emfv_popup(EMFolderView *emfv, GdkEvent *event)
if (event == NULL || event->type == GDK_KEY_PRESS) {
/* FIXME: menu pos function */
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, event ? event->key.time : time (NULL));
+ gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, event ? event->key.time : gtk_get_current_event_time());
} else {
gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button.button, event->button.time);
}
@@ -2074,10 +2078,6 @@ emfv_list_key_press(ETree *tree, int row, ETreePath path, int col, GdkEvent *ev,
case GDK_ISO_Enter:
em_folder_view_open_selected(emfv);
break;
- case GDK_Menu:
- /* FIXME: location of popup */
- emfv_popup(emfv, NULL);
- break;
case '!':
uids = message_list_get_selected(emfv->list);
@@ -2100,6 +2100,16 @@ emfv_list_key_press(ETree *tree, int row, ETreePath path, int col, GdkEvent *ev,
return TRUE;
}
+static gboolean
+emfv_popup_menu (GtkWidget *widget)
+{
+ EMFolderView *emfv = (EMFolderView *)widget;
+
+ emfv_popup (emfv, NULL);
+
+ return TRUE;
+}
+
static void
emfv_list_selection_change(ETree *tree, EMFolderView *emfv)
{