summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/filebrowser/pluma-file-browser-widget.c8
-rw-r--r--pluma/pluma-documents-panel.c80
-rw-r--r--pluma/pluma-print-preview.c4
-rw-r--r--pluma/pluma-status-combo-box.c40
-rw-r--r--pluma/pluma-utils.c25
-rw-r--r--pluma/pluma-utils.h3
-rw-r--r--pluma/pluma-view.c8
-rw-r--r--pluma/pluma-window.c12
8 files changed, 45 insertions, 135 deletions
diff --git a/plugins/filebrowser/pluma-file-browser-widget.c b/plugins/filebrowser/pluma-file-browser-widget.c
index 7b5f1245..0763e44a 100644
--- a/plugins/filebrowser/pluma-file-browser-widget.c
+++ b/plugins/filebrowser/pluma-file-browser-widget.c
@@ -1375,13 +1375,9 @@ popup_menu (PlumaFileBrowserWidget * obj, GdkEventButton * event, GtkTreeModel *
}
}
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
- event->button, event->time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
} else {
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- pluma_utils_menu_position_under_tree_view,
- obj->priv->treeview, 0,
- gtk_get_current_event_time ());
+ menu_popup_at_treeview_selection (menu, GTK_WIDGET (obj->priv->treeview));
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
}
diff --git a/pluma/pluma-documents-panel.c b/pluma/pluma-documents-panel.c
index 62ded929..d7cbf2b4 100644
--- a/pluma/pluma-documents-panel.c
+++ b/pluma/pluma-documents-panel.c
@@ -491,69 +491,6 @@ pluma_documents_panel_class_init (PlumaDocumentsPanelClass *klass)
g_type_class_add_private (object_class, sizeof (PlumaDocumentsPanelPrivate));
}
-static GtkTreePath *
-get_current_path (PlumaDocumentsPanel *panel)
-{
- gint num;
- GtkWidget *nb;
- GtkTreePath *path;
-
- nb = _pluma_window_get_notebook (panel->priv->window);
- num = gtk_notebook_get_current_page (GTK_NOTEBOOK (nb));
-
- path = gtk_tree_path_new_from_indices (num, -1);
-
- return path;
-}
-
-static void
-menu_position (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- PlumaDocumentsPanel *panel)
-{
- GtkTreePath *path;
- GdkRectangle rect;
- gint wy;
- GtkAllocation allocation;
- GtkRequisition requisition;
- GtkWidget *w;
-
- w = panel->priv->treeview;
-
- gtk_widget_get_allocation(w, &allocation);
-
- path = get_current_path (panel);
-
- gtk_tree_view_get_cell_area (GTK_TREE_VIEW (w),
- path,
- NULL,
- &rect);
-
- wy = rect.y;
-
- gdk_window_get_origin (gtk_widget_get_window (w), x, y);
-
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &requisition);
-
- if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
- {
- *x += allocation.x + allocation.width - requisition.width - 10;
- }
- else
- {
- *x += allocation.x + 10;
- }
-
- wy = MAX (*y + 5, *y + wy + 5);
- wy = MIN (wy, *y + allocation.height - requisition.height - 5);
-
- *y = wy;
-
- *push_in = TRUE;
-}
-
static gboolean
show_popup_menu (PlumaDocumentsPanel *panel,
GdkEventButton *event)
@@ -566,24 +503,11 @@ show_popup_menu (PlumaDocumentsPanel *panel,
if (event != NULL)
{
- gtk_menu_popup (GTK_MENU (menu),
- NULL,
- NULL,
- NULL,
- NULL,
- event->button,
- event->time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
}
else
{
- gtk_menu_popup (GTK_MENU (menu),
- NULL,
- NULL,
- (GtkMenuPositionFunc) menu_position,
- panel,
- 0,
- gtk_get_current_event_time ());
-
+ menu_popup_at_treeview_selection (menu, panel->priv->treeview);
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
}
diff --git a/pluma/pluma-print-preview.c b/pluma/pluma-print-preview.c
index dead7490..3f1c6e13 100644
--- a/pluma/pluma-print-preview.c
+++ b/pluma/pluma-print-preview.c
@@ -498,9 +498,7 @@ multi_button_clicked (GtkWidget *button,
gtk_menu_attach (GTK_MENU (m), i, 1, 2, 1, 2);
g_signal_connect (i, "activate", G_CALLBACK (on_2x2_clicked), preview);
- gtk_menu_popup (GTK_MENU (m),
- NULL, NULL, NULL, preview, 0,
- GDK_CURRENT_TIME);
+ gtk_menu_popup_at_pointer (GTK_MENU (m), NULL);
}
static void
diff --git a/pluma/pluma-status-combo-box.c b/pluma/pluma-status-combo-box.c
index 36b9bd9d..d5c8eaec 100644
--- a/pluma/pluma-status-combo-box.c
+++ b/pluma/pluma-status-combo-box.c
@@ -183,34 +183,6 @@ menu_deactivate (GtkMenu *menu,
}
static void
-menu_position_func (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- PlumaStatusComboBox *combo)
-{
- GtkRequisition request;
- GtkAllocation allocation;
-
- *push_in = FALSE;
-
- gtk_widget_get_preferred_size (gtk_widget_get_toplevel (GTK_WIDGET (menu)), NULL, &request);
-
- /* get the origin... */
- gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (combo)), x, y);
- gtk_widget_get_allocation (GTK_WIDGET (combo), &allocation);
-
- /* make the menu as wide as the widget */
- if (request.width < allocation.width)
- {
- gtk_widget_set_size_request (GTK_WIDGET (menu), allocation.width, -1);
- }
-
- /* position it above the widget */
- *y -= request.height;
-}
-
-static void
button_press_event (GtkWidget *widget,
GdkEventButton *event,
PlumaStatusComboBox *combo)
@@ -231,13 +203,11 @@ button_press_event (GtkWidget *widget,
gtk_widget_set_size_request (gtk_widget_get_toplevel (combo->priv->menu), -1, max_height);
}
- gtk_menu_popup (GTK_MENU (combo->priv->menu),
- NULL,
- NULL,
- (GtkMenuPositionFunc)menu_position_func,
- combo,
- event->button,
- event->time);
+ gtk_menu_popup_at_widget (GTK_MENU (combo->priv->menu),
+ gtk_widget_get_parent (widget),
+ GDK_GRAVITY_NORTH_WEST,
+ GDK_GRAVITY_SOUTH_WEST,
+ (const GdkEvent*) event);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo->priv->button), TRUE);
diff --git a/pluma/pluma-utils.c b/pluma/pluma-utils.c
index e8fa3f55..0e37f92d 100644
--- a/pluma/pluma-utils.c
+++ b/pluma/pluma-utils.c
@@ -202,6 +202,31 @@ pluma_utils_menu_position_under_tree_view (GtkMenu *menu,
}
}
+void
+menu_popup_at_treeview_selection (GtkWidget *menu,
+ GtkWidget *treeview)
+{
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+ GdkWindow *bin_window;
+ GdkRectangle rect;
+
+ gtk_tree_view_get_cursor (GTK_TREE_VIEW (treeview), &path, &column);
+ g_return_if_fail (path != NULL);
+
+ if (column == NULL)
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), 0);
+
+ bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (treeview));
+ gtk_tree_view_get_cell_area (GTK_TREE_VIEW (treeview), path, column, &rect);
+
+ gtk_menu_popup_at_rect (GTK_MENU (menu), bin_window, &rect,
+ GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST,
+ NULL);
+
+ gtk_tree_path_free(path);
+}
+
/**
* pluma_gtk_button_new_with_icon:
* @label:
diff --git a/pluma/pluma-utils.h b/pluma/pluma-utils.h
index dbd7812b..22f03a49 100644
--- a/pluma/pluma-utils.h
+++ b/pluma/pluma-utils.h
@@ -64,6 +64,9 @@ void pluma_utils_menu_position_under_tree_view
gboolean *push_in,
gpointer user_data);
+void menu_popup_at_treeview_selection (GtkWidget *menu,
+ GtkWidget *treeview);
+
GtkWidget *pluma_gtk_button_new_with_icon (const gchar *label,
const gchar *icon_name);
diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c
index c38bdac1..3798b13d 100644
--- a/pluma/pluma-view.c
+++ b/pluma/pluma-view.c
@@ -2014,13 +2014,7 @@ show_line_numbers_menu (GtkWidget *view,
menu = create_line_numbers_menu (view);
- gtk_menu_popup (GTK_MENU (menu),
- NULL,
- NULL,
- NULL,
- NULL,
- event->button,
- event->time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
}
static gboolean
diff --git a/pluma/pluma-window.c b/pluma/pluma-window.c
index f2f5a8ad..7363442c 100644
--- a/pluma/pluma-window.c
+++ b/pluma/pluma-window.c
@@ -3442,9 +3442,7 @@ show_notebook_popup_menu (GtkNotebook *notebook,
#endif
if (event != NULL)
{
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- NULL, NULL,
- event->button, event->time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
}
else
{
@@ -3456,9 +3454,11 @@ show_notebook_popup_menu (GtkNotebook *notebook,
tab_label = gtk_notebook_get_tab_label (notebook, tab);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- pluma_utils_menu_position_under_widget, tab_label,
- 0, gtk_get_current_event_time ());
+ gtk_menu_popup_at_widget (GTK_MENU (menu),
+ tab_label,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ (const GdkEvent*) event);
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
}