gdm r6112 - in trunk: . gui/simple-greeter



Author: halfline
Date: Sat Apr  5 22:02:10 2008
New Revision: 6112
URL: http://svn.gnome.org/viewvc/gdm?rev=6112&view=rev

Log:
2008-04-05 Ray Strode <rstrode redhat com>

	* gui/simple-greeter/gdm-chooser-widget.c
	(get_number_of_on_screen_rows),
	(on_grow_animation_complete),
	(on_grow_animation_step), (start_grow_animation),
	(skip_resize_animation), (gdm_chooser_widget_grow),
	(gdm_chooser_widget_shrink),
	(gdm_chooser_widget_size_allocate):
	In some situations we don't start the login window
	fully grown, so we don't know how far to grow back
	to after shrinking.  Try to identify when those cases
	happen and instead initiate a slide to the height of
	the screen. To mitigate the obviousness of over guessing
	how far to grow. Detect when we've grown enough, and stop
	the animation early.
	* gui/simple-greeter/gdm-chooser-widget.h:
	Remove unused field from structure


Modified:
   trunk/ChangeLog
   trunk/gui/simple-greeter/gdm-chooser-widget.c
   trunk/gui/simple-greeter/gdm-chooser-widget.h

Modified: trunk/gui/simple-greeter/gdm-chooser-widget.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-chooser-widget.c	(original)
+++ trunk/gui/simple-greeter/gdm-chooser-widget.c	Sat Apr  5 22:02:10 2008
@@ -89,6 +89,7 @@
 
         guint32                  should_hide_inactive_items : 1;
         guint32                  emit_activated_after_resize_animation : 1;
+        guint32                  was_fully_grown : 1;
 
         GdmChooserWidgetPosition separator_position;
         GdmChooserWidgetState    state;
@@ -543,6 +544,7 @@
 {
         g_assert (widget->priv->state == GDM_CHOOSER_WIDGET_STATE_GROWING);
         widget->priv->state = GDM_CHOOSER_WIDGET_STATE_GROWN;
+        widget->priv->was_fully_grown = TRUE;
 
         if (widget->priv->emit_activated_after_resize_animation) {
                 g_signal_emit (widget, signals[ACTIVATED], 0);
@@ -566,11 +568,54 @@
         return area.height;
 }
 
+static int
+get_number_of_on_screen_rows (GdmChooserWidget *widget)
+{
+        GtkTreePath *start_path;
+        GtkTreePath *end_path;
+        int         *start_index;
+        int         *end_index;
+        int          number_of_rows;
+
+        if (!gtk_tree_view_get_visible_range (GTK_TREE_VIEW (widget->priv->items_view),
+                                              &start_path, &end_path)) {
+                return 0;
+        }
+
+        start_index = gtk_tree_path_get_indices (start_path);
+        end_index = gtk_tree_path_get_indices (end_path);
+
+        number_of_rows = *end_index - *start_index;
+
+        gtk_tree_path_free (start_path);
+        gtk_tree_path_free (end_path);
+
+        return number_of_rows;
+}
+
+static void
+on_grow_animation_step (GdmScrollableWidget *scrollable_widget,
+                        double               progress,
+                        GdmChooserWidget    *widget)
+{
+        int number_of_visible_rows;
+        int number_of_on_screen_rows;
+
+        number_of_visible_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->model_sorter), NULL);
+        number_of_on_screen_rows = get_number_of_on_screen_rows (widget);
+
+        if (number_of_on_screen_rows >= number_of_visible_rows) {
+                gdm_scrollable_widget_stop_sliding (scrollable_widget);
+                return;
+        }
+}
+
 static void
 start_grow_animation (GdmChooserWidget *widget)
 {
         int number_of_visible_rows;
         int number_of_rows;
+        int height;
 
         number_of_visible_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->model_sorter), NULL);
         number_of_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->list_store), NULL);
@@ -581,9 +626,16 @@
         }
 
         set_inactive_items_visible (widget, TRUE);
+
+        if (widget->priv->was_fully_grown) {
+                height = widget->priv->height_when_grown;
+        } else {
+                height = get_height_of_screen (widget);
+        }
         gdm_scrollable_widget_slide_to_height (GDM_SCROLLABLE_WIDGET (widget->priv->scrollable_widget),
                                                widget->priv->height_when_grown,
-                                               NULL, NULL,
+                                               (GdmScrollableWidgetSlideStepFunc)
+                                               on_grow_animation_step, widget,
                                                (GdmScrollableWidgetSlideDoneFunc)
                                                on_grow_animation_complete, widget);
 }
@@ -597,6 +649,7 @@
         } else if (widget->priv->state == GDM_CHOOSER_WIDGET_STATE_GROWING) {
                 set_inactive_items_visible (GDM_CHOOSER_WIDGET (widget), TRUE);
                 widget->priv->state = GDM_CHOOSER_WIDGET_STATE_GROWN;
+                widget->priv->was_fully_grown = FALSE;
         }
 }
 
@@ -605,6 +658,7 @@
 {
         if (widget->priv->state == GDM_CHOOSER_WIDGET_STATE_SHRINKING) {
                 gdm_scrollable_widget_stop_sliding (GDM_SCROLLABLE_WIDGET (widget->priv->scrollable_widget));
+                widget->priv->was_fully_grown = FALSE;
         }
 
         gtk_alignment_set (GTK_ALIGNMENT (widget->priv->frame_alignment),
@@ -656,12 +710,6 @@
         g_assert (widget->priv->should_hide_inactive_items == TRUE);
 
         if (widget->priv->state == GDM_CHOOSER_WIDGET_STATE_GROWING) {
-
-                /* FIXME: since we don't distinguish between a canceled
-                 * animation and a finished one, the next line is going
-                 * to mean at the next size-allocate signal,
-                 * height_when_grown is going to get set to the wrong value
-                 */
                 gdm_scrollable_widget_stop_sliding (GDM_SCROLLABLE_WIDGET (widget->priv->scrollable_widget));
         }
 
@@ -933,7 +981,9 @@
         chooser_widget = GDM_CHOOSER_WIDGET (widget);
 
         if (chooser_widget->priv->state == GDM_CHOOSER_WIDGET_STATE_GROWN) {
-                chooser_widget->priv->height_when_grown = allocation->height;
+                if (chooser_widget->priv->was_fully_grown) {
+                        chooser_widget->priv->height_when_grown = allocation->height;
+                }
         }
 }
 

Modified: trunk/gui/simple-greeter/gdm-chooser-widget.h
==============================================================================
--- trunk/gui/simple-greeter/gdm-chooser-widget.h	(original)
+++ trunk/gui/simple-greeter/gdm-chooser-widget.h	Sat Apr  5 22:02:10 2008
@@ -48,10 +48,6 @@
 
         void (* activated)      (GdmChooserWidget *widget);
         void (* deactivated)    (GdmChooserWidget *widget);
-
-#ifdef BUILD_ALLOCATION_HACK
-        gulong size_negotiation_handler;
-#endif
 } GdmChooserWidgetClass;
 
 typedef enum {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]