[evolution/gnome-3-22] Bug 489466 - Right-clicking empty space in an ETable does not show context menu



commit 93228a24c007c35af071730ab5ba296935b77391
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jan 4 14:14:48 2017 +0100

    Bug 489466 - Right-clicking empty space in an ETable does not show context menu

 calendar/gui/e-cal-list-view.c |   41 +++++++++++++++++++++++++++++++++++----
 calendar/gui/e-memo-table.c    |   28 +++++++++++++++++++++++++++
 calendar/gui/e-task-table.c    |   32 ++++++++++++++++++++++++++++--
 3 files changed, 93 insertions(+), 8 deletions(-)
---
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index 1cbd114..929452a 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -55,12 +55,11 @@ static gboolean  e_cal_list_view_get_visible_time_range (ECalendarView *cal_view
 
 static gboolean  e_cal_list_view_popup_menu             (GtkWidget *widget);
 
-static void      e_cal_list_view_show_popup_menu        (ECalListView *cal_list_view, gint row,
-                                                        GdkEvent *event);
 static gboolean  e_cal_list_view_on_table_double_click   (GtkWidget *table, gint row, gint col,
                                                         GdkEvent *event, gpointer data);
 static gboolean  e_cal_list_view_on_table_right_click   (GtkWidget *table, gint row, gint col,
                                                         GdkEvent *event, gpointer data);
+static gboolean  e_cal_list_view_on_table_white_space_event (ETable *table, GdkEvent *event, gpointer data);
 static void e_cal_list_view_cursor_change_cb (ETable *etable, gint row, gpointer data);
 
 G_DEFINE_TYPE (ECalListView, e_cal_list_view, E_TYPE_CALENDAR_VIEW)
@@ -306,6 +305,10 @@ setup_e_table (ECalListView *cal_list_view)
                cal_list_view->table, "right-click",
                G_CALLBACK (e_cal_list_view_on_table_right_click),
                cal_list_view);
