[maemo-commits] [maemo-commits] r14258 - in projects/haf/trunk/hildon-desktop: . libhildondesktop src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Oct 2 13:33:56 EEST 2007
- Previous message: [maemo-commits] r14257 - in projects/haf/trunk/hildon-fm: . debian hildon-fm
- Next message: [maemo-commits] r14259 - projects/haf/trunk/hildon-fm/hildon-fm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: lucasr Date: 2007-10-02 13:33:53 +0300 (Tue, 02 Oct 2007) New Revision: 14258 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/libhildondesktop/hildon-desktop-popup-window.c projects/haf/trunk/hildon-desktop/src/hd-applications-menu.c projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c Log: 2007-10-02 Lucas Rocha <lucas.rocha at nokia.com> * src/hd-applications-menu.c (hd_applications_menu_finalize, hd_applications_menu_activate_category, hd_applications_menu_free_menu_list, hd_applications_menu_create_menu, hd_applications_menu_get_items, hd_applications_menu_populate): complete refactoring of the way applications pane is update. Instead of removing and adding items from the popup menu widget, we just add all application menu items to the popup menu and keep hinding and showing certain menu items each time a category is activated. This brings a mass performance improvement as GTK+ doesn't perform very well with massively adding/removing widgets from containers. * src/hd-switcher-menu.c (hd_switcher_menu_init, hd_switcher_menu_eventbox_keypress_cb): add an eventbox around the popup menus in order to avoid flickers on scroll buttons area. Explicitly show menu items on their creation as the popup menu doesn't call gtk_widget_show on them anymore. * libhildondesktop/hildon-desktop-popup-menu.[ch] (hildon_desktop_popup_menu_get_children, hildon_desktop_popup_menu_parent_size, hildon_desktop_popup_menu_item_is_valid, hildon_desktop_popup_menu_motion_notify): take in to account the visibility of the menu items on all basic operations on popup menu like motion notify, keyboard navigation, getting children, etc. Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-10-02 10:25:33 UTC (rev 14257) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-10-02 10:33:53 UTC (rev 14258) @@ -1,3 +1,28 @@ +2007-10-02 Lucas Rocha <lucas.rocha at nokia.com> + + * src/hd-applications-menu.c (hd_applications_menu_finalize, + hd_applications_menu_activate_category, + hd_applications_menu_free_menu_list, hd_applications_menu_create_menu, + hd_applications_menu_get_items, hd_applications_menu_populate): + complete refactoring of the way applications pane is update. Instead + of removing and adding items from the popup menu widget, we just add + all application menu items to the popup menu and keep hinding and + showing certain menu items each time a category is activated. This + brings a mass performance improvement as GTK+ doesn't perform very + well with massively adding/removing widgets from containers. + * src/hd-switcher-menu.c (hd_switcher_menu_init, + hd_switcher_menu_eventbox_keypress_cb): add an eventbox around the + popup menus in order to avoid flickers on scroll buttons area. + Explicitly show menu items on their creation as the popup menu doesn't + call gtk_widget_show on them anymore. + * libhildondesktop/hildon-desktop-popup-menu.[ch] + (hildon_desktop_popup_menu_get_children, + hildon_desktop_popup_menu_parent_size, + hildon_desktop_popup_menu_item_is_valid, + hildon_desktop_popup_menu_motion_notify): take in to account the + visibility of the menu items on all basic operations on popup menu + like motion notify, keyboard navigation, getting children, etc. + 2007-10-01 Johan Bilien <johan.bilien at nokia.com> * configure.ac: 0.0.39 Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c 2007-10-02 10:25:33 UTC (rev 14257) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c 2007-10-02 10:33:53 UTC (rev 14258) @@ -252,8 +252,7 @@ static gboolean hildon_desktop_popup_menu_item_is_selectable (GtkWidget *menu_item) { - if ((!GTK_BIN (menu_item)->child && - GTK_IS_MENU_ITEM (menu_item)) || + if ((!GTK_BIN (menu_item)->child && GTK_IS_MENU_ITEM (menu_item)) || GTK_IS_SEPARATOR_MENU_ITEM (menu_item) || !GTK_WIDGET_IS_SENSITIVE (menu_item) || !GTK_WIDGET_VISIBLE (menu_item)) @@ -262,6 +261,17 @@ return TRUE; } +static gboolean +hildon_desktop_popup_menu_item_is_valid (GtkWidget *menu_item) +{ + if ((!GTK_BIN (menu_item)->child && GTK_IS_MENU_ITEM (menu_item) + && !GTK_IS_SEPARATOR_MENU_ITEM (menu_item)) || + !GTK_WIDGET_VISIBLE (menu_item)) + return FALSE; + + return TRUE; +} + static GObject * hildon_desktop_popup_menu_constructor (GType gtype, guint n_params, @@ -552,6 +562,9 @@ for (l = menu_items; l != NULL; l = g_list_next (l)) { + if (!hildon_desktop_popup_menu_item_is_selectable (GTK_WIDGET (l->data))) + continue; + gtk_widget_get_pointer (GTK_WIDGET (l->data), &x, &y); w = GTK_WIDGET (l->data)->allocation.width; @@ -559,8 +572,7 @@ if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h)) { - if (hildon_desktop_popup_menu_item_is_selectable (GTK_WIDGET (l->data)) && - menu->priv->selected_item != GTK_MENU_ITEM (l->data)) + if (menu->priv->selected_item != GTK_MENU_ITEM (l->data)) { if (GTK_IS_ITEM (menu->priv->selected_item)) gtk_item_deselect (GTK_ITEM (menu->priv->selected_item)); @@ -839,7 +851,7 @@ } } -static void +void hildon_desktop_popup_menu_parent_size (HildonDesktopPopupMenu *menu) { GtkRequisition req, parent_req; @@ -860,15 +872,18 @@ for (l = children; l != NULL; l = g_list_next (l)) { - gtk_widget_size_request (GTK_WIDGET (l->data), &req); + if (hildon_desktop_popup_menu_item_is_valid (GTK_WIDGET (l->data))) + { + gtk_widget_size_request (GTK_WIDGET (l->data), &req); - d_height += req.height; + d_height += req.height; - if (d_height > max_height) - { - d_height -= menu->priv->item_height; - show_scroll_controls = TRUE; - break; + if (d_height > max_height) + { + d_height -= menu->priv->item_height; + show_scroll_controls = TRUE; + break; + } } } @@ -941,7 +956,7 @@ { if (l != item) { - if (l->data && !GTK_IS_SEPARATOR_MENU_ITEM (l->data) && GTK_IS_MENU_ITEM (l->data)) + if (l->data && hildon_desktop_popup_menu_item_is_selectable (GTK_WIDGET (l->data))) { hildon_desktop_popup_menu_select_item (menu, GTK_MENU_ITEM (l->data)); break; @@ -988,8 +1003,6 @@ gtk_widget_set_size_request (GTK_WIDGET (item), item_width, menu->priv->item_height); } - gtk_widget_show (GTK_WIDGET (item)); - menu->priv->n_items++; } @@ -1097,10 +1110,22 @@ GList * hildon_desktop_popup_menu_get_children (HildonDesktopPopupMenu *menu) { + GList *list = NULL, *children, *l; + g_return_val_if_fail (HILDON_DESKTOP_IS_POPUP_MENU (menu), NULL); - GList *list = gtk_container_get_children (GTK_CONTAINER (menu->priv->box_items)); + children = gtk_container_get_children (GTK_CONTAINER (menu->priv->box_items)); + for (l = children; l != NULL; l = l->next) + { + if (hildon_desktop_popup_menu_item_is_valid (GTK_WIDGET (l->data))) + { + list = g_list_append (list, l->data); + } + } + + g_list_free (children); + return list; } Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h 2007-10-02 10:25:33 UTC (rev 14257) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h 2007-10-02 10:33:53 UTC (rev 14258) @@ -109,6 +109,9 @@ GtkAdjustment * hildon_desktop_popup_menu_get_adjustment (HildonDesktopPopupMenu *menu); +void +hildon_desktop_popup_menu_parent_size (HildonDesktopPopupMenu *menu); + G_BEGIN_DECLS #endif/*__HILDON_DESKTOP_POPUP_MENU_H__*/ Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c 2007-10-02 10:25:33 UTC (rev 14257) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c 2007-10-02 10:33:53 UTC (rev 14258) @@ -27,6 +27,7 @@ #include <gtk/gtk.h> #include <gdk/gdkx.h> +#include <gdk/gdkkeysyms.h> #include <gdk/gdkwindow.h> #ifdef HAVE_CONFIG_H Modified: projects/haf/trunk/hildon-desktop/src/hd-applications-menu.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-applications-menu.c 2007-10-02 10:25:33 UTC (rev 14257) +++ projects/haf/trunk/hildon-desktop/src/hd-applications-menu.c 2007-10-02 10:33:53 UTC (rev 14258) @@ -108,6 +108,8 @@ guint menu_update_timeout; gboolean focus_applications; gboolean motion_reset; + + GList *apps_list; }; static void hd_applications_menu_register_monitors (HDApplicationsMenu *button); @@ -141,6 +143,9 @@ if (TASKNAVIGATOR_ITEM (button)->menu) gtk_widget_destroy (GTK_WIDGET (TASKNAVIGATOR_ITEM (button)->menu)); + if (button->priv->apps_list) + g_list_free (button->priv->apps_list); + G_OBJECT_CLASS (hd_applications_menu_parent_class)->finalize (gobject); } @@ -246,6 +251,8 @@ return TRUE; } + g_list_free (items); + return FALSE; } @@ -377,32 +384,44 @@ { static GtkMenuItem *last_selected_item = NULL; - GList *sub_items, *i; + GList *sub_items = NULL; gboolean replaced = FALSE; - sub_items = hildon_desktop_popup_menu_get_children - (button->priv->menu_applications); - + if (GTK_IS_MENU_ITEM (last_selected_item)) + { + sub_items = (GList *) g_object_get_data (G_OBJECT (last_selected_item), + CATEGORY_SUB_ITEMS); + } + if (last_selected_item != item) { - last_selected_item = item; + GList *i; - replaced = TRUE; - - for (i = g_list_first (sub_items); i; i = i->next) + if (GTK_IS_MENU_ITEM (last_selected_item)) { - GtkMenuItem *child = (GtkMenuItem *) i->data; + for (i = g_list_first (sub_items); i; i = i->next) + { + GtkWidget *child = (GtkWidget *) i->data; - g_object_ref (child); + gtk_widget_hide (child); + } } - g_list_free (sub_items); - + last_selected_item = item; + + replaced = TRUE; + sub_items = (GList *) g_object_get_data (G_OBJECT (item), CATEGORY_SUB_ITEMS); - hildon_desktop_popup_menu_replace_items (button->priv->menu_applications, - sub_items); + for (i = g_list_first (sub_items); i; i = i->next) + { + GtkWidget *child = (GtkWidget *) i->data; + + gtk_widget_show (child); + } + + hildon_desktop_popup_menu_parent_size (button->priv->menu_applications); } else { @@ -422,9 +441,6 @@ } button->priv->focus_applications = FALSE; - - if (!replaced) - g_list_free (sub_items); } static void @@ -542,9 +558,8 @@ } static void -hd_applications_menu_free_menu_items (GList *menu_items) +hd_applications_menu_free_menu_list (GList *menu_items) { - g_list_foreach (menu_items, (GFunc) gtk_widget_destroy, NULL); g_list_free (menu_items); } @@ -632,7 +647,7 @@ gtk_container_add (GTK_CONTAINER (menu_item), hbox); - gtk_widget_show_all (hbox); + gtk_widget_show_all (menu_item); #endif GTK_WIDGET_SET_FLAGS (menu_item, GTK_CAN_FOCUS); @@ -661,13 +676,15 @@ gtk_widget_set_sensitive (no_app_item, FALSE); + button->priv->apps_list = g_list_prepend (button->priv->apps_list, no_app_item); + sub_items = g_list_prepend (sub_items, no_app_item); } g_object_set_data_full (G_OBJECT (menu_item), CATEGORY_SUB_ITEMS, sub_items, - (GDestroyNotify) hd_applications_menu_free_menu_items); + (GDestroyNotify) hd_applications_menu_free_menu_list); g_signal_connect (G_OBJECT (menu_item), "activate", @@ -743,9 +760,9 @@ TRUE, 0); + gtk_widget_show_all (hbox); + gtk_container_add (GTK_CONTAINER (menu_item), hbox); - - gtk_widget_show_all (hbox); #endif } @@ -771,10 +788,16 @@ { GtkWidget *separator = gtk_separator_menu_item_new (); - if (level > 0) + if (level > 0) + { gtk_widget_set_name (GTK_WIDGET (separator), HD_APPS_MENU_APP_MENU_ITEM_NAME); + button->priv->apps_list = g_list_prepend (button->priv->apps_list, separator); + } else + { gtk_widget_set_name (GTK_WIDGET (separator), HD_APPS_MENU_CAT_MENU_ITEM_NAME); + gtk_widget_show (separator); + } menu_items = g_list_prepend (menu_items, separator); } @@ -783,9 +806,12 @@ first_item = FALSE; } + if (level > 0) + button->priv->apps_list = g_list_prepend (button->priv->apps_list, menu_item); + menu_items = g_list_prepend (menu_items, menu_item); } - + g_free (item_name); if (item_icon) @@ -807,19 +833,20 @@ static void hd_applications_menu_populate (HDApplicationsMenu *button) { - GList *menu_items, *i; + GList *menu_items; GtkTreeIter iter; + + g_list_free (button->priv->apps_list); + button->priv->apps_list = NULL; menu_items = hd_applications_menu_get_items (button, NULL, &iter, 0); - for (i = g_list_first (menu_items); i; i = i->next) - { - GtkMenuItem *menu_item = (GtkMenuItem *) i->data; - - hildon_desktop_popup_menu_add_item - (button->priv->menu_categories, menu_item); - } - + hildon_desktop_popup_menu_replace_items + (button->priv->menu_categories, menu_items); + + hildon_desktop_popup_menu_replace_items + (button->priv->menu_applications, button->priv->apps_list); + g_list_free (menu_items); } Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c 2007-10-02 10:25:33 UTC (rev 14257) +++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c 2007-10-02 10:33:53 UTC (rev 14258) @@ -358,6 +358,14 @@ } static gboolean +hd_switcher_menu_eventbox_keypress_cb (GtkWidget *widget, + GdkEventKey *event, + HDSwitcherMenu *switcher) +{ + return gtk_widget_event (GTK_BIN (widget)->child, (GdkEvent *) event); +} + +static gboolean hd_switcher_menu_popup_window_keypress_cb (GtkWidget *widget, GdkEventKey *event, HDSwitcherMenu *switcher) @@ -724,6 +732,8 @@ gtk_widget_set_name (GTK_WIDGET (menu_item), HD_SWITCHER_MENU_NOT_MENU_ITEM_NAME); + gtk_widget_show (GTK_WIDGET (menu_item)); + *items = g_list_append (*items, menu_item); } } @@ -917,7 +927,7 @@ HDWM *hdwm = hd_wm_get_singleton (); const GtkWidget *button_up, *button_down; GdkPixbuf *pixbuf; - GtkWidget *button, *arrow; + GtkWidget *button, *arrow, *event_box; object = G_OBJECT_CLASS (hd_switcher_menu_parent_class)->constructor (gtype, n_params, @@ -972,26 +982,57 @@ gtk_widget_set_size_request (GTK_WIDGET (switcher->priv->notifications_window), AS_MENU_PANE_WIDTH, 1); + event_box = gtk_event_box_new (); + + gtk_widget_set_name (event_box, + HD_SWITCHER_MENU_APP_MENU_NAME); + + g_signal_connect (G_OBJECT (event_box), + "key-press-event", + G_CALLBACK (hd_switcher_menu_eventbox_keypress_cb), + switcher); + + gtk_widget_show (event_box); + switcher->priv->menu_applications = HILDON_DESKTOP_POPUP_MENU (g_object_new (HILDON_DESKTOP_TYPE_POPUP_MENU, "item-height", 72, "parent", switcher->priv->popup_window, NULL)); + gtk_widget_show (GTK_WIDGET (switcher->priv->menu_applications)); + + gtk_container_add (GTK_CONTAINER (event_box), + GTK_WIDGET (switcher->priv->menu_applications)); + + gtk_container_add (GTK_CONTAINER (switcher->priv->popup_window), + GTK_WIDGET (event_box)); + + event_box = gtk_event_box_new (); + + gtk_widget_set_name (event_box, + HD_SWITCHER_MENU_NOT_MENU_NAME); + + g_signal_connect (G_OBJECT (event_box), + "key-press-event", + G_CALLBACK (hd_switcher_menu_eventbox_keypress_cb), + switcher); + + gtk_widget_show (event_box); + switcher->priv->menu_notifications = HILDON_DESKTOP_POPUP_MENU (g_object_new (HILDON_DESKTOP_TYPE_POPUP_MENU, "item-height", 72, "parent", switcher->priv->notifications_window, NULL)); - gtk_container_add (GTK_CONTAINER (switcher->priv->popup_window), - GTK_WIDGET (switcher->priv->menu_applications)); + gtk_widget_show (GTK_WIDGET (switcher->priv->menu_notifications)); - gtk_container_add (GTK_CONTAINER (switcher->priv->notifications_window), + gtk_container_add (GTK_CONTAINER (event_box), GTK_WIDGET (switcher->priv->menu_notifications)); - gtk_widget_show (GTK_WIDGET (switcher->priv->menu_applications)); - gtk_widget_show (GTK_WIDGET (switcher->priv->menu_notifications)); + gtk_container_add (GTK_CONTAINER (switcher->priv->notifications_window), + GTK_WIDGET (event_box)); button_up = hildon_desktop_popup_menu_get_scroll_button_up (switcher->priv->menu_applications); @@ -1148,6 +1189,8 @@ G_CALLBACK (hd_switcher_menu_item_activated), switcher); + gtk_widget_show (GTK_WIDGET (switcher->priv->home_item)); + hd_switcher_menu_create_applications_menu (switcher, hdwm); switcher->priv->notification_groups = @@ -1823,6 +1866,8 @@ G_CALLBACK (hd_switcher_menu_item_activated), switcher); + gtk_widget_show (GTK_WIDGET (menu_item)); + children = g_list_append (children, menu_item); if (!ack && !icon_is_set) @@ -1909,6 +1954,8 @@ G_CALLBACK (hd_switcher_menu_item_activated), (gpointer)switcher); + gtk_widget_show (GTK_WIDGET (menu_item)); + items = g_list_append (items, menu_item); if (hd_wm_entry_info_is_active (entry))
- Previous message: [maemo-commits] r14257 - in projects/haf/trunk/hildon-fm: . debian hildon-fm
- Next message: [maemo-commits] r14259 - projects/haf/trunk/hildon-fm/hildon-fm
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]