Thanks, A couple of minor things in-line below. On Fri, 2004-10-08 at 15:21 +0800, Harry Lu wrote: Not Zed, no need to rename this. #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); Do we still get a key pressed event? If the popup thing swallows that event and we don't get a key-press-event, then we need to keep this emft_tree_user_event thing here, since it is used to flush pending changes if the user does something while the tree is loading. It can just pass NULL as the event pointer. - 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); you should use gtk_get_current_event_time() here rather than 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]); again, no need to rename these labels. 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); same with the gtk_get_current_event_time thing. } 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; }
|