libegg r849 - in trunk: . libegg/toolpalette
- From: hasselmm svn gnome org
- To: svn-commits-list gnome org
- Subject: libegg r849 - in trunk: . libegg/toolpalette
- Date: Wed, 23 Jan 2008 09:45:23 +0000 (GMT)
Author: hasselmm
Date: Wed Jan 23 09:45:22 2008
New Revision: 849
URL: http://svn.gnome.org/viewvc/libegg?rev=849&view=rev
Log:
Expand tool items when not in icon-only mode,
or when the item requests this.
* libegg/toolpalette/eggtoolitemgroup.c: Expand tool items.
* libegg/toolpalette/testtoolpalette.c: Set label instead of tooltip.
* libegg/toolpalette/TODO: Adding TODO list.
Added:
trunk/libegg/toolpalette/TODO
Modified:
trunk/ChangeLog
trunk/libegg/toolpalette/eggtoolitemgroup.c
trunk/libegg/toolpalette/testtoolpalette.c
Added: trunk/libegg/toolpalette/TODO
==============================================================================
--- (empty file)
+++ trunk/libegg/toolpalette/TODO Wed Jan 23 09:45:22 2008
@@ -0,0 +1,7 @@
+* support horizontal orientation
+* ask tool items to apply ellipses to labels
+* left-align labels (and center icons) in both-horiz mode
+* implement stubs (g_return_if_reached)
+* avoid flickering in non-icon-only modes
+* implement natural-size interface
+* scroll to group, when expanding
Modified: trunk/libegg/toolpalette/eggtoolitemgroup.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.c (original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.c Wed Jan 23 09:45:22 2008
@@ -355,22 +355,33 @@
}
static void
-egg_tool_item_group_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+egg_tool_item_group_real_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation,
+ GtkRequisition *inquery)
{
const gint border_width = GTK_CONTAINER (widget)->border_width;
EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (widget);
GtkRequisition child_requistion;
GtkAllocation child_allocation;
- GtkOrientation orientation;
GtkRequisition item_size;
- guint i;
+
+ guint i, n_columns;
+ gint width;
+
+ GtkOrientation orientation;
+ GtkToolbarStyle style;
GTK_WIDGET_CLASS (egg_tool_item_group_parent_class)->size_allocate (widget, allocation);
orientation = egg_tool_item_group_get_orientation (GTK_TOOL_SHELL (group));
+ style = egg_tool_item_group_get_style (GTK_TOOL_SHELL (group));
+
egg_tool_item_group_get_item_size (group, &item_size);
+ item_size.width = MIN (item_size.width, allocation->width);
+ n_columns = MAX (allocation->width / item_size.width, 1);
+ width = item_size.width * n_columns;
+
child_allocation.x = border_width;
child_allocation.y = border_width;
@@ -381,12 +392,12 @@
child_allocation.width = allocation->width;
child_allocation.height = child_requistion.height;
- gtk_widget_size_allocate (group->priv->header, &child_allocation);
+ if (!inquery)
+ gtk_widget_size_allocate (group->priv->header, &child_allocation);
child_allocation.y += child_allocation.height;
}
-
if (group->priv->expanded || group->priv->animation_timeout)
{
for (i = 0; i < group->priv->items_length; ++i)
@@ -398,22 +409,30 @@
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);
+ if (!inquery) /* in case of orientation preferences */
+ gtk_widget_set_child_visible (GTK_WIDGET (item), FALSE);
+
continue;
}
- child_allocation.width = item_size.width;
- child_allocation.height = item_size.height;
-
- if (child_allocation.x + child_allocation.width > allocation->width)
+ if (child_allocation.x + item_size.width > width)
{
child_allocation.y += child_allocation.height;
child_allocation.x = border_width;
}
- gtk_widget_size_allocate (GTK_WIDGET (item), &child_allocation);
- gtk_widget_set_child_visible (GTK_WIDGET (item), TRUE);
+ if (style != GTK_TOOLBAR_ICONS || gtk_tool_item_get_expand (item))
+ child_allocation.width = width - child_allocation.x;
+ else
+ child_allocation.width = item_size.width;
+
+ child_allocation.height = item_size.height;
+
+ if (!inquery)
+ {
+ gtk_widget_size_allocate (GTK_WIDGET (item), &child_allocation);
+ gtk_widget_set_child_visible (GTK_WIDGET (item), TRUE);
+ }
child_allocation.x += child_allocation.width;
}
@@ -421,7 +440,7 @@
child_allocation.y += item_size.height;
child_allocation.x = border_width;
}
- else
+ else if (!inquery)
{
for (i = 0; i < group->priv->items_length; ++i)
{
@@ -434,6 +453,19 @@
}
}
+ if (inquery)
+ {
+ inquery->width = child_allocation.width;
+ inquery->height = child_allocation.y;
+ }
+}
+
+static void
+egg_tool_item_group_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ egg_tool_item_group_real_size_allocate (widget, allocation, NULL);
+
if (GTK_WIDGET_MAPPED (widget))
gdk_window_invalidate_rect (widget->window, NULL, FALSE);
}
@@ -966,45 +998,24 @@
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 = egg_tool_item_group_get_visible_item_count (group);
- GtkRequisition child_requisition;
+ GtkRequisition requisition;
egg_tool_item_group_repack (group);
- gtk_widget_size_request (GTK_WIDGET (group), &child_requisition);
+ gtk_widget_size_request (GTK_WIDGET (group), &requisition);
- if (n_items && (group->priv->expanded || group->priv->animation_timeout))
+ if (group->priv->expanded || group->priv->animation_timeout)
{
- gint n_columns, n_rows, height;
- GtkRequisition item_size;
+ GtkAllocation allocation = { 0, 0, width, requisition.height };
+ GtkRequisition inquery;
- egg_tool_item_group_get_item_size (group, &item_size);
+ egg_tool_item_group_real_size_allocate (GTK_WIDGET (group),
+ &allocation, &inquery);
- n_columns = width / item_size.width;
- n_rows = (n_items + n_columns - 1) / n_columns;
- height = item_size.height * n_rows;
+ inquery.height -= requisition.height;
if (group->priv->animation_timeout)
{
@@ -1015,11 +1026,12 @@
if (!group->priv->expanded)
timestamp = ANIMATION_DURATION - timestamp;
- height = height * timestamp / ANIMATION_DURATION;
+ inquery.height *= timestamp;
+ inquery.height /= ANIMATION_DURATION;
}
- child_requisition.height += height;
+ requisition.height += inquery.height;
}
- return child_requisition.height;
+ return requisition.height;
}
Modified: trunk/libegg/toolpalette/testtoolpalette.c
==============================================================================
--- trunk/libegg/toolpalette/testtoolpalette.c (original)
+++ trunk/libegg/toolpalette/testtoolpalette.c Wed Jan 23 09:45:22 2008
@@ -308,6 +308,7 @@
for (iter = stock_ids; iter; iter = g_slist_next (iter))
{
+ GtkStockItem stock_item;
gchar *id = iter->data;
switch (id[4])
@@ -333,6 +334,9 @@
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item), id);
egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1);
+ if (!gtk_stock_lookup (id, &stock_item) || !stock_item.label)
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), id);
+
g_free (id);
}
@@ -349,27 +353,32 @@
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_button_set_label (GTK_TOOL_BUTTON (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_button_set_label (GTK_TOOL_BUTTON (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_tool_button_set_label (GTK_TOOL_BUTTON (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_button_set_label (GTK_TOOL_BUTTON (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");
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (item),
+ "A regular item");
egg_tool_item_group_insert (EGG_TOOL_ITEM_GROUP (group), item, -1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]