[maemo-commits] [maemo-commits] r13315 - in projects/haf/trunk/hildon-desktop: . libhildondesktop src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Aug 21 14:01:27 EEST 2007
- Previous message: [maemo-commits] r13314 - projects/haf/tags/osso-gnome-vfs2
- Next message: [maemo-commits] r13316 - projects/haf/trunk/hildon-desktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: lucasr Date: 2007-08-21 14:01:21 +0300 (Tue, 21 Aug 2007) New Revision: 13315 Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c Log: 2007-08-21 Lucas Rocha <lucas.rocha at nokia.com> * libhildondesktop/hildon-desktop-popup-menu.c (hildon_desktop_menu_check_scroll_item, hildon_desktop_popup_menu_scroll_to_selected, hildon_desktop_popup_menu_key_press_event, hildon_desktop_popup_menu_select_next_prev_item): fix scrolling behavior on key press, select next item and scroll to selected item functionalities in popup menu. Fixes NB#54023. Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-08-21 10:53:10 UTC (rev 13314) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-08-21 11:01:21 UTC (rev 13315) @@ -1,5 +1,15 @@ 2007-08-21 Lucas Rocha <lucas.rocha at nokia.com> + * libhildondesktop/hildon-desktop-popup-menu.c + (hildon_desktop_menu_check_scroll_item, + hildon_desktop_popup_menu_scroll_to_selected, + hildon_desktop_popup_menu_key_press_event, + hildon_desktop_popup_menu_select_next_prev_item): fix scrolling + behavior on key press, select next item and scroll to selected item + functionalities in popup menu. Fixes NB#54023. + +2007-08-21 Lucas Rocha <lucas.rocha at nokia.com> + * src/hd-switcher-menu.c (hd_switcher_menu_update_highlighting): set the widget name for highlighted state. 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-21 10:53:10 UTC (rev 13314) +++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c 2007-08-21 11:01:21 UTC (rev 13315) @@ -569,30 +569,41 @@ } static void -hildon_desktop_menu_check_scroll_item (HildonDesktopPopupMenu *menu, - GtkScrollType type) +hildon_desktop_menu_check_scroll_item (HildonDesktopPopupMenu *menu) { - GtkAdjustment *adj; - gint visible_y; - GtkWidget *view = GTK_WIDGET (menu->priv->selected_item); - gdouble upper_hack; + GtkWidget *view = menu->priv->box_items; + GtkWidget *menu_item = GTK_WIDGET (menu->priv->selected_item); + GtkWidget *viewport = menu->priv->viewport; + GtkAdjustment *adj; GtkRequisition req; + gint visible_y; + if (menu_item == NULL) + return; + gtk_widget_size_request (menu->priv->parent, &req); adj = gtk_viewport_get_vadjustment (GTK_VIEWPORT (menu->priv->viewport)); - if (menu->priv->parent) - upper_hack = adj->upper - (req.height - menu->priv->item_height + 1); - else - upper_hack = adj->upper; + g_return_if_fail ((adj->upper - adj->lower) && view->allocation.height); - visible_y = view->allocation.y + menu->priv->item_height; - - if (visible_y < (req.height - menu->priv->item_height)) - hildon_desktop_popup_menu_scroll_cb (menu->priv->scroll_up, menu); - else - hildon_desktop_popup_menu_scroll_cb (menu->priv->scroll_down, menu); + visible_y = view->allocation.y + + (gint)(view->allocation.height * adj->value / (adj->upper - adj->lower)); + + if (menu_item->allocation.y < visible_y) + { + adj->value = menu_item->allocation.y * (adj->upper - adj->lower) + / view->allocation.height; + gtk_adjustment_value_changed (adj); + } + else if (menu_item->allocation.y + menu_item->allocation.height > + visible_y + viewport->allocation.height) + { + adj->value = (menu_item->allocation.y + menu_item->allocation.height + - viewport->allocation.height) * (adj->upper - adj->lower) + / view->allocation.height; + gtk_adjustment_value_changed (adj); + } } static gboolean @@ -628,7 +639,7 @@ menu->priv->selected_item = GTK_MENU_ITEM (item->data); if (menu->priv->controls_on) - hildon_desktop_menu_check_scroll_item (menu, GTK_SCROLL_STEP_UP); + hildon_desktop_menu_check_scroll_item (menu); break; } @@ -652,7 +663,7 @@ menu->priv->selected_item = GTK_MENU_ITEM (item->data); if (menu->priv->controls_on) - hildon_desktop_menu_check_scroll_item (menu, GTK_SCROLL_STEP_DOWN); + hildon_desktop_menu_check_scroll_item (menu); break; } @@ -822,6 +833,11 @@ 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); + } + g_list_free (children); } } @@ -991,38 +1007,13 @@ void hildon_desktop_popup_menu_scroll_to_selected (HildonDesktopPopupMenu *menu) { - GList *children = NULL, *l; - gint position = 0, screen_height = gdk_screen_height (); - - if (!HILDON_DESKTOP_IS_POPUP_MENU (menu)) - return; + g_return_if_fail (HILDON_DESKTOP_IS_POPUP_MENU (menu)); if (!menu->priv->controls_on) return; if (menu->priv->selected_item) - { - children = gtk_container_get_children (GTK_CONTAINER (menu->priv->box_items)); - - for (l=children; l != NULL; l = g_list_next (l)) - { - position += menu->priv->item_height; - - if (l->data == menu->priv->selected_item) - break; - } - - if (position > screen_height) - { - do - { - hildon_desktop_popup_menu_scroll_cb (menu->priv->scroll_up, menu); - position -= menu->priv->item_height; - } - while (position > screen_height); - } - - } + hildon_desktop_menu_check_scroll_item (menu); } const GtkWidget * Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c =================================================================== --- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c 2007-08-21 10:53:10 UTC (rev 13314) +++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c 2007-08-21 11:01:21 UTC (rev 13315) @@ -1539,14 +1539,14 @@ !switcher->priv->menu_notifications) { return; - } + } + hildon_desktop_popup_menu_scroll_to_selected (switcher->priv->menu_applications); adj = hildon_desktop_popup_menu_get_adjustment (switcher->priv->menu_notifications); - if (adj) - gtk_adjustment_set_value (adj, adj->upper - adj->page_size); + gtk_adjustment_set_value (adj, adj->upper - adj->page_size); } static void
- Previous message: [maemo-commits] r13314 - projects/haf/tags/osso-gnome-vfs2
- Next message: [maemo-commits] r13316 - projects/haf/trunk/hildon-desktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]