]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkbbox.c
when not using an explicit alignment, use the full area of the row (not
[~andy/gtk] / gtk / gtkbbox.c
index b7167e4e026c43f39a2ae14825aed6a51a54ebf9..c546a344b484f1527870a3186d348deb73baf5de 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#include <config.h>
 #include "gtkbbox.h"
+#include "gtkprivate.h"
 #include "gtkintl.h"
+#include "gtkalias.h"
 
 enum {
   PROP_0,
@@ -38,8 +41,6 @@ enum {
   CHILD_PROP_SECONDARY
 };
 
-static void gtk_button_box_class_init         (GtkButtonBoxClass *klass);
-static void gtk_button_box_init               (GtkButtonBox      *box);
 static void gtk_button_box_set_property       (GObject           *object,
                                               guint              prop_id,
                                               const GValue      *value,
@@ -64,33 +65,7 @@ static void gtk_button_box_get_child_property (GtkContainer      *container,
 #define DEFAULT_CHILD_IPAD_X 4
 #define DEFAULT_CHILD_IPAD_Y 0
 
-GtkType
-gtk_button_box_get_type (void)
-{
-  static GtkType button_box_type = 0;
-
-  if (!button_box_type)
-    {
-      static const GTypeInfo button_box_info =
-      {
-       sizeof (GtkButtonBoxClass),
-       NULL,            /* base_init */
-       NULL,            /* base_finalize */
-       (GClassInitFunc) gtk_button_box_class_init,
-       NULL,            /* class_finalize */
-       NULL,            /* class_data */
-       sizeof (GtkButtonBox),
-       0,               /* n_preallocs */
-       (GInstanceInitFunc) gtk_button_box_init,
-       NULL,            /* value_table */
-      };
-
-      button_box_type = g_type_register_static (GTK_TYPE_BOX, "GtkButtonBox",
-                                               &button_box_info, G_TYPE_FLAG_ABSTRACT);
-    }
-
-  return button_box_type;
-}
+G_DEFINE_ABSTRACT_TYPE (GtkButtonBox, gtk_button_box, GTK_TYPE_BOX)
 
 static void
 gtk_button_box_class_init (GtkButtonBoxClass *class)
@@ -112,58 +87,57 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
   /* FIXME we need to override the "spacing" property on GtkBox once
    * libgobject allows that.
    */
-
   gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_int ("child_min_width",
-                                                            _("Minimum child width"),
-                                                            _("Minimum width of buttons inside the box"),
+                                          g_param_spec_int ("child-min-width",
+                                                            P_("Minimum child width"),
+                                                            P_("Minimum width of buttons inside the box"),
                                                             0,
                                                             G_MAXINT,
                                                              DEFAULT_CHILD_MIN_WIDTH,
-                                                            G_PARAM_READABLE));
+                                                            GTK_PARAM_READABLE));
 
   gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_int ("child_min_height",
-                                                            _("Minimum child height"),
-                                                            _("Minimum height of buttons inside the box"),
+                                          g_param_spec_int ("child-min-height",
+                                                            P_("Minimum child height"),
+                                                            P_("Minimum height of buttons inside the box"),
                                                             0,
                                                             G_MAXINT,
                                                              DEFAULT_CHILD_MIN_HEIGHT,
-                                                            G_PARAM_READABLE));
+                                                            GTK_PARAM_READABLE));
 
   gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_int ("child_internal_pad_x",
-                                                            _("Child internal width padding"),
-                                                            _("Amount to increase child's size on either side"),
+                                          g_param_spec_int ("child-internal-pad-x",
+                                                            P_("Child internal width padding"),
+                                                            P_("Amount to increase child's size on either side"),
                                                             0,
                                                             G_MAXINT,
                                                              DEFAULT_CHILD_IPAD_X,
-                                                            G_PARAM_READABLE));
+                                                            GTK_PARAM_READABLE));
 
   gtk_widget_class_install_style_property (widget_class,
-                                          g_param_spec_int ("child_internal_pad_y",
-                                                            _("Child internal height padding"),
-                                                            _("Amount to increase child's size on the top and bottom"),
+                                          g_param_spec_int ("child-internal-pad-y",
+                                                            P_("Child internal height padding"),
+                                                            P_("Amount to increase child's size on the top and bottom"),
                                                             0,
                                                             G_MAXINT,
                                                              DEFAULT_CHILD_IPAD_Y,
-                                                            G_PARAM_READABLE));
+                                                            GTK_PARAM_READABLE));
   g_object_class_install_property (gobject_class,
                                    PROP_LAYOUT_STYLE,
-                                   g_param_spec_enum ("layout_style",
-                                                      _("Layout style"),
-                                                      _("How to layout the buttons in the box. Possible values are default, spread, edge, start and end"),
+                                   g_param_spec_enum ("layout-style",
+                                                      P_("Layout style"),
+                                                      P_("How to layout the buttons in the box. Possible values are default, spread, edge, start and end"),
                                                      GTK_TYPE_BUTTON_BOX_STYLE,
                                                      GTK_BUTTONBOX_DEFAULT_STYLE,
-                                                      G_PARAM_READWRITE));
+                                                      GTK_PARAM_READWRITE));
 
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_SECONDARY,
                                              g_param_spec_boolean ("secondary", 
-                                                                   _("Secondary"),
-                                                                   _("If TRUE, the child appears in a secondary group of children, suitable for, e.g., help buttons"),
+                                                                   P_("Secondary"),
+                                                                   P_("If TRUE, the child appears in a secondary group of children, suitable for, e.g., help buttons"),
                                                                    FALSE,
-                                                                   G_PARAM_READWRITE));
+                                                                   GTK_PARAM_READWRITE));
 }
 
 static void
