libegg r865 - in trunk: . libegg/toolpalette



Author: hasselmm
Date: Sat Mar 29 22:13:54 2008
New Revision: 865
URL: http://svn.gnome.org/viewvc/libegg?rev=865&view=rev

Log:
Support child properties in EggToolItemGroup.

* libegg/toolpalette/eggtoolitemgroup.c:
  Implement "expand", "homogeneous" and "position".
* libegg/toolpalette/TODO: Updated.


Modified:
   trunk/ChangeLog
   trunk/libegg/toolpalette/TODO
   trunk/libegg/toolpalette/eggtoolitemgroup.c

Modified: trunk/libegg/toolpalette/TODO
==============================================================================
--- trunk/libegg/toolpalette/TODO	(original)
+++ trunk/libegg/toolpalette/TODO	Sat Mar 29 22:13:54 2008
@@ -1,14 +1,17 @@
 EggToolPalette
+==============
 
- * implement natural-size interface
- * scroll to group, when expanding
- * consider scrollbar size in size-request
- * install position child properties
- * support ellipses in group headers again
- * support horizontal orientation for other styles but icon only
+* scroll to group, when expanding
+* support horizontal orientation for other styles but icon only
+* consider scrollbar size in size-request
+  - is that even possible?
+* implement natural-size interface:
+  - requires GtkNaturalSize to be pushed to GTK+
 
-GtkToolShell:
+GtkToolShell
+============
 
-* ask tool items to apply ellipses to labels
 * left-align labels (and center icons) in both-horiz mode
 * enforce "expand" and "homogeneous" child property
+* request rotated rendering of text-only items
+* ask tool items to apply ellipses to labels

Modified: trunk/libegg/toolpalette/eggtoolitemgroup.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.c	(original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.c	Sat Mar 29 22:13:54 2008
@@ -25,13 +25,13 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
+#define P_(msgid)               (msgid)
+
 #define ANIMATION_TIMEOUT        50
 #define ANIMATION_DURATION      (ANIMATION_TIMEOUT * 4)
 #define DEFAULT_EXPANDER_SIZE    16
 #define DEFAULT_HEADER_SPACING   2
 
-#define P_(msgid) (msgid)
-
 #define DEFAULT_NAME             NULL
 #define DEFAULT_EXPANDED         TRUE
 #define DEFAULT_ELLIPSIZE        PANGO_ELLIPSIZE_NONE
@@ -44,6 +44,14 @@
   PROP_ELLIPSIZE,
 };
 
+enum
+{
+  CHILD_PROP_NONE,
+  CHILD_PROP_EXPAND,
+  CHILD_PROP_HOMOGENEOUS,
+  CHILD_PROP_POSITION,
+};
+
 struct _EggToolItemGroupPrivate
 {
   GtkWidget         *header;
@@ -705,25 +713,87 @@
 }
 
 static void
