libegg r848 - in trunk: . libegg/toolpalette
- From: hasselmm svn gnome org
- To: svn-commits-list gnome org
- Subject: libegg r848 - in trunk: . libegg/toolpalette
- Date: Wed, 23 Jan 2008 08:41:29 +0000 (GMT)
Author: hasselmm
Date: Wed Jan 23 08:41:29 2008
New Revision: 848
URL: http://svn.gnome.org/viewvc/libegg?rev=848&view=rev
Log:
Consider item visibility during size-allocation.
* libegg/toolpalette/eggtoolitemgroup.c: Add and consider
return value of egg_tool_item_group_is_item_visible().
* libegg/toolpalette/testtoolpalette.c: Add a tool item
group with some special cases.
Modified:
trunk/ChangeLog
trunk/libegg/toolpalette/eggtoolitemgroup.c
trunk/libegg/toolpalette/testtoolpalette.c
Modified: trunk/libegg/toolpalette/eggtoolitemgroup.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.c (original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.c Wed Jan 23 08:41:29 2008
@@ -343,6 +343,17 @@
requisition->height += border_width;
}
+static gboolean
+egg_tool_item_group_is_item_visible (GtkToolItem *item,
+ GtkOrientation orientation)
+{
+ return
+ (GTK_WIDGET_VISIBLE (item)) &&
+ (GTK_ORIENTATION_VERTICAL == orientation ?
+ gtk_tool_item_get_visible_vertical (item) :
+ gtk_tool_item_get_visible_horizontal (item));
+}
+
static void
egg_tool_item_group_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -351,10 +362,13 @@
EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (widget);
GtkRequisition child_requistion;
GtkAllocation child_allocation;
+ GtkOrientation orientation;
GtkRequisition item_size;
guint i;
GTK_WIDGET_CLASS (egg_tool_item_group_parent_class)->size_allocate (widget, allocation);
+
+ orientation = egg_tool_item_group_get_orientation (GTK_TOOL_SHELL (group));
egg_tool_item_group_get_item_size (group, &item_size);
child_allocation.x = border_width;
@@ -372,43 +386,53 @@
child_allocation.y += child_allocation.height;
}
- if (group->priv->expanded || group->priv->animation_timeout)
- {
- for (i = 0; i < group->priv->items_length; ++i)
- {
- GtkToolItem *item = group->priv->items[i];
- if (!item)
+ if (group->priv->expanded || group->priv->animation_timeout)
+ {
+ for (i = 0; i < group->priv->items_length; ++i)
+ {
+ GtkToolItem *item = group->priv->items[i];
+
+ if (!item)
+ continue;
+
+ if (!egg_tool_item_group_is_item_visible (item, orientation))
+ {
+ /* in case the item is invisible due its orientation preferences */
+ gtk_widget_set_child_visible (GTK_WIDGET (item), FALSE);
continue;
+ }
- child_allocation.width = item_size.width;
- child_allocation.height = item_size.height;
+ child_allocation.width = item_size.width;
+ child_allocation.height = item_size.height;
- if (child_allocation.x + child_allocation.width > allocation->width)
- {
- child_allocation.y += child_allocation.height;
- child_allocation.x = border_width;
- }
+ if (child_allocation.x + child_allocation.width > allocation->width)
+ {
+ child_allocation.y += child_allocation.height;
+ child_allocation.x = border_width;
+ }
- gtk_widget_size_allocate (GTK_WIDGET (item), &child_allocation);
- gtk_widget_show (GTK_WIDGET (item));
+ gtk_widget_size_allocate (GTK_WIDGET (item), &child_allocation);
+ gtk_widget_set_child_visible (GTK_WIDGET (item), TRUE);
- child_allocation.x += child_allocation.width;
- }
+ child_allocation.x += child_allocation.width;
+ }
- child_allocation.y += item_size.height;
- child_allocation.x = border_width;
- }
- else
- {
- for (i = 0; i < group->priv->items_length; ++i)
- {
- GtkToolItem *item = group->priv->items[i];
-
- if (item)
- gtk_widget_hide (GTK_WIDGET (item));
- }
- }
+ child_allocation.y += item_size.height;
+ child_allocation.x = border_width;
+ }
+ else
+ {
+ for (i = 0; i < group->priv->items_length; ++i)
+ {
+ GtkToolItem *item = group->priv->items[i];
+
+ if (!item)
+ continue;
+
+ gtk_widget_set_child_visible (GTK_WIDGET (item), FALSE);
+ }
+ }
if (GTK_WIDGET_MAPPED (widget))
gdk_window_invalidate_rect (widget->window, NULL, FALSE);
@@ -942,11 +966,30 @@
cairo_paint (cr);
}
+static guint
+egg_tool_item_group_get_visible_item_count (EggToolItemGroup *group)
+{
+ GtkOrientation orientation;
+ guint i, count;
+
+ orientation = egg_tool_item_group_get_orientation (GTK_TOOL_SHELL (group));
+
+ for (i = 0, count = 0; i < group->priv->items_length; ++i)
+ {
+ GtkToolItem *item = group->priv->items[i];
+
+ if (egg_tool_item_group_is_item_visible (item, orientation))
+ count += 1;
+ }
+
+ return count;
+}
+
gint
_egg_tool_item_group_get_height_for_width (EggToolItemGroup *group,
gint width)
{
- guint n_items = group->priv->items_length;
+ guint n_items = egg_tool_item_group_get_visible_item_count (group);
GtkRequisition child_requisition;
egg_tool_item_group_repack (group);
Modified: trunk/libegg/toolpalette/testtoolpalette.c
==============================================================================
--- trunk/libegg/toolpalette/testtoolpalette.c (original)
+++ trunk/libegg/toolpalette/testtoolpalette.c Wed Jan 23 08:41:29 2008
@@ -339,6 +339,40 @@
g_slist_free (stock_ids);
}
+static void
+load_special_items (EggToolPalette *palette)
+{
+ GtkToolItem *item;
+ GtkWidget *group;
+
+ group = egg_tool_item_group_new (_("Advanced Features"));
+ gtk_container_add (GTK_CONTAINER (palette), group);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_UP);
+ gtk_tool_item_set_tooltip_text (item, "Show on vertical palettes only");
+ gtk_tool_item_set_visible_horizontal (item, FALSE);
+ egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
+ gtk_tool_item_set_tooltip_text (item, "Show on horizontal palettes only");
+ gtk_tool_item_set_visible_vertical (item, FALSE);
+ egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
+ gtk_tool_item_set_tooltip_text (item, "Do not show at all");
+ gtk_widget_set_no_show_all (GTK_WIDGET (item), TRUE);
+ egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_FULLSCREEN);
+ gtk_tool_item_set_tooltip_text (item, "Expanded this item");
+ gtk_tool_item_set_expand (item, TRUE);
+ egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_HELP);
+ gtk_tool_item_set_tooltip_text (item, "A regular item");
+ egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1);
+}
+
static gboolean
drop_invalid_icon_size (GEnumValue *enum_value,
gpointer user_data G_GNUC_UNUSED)
@@ -447,6 +481,7 @@
/* ===== palette ===== */
load_stock_items (EGG_TOOL_PALETTE (palette));
+ load_special_items (EGG_TOOL_PALETTE (palette));
palette_scroller = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (palette_scroller),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]