[maemo-commits] [maemo-commits] r9502 - in projects/haf/branches/hildon-libs/hildon-1: . examples src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Jan 31 17:41:02 EET 2007
- Previous message: [maemo-commits] r9501 - projects/haf/trunk/hildon-theme-layout-4
- Next message: [maemo-commits] r9503 - in projects/haf/trunk/hildon-theme-layout-4: . rc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: mdk Date: 2007-01-31 17:41:00 +0200 (Wed, 31 Jan 2007) New Revision: 9502 Modified: projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 projects/haf/branches/hildon-libs/hildon-1/examples/hildon-caption-example.c projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.c Log: Adding checkbutton to the caption examples to see how things are looking. Xan's fix for caption and checkbutton. Modified: projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 2007-01-31 15:33:59 UTC (rev 9501) +++ projects/haf/branches/hildon-libs/hildon-1/ChangeLog.2 2007-01-31 15:41:00 UTC (rev 9502) @@ -1,5 +1,12 @@ 2007-01-31 Michael Dominic Kostrzewa <michael.kostrzewa at nokia.com> + * examples/hildon-caption-example.c: Adding checkbutton to the caption + examples to see how things are looking. + + * src/hildon-caption.c: Xan's fix for caption and checkbutton. + +2007-01-31 Michael Dominic Kostrzewa <michael.kostrzewa at nokia.com> + * src/hildon-color-chooser-dialog.c: * src/hildon-color-chooser.c: Adding some documentation. Modified: projects/haf/branches/hildon-libs/hildon-1/examples/hildon-caption-example.c =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/examples/hildon-caption-example.c 2007-01-31 15:33:59 UTC (rev 9501) +++ projects/haf/branches/hildon-libs/hildon-1/examples/hildon-caption-example.c 2007-01-31 15:41:00 UTC (rev 9502) @@ -44,13 +44,17 @@ gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON), 0); GtkWidget *caption3 = hildon_caption_new (size_group, "Caption right", gtk_entry_new (), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON), 0); + GtkWidget *caption4 = hildon_caption_new (size_group, "Check caption", gtk_check_button_new (), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON), 0); + hildon_caption_set_icon_position (HILDON_CAPTION (caption2), HILDON_CAPTION_POSITION_LEFT); hildon_caption_set_icon_position (HILDON_CAPTION (caption3), HILDON_CAPTION_POSITION_RIGHT); gtk_box_pack_start (GTK_BOX (dialog->vbox), caption1, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (dialog->vbox), caption2, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (dialog->vbox), caption3, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (dialog->vbox), caption4, FALSE, FALSE, 0); gtk_dialog_add_button (dialog, "Close", GTK_RESPONSE_CLOSE); Modified: projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.c =================================================================== --- projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.c 2007-01-31 15:33:59 UTC (rev 9501) +++ projects/haf/branches/hildon-libs/hildon-1/src/hildon-caption.c 2007-01-31 15:41:00 UTC (rev 9502) @@ -48,6 +48,7 @@ #include <gtk/gtkoptionmenu.h> #include <gtk/gtkmarshal.h> #include <gtk/gtkalignment.h> +#include <gtk/gtkcheckbutton.h> #include <stdio.h> #include <string.h> #include "hildon-defines.h" @@ -708,8 +709,8 @@ hildon_caption_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - GtkAllocation allocA; - GtkAllocation allocB; + GtkAllocation child_alloc; + GtkAllocation caption_alloc; GtkRequisition req; GtkWidget *child = NULL; HildonCaptionPrivate *priv = NULL; @@ -728,50 +729,53 @@ child = GTK_BIN (widget)->child; - widget->allocation = *allocation; + widget->allocation = *allocation; gtk_widget_get_child_requisition (priv->caption_area, &req); - allocA.height = allocB.height = allocation->height; - allocA.width = allocB.width = allocation->width; - allocA.x = allocB.x = allocB.y = allocA.y = 0; + child_alloc.height = caption_alloc.height = allocation->height; + child_alloc.width = caption_alloc.width = allocation->width; + child_alloc.x = caption_alloc.x = caption_alloc.y = child_alloc.y = 0; /* Center the captioned widget */ - if (allocA.width > req.width + HILDON_CAPTION_SPACING) + if (child_alloc.width > req.width + HILDON_CAPTION_SPACING) { - allocA.x += req.width + HILDON_CAPTION_SPACING * 2; - allocB.width = req.width; + child_alloc.x += req.width + HILDON_CAPTION_SPACING * 2; + caption_alloc.width = req.width; } /* Leave at least the space of the HILDON_CAPTION_SPACING in the left */ - allocB.x = HILDON_CAPTION_SPACING; + caption_alloc.x = HILDON_CAPTION_SPACING; /* Leave room for the other drawable parts of the caption control */ - allocA.width -= req.width + HILDON_CAPTION_SPACING * 2; + child_alloc.width -= req.width + HILDON_CAPTION_SPACING * 2; /* Give the child at least its minimum requisition, unless it is expandable */ if (! priv->expand && child && GTK_WIDGET_VISIBLE(child)) { GtkRequisition child_req; gtk_widget_get_child_requisition (child, &child_req); - allocA.width = MIN (allocA.width, child_req.width); - allocA.height = MIN (allocA.height, child_req.height); + child_alloc.width = MIN (child_alloc.width, child_req.width); + child_alloc.height = MIN (child_alloc.height, child_req.height); + /* Center the child */ + child_alloc.y = (allocation->height - child_alloc.height - + 2 * GTK_CONTAINER (widget)->border_width)/2; } /* Ensure there are no negative dimensions */ - if (allocA.width < 0) + if (child_alloc.width < 0) { - allocB.width = req.width + allocA.width; - allocA.width = 0; - allocB.width = MAX (allocB.width, 0); + caption_alloc.width = req.width + child_alloc.width; + child_alloc.width = 0; + caption_alloc.width = MAX (caption_alloc.width, 0); } - allocA.height = MAX (allocA.height, 0); - allocB.height = MAX (allocB.height, 0); + child_alloc.height = MAX (child_alloc.height, 0); + caption_alloc.height = MAX (caption_alloc.height, 0); if (child && GTK_WIDGET_VISIBLE(child) ) - gtk_widget_size_allocate( child, &allocA ); + gtk_widget_size_allocate (child, &child_alloc ); - gtk_widget_size_allocate (priv->caption_area, &allocB); + gtk_widget_size_allocate (priv->caption_area, &caption_alloc); } static void @@ -871,6 +875,10 @@ "status", flag, NULL); + /* Do not expand GtkCheckButton by default, we want to reduce its activation area */ + if (GTK_IS_CHECK_BUTTON (child)) + hildon_caption_set_child_expand (HILDON_CAPTION (widget), FALSE); + return widget; }
- Previous message: [maemo-commits] r9501 - projects/haf/trunk/hildon-theme-layout-4
- Next message: [maemo-commits] r9503 - in projects/haf/trunk/hildon-theme-layout-4: . rc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]