Not Zed, Modified patch for HEAD is attached. Please review it. Thanks! Harry Not Zed wrote:
|
Index: ChangeLog =================================================================== RCS file: /cvs/gnome/evolution/mail/ChangeLog,v retrieving revision 1.3469 diff -u -r1.3469 ChangeLog --- ChangeLog 7 Oct 2004 08:20:49 -0000 1.3469 +++ ChangeLog 8 Oct 2004 07:12:38 -0000 @@ -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 Index: em-folder-tree.c =================================================================== RCS file: /cvs/gnome/evolution/mail/em-folder-tree.c,v retrieving revision 1.131 diff -u -r1.131 em-folder-tree.c --- em-folder-tree.c 7 Oct 2004 01:32:09 -0000 1.131 +++ em-folder-tree.c 8 Oct 2004 07:12:38 -0000 @@ -163,6 +163,7 @@ 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 @@ { 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 @@ 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 @@ } 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,10 @@ EMPopup *emp; int i; - /* 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); - + treeview = emft->priv->treeview; + /* 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 +2811,8 @@ /* 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,15 +2820,52 @@ 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, GDK_CURRENT_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 Index: em-folder-view.c =================================================================== RCS file: /cvs/gnome/evolution/mail/em-folder-view.c,v retrieving revision 1.87 diff -u -r1.87 em-folder-view.c --- em-folder-view.c 7 Oct 2004 01:32:09 -0000 1.87 +++ em-folder-view.c 8 Oct 2004 07:12:38 -0000 @@ -121,6 +121,8 @@ 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 @@ ((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 @@ /* 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 @@ 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 @@ 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 : GDK_CURRENT_TIME); } else { gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button.button, event->button.time); } @@ -2074,10 +2078,6 @@ 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); @@ -2097,6 +2097,16 @@ return FALSE; } + return TRUE; +} + +static gboolean +emfv_popup_menu (GtkWidget *widget) +{ + EMFolderView *emfv = (EMFolderView *)widget; + + emfv_popup (emfv, NULL); + return TRUE; }