libegg r843 - in trunk: . libegg/toolpalette



Author: hasselmm
Date: Mon Jan 14 17:35:08 2008
New Revision: 843
URL: http://svn.gnome.org/viewvc/libegg?rev=843&view=rev

Log:
* libegg/toolpalette/eggtoolitemgroup.c: Implement GtkToolShellIface.
Consider item size in size-request. Allow ellipses for table headers.
* libegg/toolpalette/eggtoolpalette.c: Emit "toolbar-reconfigured"
signal when the palette's appearance has changed.
* libegg/toolpalette/testtoolpalette.c: Apply
GtkToolButton::icon-spacing style property.


Modified:
   trunk/ChangeLog
   trunk/libegg/toolpalette/eggtoolitemgroup.c
   trunk/libegg/toolpalette/eggtoolpalette.c
   trunk/libegg/toolpalette/testtoolpalette.c

Modified: trunk/libegg/toolpalette/eggtoolitemgroup.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.c	(original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.c	Mon Jan 14 17:35:08 2008
@@ -25,6 +25,7 @@
 #include <gtk/gtkalignment.h>
 #include <gtk/gtkbutton.h>
 #include <gtk/gtklabel.h>
+#include <gtk/gtktoolshell.h>
 
 #include <string.h>
 
@@ -60,9 +61,10 @@
   guint             expanded : 1;
 };
 
-G_DEFINE_TYPE (EggToolItemGroup,
-               egg_tool_item_group,
-               GTK_TYPE_CONTAINER);
+static void egg_tool_item_group_tool_shell_init (GtkToolShellIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (EggToolItemGroup, egg_tool_item_group, GTK_TYPE_CONTAINER,
+G_IMPLEMENT_INTERFACE (GTK_TYPE_TOOL_SHELL, egg_tool_item_group_tool_shell_init));
 
 static void
 egg_tool_item_group_repack (EggToolItemGroup *group)
@@ -141,7 +143,9 @@
   group->priv->expanded = TRUE;
 
   label = gtk_label_new (NULL);
-  alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
+  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
 
   gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0,
                              group->priv->header_spacing +
@@ -235,11 +239,57 @@
 }
 
 static void
+egg_tool_item_group_get_item_size (EggToolItemGroup *group,
+                                   GtkRequisition   *item_size)
+{
+  GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (group));
+
+  if (EGG_IS_TOOL_PALETTE (parent))
+    _egg_tool_palette_get_item_size (EGG_TOOL_PALETTE (parent), item_size);
+  else
+    _egg_tool_item_group_item_size_request (group, item_size);
+}
+
+static GtkIconSize
+egg_tool_item_group_get_icon_size (GtkToolShell *shell)
+{
+  GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (shell));
+
+  if (EGG_IS_TOOL_PALETTE (parent))
+    return egg_tool_palette_get_icon_size (EGG_TOOL_PALETTE (parent));
+
+  return GTK_ICON_SIZE_SMALL_TOOLBAR;
+}
+
+static GtkOrientation
+egg_tool_item_group_get_orientation (GtkToolShell *shell)
+{
+  GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (shell));
+
+  if (EGG_IS_TOOL_PALETTE (parent))
+    return egg_tool_palette_get_orientation (EGG_TOOL_PALETTE (parent));
+
+  return GTK_ORIENTATION_VERTICAL;
+}
+
+static GtkToolbarStyle
+egg_tool_item_group_get_style (GtkToolShell *shell)
+{
+  GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (shell));
+
+  if (EGG_IS_TOOL_PALETTE (parent))
+    return egg_tool_palette_get_style (EGG_TOOL_PALETTE (parent));
+
+  return GTK_TOOLBAR_ICONS;
+}
+
+static void
 egg_tool_item_group_size_request (GtkWidget      *widget,
                                   GtkRequisition *requisition)
 {
   const gint border_width = GTK_CONTAINER (widget)->border_width;
   EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (widget);
+  GtkRequisition item_size;
 
   egg_tool_item_group_repack (group);
 
@@ -254,20 +304,16 @@
       gtk_widget_hide (group->priv->header);
     }
 
-  requisition->width += border_width;
-  requisition->height += border_width;
-}
-
-static void
-egg_tool_item_group_get_item_size (EggToolItemGroup *group,
-                                   GtkRequisition   *item_size)
-{
-  GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (group));
+  egg_tool_item_group_get_item_size (group, &item_size);
 
