[maemo-commits] [maemo-commits] r13614 - in projects/haf/trunk/hildon-desktop: . libhildondesktop src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Sep 5 17:29:58 EEST 2007
- Previous message: [maemo-commits] r13613 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r13615 - in projects/haf/trunk/sapwood: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: jobi Date: 2007-09-05 17:29:56 +0300 (Wed, 05 Sep 2007) New Revision: 13614 Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-home-area.c projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-home-area.h projects/haf/trunk/hildon-desktop/src/hd-home-window.c Log: 2007-09-05 Johan Bilien <johan.bilien at nokia.com> * libhildondesktop/hildon-home-area.[ch]: removed the "batch_add" optimization as it makes the code too complex * src/hd-home-window.c: do not call set_batch_add Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-09-05 14:28:07 UTC (rev 13613) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-09-05 14:29:56 UTC (rev 13614) @@ -1,3 +1,9 @@ +2007-09-05 Johan Bilien <johan.bilien at nokia.com> + + * libhildondesktop/hildon-home-area.[ch]: removed the "batch_add" + optimization as it makes the code too complex + * src/hd-home-window.c: do not call set_batch_add + 2007-09-05 Lucas Rocha <lucas.rocha at nokia.com> * libhildonwm (hd_wm_activate_window): correctly activate applications Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-home-area.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-home-area.c 2007-09-05 14:28:07 UTC (rev 13613) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-home-area.c 2007-09-05 14:29:56 UTC (rev 13614) @@ -104,9 +104,6 @@ GHashTable *layout; - GList *to_add; - gboolean batch_add; - GList *children_data; gdouble default_alpha; @@ -232,8 +229,11 @@ static void hildon_home_area_finalize (GObject *object); +static void +hildon_home_area_place (HildonHomeArea *area, GtkWidget *widget); + static void child_data_free (ChildData *child_data) { @@ -826,12 +826,6 @@ g_debug ("Adding Hildon Home applet %s", hildon_desktop_item_get_id (HILDON_DESKTOP_ITEM (applet))); - if (priv->batch_add) - { - priv->to_add = g_list_append (priv->to_add, applet); - return; - } - if (HILDON_DESKTOP_IS_HOME_ITEM (applet)) { Layout *layout = NULL; @@ -846,18 +840,22 @@ if (layout) { - hildon_home_area_put (HILDON_HOME_AREA (area), - applet, - layout->rect.x, layout->rect.y, - layout->stack_index); + + g_debug ("Found a layout, setting %ix%i", + layout->rect.width, + layout->rect.height); if (layout->rect.width > 0 && layout->rect.height > 0) gtk_widget_set_size_request (applet, layout->rect.width, layout->rect.height); + hildon_home_area_put (HILDON_HOME_AREA (area), + applet, + layout->rect.x, layout->rect.y, + layout->stack_index); } else { - hildon_home_area_put (HILDON_HOME_AREA (area), applet, 0, 0, G_MAXINT); + hildon_home_area_place (HILDON_HOME_AREA (area), applet); } } @@ -876,21 +874,11 @@ i = priv->children_data; while (i) - { - ChildData *child = i->data; - - i = i->next; - callback (child->widget, user_data); - } - - if (priv->batch_add) { - i = priv->to_add; - while (i) - { - callback (i->data, user_data); - i = i->next; - } + ChildData *child = i->data; + + i = i->next; + callback (child->widget, user_data); } } @@ -1658,18 +1646,25 @@ } static void -hildon_home_area_batch_add (HildonHomeArea *area) +hildon_home_area_place (HildonHomeArea *area, GtkWidget *w) { HildonHomeAreaPriv *priv; GdkRectangle *area_rectangle; - GList *region = NULL, *i; + GList *region = NULL; + GtkRequisition req = {0}; + GList *i_rect; + const gchar *name; + name = hildon_desktop_item_get_id (HILDON_DESKTOP_ITEM (w)); + + g_debug ("Placing: %s", name); + priv = HILDON_HOME_AREA_GET_PRIVATE (area); area_rectangle = create_rectangle (0, 0, GTK_WIDGET (area)->allocation.width, - GTK_WIDGET (area)->allocation.height); + GTK_WIDGET (area)->allocation.height); region = g_list_append (region, area_rectangle); @@ -1678,93 +1673,74 @@ region); region = g_list_sort (region, (GCompareFunc)sort_rectangles); - i = priv->to_add; - while (i) - { - GtkRequisition req = {0}; - GList *i_rect; - GtkWidget *w; - const gchar *name; + gtk_widget_size_request (w, &req); + g_debug ("size request: %ix%i", req.width, req.height); - w = GTK_WIDGET (i->data); - name = hildon_desktop_item_get_id (HILDON_DESKTOP_ITEM (w)); + if (req.width > area_rectangle->width || + req.height > area_rectangle->height) + { + /* Applet is bigger than the area ... Put it in top-left corner */ + Layout *layout = g_new (Layout, 1); - gtk_widget_size_request (w, &req); + layout->rect.x = 0; + layout->rect.y = 0; + layout->rect.width = req.width; + layout->rect.height = req.height; + layout->stack_index = G_MAXINT; - i_rect = region; + g_hash_table_insert (priv->layout, g_strdup (name), layout); + hildon_home_area_put (area, w, 0, 0, G_MAXINT); - while (i_rect) - { - GdkRectangle *r = (GdkRectangle *)i_rect->data; + g_list_foreach (region, (GFunc)g_free, NULL); + g_list_free (region); - if (r->width >= req.width && - r->height >= req.height) - { - Layout *layout = g_new (Layout, 1); - GdkRectangle *padded_layout = g_new (GdkRectangle, 1); + return; + } - layout->rect.x = r->x; - layout->rect.y = r->y; - layout->rect.width = req.width; - layout->rect.height = req.height; - layout->stack_index = G_MAXINT; + while (TRUE) + { + i_rect = region; - g_hash_table_insert (priv->layout, g_strdup (name), layout); - gtk_container_add (GTK_CONTAINER (area), w); + while (i_rect) + { + GdkRectangle *r = (GdkRectangle *)i_rect->data; - *padded_layout = layout->rect; + if (r->width >= req.width && + r->height >= req.height) + { + Layout *layout = g_new (Layout, 1); - if (padded_layout->x + padded_layout->width < - area_rectangle->width) - padded_layout->width += priv->applet_padding; + layout->rect.x = r->x; + layout->rect.y = r->y; + layout->rect.width = req.width; + layout->rect.height = req.height; + layout->stack_index = G_MAXINT; - if (padded_layout->y + padded_layout->height < - area_rectangle->height) - padded_layout->height += priv->applet_padding; + g_hash_table_insert (priv->layout, g_strdup (name), layout); + hildon_home_area_put (area, w, r->x, r->y, G_MAXINT); - if (padded_layout->x) - { - padded_layout->x -= priv->applet_padding; - padded_layout->width += priv->applet_padding; - } + break; + } - if (padded_layout->y) - { - padded_layout->y-= priv->applet_padding; - padded_layout->height += priv->applet_padding; - } + i_rect = g_list_next (i_rect); - substract_rectangle_from_region (region, padded_layout); - region = g_list_sort (region, (GCompareFunc)sort_rectangles); + } - break; - } - - i_rect = g_list_next (i_rect); - - } - - if (!i_rect) - { - g_debug ("Adding layer"); - /* Not enough place in this layer, we need to add one */ - g_list_foreach (region, (GFunc)g_free, NULL); - g_list_free (region); - region = NULL; - region = g_list_append (region, area_rectangle); - } - else - i = g_list_next (i); - + if (!i_rect) + { + /* Not enough place in this layer, we need to add one */ + g_list_foreach (region, (GFunc)g_free, NULL); + g_list_free (region); + region = NULL; + region = g_list_append (region, area_rectangle); } + else + break; + } g_list_foreach (region, (GFunc)g_free, NULL); g_list_free (region); - - g_list_free (priv->to_add); - priv->to_add = NULL; - } static void @@ -2087,23 +2063,6 @@ } void -hildon_home_area_set_batch_add (HildonHomeArea *area, gboolean batch_add) -{ - HildonHomeAreaPriv *priv; - g_return_if_fail (area); - priv = HILDON_HOME_AREA_GET_PRIVATE (area); - - if (priv->batch_add && !batch_add) - { - priv->batch_add = FALSE; - hildon_home_area_batch_add (area); - g_signal_emit_by_name (area, "layout-changed"); - } - - priv->batch_add = batch_add; -} - -void hildon_home_area_put (HildonHomeArea *area, GtkWidget *widget, gint x, gint y, Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-home-area.h =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-home-area.h 2007-09-05 14:28:07 UTC (rev 13613) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-home-area.h 2007-09-05 14:29:56 UTC (rev 13614) @@ -90,9 +90,6 @@ gboolean hildon_home_area_get_overlaps (HildonHomeArea *area); -void hildon_home_area_set_batch_add (HildonHomeArea *area, - gboolean batch_add); - void hildon_home_area_put (HildonHomeArea *area, GtkWidget *child, gint x, Modified: projects/haf/trunk/hildon-desktop/src/hd-home-window.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-home-window.c 2007-09-05 14:28:07 UTC (rev 13613) +++ projects/haf/trunk/hildon-desktop/src/hd-home-window.c 2007-09-05 14:29:56 UTC (rev 13614) @@ -1464,9 +1464,7 @@ priv->selecting_applets = TRUE; - hildon_home_area_set_batch_add (HILDON_HOME_AREA (area), TRUE); g_signal_emit_by_name (window, "select-plugins", NULL); - hildon_home_area_set_batch_add (HILDON_HOME_AREA (area), FALSE); priv->selecting_applets = FALSE; }
- Previous message: [maemo-commits] r13613 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r13615 - in projects/haf/trunk/sapwood: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]