[gtk+/wip/attach-params] 178a6453 gtkmenu: GObjectify
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/attach-params] 178a6453 gtkmenu: GObjectify
- Date: Sat, 30 Jan 2016 06:35:27 +0000 (UTC)
commit 4f5d93db7c09f169cc1c4d23770569392e4d5b67
Author: William Hua <william hua canonical com>
Date: Sat Jan 30 01:26:42 2016 -0500
178a6453 gtkmenu: GObjectify
gtk/gtkmenu.c | 59 +++++++++++++++++++++++++++++---------------------------
gtk/gtkmenu.h | 38 ++++++++++++++++++------------------
2 files changed, 50 insertions(+), 47 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 6a51c1a..1086e19 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1211,7 +1211,7 @@ gtk_menu_destroy (GtkWidget *widget)
g_clear_object (&priv->top_arrow_gadget);
g_clear_object (&priv->bottom_arrow_gadget);
- g_clear_pointer (&priv->attach_params, gdk_attach_params_free);
+ g_clear_object (&priv->attach_params);
GTK_WIDGET_CLASS (gtk_menu_parent_class)->destroy (widget);
}
@@ -1564,8 +1564,13 @@ gtk_menu_popup_internal (GtkMenu *menu,
GdkDevice *source_device = NULL;
GdkDisplay *display;
- if (!GTK_IS_MENU (menu) || (seat && !GDK_IS_SEAT (seat)))
- g_clear_pointer (¶ms, gdk_attach_params_free);
+ if (params)
+ {
+ g_object_ref_sink (params);
+
+ if (!GTK_IS_MENU (menu) || (seat && !GDK_IS_SEAT (seat)))
+ g_clear_object (¶ms);
+ }
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (!seat || GDK_IS_SEAT (seat));
@@ -1676,7 +1681,7 @@ gtk_menu_popup_internal (GtkMenu *menu,
menu_grab_transfer_window_destroy (menu);
g_clear_object (&pointer);
- g_clear_pointer (¶ms, gdk_attach_params_free);
+ g_clear_object (¶ms);
return;
}
@@ -1731,13 +1736,8 @@ gtk_menu_popup_internal (GtkMenu *menu,
priv->position_func_data_destroy = destroy;
menu_shell->priv->activate_time = activate_time;
- if (params != priv->attach_params)
- {
- g_clear_pointer (&priv->attach_params, gdk_attach_params_free);
- priv->attach_params = params;
- }
- else if (params)
- g_warning ("%s (): menu already owns params", G_STRFUNC);
+ g_clear_object (&priv->attach_params);
+ priv->attach_params = params;
/* We need to show the menu here rather in the init function
* because code expects to be able to tell if the menu is onscreen
@@ -1788,8 +1788,7 @@ gtk_menu_popup_internal (GtkMenu *menu,
* Creates a new #GdkAttachParams with some common parameters initialized from
* @menu, such as shadow width.
*
- * Returns: (transfer full): a new #GdkAttachParams that should be freed with
- * gdk_attach_params_free()
+ * Returns: (transfer floating): a new #GdkAttachParams
*
* Since: 3.20
*/
@@ -1859,15 +1858,15 @@ get_arrows_border (GtkMenu *menu,
/**
* gtk_menu_update_scroll_offset:
* @window: the #GdkWindow that was moved
- * @params: (nullable): the #GdkAttachParams that was used
+ * @params: (transfer none) (nullable): the #GdkAttachParams that was used
* @x: the final x-coordinate of @window
* @y: the final y-coordinate of @window
* @offset_x: the horizontal displacement applied to keep @window on-screen
* @offset_y: the vertical displacement applied to keep @window on-screen
* @flipped_x: %TRUE if @window was flipped horizontally
* @flipped_y: %TRUE if @window was flipped vertically
- * @user_data: (not nullable): the #GtkMenu whose scroll offset should be
- * updated
+ * @user_data: (transfer none) (not nullable): the #GtkMenu whose scroll offset
+ * should be updated
*
* Updates the scroll offset for the #GtkMenu @user_data. This function has
* type #GdkAttachCallback and can be passed to
@@ -1876,15 +1875,15 @@ get_arrows_border (GtkMenu *menu,
* Since: 3.20
*/
void
-gtk_menu_update_scroll_offset (GdkWindow *window,
- const GdkAttachParams *params,
- gint x,
- gint y,
- gint offset_x,
- gint offset_y,
- gboolean flipped_x,
- gboolean flipped_y,
- gpointer user_data)
+gtk_menu_update_scroll_offset (GdkWindow *window,
+ GdkAttachParams *params,
+ gint x,
+ gint y,
+ gint offset_x,
+ gint offset_y,
+ gboolean flipped_x,
+ gboolean flipped_y,
+ gpointer user_data)
{
GtkMenu *menu;
GtkBorder border;
@@ -1959,7 +1958,8 @@ flip_anchors_horizontally (GdkAttachParams *params)
* @flip_if_rtl: %TRUE if horizontal constraints should be flipped when the
* text direction is right-to-left
* @type_hint: window type hint to use for the popup menu's top-level window
- * @params: (transfer full) (nullable): a description of how to position @menu
+ * @params: (transfer floating) (nullable): a description of how to position
+ * @menu
*
* Displays a menu and makes it available for selection.
*
@@ -2011,8 +2011,11 @@ gtk_menu_popup_with_params (GtkMenu *menu,
gint x;
gint y;
- if (!GTK_IS_MENU (menu))
- g_clear_pointer (¶ms, gdk_attach_params_free);
+ if (!GTK_IS_MENU (menu) && params)
+ {
+ g_object_ref_sink (params);
+ g_clear_object (¶ms);
+ }
g_return_if_fail (GTK_IS_MENU (menu));
diff --git a/gtk/gtkmenu.h b/gtk/gtkmenu.h
index 97b271f..dfc7fcd 100644
--- a/gtk/gtkmenu.h
+++ b/gtk/gtkmenu.h
@@ -154,29 +154,29 @@ void gtk_menu_popup_for_device (GtkMenu *menu,
guint32 activate_time);
GDK_AVAILABLE_IN_3_20
-GdkAttachParams * gtk_menu_create_params (GtkMenu *menu);
+GdkAttachParams * gtk_menu_create_params (GtkMenu *menu);
GDK_AVAILABLE_IN_3_20
-void gtk_menu_update_scroll_offset (GdkWindow *window,
- const GdkAttachParams *params,
- gint x,
- gint y,
- gint offset_x,
- gint offset_y,
- gboolean flipped_x,
- gboolean flipped_y,
- gpointer user_data);
+void gtk_menu_update_scroll_offset (GdkWindow *window,
+ GdkAttachParams *params,
+ gint x,
+ gint y,
+ gint offset_x,
+ gint offset_y,
+ gboolean flipped_x,
+ gboolean flipped_y,
+ gpointer user_data);
GDK_AVAILABLE_IN_3_20
-void gtk_menu_popup_with_params (GtkMenu *menu,
- GdkSeat *seat,
- GtkWidget *parent_menu_shell,
- GtkWidget *attach_widget,
- guint button,
- guint32 activate_time,
- gboolean flip_if_rtl,
- GdkWindowTypeHint type_hint,
- GdkAttachParams *params);
+void gtk_menu_popup_with_params (GtkMenu *menu,
+ GdkSeat *seat,
+ GtkWidget *parent_menu_shell,
+ GtkWidget *attach_widget,
+ guint button,
+ guint32 activate_time,
+ gboolean flip_if_rtl,
+ GdkWindowTypeHint type_hint,
+ GdkAttachParams *params);
/* Position the menu according to its position function. Called
* from gtkmenuitem.c when a menu-item changes its allocation
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]