[maemo-commits] [maemo-commits] r13474 - in projects/haf/trunk/hildon-desktop: . libhildondesktop
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Aug 30 13:45:14 EEST 2007
- Previous message: [maemo-commits] r13473 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r13475 - in projects/haf/trunk/hildon-desktop: . libhildondesktop libhildonwm src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: lucasr Date: 2007-08-30 13:45:12 +0300 (Thu, 30 Aug 2007) New Revision: 13474 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 Log: 2007-08-30 Lucas Rocha <lucas.rocha at nokia.com> * libhildondesktop/hildon-desktop-popup-menu.[ch] (hildon_desktop_popup_menu_select_next_prev_item): optimizations and implementation for go to last item when the end of menu items list is reached. (hildon_desktop_popup_menu_key_press_event): optimizations by just using internal method for select next and previous items. (hildon_desktop_popup_menu_select_last_item): new method to select last menu item. (hildon_desktop_popup_menu_select_item): optimizations in order to avoid extra paints on menu items and to make it faster. Fixes #66744. Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-08-30 08:59:36 UTC (rev 13473) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-08-30 10:45:12 UTC (rev 13474) @@ -1,3 +1,17 @@ +2007-08-30 Lucas Rocha <lucas.rocha at nokia.com> + + * libhildondesktop/hildon-desktop-popup-menu.[ch] + (hildon_desktop_popup_menu_select_next_prev_item): optimizations and + implementation for go to last item when the end of menu items list is + reached. + (hildon_desktop_popup_menu_key_press_event): optimizations by just + using internal method for select next and previous items. + (hildon_desktop_popup_menu_select_last_item): new method to select + last menu item. + (hildon_desktop_popup_menu_select_item): optimizations in order to + avoid extra paints on menu items and to make it faster. + Fixes #66744. + 2007-08-29 Lucas Rocha <lucas.rocha at nokia.com> * libhildondesktop/hildon-desktop-popup-menu.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-08-30 08:59:36 UTC (rev 13473) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c 2007-08-30 10:45:12 UTC (rev 13474) @@ -4,6 +4,7 @@ * Copyright (C) 2007 Nokia Corporation. * * Author: Moises Martinez <moises.martinez at nokia.com> + * Lucas Rocha <lucas.rocha at nokia.com> * Contact: Karoliina Salminen <karoliina.t.salminen at nokia.com> * * This library is free software; you can redistribute it and/or @@ -107,6 +108,7 @@ static gboolean hildon_desktop_popup_menu_press_event (GtkWidget *widget, GdkEventButton *event); static gboolean hildon_desktop_popup_menu_release_event (GtkWidget *widget, GdkEventButton *event); static gboolean hildon_desktop_popup_menu_key_press_event (GtkWidget *widget, GdkEventKey *event); +static void hildon_desktop_popup_menu_select_next_prev_item (HildonDesktopPopupMenu *menu, gboolean next); static void hildon_desktop_popup_menu_scroll_cb (GtkWidget *widget, HildonDesktopPopupMenu *menu); static void hildon_desktop_popup_menu_scroll_start (GtkWidget *widget, HildonDesktopPopupMenu *menu); static void hildon_desktop_popup_menu_scroll_stop (GtkWidget *widget, HildonDesktopPopupMenu *menu); @@ -713,67 +715,20 @@ GdkEventKey *event) { HildonDesktopPopupMenu *menu = HILDON_DESKTOP_POPUP_MENU (widget); - GList *menu_items = NULL, *l; - menu_items = - gtk_container_get_children (GTK_CONTAINER (menu->priv->box_items)); - - for (l = menu_items; l != NULL; l = g_list_next (l)) - { - if (l->data == menu->priv->selected_item) - break; - } - - if (l == NULL) - return FALSE; - if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up) { - GList *item = l->prev; - - while (item) - { - if (GTK_IS_MENU_ITEM (item->data) && !GTK_IS_SEPARATOR_MENU_ITEM (item->data)) - { - gtk_item_deselect (GTK_ITEM (l->data)); - gtk_item_select (GTK_ITEM (item->data)); - menu->priv->selected_item = GTK_MENU_ITEM (item->data); - - if (menu->priv->controls_on) - hildon_desktop_menu_check_scroll_item (menu); - - break; - } - - item = g_list_previous (item); - } + hildon_desktop_popup_menu_select_next_prev_item (menu, FALSE); return TRUE; } else if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down) { - GList *item = l->next; - - while (item) - { - if (GTK_IS_MENU_ITEM (item->data) && !GTK_IS_SEPARATOR_MENU_ITEM (item->data)) - { - gtk_item_deselect (GTK_ITEM (l->data)); - gtk_item_select (GTK_ITEM (item->data)); - menu->priv->selected_item = GTK_MENU_ITEM (item->data); - - if (menu->priv->controls_on) - hildon_desktop_menu_check_scroll_item (menu); - - break; - } - - item = g_list_next (item); - } + hildon_desktop_popup_menu_select_next_prev_item (menu, TRUE); return TRUE; - } + } else if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || @@ -925,7 +880,7 @@ hildon_desktop_popup_menu_select_item (menu, GTK_MENU_ITEM (l->data)); break; } - } + } if (next) l = l->next; @@ -933,12 +888,12 @@ l = l->prev; } - if (previous_selected_item == menu->priv->selected_item) /* TODO: This only cover one case. */ - hildon_desktop_popup_menu_select_first_item (menu); /* It doesn't take into account the direction */ - - if (menu->priv->controls_on) - { - hildon_desktop_menu_check_scroll_item (menu); + if (previous_selected_item == menu->priv->selected_item) + { + if (next) + hildon_desktop_popup_menu_select_first_item (menu); + else + hildon_desktop_popup_menu_select_last_item (menu); } g_list_free (children); @@ -1014,25 +969,15 @@ void hildon_desktop_popup_menu_select_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item) { - GList *children = NULL, *l; - g_return_if_fail (HILDON_DESKTOP_IS_POPUP_MENU (menu)); + g_return_if_fail (GTK_IS_MENU_ITEM (item)); - children = gtk_container_get_children (GTK_CONTAINER (menu->priv->box_items)); + if (GTK_IS_ITEM (menu->priv->selected_item)) + gtk_item_deselect (GTK_ITEM (menu->priv->selected_item)); - for (l = children; l != NULL; l = g_list_next (l)) - { - if (l->data && l->data == item) - { - gtk_item_select (GTK_ITEM (item)); - menu->priv->selected_item = item; - hildon_desktop_menu_check_scroll_item (menu); - } - else - gtk_item_deselect (GTK_ITEM (l->data)); - } - - g_list_free (children); + gtk_item_select (GTK_ITEM (item)); + menu->priv->selected_item = item; + hildon_desktop_menu_check_scroll_item (menu); } void @@ -1060,18 +1005,44 @@ { if (!GTK_IS_SEPARATOR_MENU_ITEM (l->data)) { - if (menu->priv->selected_item != NULL) + if (GTK_IS_ITEM (menu->priv->selected_item)) gtk_item_deselect (GTK_ITEM (menu->priv->selected_item)); gtk_item_select (GTK_ITEM (l->data)); menu->priv->selected_item = GTK_MENU_ITEM (l->data); hildon_desktop_menu_check_scroll_item (menu); + break; } } } void +hildon_desktop_popup_menu_select_last_item (HildonDesktopPopupMenu *menu) +{ + GList *children = NULL, *l; + + g_return_if_fail (HILDON_DESKTOP_IS_POPUP_MENU (menu)); + + children = gtk_container_get_children (GTK_CONTAINER (menu->priv->box_items)); + + for (l = g_list_last (children); l != NULL; l = g_list_previous (l)) + { + if (!GTK_IS_SEPARATOR_MENU_ITEM (l->data)) + { + if (GTK_IS_ITEM (menu->priv->selected_item)) + gtk_item_deselect (GTK_ITEM (menu->priv->selected_item)); + + gtk_item_select (GTK_ITEM (l->data)); + menu->priv->selected_item = GTK_MENU_ITEM (l->data); + hildon_desktop_menu_check_scroll_item (menu); + + break; + } + } +} + +void hildon_desktop_popup_menu_activate_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item) { GList *children = NULL, *l; Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h =================================================================== --- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h 2007-08-30 08:59:36 UTC (rev 13473) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h 2007-08-30 10:45:12 UTC (rev 13474) @@ -78,6 +78,9 @@ void hildon_desktop_popup_menu_select_first_item (HildonDesktopPopupMenu *menu); +void +hildon_desktop_popup_menu_select_last_item (HildonDesktopPopupMenu *menu); + void hildon_desktop_popup_menu_activate_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item);
- Previous message: [maemo-commits] r13473 - projects/haf/hafbuildbot
- Next message: [maemo-commits] r13475 - in projects/haf/trunk/hildon-desktop: . libhildondesktop libhildonwm src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]