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



commit 1024e227b22f4942a4962f6c0c0313767afcad3e
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 a81980a..dbc2bdb 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -5675,6 +5675,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 36fcbee..b5e9d07 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -11905,3 +11905,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]