summaryrefslogtreecommitdiff
path: root/gtk/gtksizegroup.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-06-19 04:16:28 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-06-19 04:16:28 +0000
commitb6e4e4cb0cca0ed0d1c58a3b02917655affbfe23 (patch)
tree364f7309971be4046e45e39065c364711c5c2672 /gtk/gtksizegroup.c
parente109b31b0af76716326ef4e73bfee11ec4eba856 (diff)
downloadgtk+-b6e4e4cb0cca0ed0d1c58a3b02917655affbfe23.tar.gz
Add an ignore-hidden property with getter and setter. (#171612, Christian
2005-06-19 Matthias Clasen <mclasen@redhat.com> * gtk/gtk.symbols: * gtk/gtksizegroup.[hc]: Add an ignore-hidden property with getter and setter. (#171612, Christian Neumair)
Diffstat (limited to 'gtk/gtksizegroup.c')
-rw-r--r--gtk/gtksizegroup.c81
1 files changed, 77 insertions, 4 deletions
diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c
index 5d62d181e0..707001fa3b 100644
--- a/gtk/gtksizegroup.c
+++ b/gtk/gtksizegroup.c
@@ -27,7 +27,8 @@
enum {
PROP_0,
- PROP_MODE
+ PROP_MODE,
+ PROP_IGNORE_HIDDEN
};
static void gtk_size_group_set_property (GObject *object,
@@ -246,6 +247,23 @@ gtk_size_group_class_init (GtkSizeGroupClass *klass)
GTK_TYPE_SIZE_GROUP_MODE,
GTK_SIZE_GROUP_HORIZONTAL,
GTK_PARAM_READWRITE));
+
+ /**
+ * GtkSizeGroup:ignore-hidden:
+ *
+ * If %TRUE, hidden widgets are ignored when determining
+ * the size of the group.
+ *
+ * Since: 2.8
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_IGNORE_HIDDEN,
+ g_param_spec_boolean ("ignore-hidden",
+ P_("Ignore hidden"),
+ P_("If TRUE, hidden widgets are ignored "
+ "when determining the size of the group"),
+ FALSE,
+ GTK_PARAM_READWRITE));
}
static void
@@ -255,6 +273,7 @@ gtk_size_group_init (GtkSizeGroup *size_group)
size_group->mode = GTK_SIZE_GROUP_HORIZONTAL;
size_group->have_width = 0;
size_group->have_height = 0;
+ size_group->ignore_hidden = 0;
}
GType
@@ -297,6 +316,9 @@ gtk_size_group_set_property (GObject *object,
case PROP_MODE:
gtk_size_group_set_mode (size_group, g_value_get_enum (value));
break;
+ case PROP_IGNORE_HIDDEN:
+ gtk_size_group_set_ignore_hidden (size_group, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -316,6 +338,9 @@ gtk_size_group_get_property (GObject *object,
case PROP_MODE:
g_value_set_enum (value, size_group->mode);
break;
+ case PROP_IGNORE_HIDDEN:
+ g_value_set_boolean (value, size_group->ignore_hidden);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -386,6 +411,51 @@ gtk_size_group_get_mode (GtkSizeGroup *size_group)
return size_group->mode;
}
+/**
+ * gtk_size_group_set_ignore_hidden:
+ * @size_group: a #GtkSizeGroup
+ * @ignore_hidden: whether hidden widgets should be ignored
+ * when calculating the size
+ *
+ * Sets whether invisible widgets should be ignored when
+ * calculating the size.
+ *
+ * Since: 2.8
+ */
+void
+gtk_size_group_set_ignore_hidden (GtkSizeGroup *size_group,
+ gboolean ignore_hidden)
+{
+ g_return_if_fail (GTK_IS_SIZE_GROUP (size_group));
+
+ ignore_hidden = ignore_hidden != FALSE;
+
+ if (size_group->ignore_hidden != ignore_hidden)
+ {
+ size_group->ignore_hidden = ignore_hidden;
+
+ g_object_notify (G_OBJECT (size_group), "ignore-hidden");
+ }
+}
+
+/**
+ * gtk_size_group_get_ignore_hidden:
+ * @size_group: a #GtkSizeGroup
+ *
+ * Returns if invisible widgets are ignored when calculating the size.
+ *
+ * Returns: %TRUE if invisible widgets are ignored.
+ *
+ * Since: 2.8
+ */
+gboolean
+gtk_size_group_get_ignore_hidden (GtkSizeGroup *size_group)
+{
+ g_return_val_if_fail (GTK_IS_SIZE_GROUP (size_group), FALSE);
+
+ return size_group->ignore_hidden;
+}
+
static void
gtk_size_group_widget_destroyed (GtkWidget *widget,
GtkSizeGroup *size_group)
@@ -542,9 +612,12 @@ compute_dimension (GtkWidget *widget,
gint dimension = compute_base_dimension (tmp_widget, mode);
- if (dimension > result)
- result = dimension;
-
+ if (GTK_WIDGET_VISIBLE (tmp_widget) || !group->ignore_hidden)
+ {
+ if (dimension > result)
+ result = dimension;
+ }
+
tmp_list = tmp_list->next;
}