-  if (EGG_IS_TOOL_PALETTE (parent))
-    _egg_tool_palette_get_item_size (EGG_TOOL_PALETTE (parent), item_size);
+  if (GTK_ORIENTATION_VERTICAL ==
+      egg_tool_item_group_get_orientation (GTK_TOOL_SHELL (group)))
+    requisition->width = MAX (requisition->width, item_size.width);
   else
-    _egg_tool_item_group_item_size_request (group, item_size);
+    requisition->height = MAX (requisition->height, item_size.height);
+
+  requisition->width += border_width;
+  requisition->height += border_width;
 }
 
 static void
@@ -535,6 +581,14 @@
   g_type_class_add_private (cls, sizeof (EggToolItemGroupPrivate));
 }
 
+static void
+egg_tool_item_group_tool_shell_init (GtkToolShellIface *iface)
+{
+  iface->get_icon_size = egg_tool_item_group_get_icon_size;
+  iface->get_orientation = egg_tool_item_group_get_orientation;
+  iface->get_style = egg_tool_item_group_get_style;
+}
+
 GtkWidget*
 egg_tool_item_group_new (const gchar *name)
 {

Modified: trunk/libegg/toolpalette/eggtoolpalette.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolpalette.c	(original)
+++ trunk/libegg/toolpalette/eggtoolpalette.c	Mon Jan 14 17:35:08 2008
@@ -94,6 +94,34 @@
 }
 
 static void
+egg_tool_palette_reconfigured_foreach_item (GtkWidget *child,
+                                            gpointer   data G_GNUC_UNUSED)
+{
+  if (GTK_IS_TOOL_ITEM (child))
+    gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (child));
+}
+
+static void
+egg_tool_palette_reconfigured (EggToolPalette *palette)
+{
+  guint i;
+
+  for (i = 0; i < palette->priv->groups_length; ++i)
+    {
+      EggToolItemGroup *group = palette->priv->groups[i];
+
+      if (!group)
+        continue;
+
+      gtk_container_foreach (GTK_CONTAINER (group),
+                             egg_tool_palette_reconfigured_foreach_item,
+                             NULL);
+    }
+
+  gtk_widget_queue_resize_no_redraw (GTK_WIDGET (palette));
+}
+
+static void
 egg_tool_palette_set_property (GObject      *object,
                                guint         prop_id,
                                const GValue *value,
@@ -107,7 +135,7 @@
         if ((guint) g_value_get_enum (value) != palette->priv->icon_size)
           {
             palette->priv->icon_size = g_value_get_enum (value);
-            gtk_widget_queue_resize_no_redraw (GTK_WIDGET (palette));
+            egg_tool_palette_reconfigured (palette);
           }
         break;
 
@@ -115,7 +143,7 @@
         if ((guint) g_value_get_enum (value) != palette->priv->orientation)
           {
             palette->priv->orientation = g_value_get_enum (value);
-            gtk_widget_queue_resize_no_redraw (GTK_WIDGET (palette));
+            egg_tool_palette_reconfigured (palette);
           }
         break;
 
@@ -123,7 +151,7 @@
         if ((guint) g_value_get_enum (value) != palette->priv->style)
           {
             palette->priv->style = g_value_get_enum (value);
-            gtk_widget_queue_resize_no_redraw (GTK_WIDGET (palette));
+            egg_tool_palette_reconfigured (palette);
           }
         break;
 

Modified: trunk/libegg/toolpalette/testtoolpalette.c
==============================================================================
--- trunk/libegg/toolpalette/testtoolpalette.c	(original)
+++ trunk/libegg/toolpalette/testtoolpalette.c	Mon Jan 14 17:35:08 2008
@@ -293,11 +293,18 @@
       GtkButton::inner_border = { 0, 3, 0, 0 }          \
     }                                                   \
                                                         \
+    style 'egg-tool-item-group-button' {                \
+      GtkToolButton::icon-spacing = 12                  \
+    }                                                   \
+                                                        \
     class 'EggToolItemGroup'                            \
     style 'egg-tool-item-group'                         \
                                                         \
     widget_class '*<EggToolItemGroup>.GtkButton*'       \
     style 'egg-tool-item-group-header'                  \
+                                                        \
+    widget_class '*<EggToolItemGroup>.GtkToolButton'    \
+    style 'egg-tool-item-group-button'                  \
     ");
 
   ui = create_ui ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]