[Galago-commits] r2951 - in trunk/notification-daemon: . src/daemon

galago-commits at freedesktop.org galago-commits at freedesktop.org
Mon Nov 13 21:48:41 PST 2006


Author: chipx86
Date: 2006-11-13 21:48:35 -0800 (Mon, 13 Nov 2006)
New Revision: 2951

Modified:
   trunk/notification-daemon/ChangeLog
   trunk/notification-daemon/src/daemon/stack.c
Log:
Condense a lot of duplicate logic from notify_stack_add_window() and notify_stack_remove_window() into notify_stack_shift_notifications()


Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog	2006-11-13 08:51:10 UTC (rev 2950)
+++ trunk/notification-daemon/ChangeLog	2006-11-14 05:48:35 UTC (rev 2951)
@@ -1,3 +1,9 @@
+Mon Nov 13 21:48:11 PST 2006  Christian Hammond <chipx86 at chipx86.com>
+
+	* src/daemon/stack.c:
+	  - Condense a lot of duplicate logic from notify_stack_add_window() and
+	    notify_stack_remove_window() into notify_stack_shift_notifications().
+
 Mon Nov 13 00:49:42 PST 2006  Christian Hammond <chipx86 at chipx86.com>
 
 	* src/themes/standard/theme.c:

Modified: trunk/notification-daemon/src/daemon/stack.c
===================================================================
--- trunk/notification-daemon/src/daemon/stack.c	2006-11-13 08:51:10 UTC (rev 2950)
+++ trunk/notification-daemon/src/daemon/stack.c	2006-11-14 05:48:35 UTC (rev 2951)
@@ -90,32 +90,32 @@
 
 static void
 get_origin_coordinates(NotifyStackLocation stack_location,
-					   GdkRectangle workarea,
+					   GdkRectangle *workarea,
 					   gint *x, gint *y, gint *shiftx, gint *shifty,
 					   gint width, gint height)
 {
 	switch (stack_location)
 	{
 		case NOTIFY_STACK_LOCATION_TOP_LEFT:
-			*x = workarea.x;
-			*y = workarea.y;
+			*x = workarea->x;
+			*y = workarea->y;
 			*shifty = height;
 			break;
 
 		case NOTIFY_STACK_LOCATION_TOP_RIGHT:
-			*x = workarea.x + workarea.width - width;
-			*y = workarea.y;
+			*x = workarea->x + workarea->width - width;
+			*y = workarea->y;
 			*shifty = height;
 			break;
 
 		case NOTIFY_STACK_LOCATION_BOTTOM_LEFT:
-			*x = workarea.x;
-			*y = workarea.y + workarea.height - height;
+			*x = workarea->x;
+			*y = workarea->y + workarea->height - height;
 			break;
 
 		case NOTIFY_STACK_LOCATION_BOTTOM_RIGHT:
-			*x = workarea.x + workarea.width - width;
-			*y = workarea.y + workarea.height - height;
+			*x = workarea->x + workarea->width - width;
+			*y = workarea->y + workarea->height - height;
 			break;
 
 		default:
@@ -125,31 +125,31 @@
 
 static void
 translate_coordinates(NotifyStackLocation stack_location,
-					  GdkRectangle workarea,
+					  GdkRectangle *workarea,
 					  gint *x, gint *y, gint *shiftx, gint *shifty,
 					  gint width, gint height, gint index)
 {
 	switch (stack_location)
 	{
 		case NOTIFY_STACK_LOCATION_TOP_LEFT:
-			*x = workarea.x;
+			*x = workarea->x;
 			*y += *shifty;
 			*shifty = height;
 			break;
 
 		case NOTIFY_STACK_LOCATION_TOP_RIGHT:
-			*x = workarea.x + workarea.width - width;
+			*x = workarea->x + workarea->width - width;
 			*y += *shifty;
 			*shifty = height;
 			break;
 
 		case NOTIFY_STACK_LOCATION_BOTTOM_LEFT:
-			*x = workarea.x;
+			*x = workarea->x;
 			*y -= height;
 			break;
 
 		case NOTIFY_STACK_LOCATION_BOTTOM_RIGHT:
-			*x = workarea.x + workarea.width - width;
+			*x = workarea->x + workarea->width - width;
 			*y -= height;
 			break;
 
@@ -196,39 +196,64 @@
 	stack->location = location;
 }
 
-void
-notify_stack_add_window(NotifyStack *stack,
-						GtkWindow *nw,
-						gboolean new_notification)
+static void
+notify_stack_shift_notifications(NotifyStack *stack,
+								 GtkWindow *nw,
+								 GSList **nw_l,
+								 gint init_width,
+								 gint init_height,
+								 gint *nw_x,
+								 gint *nw_y)
 {
-	GtkRequisition req;
 	GdkRectangle workarea;
 	GSList *l;
 	gint x, y, shiftx = 0, shifty = 0, index = 1;
 
-	gtk_widget_size_request(GTK_WIDGET(nw), &req);
-
 	get_work_area(GTK_WIDGET(nw), &workarea);
-	get_origin_coordinates(stack->location, workarea, &x, &y,
-						   &shiftx, &shifty, req.width, req.height);
+	get_origin_coordinates(stack->location, &workarea, &x, &y,
+						   &shiftx, &shifty, init_width, init_height);
 
-	theme_move_notification(nw, x, y);
+	if (nw_x != NULL)
+		*nw_x = x;
 
+	if (nw_y != NULL)
+		*nw_y = y;
+
 	for (l = stack->windows; l != NULL; l = l->next)
 	{
 		GtkWindow *nw2 = GTK_WINDOW(l->data);
+		GtkRequisition req;
 
 		if (nw2 != nw)
 		{
-			gtk_widget_size_request(GTK_WIDGET(nw2), &req);
+			gtk_widget_size_request(GTK_WIDGET(nw), &req);
 
-			translate_coordinates(stack->location, workarea, &x, &y,
+			translate_coordinates(stack->location, &workarea, &x, &y,
 								  &shiftx, &shifty, req.width, req.height,
 								  index++);
 			theme_move_notification(nw2, x, y);
 		}
+		else if (nw_l != NULL)
+		{
+			*nw_l = l;
+		}
 	}
 
+}
+
+void
+notify_stack_add_window(NotifyStack *stack,
+						GtkWindow *nw,
+						gboolean new_notification)
+{
+	GtkRequisition req;
+	gint x, y;
+
+	gtk_widget_size_request(GTK_WIDGET(nw), &req);
+	notify_stack_shift_notifications(stack, nw, NULL,
+									 req.width, req.height, &x, &y);
+	theme_move_notification(nw, x, y);
+
 	if (new_notification)
 	{
 		g_signal_connect_swapped(G_OBJECT(nw), "destroy",
@@ -242,35 +267,10 @@
 notify_stack_remove_window(NotifyStack *stack,
 						   GtkWindow *nw)
 {
-	GdkRectangle workarea;
-	GSList *l, *remove_l = NULL;
-	gint x, y, shiftx = 0, shifty = 0, index = 0;
+	GSList *remove_l = NULL;
 
-	get_work_area(GTK_WIDGET(nw), &workarea);
+	notify_stack_shift_notifications(stack, nw, &remove_l, 0, 0, NULL, NULL);
 
-	get_origin_coordinates(stack->location, workarea, &x, &y,
-						   &shiftx, &shifty, 0, 0);
-
-	for (l = stack->windows; l != NULL; l = l->next)
-	{
-		GtkWindow *nw2 = GTK_WINDOW(l->data);
-		GtkRequisition req;
-
-		if (nw2 != nw)
-		{
-			gtk_widget_size_request(GTK_WIDGET(nw2), &req);
-
-			translate_coordinates(stack->location, workarea, &x, &y,
-								  &shiftx, &shifty, req.width, req.height,
-								  index++);
-			theme_move_notification(nw2, x, y);
-		}
-		else
-		{
-			remove_l = l;
-		}
-	}
-
 	if (remove_l != NULL)
 		stack->windows = g_slist_remove_link(stack->windows, remove_l);
 



More information about the galago-commits mailing list