+       g_signal_connect (
+               cal_list_view->table, "white-space-event",
+               G_CALLBACK (e_cal_list_view_on_table_white_space_event),
+               cal_list_view);
        g_signal_connect_after (
                cal_list_view->table, "cursor_change",
                G_CALLBACK (e_cal_list_view_cursor_change_cb),
@@ -362,7 +365,6 @@ e_cal_list_view_dispose (GObject *object)
 
 static void
 e_cal_list_view_show_popup_menu (ECalListView *cal_list_view,
-                                 gint row,
                                  GdkEvent *event)
 {
        e_calendar_view_popup_event (E_CALENDAR_VIEW (cal_list_view), event);
@@ -373,7 +375,7 @@ e_cal_list_view_popup_menu (GtkWidget *widget)
 {
        ECalListView *cal_list_view = E_CAL_LIST_VIEW (widget);
 
-       e_cal_list_view_show_popup_menu (cal_list_view, -1, NULL);
+       e_cal_list_view_show_popup_menu (cal_list_view, NULL);
        return TRUE;
 }
 
@@ -402,11 +404,40 @@ e_cal_list_view_on_table_right_click (GtkWidget *table,
 {
        ECalListView *cal_list_view = E_CAL_LIST_VIEW (data);
 
-       e_cal_list_view_show_popup_menu (cal_list_view, row, event);
+       e_cal_list_view_show_popup_menu (cal_list_view, event);
 
        return TRUE;
 }
 
+static gboolean
+e_cal_list_view_on_table_white_space_event (ETable *table,
+                                           GdkEvent *event,
+                                           gpointer user_data)
+{
+       ECalListView *cal_list_view = user_data;
+       guint event_button = 0;
+
+       g_return_val_if_fail (E_IS_CAL_LIST_VIEW (cal_list_view), FALSE);
+       g_return_val_if_fail (event != NULL, FALSE);
+
+       if (event->type == GDK_BUTTON_PRESS &&
+           gdk_event_get_button (event, &event_button) &&
+           event_button == 3) {
+               GtkWidget *table_canvas;
+
+               table_canvas = GTK_WIDGET (table->table_canvas);
+
+               if (!gtk_widget_has_focus (table_canvas))
+                       gtk_widget_grab_focus (table_canvas);
+
+               e_cal_list_view_show_popup_menu (cal_list_view, event);
+
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
 static void
 e_cal_list_view_cursor_change_cb (ETable *etable,
                                   gint row,
diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c
index f4309ee..865f990 100644
--- a/calendar/gui/e-memo-table.c
+++ b/calendar/gui/e-memo-table.c
@@ -679,6 +679,33 @@ memo_table_right_click (ETable *table,
        return TRUE;
 }
 
+static gboolean
+memo_table_white_space_event (ETable *table,
+                             GdkEvent *event)
+{
+       guint event_button = 0;
+
+       g_return_val_if_fail (E_IS_MEMO_TABLE (table), FALSE);
+       g_return_val_if_fail (event != NULL, FALSE);
+
+       if (event->type == GDK_BUTTON_PRESS &&
+           gdk_event_get_button (event, &event_button) &&
+           event_button == 3) {
+               GtkWidget *table_canvas;
+
+               table_canvas = GTK_WIDGET (table->table_canvas);
+
+               if (!gtk_widget_has_focus (table_canvas))
+                       gtk_widget_grab_focus (table_canvas);
+
+               memo_table_emit_popup_event (E_MEMO_TABLE (table), event);
+
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
 static void
 memo_table_update_actions (ESelectable *selectable,
                            EFocusTracker *focus_tracker,
@@ -970,6 +997,7 @@ e_memo_table_class_init (EMemoTableClass *class)
        table_class = E_TABLE_CLASS (class);
        table_class->double_click = memo_table_double_click;
        table_class->right_click = memo_table_right_click;
+       table_class->white_space_event = memo_table_white_space_event;
 
        /* Inherited from ESelectableInterface */
        g_object_class_override_property (
diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c
index 2216e06..ae3329e 100644
--- a/calendar/gui/e-task-table.c
+++ b/calendar/gui/e-task-table.c
@@ -116,9 +116,7 @@ static void
 task_table_emit_popup_event (ETaskTable *task_table,
                              GdkEvent *event)
 {
-       guint signal_id = signals[POPUP_EVENT];
-
-       g_signal_emit (task_table, signal_id, 0, event);
+       g_signal_emit (task_table, signals[POPUP_EVENT], 0, event);
 }
 
 static gint
@@ -989,6 +987,33 @@ task_table_right_click (ETable *table,
        return TRUE;
 }
 
+static gboolean
+task_table_white_space_event (ETable *table,
+                             GdkEvent *event)
+{
+       guint event_button = 0;
+
+       g_return_val_if_fail (E_IS_TASK_TABLE (table), FALSE);
+       g_return_val_if_fail (event != NULL, FALSE);
+
+       if (event->type == GDK_BUTTON_PRESS &&
+           gdk_event_get_button (event, &event_button) &&
+           event_button == 3) {
+               GtkWidget *table_canvas;
+
+               table_canvas = GTK_WIDGET (table->table_canvas);
+
+               if (!gtk_widget_has_focus (table_canvas))
+                       gtk_widget_grab_focus (table_canvas);
+
+               task_table_emit_popup_event (E_TASK_TABLE (table), event);
+
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
 static void
 task_table_update_actions (ESelectable *selectable,
                            EFocusTracker *focus_tracker,
@@ -1354,6 +1379,7 @@ e_task_table_class_init (ETaskTableClass *class)
        table_class = E_TABLE_CLASS (class);
        table_class->double_click = task_table_double_click;
        table_class->right_click = task_table_right_click;
+       table_class->white_space_event = task_table_white_space_event;
 
        /* Inherited from ESelectableInterface */
        g_object_class_override_property (


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]