@@ -238,25 +212,12 @@ gtk_button_box_get_child_property (GtkContainer *container,
                                   GValue       *value,
                                   GParamSpec   *pspec)
 {
-  GList *list;
-  GtkBoxChild *child_info = NULL;
-
-  list = GTK_BOX (container)->children;
-  while (list)
-    {
-      child_info = list->data;
-      if (child_info->widget == child)
-       break;
-
-      list = list->next;
-    }
-
-  g_assert (list != NULL);
-  
   switch (property_id)
     {
     case CHILD_PROP_SECONDARY:
-      g_value_set_boolean (value, child_info->is_secondary);
+      g_value_set_boolean (value, 
+                          gtk_button_box_get_child_secondary (GTK_BUTTON_BOX (container), 
+                                                              child));
       break;
     default:
       GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
@@ -297,7 +258,7 @@ gtk_button_box_set_layout (GtkButtonBox      *widget,
   if (widget->layout_style != layout_style)
     {
       widget->layout_style = layout_style;
-      g_object_notify (G_OBJECT (widget), "layout_style");
+      g_object_notify (G_OBJECT (widget), "layout-style");
       gtk_widget_queue_resize (GTK_WIDGET (widget));
     }
 }
@@ -337,6 +298,43 @@ gtk_button_box_get_layout (GtkButtonBox *widget)
   return widget->layout_style;
 }
 
+/**
+ * gtk_button_box_get_child_secondary:
+ * @widget: a #GtkButtonBox
+ * @child: a child of @widget 
+ * 
+ * Returns whether @child should appear in a secondary group of children.
+ *
+ * Return value: whether @child should appear in a secondary group of children.
+ *
+ * Since: 2.4
+ **/
+gboolean 
+gtk_button_box_get_child_secondary (GtkButtonBox *widget,
+                                   GtkWidget    *child)
+{
+  GList *list;
+  GtkBoxChild *child_info;
+
+  g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), FALSE);
+  g_return_val_if_fail (GTK_IS_WIDGET (child), FALSE);
+
+  child_info = NULL;
+  list = GTK_BOX (widget)->children;
+  while (list)
+    {
+      child_info = list->data;
+      if (child_info->widget == child)
+       break;
+
+      list = list->next;
+    }
+
+  g_return_val_if_fail (list != NULL, FALSE);
+
+  return child_info->is_secondary;
+}
+
 /**
  * gtk_button_box_set_child_secondary
  * @widget: a #GtkButtonBox
@@ -349,7 +347,7 @@ gtk_button_box_get_layout (GtkButtonBox *widget)
  *
  * This group appears after the other children if the style
  * is %GTK_BUTTONBOX_START, %GTK_BUTTONBOX_SPREAD or
- * %GTK_BUTTONBOX_EDGE, and before the the other children if the style
+ * %GTK_BUTTONBOX_EDGE, and before the other children if the style
  * is %GTK_BUTTONBOX_END. For horizontal button boxes, the definition
  * of before/after depends on direction of the widget (see
  * gtk_widget_set_direction()). If the style is %GTK_BUTTONBOX_START
@@ -422,14 +420,11 @@ _gtk_button_box_child_requisition (GtkWidget *widget,
   bbox = GTK_BUTTON_BOX (widget);
 
   gtk_widget_style_get (widget,
-                        "child_min_width",
-                        &width_default,
-                        "child_min_height",
-                        &height_default,
-                        "child_internal_pad_x",
-                        &ipad_x_default,
-                        "child_internal_pad_y",
-                        &ipad_y_default, NULL);
+                        "child-min-width", &width_default,
+                        "child-min-height", &height_default,
+                        "child-internal-pad-x", &ipad_x_default,
+                        "child-internal-pad-y", &ipad_y_default, 
+                       NULL);
   
   child_min_width = bbox->child_min_width   != GTK_BUTTONBOX_DEFAULT
          ? bbox->child_min_width : width_default;
@@ -476,3 +471,6 @@ _gtk_button_box_child_requisition (GtkWidget *widget,
   if (height)
     *height = needed_height;
 }
+
+#define __GTK_BUTTON_BOX_C__
+#include "gtkaliasdef.c"