aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2012-03-26 05:41:49 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2012-03-26 05:41:49 +0000
commitc0e22aef9eecfddde486a62a4d366edd45d86d00 (patch)
treeda055d82ef1c632429fda4a701fb4ce3161085cc
parent7eba3af6a0470bf25ec360cc714c1ffd75cb3e7d (diff)
src/folderview.c: enabled menu popup with Menu key.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3029 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog5
-rw-r--r--src/folderview.c19
-rw-r--r--src/menu.c41
-rw-r--r--src/menu.h5
4 files changed, 61 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 42feb4f2..d5a59af6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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;
}
diff --git a/src/menu.c b/src/menu.c
index f956b312..82034dfb 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -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)
{
diff --git a/src/menu.h b/src/menu.h
index 270d7b49..a099df8d 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -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,