[gtk+] GtkPopoverMenu: expose more properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkPopoverMenu: expose more properties
- Date: Tue, 18 Nov 2014 12:40:46 +0000 (UTC)
commit 955c798ab1ef799d2778ebbc878c1d9613a3b08a
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Nov 18 13:39:15 2014 +0100
GtkPopoverMenu: expose more properties
Expose the position as a child property and the visible page
as a property. These are useful in glade.
gtk/gtkpopovermenu.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 87 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c
index fefcdc5..4d6ecde 100644
--- a/gtk/gtkpopovermenu.c
+++ b/gtk/gtkpopovermenu.c
@@ -103,7 +103,12 @@ struct _GtkPopoverMenu
};
enum {
- CHILD_PROP_SUBMENU = 1
+ PROP_VISIBLE_SUBMENU = 1
+};
+
+enum {
+ CHILD_PROP_SUBMENU = 1,
+ CHILD_PROP_POSITION
};
G_DEFINE_TYPE (GtkPopoverMenu, gtk_popover_menu, GTK_TYPE_POPOVER)
@@ -205,7 +210,6 @@ gtk_popover_menu_get_child_property (GtkContainer *container,
return;
switch (property_id)
-
{
case CHILD_PROP_SUBMENU:
{
@@ -215,6 +219,14 @@ gtk_popover_menu_get_child_property (GtkContainer *container,
}
break;
+ case CHILD_PROP_POSITION:
+ {
+ gint position;
+ gtk_container_child_get (GTK_CONTAINER (stack), child, "position", &position, NULL);
+ g_value_set_int (value, position);
+ }
+ break;
+
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
@@ -245,6 +257,14 @@ gtk_popover_menu_set_child_property (GtkContainer *container,
}
break;
+ case CHILD_PROP_POSITION:
+ {
+ gint position;
+ position = g_value_get_int (value);
+ gtk_container_child_set (GTK_CONTAINER (stack), child, "position", position, NULL);
+ }
+ break;
+
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
@@ -252,10 +272,58 @@ gtk_popover_menu_set_child_property (GtkContainer *container,
}
static void
+gtk_popover_menu_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkWidget *stack;
+
+ stack = gtk_bin_get_child (GTK_BIN (object));
+
+ switch (property_id)
+ {
+ case PROP_VISIBLE_SUBMENU:
+ g_value_set_string (value, gtk_stack_get_visible_child_name (GTK_STACK (stack)));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_popover_menu_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkWidget *stack;
+
+ stack = gtk_bin_get_child (GTK_BIN (object));
+
+ switch (property_id)
+ {
+ case PROP_VISIBLE_SUBMENU:
+ gtk_stack_set_visible_child_name (GTK_STACK (stack), g_value_get_string (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
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->set_property = gtk_popover_menu_set_property;
+ object_class->get_property = gtk_popover_menu_get_property;
widget_class->map = gtk_popover_menu_map;
widget_class->unmap = gtk_popover_menu_unmap;
@@ -266,6 +334,14 @@ gtk_popover_menu_class_init (GtkPopoverMenuClass *klass)
container_class->set_child_property = gtk_popover_menu_set_child_property;
container_class->get_child_property = gtk_popover_menu_get_child_property;
+ g_object_class_install_property (object_class,
+ PROP_VISIBLE_SUBMENU,
+ g_param_spec_string ("visible-submenu",
+ P_("Visible submenu"),
+ P_("The name of the visible submenu"),
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
/**
* GtkPopoverMenu:submenu:
*
@@ -282,6 +358,14 @@ gtk_popover_menu_class_init (GtkPopoverMenuClass *klass)
P_("The name of the submenu"),
NULL,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
+
+ gtk_container_class_install_child_property (container_class,
+ CHILD_PROP_POSITION,
+ g_param_spec_int ("position",
+ P_("Position"),
+ P_("The index of the child in the parent"),
+ -1, G_MAXINT, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
/**
@@ -326,4 +410,5 @@ gtk_popover_menu_open_submenu (GtkPopoverMenu *popover,
stack = gtk_bin_get_child (GTK_BIN (popover));
gtk_stack_set_visible_child_name (GTK_STACK (stack), name);
+ g_object_notify (G_OBJECT (popover), "visible-submenu");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]