[gtk+/wip/attach-params: 21/22] gtkcolorsel: use gtk_menu_popup_with_params ()
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/attach-params: 21/22] gtkcolorsel: use gtk_menu_popup_with_params ()
- Date: Wed, 20 Jan 2016 08:23:41 +0000 (UTC)
commit 58725ce50184029cba775c8d6aedad6c93331c3e
Author: William Hua <william hua canonical com>
Date: Wed Jan 20 02:20:20 2016 -0600
gtkcolorsel: use gtk_menu_popup_with_params ()
https://bugzilla.gnome.org/show_bug.cgi?id=756579
gtk/deprecated/gtkcolorsel.c | 55 +++++++++++++----------------------------
1 files changed, 18 insertions(+), 37 deletions(-)
---
diff --git a/gtk/deprecated/gtkcolorsel.c b/gtk/deprecated/gtkcolorsel.c
index 730b2b8..548ae57 100644
--- a/gtk/deprecated/gtkcolorsel.c
+++ b/gtk/deprecated/gtkcolorsel.c
@@ -1422,40 +1422,6 @@ palette_set_color (GtkWidget *drawing_area,
}
static void
-popup_position_func (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- GtkAllocation allocation;
- GtkWidget *widget;
- GtkRequisition req;
- gint root_x, root_y;
- GdkScreen *screen;
-
- widget = GTK_WIDGET (user_data);
-
- g_return_if_fail (gtk_widget_get_realized (widget));
-
- gdk_window_get_origin (gtk_widget_get_window (widget),
- &root_x, &root_y);
-
- gtk_widget_get_preferred_size (GTK_WIDGET (menu),
- &req, NULL);
- gtk_widget_get_allocation (widget, &allocation);
-
- /* Put corner of menu centered on color cell */
- *x = root_x + allocation.width / 2;
- *y = root_y + allocation.height / 2;
-
- /* Ensure sanity */
- screen = gtk_widget_get_screen (widget);
- *x = CLAMP (*x, 0, MAX (0, gdk_screen_get_width (screen) - req.width));
- *y = CLAMP (*y, 0, MAX (0, gdk_screen_get_height (screen) - req.height));
-}
-
-static void
save_color_selected (GtkWidget *menuitem,
gpointer data)
{
@@ -1480,6 +1446,7 @@ do_popup (GtkColorSelection *colorsel,
{
GtkWidget *menu;
GtkWidget *mi;
+ GdkAttachParams *params;
g_object_set_data (G_OBJECT (drawing_area),
I_("gtk-color-sel"),
@@ -1498,9 +1465,23 @@ do_popup (GtkColorSelection *colorsel,
gtk_widget_show_all (mi);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- popup_position_func, drawing_area,
- 3, timestamp);
+ params = gtk_menu_create_params (GTK_MENU (menu));
+
+ gdk_attach_params_set_anchors (params,
+ GDK_WINDOW_EDGE_CENTER,
+ GDK_WINDOW_EDGE_NORTH_WEST,
+ TRUE,
+ TRUE);
+
+ gtk_menu_popup_with_params (GTK_MENU (menu),
+ NULL,
+ NULL,
+ drawing_area,
+ 3,
+ timestamp,
+ TRUE,
+ GDK_WINDOW_TYPE_HINT_POPUP_MENU,
+ params);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]