diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/folderview.c | 19 | ||||
-rw-r--r-- | src/menu.c | 41 | ||||
-rw-r--r-- | src/menu.h | 5 |
4 files changed, 61 insertions, 9 deletions
@@ -1,3 +1,8 @@ +2012-03-26 + + * src/menu.[ch] + src/folderview.c: enabled menu popup with Menu key. + 2012-03-02 * libsylph/imap.c: relaxed the response check of AUTHENTICATE and diff --git a/src/folderview.c b/src/folderview.c index 69844bb9..252f4268 100644 --- a/src/folderview.c +++ b/src/folderview.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2011 Hiroyuki Yamamoto + * Copyright (C) 1999-2012 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1663,11 +1663,6 @@ static gboolean folderview_menu_popup(FolderView *folderview, gboolean search_folder = FALSE; gboolean folder_property = FALSE; - if (!event) return FALSE; - - if (event->button != 3) - return FALSE; - if (!gtk_tree_selection_get_selected (folderview->selection, NULL, &iter)) return FALSE; @@ -1868,8 +1863,13 @@ static gboolean folderview_menu_popup(FolderView *folderview, syl_plugin_signal_emit("folderview-menu-popup", ifactory); - gtk_menu_popup(GTK_MENU(popup), NULL, NULL, NULL, NULL, - event->button, event->time); + if (event) + gtk_menu_popup(GTK_MENU(popup), NULL, NULL, NULL, NULL, + event->button, event->time); + else + gtk_menu_popup(GTK_MENU(popup), NULL, NULL, + menu_widget_position, folderview->treeview, + 0, GDK_CURRENT_TIME); return FALSE; } @@ -2016,6 +2016,9 @@ static gboolean folderview_key_pressed(GtkWidget *widget, GdkEventKey *event, } } break; + case GDK_Menu: + folderview_menu_popup(folderview, NULL); + return TRUE; default: break; } @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2004 Hiroyuki Yamamoto + * Copyright (C) 1999-2012 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -222,6 +222,45 @@ void menu_button_position(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, *y = ypos; } +void menu_widget_position(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, + gpointer user_data) +{ + GtkWidget *widget; + GtkRequisition requisition; + gint w_xpos, w_ypos; + gint xpos, ypos; + gint width, height; + gint scr_width, scr_height; + + g_return_if_fail(x != NULL && y != NULL && push_in != NULL); + + widget = GTK_WIDGET(user_data); + + gtk_widget_get_child_requisition(GTK_WIDGET(menu), &requisition); + width = requisition.width; + height = requisition.height; + gdk_window_get_origin(widget->window, &w_xpos, &w_ypos); + + xpos = w_xpos; + ypos = w_ypos; + + scr_width = gdk_screen_width(); + scr_height = gdk_screen_height(); + + if (xpos + width > scr_width) + xpos -= (xpos + width) - scr_width; + if (ypos + height > scr_height) + ypos -= height; + if (xpos < 0) + xpos = 0; + if (ypos < 0) + ypos = 0; + + *x = xpos; + *y = ypos; + *push_in = FALSE; +} + gint menu_find_option_menu_index(GtkOptionMenu *optmenu, gpointer data, GCompareFunc func) { @@ -134,6 +134,11 @@ void menu_button_position (GtkMenu *menu, gint *y, gboolean *push_in, gpointer user_data); +void menu_widget_position (GtkMenu *menu, + gint *x, + gint *y, + gboolean *push_in, + gpointer user_data); gint menu_find_option_menu_index(GtkOptionMenu *optmenu, gpointer data, |