[Goodies-commits] r2168 - in notification-daemon-xfce/trunk/src: daemon themes/standard

Nick Schermer nick at xfce.org
Tue Nov 14 21:34:10 CET 2006


Author: nick
Date: 2006-11-14 20:34:05 +0000 (Tue, 14 Nov 2006)
New Revision: 2168

Modified:
   notification-daemon-xfce/trunk/src/daemon/stack.c
   notification-daemon-xfce/trunk/src/themes/standard/theme.c
Log:
Synced with rev. 2955 of the origional daemon.

Modified: notification-daemon-xfce/trunk/src/daemon/stack.c
===================================================================
--- notification-daemon-xfce/trunk/src/daemon/stack.c	2006-11-13 19:37:29 UTC (rev 2167)
+++ notification-daemon-xfce/trunk/src/daemon/stack.c	2006-11-14 20:34:05 UTC (rev 2168)
@@ -1,4 +1,5 @@
-/* $Id$
+/*
+ * stack.c - Notification stack groups.
  *
  * Copyright (C) 2006 Christian Hammond <chipx86 at chipx86.com>
  *
@@ -17,7 +18,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-
 #include "config.h"
 #include "engines.h"
 #include "stack.h"
@@ -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,63 @@
 	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);
 
-			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 +266,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);
 

Modified: notification-daemon-xfce/trunk/src/themes/standard/theme.c
===================================================================
--- notification-daemon-xfce/trunk/src/themes/standard/theme.c	2006-11-13 19:37:29 UTC (rev 2167)
+++ notification-daemon-xfce/trunk/src/themes/standard/theme.c	2006-11-14 20:34:05 UTC (rev 2168)
@@ -57,7 +57,7 @@
 	URGENCY_CRITICAL
 };
 
-#define WIDTH         300
+#define WIDTH         400
 #define IMAGE_SIZE    32
 #define IMAGE_PADDING 10
 #define STRIPE_WIDTH  30
@@ -82,9 +82,9 @@
 }
 
 static void
-draw_stripe(GtkWidget *win, WindowData *windata)
+draw_stripe(GtkWidget *widget, WindowData *windata)
 {
-	GtkStyle *style = gtk_widget_get_style(win);
+	GtkStyle *style = gtk_widget_get_style(widget);
 	gboolean custom_gc = FALSE;
 	GdkColor color;
 	GdkGC *gc;
@@ -97,7 +97,7 @@
 
 		case URGENCY_CRITICAL: // CRITICAL
 			custom_gc = TRUE;
-			gc = gdk_gc_new(GDK_DRAWABLE(win->window));
+			gc = gdk_gc_new(GDK_DRAWABLE(widget->window));
 			gdk_color_parse("#CC0000", &color);
 			gdk_gc_set_rgb_fg_color(gc, &color);
 			break;
@@ -109,7 +109,7 @@
 	}
 
 
-	gdk_draw_rectangle(win->window, gc, TRUE,
+	gdk_draw_rectangle(widget->window, gc, TRUE,
 					   windata->main_hbox->allocation.x + 1,
 					   windata->main_hbox->allocation.y + 1,
 					   STRIPE_WIDTH,
@@ -149,7 +149,7 @@
 	} G_STMT_END
 
 static void
-create_border_with_arrow(GtkWidget *nw, WindowData *windata)
+create_border_with_arrow(GtkWidget *widget, WindowData *windata)
 {
 	int width;
 	int height;
@@ -167,13 +167,13 @@
 	width  = windata->width;
 	height = windata->height;
 
-	screen        = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window));
+	screen        = gdk_drawable_get_screen(GDK_DRAWABLE(widget->window));
 	screen_width  = gdk_screen_get_width(screen);
 	screen_height = gdk_screen_get_height(screen);
 
 	windata->num_border_points = 5;
 
-	arrow_type = get_notification_arrow_type(nw);
+	arrow_type = get_notification_arrow_type(widget);
 
 	/* Handle the offset and such */
 	switch (arrow_type)
@@ -314,7 +314,7 @@
 			g_assert(i == windata->num_border_points);
 			g_assert(windata->point_x - arrow_offset - arrow_side1_width >= 0);
 #endif
