diff options
author | Alexandre Mazari <amazari@igalia.com> | 2011-04-19 00:30:58 +0800 |
---|---|---|
committer | Alexandre Mazari <amazari@igalia.com> | 2011-04-19 17:04:39 +0800 |
commit | 05d631cb9b95e3be827cbfbcdeb569834a967959 (patch) | |
tree | 2f82caed7b1e18aa01464bebe895469d1da561ba /lib/widgets/gedit-overlay-child.c | |
parent | 03d920eebb49fb9ecfda4ec00b669d1032caf587 (diff) | |
download | gsoc2013-epiphany-05d631cb9b95e3be827cbfbcdeb569834a967959.tar gsoc2013-epiphany-05d631cb9b95e3be827cbfbcdeb569834a967959.tar.gz gsoc2013-epiphany-05d631cb9b95e3be827cbfbcdeb569834a967959.tar.bz2 gsoc2013-epiphany-05d631cb9b95e3be827cbfbcdeb569834a967959.tar.lz gsoc2013-epiphany-05d631cb9b95e3be827cbfbcdeb569834a967959.tar.xz gsoc2013-epiphany-05d631cb9b95e3be827cbfbcdeb569834a967959.tar.zst gsoc2013-epiphany-05d631cb9b95e3be827cbfbcdeb569834a967959.zip |
Import latest version of Gedit's overlay code.
Diffstat (limited to 'lib/widgets/gedit-overlay-child.c')
-rw-r--r-- | lib/widgets/gedit-overlay-child.c | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/lib/widgets/gedit-overlay-child.c b/lib/widgets/gedit-overlay-child.c index e30d6edfb..7593fe18c 100644 --- a/lib/widgets/gedit-overlay-child.c +++ b/lib/widgets/gedit-overlay-child.c @@ -23,7 +23,6 @@ struct _GeditOverlayChildPrivate { - GtkWidget *widget; GBinding *binding; GeditOverlayChildPosition position; guint offset; @@ -50,7 +49,7 @@ gedit_overlay_child_get_property (GObject *object, switch (prop_id) { case PROP_WIDGET: - g_value_set_object (value, child->priv->widget); + g_value_set_object (value, gtk_bin_get_child (GTK_BIN (child))); break; case PROP_POSITION: g_value_set_uint (value, child->priv->position); @@ -117,17 +116,29 @@ gedit_overlay_child_realize (GtkWidget *widget) } static void -gedit_overlay_child_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural) +gedit_overlay_child_get_size (GtkWidget *widget, + GtkOrientation orientation, + gint *minimum, + gint *natural) { - GeditOverlayChild *child = GEDIT_OVERLAY_CHILD (widget); + GeditOverlayChild *overlay_child = GEDIT_OVERLAY_CHILD (widget); + GtkWidget *child; gint child_min = 0, child_nat = 0; - if (child->priv->widget != NULL) + child = gtk_bin_get_child (GTK_BIN (overlay_child)); + + if (child != NULL) { - gtk_widget_get_preferred_width (child->priv->widget, - &child_min, &child_nat); + if (orientation == GTK_ORIENTATION_HORIZONTAL) + { + gtk_widget_get_preferred_width (child, + &child_min, &child_nat); + } + else + { + gtk_widget_get_preferred_height (child, + &child_min, &child_nat); + } } *minimum = child_min; @@ -135,28 +146,27 @@ gedit_overlay_child_get_preferred_width (GtkWidget *widget, } static void +gedit_overlay_child_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + gedit_overlay_child_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum, natural); +} + +static void gedit_overlay_child_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural) { - GeditOverlayChild *child = GEDIT_OVERLAY_CHILD (widget); - gint child_min = 0, child_nat = 0; - - if (child->priv->widget != NULL) - { - gtk_widget_get_preferred_height (child->priv->widget, - &child_min, &child_nat); - } - - *minimum = child_min; - *natural = child_nat; + gedit_overlay_child_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum, natural); } static void gedit_overlay_child_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - GeditOverlayChild *child = GEDIT_OVERLAY_CHILD (widget); + GeditOverlayChild *overlay_child = GEDIT_OVERLAY_CHILD (widget); + GtkWidget *child; GtkAllocation tmp; tmp.width = allocation->width; @@ -165,10 +175,11 @@ gedit_overlay_child_size_allocate (GtkWidget *widget, GTK_WIDGET_CLASS (gedit_overlay_child_parent_class)->size_allocate (widget, allocation); - if (child->priv->widget != NULL) + child = gtk_bin_get_child (GTK_BIN (overlay_child)); + + if (child != NULL) { - gtk_widget_size_allocate (child->priv->widget, - &tmp); + gtk_widget_size_allocate (child, &tmp); } } @@ -176,13 +187,11 @@ static void gedit_overlay_child_add (GtkContainer *container, GtkWidget *widget) { - GeditOverlayChild *child = GEDIT_OVERLAY_CHILD (container); + GeditOverlayChild *overlay_child = GEDIT_OVERLAY_CHILD (container); - child->priv->widget = widget; - - child->priv->binding = g_object_bind_property (G_OBJECT (widget), "visible", - G_OBJECT (container), "visible", - G_BINDING_BIDIRECTIONAL); + overlay_child->priv->binding = g_object_bind_property (G_OBJECT (widget), "visible", + G_OBJECT (container), "visible", + G_BINDING_BIDIRECTIONAL); GTK_CONTAINER_CLASS (gedit_overlay_child_parent_class)->add (container, widget); } @@ -193,8 +202,6 @@ gedit_overlay_child_remove (GtkContainer *container, { GeditOverlayChild *child = GEDIT_OVERLAY_CHILD (container); - child->priv->widget = NULL; - g_object_unref (child->priv->binding); GTK_CONTAINER_CLASS (gedit_overlay_child_parent_class)->remove (container, widget); |