[maemo-commits] [maemo-commits] r13854 - in projects/haf/trunk/hildon-desktop: . libhildondesktop src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Sep 17 17:09:40 EEST 2007
- Previous message: [maemo-commits] r13853 - in projects/haf/trunk/hildon-desktop/debian: . config
- Next message: [maemo-commits] r13855 - in projects/haf/trunk/glib: . glib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: lucasr Date: 2007-09-17 17:09:37 +0300 (Mon, 17 Sep 2007) New Revision: 13854 Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h projects/haf/trunk/hildon-desktop/src/hd-applications-menu.c Log: 2007-09-17 Lucas Rocha <lucas.rocha at nokia.com> * src/hd-applications-menu.c (hd_applications_menu_activate_category): use new optimized functions to add and remove several items at once. * libhildondesktop/hildon-desktop-popup-menu.[ch] (hildon_desktop_popup_menu_add_item, hildon_desktop_popup_menu_add_items, hildon_desktop_popup_menu_real_add_item, hildon_desktop_popup_menu_remove_item, hildon_desktop_popup_menu_remove_all, hildon_desktop_popup_menu_real_remove_item): new functions to add several items at once in the menu and to remove all items. Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-09-17 14:05:32 UTC (rev 13853) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-09-17 14:09:37 UTC (rev 13854) @@ -1,3 +1,16 @@ +2007-09-17 Lucas Rocha <lucas.rocha at nokia.com> + + * src/hd-applications-menu.c (hd_applications_menu_activate_category): + use new optimized functions to add and remove several items at once. + * libhildondesktop/hildon-desktop-popup-menu.[ch] + (hildon_desktop_popup_menu_add_item, + hildon_desktop_popup_menu_add_items, + hildon_desktop_popup_menu_real_add_item, + hildon_desktop_popup_menu_remove_item, + hildon_desktop_popup_menu_remove_all, + hildon_desktop_popup_menu_real_remove_item): new functions to add + several items at once in the menu and to remove all items. + 2007-09-17 Moises Martinez <moises.martinez at nokia.com> * policies/tasknavigator-policy.c: Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c 2007-09-17 14:05:32 UTC (rev 13853) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c 2007-09-17 14:09:37 UTC (rev 13854) @@ -191,7 +191,7 @@ "resize-parent", "Whether resize or not parent window of menu", TRUE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); g_object_class_install_property (object_class, PROP_POPUP_PARENT, @@ -959,6 +959,33 @@ } } +static void +hildon_desktop_popup_menu_real_add_item (HildonDesktopPopupMenu *menu, + GtkMenuItem *item, + gint item_width) +{ + gtk_box_pack_end (GTK_BOX (menu->priv->box_items), + GTK_WIDGET (item), + FALSE, FALSE, 0); + + if (GTK_IS_SEPARATOR_MENU_ITEM (item)) + { + GtkRequisition req_sep; + + gtk_widget_size_request (GTK_WIDGET (item), &req_sep); + + gtk_widget_set_size_request (GTK_WIDGET (item), item_width, req_sep.height); + } + else + { + gtk_widget_set_size_request (GTK_WIDGET (item), item_width, menu->priv->item_height); + } + + gtk_widget_show (GTK_WIDGET (item)); + + menu->priv->n_items++; +} + void hildon_desktop_popup_menu_add_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item) { @@ -973,45 +1000,84 @@ gtk_widget_size_request (menu->priv->parent, &req); item_width = req.width; } + + hildon_desktop_popup_menu_real_add_item (menu, item, item_width); - gtk_box_pack_end (GTK_BOX (menu->priv->box_items), - GTK_WIDGET (item), - FALSE, FALSE, 0); + gtk_widget_set_size_request (menu->priv->box_buttons, + item_width, + menu->priv->item_height + 2); - if (GTK_IS_SEPARATOR_MENU_ITEM (item)) - { - GtkRequisition req_sep; + hildon_desktop_popup_menu_parent_size (menu); +} - gtk_widget_size_request (GTK_WIDGET (item), &req_sep); +void +hildon_desktop_popup_menu_add_items (HildonDesktopPopupMenu *menu, GList *items) +{ + GtkRequisition req; + GList *l; + gint item_width = -1; + + g_return_if_fail (HILDON_DESKTOP_IS_POPUP_MENU (menu)); - gtk_widget_set_size_request (GTK_WIDGET (item), item_width, req_sep.height); + if (GTK_IS_WINDOW (menu->priv->parent)) + { + gtk_widget_size_request (menu->priv->parent, &req); + item_width = req.width; } - else + + for (l = items; l != NULL; l = l->next) { - gtk_widget_set_size_request (GTK_WIDGET (item), item_width, menu->priv->item_height); + GtkWidget *item = GTK_WIDGET (l->data); + + if (GTK_IS_MENU_ITEM (item)) + hildon_desktop_popup_menu_real_add_item (menu, + GTK_MENU_ITEM (item), + item_width); } - gtk_widget_show (GTK_WIDGET (item)); - gtk_widget_set_size_request (menu->priv->box_buttons, item_width, menu->priv->item_height + 2); - menu->priv->n_items++; + hildon_desktop_popup_menu_parent_size (menu); - hildon_desktop_popup_menu_parent_size (menu); } +static void +hildon_desktop_popup_menu_real_remove_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item) +{ + gtk_container_remove (GTK_CONTAINER (menu->priv->box_items), GTK_WIDGET (item)); + + menu->priv->n_items--; +} + void hildon_desktop_popup_menu_remove_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item) { g_assert (HILDON_DESKTOP_IS_POPUP_MENU (menu)); g_return_if_fail (GTK_IS_MENU_ITEM (item)); - gtk_container_remove (GTK_CONTAINER (menu->priv->box_items), GTK_WIDGET (item)); - - menu->priv->n_items--; + hildon_desktop_popup_menu_real_remove_item (menu, item); + + hildon_desktop_popup_menu_parent_size (menu); +} +void +hildon_desktop_popup_menu_remove_all (HildonDesktopPopupMenu *menu) +{ + GList *children, *l; + + g_assert (HILDON_DESKTOP_IS_POPUP_MENU (menu)); + + children = hildon_desktop_popup_menu_get_children (menu); + + for (l = children; l != NULL; l = l->next) + { + GtkWidget *item = GTK_WIDGET (l->data); + + hildon_desktop_popup_menu_real_remove_item (menu, GTK_MENU_ITEM (item)); + } + hildon_desktop_popup_menu_parent_size (menu); } Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h 2007-09-17 14:05:32 UTC (rev 13853) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h 2007-09-17 14:09:37 UTC (rev 13854) @@ -62,10 +62,17 @@ hildon_desktop_popup_menu_add_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item); +void +hildon_desktop_popup_menu_add_items (HildonDesktopPopupMenu *menu, + GList *items); + void hildon_desktop_popup_menu_remove_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item); +void +hildon_desktop_popup_menu_remove_all (HildonDesktopPopupMenu *menu); + GList * hildon_desktop_popup_menu_get_children (HildonDesktopPopupMenu *menu); Modified: projects/haf/trunk/hildon-desktop/src/hd-applications-menu.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-applications-menu.c 2007-09-17 14:05:32 UTC (rev 13853) +++ projects/haf/trunk/hildon-desktop/src/hd-applications-menu.c 2007-09-17 14:09:37 UTC (rev 13854) @@ -383,23 +383,17 @@ GtkMenuItem *child = (GtkMenuItem *) i->data; g_object_ref (child); - - hildon_desktop_popup_menu_remove_item - (button->priv->menu_applications, child); } + hildon_desktop_popup_menu_remove_all (button->priv->menu_applications); + g_list_free (sub_items); sub_items = (GList *) g_object_get_data (G_OBJECT (item), - CATEGORY_SUB_ITEMS); + CATEGORY_SUB_ITEMS); - for (i = g_list_first (sub_items); i; i = i->next) - { - GtkMenuItem *child = (GtkMenuItem *) i->data; - - hildon_desktop_popup_menu_add_item - (button->priv->menu_applications, child); - } + hildon_desktop_popup_menu_add_items (button->priv->menu_applications, + sub_items); } if (button->priv->focus_applications &&
- Previous message: [maemo-commits] r13853 - in projects/haf/trunk/hildon-desktop/debian: . config
- Next message: [maemo-commits] r13855 - in projects/haf/trunk/glib: . glib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]