* src/hildon-bread-crumb.c: * src/hildon-bread-crumb-trail.c:
authorXan Lopez <xan.lopez@nokia.com>
Mon, 16 Apr 2007 13:42:07 +0000 (13:42 +0000)
committerXan Lopez <xan.lopez@nokia.com>
Mon, 16 Apr 2007 13:42:07 +0000 (13:42 +0000)
Some cleanups.

ChangeLog
src/hildon-bread-crumb-trail.c
src/hildon-bread-crumb.c

index 27f1591..78f12fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-04-16  Xan Lopez  <xan.lopez@nokia.com>
+
+       * src/hildon-bread-crumb.c:
+       * src/hildon-bread-crumb-trail.c:
+
+       Some cleanups.
+
 2007-04-16  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
        [1.0.1 release]
index 50779af..2612d09 100644 (file)
@@ -31,7 +31,6 @@ struct _HildonBreadCrumbTrailPrivate
 {
   GtkWidget *back_button;
   GList *item_list;
-  gchar *path_separator;
 };
 
 /* Signals */
@@ -145,7 +144,6 @@ hildon_bread_crumb_trail_finalize (GObject *object)
 {
   HildonBreadCrumbTrailPrivate *priv = HILDON_BREAD_CRUMB_TRAIL (object)->priv;
 
-  g_free (priv->path_separator);
   g_list_free (priv->item_list);
 
   G_OBJECT_CLASS (hildon_bread_crumb_trail_parent_class)->finalize (object);
@@ -193,7 +191,10 @@ hildon_bread_crumb_trail_size_request (GtkWidget *widget,
   /* Button requisitions */
   for (p = priv->item_list; p; p = p->next)
     {
-      gtk_widget_size_request (GTK_WIDGET (p->data), &child_requisition);
+      GtkWidget *child = GTK_WIDGET (p->data);
+
+      if (GTK_WIDGET_VISIBLE (child))
+        gtk_widget_size_request (child, &child_requisition);
     }
 
   /* Border width */
@@ -229,8 +230,8 @@ hildon_bread_crumb_trail_size_allocate (GtkWidget *widget,
   allocation_width = allocation->width - 2 * border_width;
 
   /* Allocate the back button */
-  child_allocation.x = allocation->x;
-  child_allocation.y = allocation->y;
+  child_allocation.x = allocation->x + border_width;
+  child_allocation.y = allocation->y + border_width;
   gtk_widget_get_child_requisition (priv->back_button, &child_requisition);
   child_allocation.width = child_requisition.width;
   child_allocation.height = child_requisition.height;
@@ -250,6 +251,10 @@ hildon_bread_crumb_trail_size_allocate (GtkWidget *widget,
   first_hide = NULL; 
   extra_space = 0;
 
+  gtk_widget_style_get (widget,
+                        "maximum-width", &maximum_width,
+                        NULL);
+
   for (p = priv->item_list; p; p = p->next)
     {
       item = HILDON_BREAD_CRUMB (p->data);
@@ -260,10 +265,6 @@ hildon_bread_crumb_trail_size_allocate (GtkWidget *widget,
                                            &natural_width,
                                            &natural_height);
 
-      gtk_widget_style_get (widget,
-                            "maximum-width", &maximum_width,
-                            NULL);
-
       desired_width = MIN (natural_width, maximum_width);
 
       if (width + desired_width <= allocation_width)
@@ -379,7 +380,6 @@ crumb_clicked_cb (GtkWidget *button,
       child = GTK_WIDGET (priv->item_list->data);
     }
 
-  /* We need the item for the ID */
   g_signal_emit (bct, bread_crumb_trail_signals[CRUMB_CLICKED], 0,
                  get_bread_crumb_id (HILDON_BREAD_CRUMB (child)));
 }
index 2d045f7..85c2c37 100644 (file)
@@ -234,7 +234,7 @@ hildon_bread_crumb_get_natural_size (HildonBreadCrumb *item,
                                      gint *natural_width,
                                      gint *natural_height)
 {
-  GtkRequisition req;
+  GtkRequisition widget_req, label_req;
   gint width, height;
   PangoLayout *layout;
   HildonBreadCrumbPrivate *priv;
@@ -243,28 +243,29 @@ hildon_bread_crumb_get_natural_size (HildonBreadCrumb *item,
 
   priv = item->priv;
 
-  gtk_widget_size_request (GTK_WIDGET (item), &req);
-  if (natural_width)
-    *natural_width = req.width;
+  gtk_widget_size_request (GTK_WIDGET (item), &widget_req);
 
-  if (natural_height)
-    *natural_height = req.height;
-  /* Substract the size request of the label */
-  gtk_widget_size_request (priv->label, &req);
-  if (natural_width)
-    *natural_width -= req.width;
   layout = gtk_widget_create_pango_layout (priv->label, priv->text);
   pango_layout_get_size (layout, &width, &height);
   g_object_unref (layout);
 
   if (natural_width)
-    *natural_width += PANGO_PIXELS (width);
-  /* Border width */
-  if (natural_width)
-    *natural_width += GTK_CONTAINER (item)->border_width * 2;
+    {
+      *natural_width = widget_req.width;
+      /* Substract the size request of the label */
+      gtk_widget_size_request (priv->label, &label_req);
+      *natural_width -= label_req.width;
+
+      /* Add the "natural" width for the label */
+      *natural_width += PANGO_PIXELS (width);
+      *natural_width += GTK_CONTAINER (item)->border_width * 2;
+    }
 
   if (natural_height)
-    *natural_height += GTK_CONTAINER (item)->border_width * 2;
+    {
+      *natural_height = widget_req.height;
+      *natural_height += GTK_CONTAINER (item)->border_width * 2;
+    }
 }
 
 GtkWidget*