Author: Ray Strode <rstrode@redhat.com>
Date:   Wed Oct 22 08:56:23 2008 -0400

    Split animation end side calculation to new func

    We're going to need it in other places than
    start_animation.

--- gnome-panel-2.24.0/gnome-panel/panel-toplevel.c
+++ gnome-panel-2.24.0/gnome-panel/panel-toplevel.c
@@ -3334,22 +3334,19 @@ panel_toplevel_get_animation_time (PanelToplevel *toplevel)
 }
 
 static void
-panel_toplevel_start_animation (PanelToplevel *toplevel)
+panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel)
 {
 	GdkScreen *screen;
 	int        monitor_width, monitor_height;
-	int        deltax, deltay, deltaw = 0, deltah = 0;
-	int        cur_x = -1, cur_y = -1;
-	long       t;
-
-	screen = panel_toplevel_get_monitor_geometry (
-				toplevel, NULL, NULL, &monitor_width, &monitor_height);
 
 	toplevel->priv->animation_end_x      = toplevel->priv->x;
 	toplevel->priv->animation_end_y      = toplevel->priv->y;
 	toplevel->priv->animation_end_width  = -1;
 	toplevel->priv->animation_end_height = -1;
 
+	screen = panel_toplevel_get_monitor_geometry (
+				toplevel, NULL, NULL, &monitor_width, &monitor_height);
+
 	if (!toplevel->priv->expand) {
 
 		if (toplevel->priv->x_centered)
@@ -3380,6 +3377,18 @@ panel_toplevel_start_animation (PanelToplevel *toplevel)
 						       &toplevel->priv->animation_end_width,
 						       &toplevel->priv->animation_end_height);
 
+}
+
+static void
+panel_toplevel_start_animation (PanelToplevel *toplevel)
+{
+	GdkScreen *screen;
+	int        deltax, deltay, deltaw = 0, deltah = 0;
+	int        cur_x = -1, cur_y = -1;
+	long       t;
+
+	panel_toplevel_calculate_animation_end_geometry (toplevel);
+
 	toplevel->priv->animating = TRUE;
 
 	panel_toplevel_update_struts (toplevel, TRUE);
@@ -3392,6 +3401,8 @@ panel_toplevel_start_animation (PanelToplevel *toplevel)
 
 	gdk_window_get_origin (GTK_WIDGET (toplevel)->window, &cur_x, &cur_y);
 
+	screen = gtk_widget_get_screen (GTK_WIDGET (toplevel));
+
 	cur_x -= panel_multiscreen_x (screen, toplevel->priv->monitor);
 	cur_y -= panel_multiscreen_y (screen, toplevel->priv->monitor);
 

Author: Ray Strode <rstrode@redhat.com>
Date:   Wed Oct 22 10:27:00 2008 -0400

    Don't change struts while animating

--- gnome-panel-2.24.0/gnome-panel/panel-toplevel.c
+++ gnome-panel-2.24.0/gnome-panel/panel-toplevel.c
@@ -231,6 +231,8 @@ enum {
 static guint         toplevel_signals [LAST_SIGNAL] = { 0 };
 static GSList       *toplevel_list = NULL;
 
+static void panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel);
+
 GSList *
 panel_toplevel_list_toplevels (void)
 {
@@ -1372,7 +1374,7 @@ panel_toplevel_get_effective_auto_hide_size (PanelToplevel *toplevel)
 }
 
 static gboolean
-panel_toplevel_update_struts (PanelToplevel *toplevel, gboolean end_of_animation)
+panel_toplevel_update_struts (PanelToplevel *toplevel)
 {
 	PanelOrientation  orientation;
 	GdkScreen        *screen;
@@ -1382,6 +1384,8 @@ panel_toplevel_update_struts (PanelToplevel *toplevel, gboolean end_of_animation
 	int               monitor_x, monitor_y;
 	int               monitor_width, monitor_height;
 
+	panel_toplevel_calculate_animation_end_geometry (toplevel);
+
 	if (!toplevel->priv->updated_geometry_initial)
 		return FALSE;
 
@@ -1397,25 +1401,18 @@ panel_toplevel_update_struts (PanelToplevel *toplevel, gboolean end_of_animation
 						      &monitor_width,
 						      &monitor_height);
 
-	if (end_of_animation) {
-		x = toplevel->priv->animation_end_x;
-		y = toplevel->priv->animation_end_y;
-		x += panel_multiscreen_x (screen, toplevel->priv->monitor);
-		x += panel_multiscreen_y (screen, toplevel->priv->monitor);
-		if (toplevel->priv->animation_end_width != -1)
-			width = toplevel->priv->animation_end_width;
-		else
-			width = toplevel->priv->geometry.width;
-		if (toplevel->priv->animation_end_height != -1)
-			height = toplevel->priv->animation_end_height;
-		else
-			height = toplevel->priv->geometry.height;
-	} else {
-		x      = toplevel->priv->geometry.x;
-		y      = toplevel->priv->geometry.y;
-		width  = toplevel->priv->geometry.width;
+	x = toplevel->priv->animation_end_x;
+	y = toplevel->priv->animation_end_y;
+	x += panel_multiscreen_x (screen, toplevel->priv->monitor);
+	x += panel_multiscreen_y (screen, toplevel->priv->monitor);
+	if (toplevel->priv->animation_end_width != -1)
+		width = toplevel->priv->animation_end_width;
+	else
+		width = toplevel->priv->geometry.width;
+	if (toplevel->priv->animation_end_height != -1)
+		height = toplevel->priv->animation_end_height;
+	else
 		height = toplevel->priv->geometry.height;
-	}
 
 	orientation = toplevel->priv->orientation;
 
@@ -2499,7 +2496,7 @@ panel_toplevel_update_geometry (PanelToplevel  *toplevel,
 	panel_toplevel_update_size (toplevel, requisition);
 	panel_toplevel_update_position (toplevel);
 
-	panel_toplevel_update_struts (toplevel, FALSE);
+	panel_toplevel_update_struts (toplevel);
 	if (toplevel->priv->state == PANEL_STATE_NORMAL ||
 	    toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN) {
 		panel_struts_update_toplevel_geometry (toplevel,
@@ -2903,6 +2900,7 @@ panel_toplevel_initially_hide (PanelToplevel *toplevel)
 		toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
 		gtk_widget_queue_resize (GTK_WIDGET (toplevel));
 
+		panel_toplevel_update_struts (toplevel);
 		panel_toplevel_queue_auto_unhide (toplevel);
 	} else
 		toplevel->priv->initial_animation_done = TRUE;
@@ -3391,13 +3389,12 @@ panel_toplevel_start_animation (PanelToplevel *toplevel)
 
 	toplevel->priv->animating = TRUE;
 
-	panel_toplevel_update_struts (toplevel, TRUE);
 	panel_struts_update_toplevel_geometry (toplevel,
 					       &toplevel->priv->animation_end_x,
 					       &toplevel->priv->animation_end_y,
 					       &toplevel->priv->animation_end_width,
 					       &toplevel->priv->animation_end_height);
-	panel_toplevel_update_struts (toplevel, FALSE);
+	panel_toplevel_update_struts (toplevel);
 
 	gdk_window_get_origin (GTK_WIDGET (toplevel)->window, &cur_x, &cur_y);
 
@@ -4794,7 +4791,7 @@ panel_toplevel_set_auto_hide_size (PanelToplevel *toplevel,
 	toplevel->priv->auto_hide_size = auto_hide_size;
 
 	if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN) {
-		if (panel_toplevel_update_struts (toplevel, FALSE)) {
+		if (panel_toplevel_update_struts (toplevel)) {
 			if (toplevel->priv->animate) {
 				panel_toplevel_unhide (toplevel);
 				panel_toplevel_hide (toplevel, TRUE, -1);
@@ -4970,7 +4967,7 @@ panel_toplevel_set_auto_hide (PanelToplevel *toplevel,
 	else
 		panel_toplevel_queue_auto_unhide (toplevel);
 
-	if (panel_toplevel_update_struts (toplevel, FALSE))
+	if (panel_toplevel_update_struts (toplevel))
 		gtk_widget_queue_resize (GTK_WIDGET (toplevel));
 
 	g_object_notify (G_OBJECT (toplevel), "auto-hide");

Author: Ray Strode <rstrode@redhat.com>
Date:   Wed Oct 22 10:55:48 2008 -0400

    Delay slide out until applets register

--- gnome-panel-2.24.0/gnome-panel/applet.c
+++ gnome-panel-2.24.0/gnome-panel/applet.c
@@ -792,6 +792,7 @@ typedef struct {
 } PanelAppletToLoad;
 
 static GSList  *panel_applets_to_load = NULL;
+static GSList  *panel_applets_loading = NULL;
 static gboolean panel_applet_have_load_idle = FALSE;
 
 static void
@@ -818,6 +819,44 @@ panel_applet_on_load_queue (const char *id)
 	return FALSE;
 }
 
+void
+panel_applet_stop_loading (const char *id)
+{
+	PanelAppletToLoad *applet;
+	GSList *l, *applet_link;
+
+	applet_link = NULL;
+	for (l = panel_applets_loading; l; l = l->next) {
+		applet = l->data;
+
+		if (strcmp (applet->id, id) == 0) {
+			break;
+		}
+	}
+
+	if (l == NULL)
+		return;
+
+	panel_applets_loading = g_slist_delete_link (panel_applets_loading, l);
+	free_applet_to_load (applet);
+
+	if (panel_applets_loading == NULL) {
+		GSList *toplevels, *l;
+
+		toplevels = panel_toplevel_list_toplevels ();
+
+                l = toplevels;
+		while (l != NULL) {
+		    PanelToplevel *toplevel;
+
+		    toplevel = (PanelToplevel *) l->data;
+
+		    panel_toplevel_queue_initial_unhide (toplevel);
+		    l = l->next;
+		}
+	}
+}
+
 static gboolean
 panel_applet_load_idle_handler (gpointer dummy)
 {
@@ -848,8 +887,8 @@ panel_applet_load_idle_handler (gpointer dummy)
 		panel_applet_have_load_idle = FALSE;
 		return FALSE;
 	}
-
 	panel_applets_to_load = g_slist_delete_link (panel_applets_to_load, l);
+	panel_applets_loading = g_slist_append (panel_applets_loading, applet);
 
 	panel_widget = panel_toplevel_get_panel_widget (toplevel);
 
@@ -873,6 +912,7 @@ panel_applet_load_idle_handler (gpointer dummy)
 					applet->locked,
 					applet->position,
 					applet->id);
+		panel_applet_stop_loading (applet->id);
 		break;
 	case PANEL_OBJECT_MENU:
 		panel_menu_button_load_from_gconf (panel_widget,
@@ -880,12 +920,14 @@ panel_applet_load_idle_handler (gpointer dummy)
 						   applet->position,
 						   TRUE,
 						   applet->id);
+		panel_applet_stop_loading (applet->id);
 		break;
 	case PANEL_OBJECT_LAUNCHER:
 		launcher_load_from_gconf (panel_widget,
 					  applet->locked,
 					  applet->position,
 					  applet->id);
+		panel_applet_stop_loading (applet->id);
 		break;
 	case PANEL_OBJECT_LOGOUT:
 	case PANEL_OBJECT_LOCK:
@@ -896,6 +938,7 @@ panel_applet_load_idle_handler (gpointer dummy)
 				applet->position,
 				TRUE,
 				applet->id);
+		panel_applet_stop_loading (applet->id);
 		break;
 	case PANEL_OBJECT_ACTION:
 		panel_action_button_load_from_gconf (
@@ -904,6 +947,7 @@ panel_applet_load_idle_handler (gpointer dummy)
 				applet->position,
 				TRUE,
 				applet->id);
+		panel_applet_stop_loading (applet->id);
 		break;
 	case PANEL_OBJECT_MENU_BAR:
 		panel_menu_bar_load_from_gconf (
@@ -912,18 +956,18 @@ panel_applet_load_idle_handler (gpointer dummy)
 				applet->position,
 				TRUE,
 				applet->id);
+		panel_applet_stop_loading (applet->id);
 		break;
 	case PANEL_OBJECT_SEPARATOR:
 		panel_separator_load_from_gconf (panel_widget,
 						 applet->locked,
 						 applet->position,
 						 applet->id);
+		panel_applet_stop_loading (applet->id);
 	default:
 		break;
 	}
 
-	free_applet_to_load (applet);
-
 	return TRUE;
 }
 
--- gnome-panel-2.24.0/gnome-panel/applet.h
+++ gnome-panel-2.24.0/gnome-panel/applet.h
@@ -53,6 +53,7 @@ AppletInfo *panel_applet_register    (GtkWidget       *applet,
 				      gboolean         exactpos,
 				      PanelObjectType  type,
 				      const char      *id);
+void panel_applet_stop_loading (const char *id);
 
 const char *panel_applet_get_id           (AppletInfo      *info);
 const char *panel_applet_get_id_by_widget (GtkWidget       *widget);
--- gnome-panel-2.24.0/gnome-panel/panel-applet-frame.c
+++ gnome-panel-2.24.0/gnome-panel/panel-applet-frame.c
@@ -1286,6 +1286,7 @@ panel_applet_frame_activated (CORBA_Object  object,
 		if (!in_default_panel_config (frame_act->id)) {
 			panel_applet_frame_loading_failed (frame, frame_act->id);
 		}
+		panel_applet_stop_loading (frame_act->id);
 		g_free (frame_act->id);
 		g_free (frame_act);
 		return;
@@ -1328,6 +1329,7 @@ panel_applet_frame_activated (CORBA_Object  object,
 		panel_applet_frame_loading_failed (frame, frame_act->id);
 		CORBA_exception_free (&corba_ev);
 		bonobo_object_release_unref (object, NULL);
+		panel_applet_stop_loading (frame_act->id);
                 g_free (frame_act->id);
 		g_free (frame_act);
 		g_free (error);
@@ -1344,6 +1346,7 @@ panel_applet_frame_activated (CORBA_Object  object,
 		g_warning (G_STRLOC ": failed to load applet %s",
 			   frame->priv->iid);
 		panel_applet_frame_loading_failed (frame, frame_act->id);
+		panel_applet_stop_loading (frame_act->id);
 		g_free (frame_act->id);
 		g_free (frame_act);
 		return;
@@ -1355,6 +1358,7 @@ panel_applet_frame_activated (CORBA_Object  object,
 			   "(cannot get control frame)", frame->priv->iid);
 		panel_applet_frame_loading_failed (frame, frame_act->id);
 		gtk_object_sink (GTK_OBJECT (widget));
+		panel_applet_stop_loading (frame_act->id);
 		g_free (frame_act->id);
 		g_free (frame_act);
 		return;
@@ -1371,6 +1375,7 @@ panel_applet_frame_activated (CORBA_Object  object,
 			   frame->priv->iid, error);
 		panel_applet_frame_loading_failed (frame, frame_act->id);
 		gtk_object_sink (GTK_OBJECT (widget));
+		panel_applet_stop_loading (frame_act->id);
 		g_free (frame_act->id);
 		g_free (frame_act);
 		g_free (error);
@@ -1394,6 +1399,7 @@ panel_applet_frame_activated (CORBA_Object  object,
 			   frame->priv->iid, error);
 		panel_applet_frame_loading_failed (frame, frame_act->id);
 		gtk_object_sink (GTK_OBJECT (widget));
+		panel_applet_stop_loading (frame_act->id);
 		g_free (frame_act->id);
 		g_free (frame_act);
 		g_free (error);
@@ -1418,6 +1424,7 @@ panel_applet_frame_activated (CORBA_Object  object,
 			   "(cannot get control)", frame->priv->iid);
 		panel_applet_frame_loading_failed (frame, frame_act->id);
 		gtk_object_sink (GTK_OBJECT (widget));
+		panel_applet_stop_loading (frame_act->id);
 		g_free (frame_act->id);
 		g_free (frame_act);
 		return;
@@ -1430,6 +1437,7 @@ panel_applet_frame_activated (CORBA_Object  object,
 			   "(cannot get applet shell)", frame->priv->iid);
 		panel_applet_frame_loading_failed (frame, frame_act->id);
 		gtk_object_sink (GTK_OBJECT (widget));
+		panel_applet_stop_loading (frame_act->id);
 		g_free (frame_act->id);
 		g_free (frame_act);
 		return;
@@ -1461,6 +1469,7 @@ panel_applet_frame_activated (CORBA_Object  object,
 	panel_lockdown_notify_add (G_CALLBACK (panel_applet_frame_sync_menu_state),
 				   frame);
 
+	panel_applet_stop_loading (frame_act->id);
 	g_free (frame_act->id);
 	g_free (frame_act);
 }
--- gnome-panel-2.24.0/gnome-panel/panel-toplevel.c
+++ gnome-panel-2.24.0/gnome-panel/panel-toplevel.c
@@ -2897,11 +2897,14 @@ panel_toplevel_initially_hide (PanelToplevel *toplevel)
 	if (!toplevel->priv->attached) {
 		toplevel->priv->initial_animation_done = FALSE;
 
+		/* We start the panel off hidden until all the
+		 * applets are loaded, and then finally slide i
+		 * down when it's ready to be used
+		 */
 		toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
 		gtk_widget_queue_resize (GTK_WIDGET (toplevel));
 
 		panel_toplevel_update_struts (toplevel);
-		panel_toplevel_queue_auto_unhide (toplevel);
 	} else
 		toplevel->priv->initial_animation_done = TRUE;
 
@@ -3646,6 +3649,17 @@ panel_toplevel_queue_auto_unhide (PanelToplevel *toplevel)
 				    toplevel);
 }
 
+void
+panel_toplevel_queue_initial_unhide (PanelToplevel *toplevel)
+{
+	if (toplevel->priv->initial_animation_done)
+		return;
+       /* Give the applets a second or so to frob after registering */
+	toplevel->priv->unhide_timeout =
+		g_timeout_add_seconds (1, (GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
+			toplevel);
+}
+
 static gboolean
 panel_toplevel_enter_notify_event (GtkWidget        *widget,
 				   GdkEventCrossing *event)
--- gnome-panel-2.24.0/gnome-panel/panel-toplevel.h
+++ gnome-panel-2.24.0/gnome-panel/panel-toplevel.h
@@ -136,6 +136,7 @@ void                 panel_toplevel_hide                   (PanelToplevel
 void                 panel_toplevel_unhide                 (PanelToplevel       *toplevel);
 void                 panel_toplevel_queue_auto_hide        (PanelToplevel       *toplevel);
 void                 panel_toplevel_queue_auto_unhide      (PanelToplevel       *toplevel);
+void                 panel_toplevel_queue_initial_unhide   (PanelToplevel       *toplevel);
 void                 panel_toplevel_push_autohide_disabler (PanelToplevel       *toplevel);
 void                 panel_toplevel_pop_autohide_disabler  (PanelToplevel       *toplevel);
 
