[gtk+/popovers: 22/26] window: Add gtk_window_get_popover_position()



commit 11ef9a31dc2a5c3c3e2fc5517fff1edee158c97b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Dec 23 19:04:48 2013 +0100

    window: Add gtk_window_get_popover_position()
    
    A getter to complement the setter

 docs/reference/gtk/gtk3-sections.txt |    1 +
 gtk/gtkwindow.c                      |   41 ++++++++++++++++++++++++++++++++++
 gtk/gtkwindow.h                      |    5 ++++
 3 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 7dc0317..d9116e7 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -5673,6 +5673,7 @@ gtk_window_set_titlebar
 gtk_window_add_popover
 gtk_window_remove_popover
 gtk_window_set_popover_position
+gtk_window_get_popover_position
 
 <SUBSECTION Standard>
 GTK_WINDOW
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 7072929..b1c3bf3 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -11895,3 +11895,44 @@ gtk_window_set_popover_position (GtkWindow                   *window,
 
   gtk_widget_queue_resize (popover);
 }
+
+/**
+ * gtk_window_get_popover_position:
+ * @window: a #GtkWindow
+ * @popover: a #GtkWidget acting as popover
+ * @pos: return value for the position of @popover relative to @rect
+ * @rect: return value for the disclosure rectangle
+ *
+ * Returns the positioning details of @popover, relative to @window.
+ *
+ * Since: 3.12
+ **/
+void
+gtk_window_get_popover_position (GtkWindow             *window,
+                                 GtkWidget             *popover,
+                                 GtkPositionType       *pos,
+                                 cairo_rectangle_int_t *rect)
+{
+  GtkWindowPopover *data;
+  GtkWindowPrivate *priv;
+
+  g_return_if_fail (GTK_IS_WINDOW (window));
+  g_return_if_fail (GTK_IS_WIDGET (popover));
+
+  priv = window->priv;
+  data = g_hash_table_lookup (priv->popovers, popover);
+
+  if (!data)
+    {
+      g_warning ("Widget %s(%p) is not a popover of window %s",
+                 gtk_widget_get_name (popover), popover,
+                 gtk_widget_get_name (GTK_WIDGET (window)));
+      return;
+    }
+
+  if (pos)
+    *pos = data->pos;
+
+  if (rect)
+    *rect = data->rect;
+}
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index aaa0bfd..4e31bd8 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -478,6 +478,11 @@ void     gtk_window_set_popover_position   (GtkWindow                   *window,
                                             GtkWidget                   *popover,
                                             GtkPositionType              pos,
                                             const cairo_rectangle_int_t *rect);
+GDK_AVAILABLE_IN_3_12
+void     gtk_window_get_popover_position   (GtkWindow                   *window,
+                                            GtkWidget                   *popover,
+                                            GtkPositionType             *pos,
+                                            cairo_rectangle_int_t       *rect);
 
 G_END_DECLS
 


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