-			gtk_window_move(GTK_WINDOW(nw),
+			gtk_window_move(GTK_WINDOW(widget),
 							windata->point_x - arrow_offset -
 							arrow_side1_width,
 							y);
@@ -345,45 +345,45 @@
 }
 
 static void
-draw_border(GtkWidget *win,
+draw_border(GtkWidget *widget,
 			WindowData *windata)
 {
 	if (windata->gc == NULL)
 	{
 		GdkColor color;
 
-		windata->gc = gdk_gc_new(win->window);
+		windata->gc = gdk_gc_new(widget->window);
 		gdk_color_parse("black", &color);
 		gdk_gc_set_rgb_fg_color(windata->gc, &color);
 	}
 
 	if (windata->has_arrow)
 	{
-		create_border_with_arrow(win, windata);
+		create_border_with_arrow(widget, windata);
 
-		gdk_draw_polygon(win->window, windata->gc, FALSE,
+		gdk_draw_polygon(widget->window, windata->gc, FALSE,
 						 windata->border_points, windata->num_border_points);
-		gdk_window_shape_combine_region(win->window, windata->window_region,
+		gdk_window_shape_combine_region(widget->window, windata->window_region,
 										0, 0);
 		g_free(windata->border_points);
 		windata->border_points = NULL;
 	}
 	else
 	{
-		gdk_draw_rectangle(win->window, windata->gc, FALSE,
+		gdk_draw_rectangle(widget->window, windata->gc, FALSE,
 						   0, 0, windata->width - 1, windata->height - 1);
 	}
 
 }
 
 static gboolean
-paint_window(GtkWidget *win,
+paint_window(GtkWidget *widget,
 			 GdkEventExpose *event,
 			 WindowData *windata)
 {
-	fill_background(win, windata);
-	draw_border(win, windata);
-	draw_stripe(win, windata);
+	fill_background(widget, windata);
+	draw_border(widget, windata);
+	draw_stripe(widget, windata);
 
 	return FALSE;
 }
@@ -467,6 +467,7 @@
 {
 	GtkWidget *spacer;
 	GtkWidget *win;
+	GtkWidget *drawbox;
 	GtkWidget *main_vbox;
 	GtkWidget *hbox;
 	GtkWidget *vbox;
@@ -487,22 +488,34 @@
 	gtk_window_set_title(GTK_WINDOW(win), "Notification");
 	gtk_widget_add_events(win, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
 	gtk_widget_realize(win);
+	gtk_widget_set_size_request(win, WIDTH, -1);
 
 	g_object_set_data_full(G_OBJECT(win), "windata", windata,
 						   (GDestroyNotify)destroy_windata);
-	gtk_widget_set_app_paintable(win, TRUE);
 	atk_object_set_role(gtk_widget_get_accessible(win), ATK_ROLE_ALERT);
 
-	g_signal_connect(G_OBJECT(win), "expose_event",
-					 G_CALLBACK(paint_window), windata);
 	g_signal_connect(G_OBJECT(win), "configure_event",
 					 G_CALLBACK(configure_event_cb), windata);
 
+	/*
+	 * For some reason, there are occasionally graphics glitches when
+	 * repainting the window. Despite filling the window with a background
+	 * color, parts of the other windows on the screen or the shadows around
+	 * notifications will appear on the notification. Somehow, adding this
+	 * eventbox makes that problem just go away. Whatever works for now.
+	 */
+	drawbox = gtk_event_box_new();
+	gtk_widget_show(drawbox);
+	gtk_container_add(GTK_CONTAINER(win), drawbox);
+
 	main_vbox = gtk_vbox_new(FALSE, 0);
 	gtk_widget_show(main_vbox);
-	gtk_container_add(GTK_CONTAINER(win), main_vbox);
+	gtk_container_add(GTK_CONTAINER(drawbox), main_vbox);
 	gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 1);
 
+	g_signal_connect(G_OBJECT(main_vbox), "expose_event",
+					 G_CALLBACK(paint_window), windata);
+
 	windata->top_spacer = gtk_image_new();
 	gtk_box_pack_start(GTK_BOX(main_vbox), windata->top_spacer,
 					   FALSE, FALSE, 0);




More information about the Goodies-commits mailing list