[gtk+/popover-menu: 12/17] Add a sizegroup to GtkPopoverMenu



commit b0ac38c72de59cc7f59a13cbce237fcee122b727
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 26 01:23:04 2014 -0400

    Add a sizegroup to GtkPopoverMenu
    
    This is the last missing feature compared to
    gtk_popover_new_from_model.

 gtk/gtkpopovermenu.c |   39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c
index 4a95f8f..4583589 100644
--- a/gtk/gtkpopovermenu.c
+++ b/gtk/gtkpopovermenu.c
@@ -19,12 +19,15 @@
 #include "gtkpopovermenu.h"
 #include "gtkstack.h"
 #include "gtkbox.h"
+#include "gtksizegroup.h"
 #include "gtkintl.h"
 
 
 struct _GtkPopoverMenu
 {
   GtkPopover parent_instance;
+
+  GtkSizeGroup *size_group;
 };
 
 enum {
@@ -33,18 +36,6 @@ enum {
 
 G_DEFINE_TYPE (GtkPopoverMenu, gtk_popover_menu, GTK_TYPE_POPOVER)
 
-static void
-gtk_popover_menu_ensure_stack (GtkPopoverMenu *popover)
-{
-  GtkWidget *stack;
-
-  stack = gtk_stack_new ();
-  gtk_stack_set_homogeneous (GTK_STACK (stack), FALSE);
-  gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
-  gtk_widget_show (stack);
-  gtk_container_add (GTK_CONTAINER (popover), stack);
-}
-
 static GtkWidget *
 gtk_popover_menu_ensure_submenu (GtkPopoverMenu *popover,
                                  const gchar    *name)
@@ -60,6 +51,7 @@ gtk_popover_menu_ensure_submenu (GtkPopoverMenu *popover,
       gtk_widget_set_halign (submenu, GTK_ALIGN_FILL);
       g_object_set (submenu, "margin", 10, NULL);
       gtk_widget_show (submenu);
+      gtk_size_group_add_widget (popover->size_group, submenu);
       gtk_stack_add_named (GTK_STACK (stack), submenu, name);
     }
 
@@ -140,11 +132,28 @@ gtk_popover_menu_remove_item (GtkPopoverMenu *popover,
 static void
 gtk_popover_menu_init (GtkPopoverMenu *popover)
 {
-  gtk_popover_menu_ensure_stack (popover);
+  GtkWidget *stack;
+
+  stack = gtk_stack_new ();
+  gtk_stack_set_homogeneous (GTK_STACK (stack), FALSE);
+  gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
+  gtk_widget_show (stack);
+  gtk_container_add (GTK_CONTAINER (popover), stack);
+  popover->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
   gtk_popover_menu_ensure_submenu (popover, "main");
 }
 
 static void
+gtk_popover_menu_finalize (GObject *object)
+{
+  GtkPopoverMenu *popover = GTK_POPOVER_MENU (object);
+
+  g_object_unref (popover->size_group);
+
+  G_OBJECT_CLASS (gtk_popover_menu_parent_class)->finalize (object);
+}
+
+static void
 back_to_main (GtkWidget *popover)
 {
   GtkWidget *stack;
@@ -202,7 +211,6 @@ gtk_popover_menu_get_child_property (GtkContainer *container,
     return;
 
   switch (property_id)
- 
     {
     case CHILD_PROP_SUBMENU:
       g_value_set_string (value, gtk_popover_menu_get_submenu (GTK_POPOVER_MENU (container), child));
@@ -241,6 +249,9 @@ gtk_popover_menu_class_init (GtkPopoverMenuClass *klass)
 {
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gtk_popover_menu_finalize;
 
   widget_class->map = gtk_popover_menu_map;
   widget_class->unmap = gtk_popover_menu_unmap;


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