X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=hildon%2Fhildon-app-menu.c;h=f1df8591ed7e56b882dbee9eaa7d793b6daac581;hb=01c54a1b0b89b139ae8bf62edaf952b54ad5bdf8;hp=7e838e445a702900af48fcd47b9d872e61652c68;hpb=2e82a267b1f5146952dd71d1cbb5151c69b6cf0a;p=hildon diff --git a/hildon/hildon-app-menu.c b/hildon/hildon-app-menu.c index 7e838e4..f1df859 100644 --- a/hildon/hildon-app-menu.c +++ b/hildon/hildon-app-menu.c @@ -20,8 +20,8 @@ * SECTION:hildon-app-menu * @short_description: Widget representing the application menu in the Hildon framework. * - * The #HildonAppMenu is a GTK widget which represents an application - * menu in the Hildon framework. + * #HildonAppMenu is a GTK widget which represents an application menu + * in the Hildon framework. * * This menu opens from the top of the screen and contains a number of * entries (#GtkButton) organized in one or two columns, depending on @@ -29,8 +29,12 @@ * if the screen is resized). Entries are added left to right and top * to bottom. * - * Besides that, the #HildonAppMenu can contain a group of filter buttons - * (#GtkToggleButton or #GtkRadioButton). + * Besides that, #HildonAppMenu can contain a group of filter buttons + * (#GtkToggleButton or #GtkRadioButton). Filters are meant to change + * the way data is presented in the application, rather than change + * the layout of the menu itself. For example, a file manager can have + * filters to decide the order used to display a list of files (name, + * date, size, etc.). * * To use a #HildonAppMenu, add it to a #HildonWindow using * hildon_window_set_app_menu(). The menu will appear when the user @@ -100,6 +104,7 @@ #include "hildon-app-menu-private.h" #include "hildon-window.h" #include "hildon-banner.h" +#include "hildon-animation-actor.h" static GdkWindow * grab_transfer_window_get (GtkWidget *widget); @@ -492,7 +497,7 @@ hildon_app_menu_find_intruder (gpointer data) * Yes, this is a hack. See NB#111027 */ if (HILDON_IS_BANNER (i->data)) { gtk_widget_hide (i->data); - } else { + } else if (!HILDON_IS_ANIMATION_ACTOR (i->data)) { intruder_found = TRUE; } } @@ -515,14 +520,15 @@ hildon_app_menu_map (GtkWidget *widget) { HildonAppMenuPrivate *priv = HILDON_APP_MENU_GET_PRIVATE(widget); + if (priv->transfer_window == NULL) + priv->transfer_window = grab_transfer_window_get (widget); + GTK_WIDGET_CLASS (hildon_app_menu_parent_class)->map (widget); /* Grab pointer and keyboard */ - if (priv->transfer_window == NULL) { + if (priv->transfer_window != NULL) { gboolean has_grab = FALSE; - priv->transfer_window = grab_transfer_window_get (widget); - if (gdk_pointer_grab (priv->transfer_window, TRUE, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | @@ -868,14 +874,18 @@ hildon_app_menu_repack_items (HildonAppMenu *menu, gint start_from) { HildonAppMenuPrivate *priv; - gint row, col; + gint row, col, nvisible, i; GList *iter; priv = HILDON_APP_MENU_GET_PRIVATE(menu); - /* Remove buttons from their parent */ - if (start_from != -1) { - for (iter = g_list_nth (priv->buttons, start_from); iter != NULL; iter = iter->next) { + i = nvisible = 0; + for (iter = priv->buttons; iter != NULL; iter = iter->next) { + /* Count number of visible items */ + if (GTK_WIDGET_VISIBLE (iter->data)) + nvisible++; + /* Remove buttons from their parent */ + if (start_from != -1 && i >= start_from) { GtkWidget *item = GTK_WIDGET (iter->data); GtkWidget *parent = gtk_widget_get_parent (item); if (parent) { @@ -883,10 +893,16 @@ hildon_app_menu_repack_items (HildonAppMenu *menu, gtk_container_remove (GTK_CONTAINER (parent), item); } } + i++; + } - /* If items have been removed, recalculate the size of the menu */ + /* If items have been removed, recalculate the size of the menu */ + if (start_from != -1) gtk_window_resize (GTK_WINDOW (menu), 1, 1); - } + + /* Set the final size now to avoid unnecessary resizes later */ + if (nvisible > 0) + gtk_table_resize (priv->table, ((nvisible - 1) / priv->columns) + 1, priv->columns); /* Add buttons */ row = col = 0; @@ -906,14 +922,6 @@ hildon_app_menu_repack_items (HildonAppMenu *menu, } } } - - /* The number of rows/columns might have changed, so we have to - * resize the table */ - if (col == 0) { - gtk_table_resize (priv->table, MAX (row, 1), priv->columns); - } else { - gtk_table_resize (priv->table, row + 1, priv->columns); - } } /**