+egg_tool_item_group_set_child_property (GtkContainer *container,
+                                        GtkWidget    *child,
+                                        guint         prop_id,
+                                        const GValue *value,
+                                        GParamSpec   *pspec)
+{
+  EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (container);
+  GtkToolItem *item = GTK_TOOL_ITEM (child);
+
+  switch (prop_id)
+    {
+      case CHILD_PROP_EXPAND:
+        gtk_tool_item_set_expand (item, g_value_get_boolean (value));
+        break;
+
+      case CHILD_PROP_HOMOGENEOUS:
+        gtk_tool_item_set_homogeneous (item, g_value_get_boolean (value));
+        break;
+
+      case CHILD_PROP_POSITION:
+        egg_tool_item_group_set_item_position (group, item, g_value_get_int (value));
+        break;
+
+      default:
+        GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+egg_tool_item_group_get_child_property (GtkContainer *container,
+                                        GtkWidget    *child,
+                                        guint         prop_id,
+                                        GValue       *value,
+                                        GParamSpec   *pspec)
+{
+  EggToolItemGroup *group = EGG_TOOL_ITEM_GROUP (container);
+  GtkToolItem *item = GTK_TOOL_ITEM (child);
+
+  switch (prop_id)
+    {
+      case CHILD_PROP_EXPAND:
+        g_value_set_boolean (value, gtk_tool_item_get_expand (item));
+        break;
+
+      case CHILD_PROP_HOMOGENEOUS:
+        g_value_set_boolean (value, gtk_tool_item_get_homogeneous (item));
+        break;
+
+      case CHILD_PROP_POSITION:
+        g_value_set_int (value, egg_tool_item_group_get_item_position (group, item));
+        break;
+
+      default:
+        GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, prop_id, pspec);
+        break;
+    }
+}
+
+static void
 egg_tool_item_group_class_init (EggToolItemGroupClass *cls)
 {
-  GObjectClass *oclass = G_OBJECT_CLASS (cls);
-  GtkWidgetClass *wclass = GTK_WIDGET_CLASS (cls);
-  GtkContainerClass *cclass = GTK_CONTAINER_CLASS (cls);
-
-  oclass->set_property  = egg_tool_item_group_set_property;
-  oclass->get_property  = egg_tool_item_group_get_property;
-  oclass->finalize      = egg_tool_item_group_finalize;
-
-  wclass->size_request  = egg_tool_item_group_size_request;
-  wclass->size_allocate = egg_tool_item_group_size_allocate;
-  wclass->realize       = egg_tool_item_group_realize;
-  wclass->style_set     = egg_tool_item_group_style_set;
-
-  cclass->add           = egg_tool_item_group_add;
-  cclass->remove        = egg_tool_item_group_remove;
-  cclass->forall        = egg_tool_item_group_forall;
-  cclass->child_type    = egg_tool_item_group_child_type;
+  GObjectClass       *oclass = G_OBJECT_CLASS (cls);
+  GtkWidgetClass     *wclass = GTK_WIDGET_CLASS (cls);
+  GtkContainerClass  *cclass = GTK_CONTAINER_CLASS (cls);
+
+  oclass->set_property       = egg_tool_item_group_set_property;
+  oclass->get_property       = egg_tool_item_group_get_property;
+  oclass->finalize           = egg_tool_item_group_finalize;
+
+  wclass->size_request       = egg_tool_item_group_size_request;
+  wclass->size_allocate      = egg_tool_item_group_size_allocate;
+  wclass->realize            = egg_tool_item_group_realize;
+  wclass->style_set          = egg_tool_item_group_style_set;
+
+  cclass->add                = egg_tool_item_group_add;
+  cclass->remove             = egg_tool_item_group_remove;
+  cclass->forall             = egg_tool_item_group_forall;
+  cclass->child_type         = egg_tool_item_group_child_type;
+  cclass->set_child_property = egg_tool_item_group_set_child_property;
+  cclass->get_child_property = egg_tool_item_group_get_child_property;
 
   g_object_class_install_property (oclass, PROP_NAME,
                                    g_param_spec_string ("name",
@@ -769,6 +839,32 @@
                                                              G_PARAM_READABLE | G_PARAM_STATIC_NAME |
                                                              G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
 
+  gtk_container_class_install_child_property (cclass, CHILD_PROP_EXPAND,
+                                              g_param_spec_boolean ("expand",
+                                                                    P_("Expand"),
+                                                                    P_("Whether the item should receive extra space when the toolbar grows"),
+                                                                    FALSE,
+                                                                    G_PARAM_READWRITE | G_PARAM_STATIC_NAME |
+                                                                    G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+  gtk_container_class_install_child_property (cclass, CHILD_PROP_HOMOGENEOUS,
+                                              g_param_spec_boolean ("homogeneous",
+                                                                    P_("Homogeneous"),
+                                                                    P_("Whether the item should be the same size as other homogeneous items"),
+                                                                    FALSE,
+                                                                    G_PARAM_READWRITE | G_PARAM_STATIC_NAME |
+                                                                    G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+  gtk_container_class_install_child_property (cclass, CHILD_PROP_POSITION,
+                                              g_param_spec_int ("position",
+                                                                P_("Position"),
+                                                                P_("Position of the item within this group"),
+                                                                0,
+                                                                G_MAXINT,
+                                                                0,
+                                                                G_PARAM_READWRITE | G_PARAM_STATIC_NAME |
+                                                                G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
   g_type_class_add_private (cls, sizeof (EggToolItemGroupPrivate));
 }
 



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