[Goodies-commits] r2352 - in notification-daemon-xfce/trunk: . src/themes/standard
Nick Schermer
nick at xfce.org
Sat Jan 13 12:05:54 CET 2007
Author: nick
Date: 2007-01-13 11:05:54 +0000 (Sat, 13 Jan 2007)
New Revision: 2352
Added:
notification-daemon-xfce/trunk/src/themes/standard/xfce.patch
Modified:
notification-daemon-xfce/trunk/ChangeLog
notification-daemon-xfce/trunk/configure.in.in
notification-daemon-xfce/trunk/src/themes/standard/theme.c
Log:
Update to latest revision.
Add configure option to enable the new gradient look (--enable-gradient-look). This is disabled by default.
Modified: notification-daemon-xfce/trunk/ChangeLog
===================================================================
--- notification-daemon-xfce/trunk/ChangeLog 2007-01-13 10:22:06 UTC (rev 2351)
+++ notification-daemon-xfce/trunk/ChangeLog 2007-01-13 11:05:54 UTC (rev 2352)
@@ -1,3 +1,9 @@
+2007-01-12 Nick Schermer <nick at xfce.org>
+
+ * Update to latest revision.
+ * Add configure option to enable the new gradient look
+ (--enable-gradient-look). This is disabled by default.
+
2007-01-11 Nick Schermer <nick at xfce.org>
* Improve the configure and makefiles a bit.
Modified: notification-daemon-xfce/trunk/configure.in.in
===================================================================
--- notification-daemon-xfce/trunk/configure.in.in 2007-01-13 10:22:06 UTC (rev 2351)
+++ notification-daemon-xfce/trunk/configure.in.in 2007-01-13 11:05:54 UTC (rev 2352)
@@ -90,6 +90,19 @@
AC_DEFINE([ENABLE_CLOSE_BUTTON], [1], [Define to 1 to show the close button.])
fi
+dnl ******************************************************
+dnl *** enable the gradient look in the standard theme ***
+dnl ******************************************************
+AC_ARG_ENABLE([gradient-look],
+ AC_HELP_STRING([--enable-gradient-look],
+ [Show a gradient look in the default theme.]),
+ [ac_enable_gradient_look=$enableval], [ac_enable_gradient_look=no])
+AC_MSG_CHECKING([whether to show a gradient look in the default theme])
+AC_MSG_RESULT([$ac_enable_gradient_look])
+if test x"$ac_enable_gradient_look" = x"yes"; then
+ AC_DEFINE([ENABLE_GRADIENT_LOOK], [1], [Define to 1 to show the gradient look.])
+fi
+
dnl ***********************************
dnl *** check for debugging support ***
dnl ***********************************
@@ -126,5 +139,6 @@
echo "* Preview in Settings Dialog: no"
fi
echo "* Show Close Button: $ac_enable_close_button"
+echo "* Gradient Look: $ac_enable_gradient_look"
echo "* Debug Support: $enable_debug"
echo
Modified: notification-daemon-xfce/trunk/src/themes/standard/theme.c
===================================================================
--- notification-daemon-xfce/trunk/src/themes/standard/theme.c 2007-01-13 10:22:06 UTC (rev 2351)
+++ notification-daemon-xfce/trunk/src/themes/standard/theme.c 2007-01-13 11:05:54 UTC (rev 2352)
@@ -23,6 +23,7 @@
GtkWidget *pie_countdown;
gboolean has_arrow;
+ gboolean enable_transparency;
int point_x;
int point_y;
@@ -57,19 +58,81 @@
URGENCY_CRITICAL
};
+//#define ENABLE_GRADIENT_LOOK
+
+#ifdef ENABLE_GRADIENT_LOOK
+# define STRIPE_WIDTH 45
+#else
+# define STRIPE_WIDTH 30
+#endif
+
#define WIDTH 400
#define IMAGE_SIZE 32
#define IMAGE_PADDING 10
-#define STRIPE_WIDTH 30
+#define SPACER_LEFT 30
#define PIE_RADIUS 12
#define PIE_WIDTH (2 * PIE_RADIUS)
#define PIE_HEIGHT (2 * PIE_RADIUS)
#define BODY_X_OFFSET (IMAGE_SIZE + 8)
-#define DEFAULT_ARROW_OFFSET (STRIPE_WIDTH + 2)
+#define DEFAULT_ARROW_OFFSET (SPACER_LEFT + 2)
#define DEFAULT_ARROW_HEIGHT 14
#define DEFAULT_ARROW_WIDTH 28
+#define BACKGROUND_OPACITY 0.92
+#define BOTTOM_GRADIENT_HEIGHT 30
+#if GTK_CHECK_VERSION(2, 8, 0)
+# define USE_CAIRO
+#endif
+
+#if GTK_CHECK_VERSION(2, 10, 0)
+# define USE_COMPOSITE
+#endif
+
+
+#ifdef USE_CAIRO
static void
+fill_background(GtkWidget *widget, WindowData *windata, cairo_t *cr)
+{
+ GtkStyle *style = gtk_widget_get_style(widget);
+ GdkColor *background_color = &style->base[GTK_STATE_NORMAL];
+#ifdef ENABLE_GRADIENT_LOOK
+ cairo_pattern_t *gradient;
+ int gradient_y = widget->allocation.height - BOTTOM_GRADIENT_HEIGHT;
+#endif
+
+ if (windata->enable_transparency)
+ {
+ cairo_set_source_rgba(cr,
+ background_color->red / 65535.0,
+ background_color->green / 65535.0,
+ background_color->blue / 65535.0,
+ BACKGROUND_OPACITY);
+ }
+ else
+ {
+ gdk_cairo_set_source_color(cr, background_color);
+ }
+
+ cairo_rectangle(cr, 0, 0,
+ widget->allocation.width,
+ widget->allocation.height);
+ cairo_fill(cr);
+
+#ifdef ENABLE_GRADIENT_LOOK
+ /* Add a very subtle gradient to the bottom of the notification */
+ gradient = cairo_pattern_create_linear(0, gradient_y, 0,
+ widget->allocation.height);
+ cairo_pattern_add_color_stop_rgba(gradient, 0, 0, 0, 0, 0);
+ cairo_pattern_add_color_stop_rgba(gradient, 1, 0, 0, 0, 0.15);
+ cairo_rectangle(cr, 0, gradient_y, widget->allocation.width,
+ BOTTOM_GRADIENT_HEIGHT);
+ cairo_set_source(cr, gradient);
+ cairo_fill(cr);
+ cairo_pattern_destroy(gradient);
+#endif
+}
+#else /* !USE_CAIRO */
+static void
fill_background(GtkWidget *widget, WindowData *windata)
{
GtkStyle *style = gtk_widget_get_style(windata->win);
@@ -80,8 +143,58 @@
widget->allocation.width,
widget->allocation.height);
}
+#endif
+#ifdef USE_CAIRO
static void
+draw_stripe(GtkWidget *widget, WindowData *windata, cairo_t *cr)
+{
+ GtkStyle *style = gtk_widget_get_style(widget);
+ GdkColor color;
+ int stripe_x = windata->main_hbox->allocation.x + 1;
+ int stripe_y = windata->main_hbox->allocation.y + 1;
+ int stripe_height = windata->main_hbox->allocation.height - 2;
+#ifdef ENABLE_GRADIENT_LOOK
+ cairo_pattern_t *gradient;
+ double r, g, b;
+#endif
+
+ switch (windata->urgency)
+ {
+ case URGENCY_LOW: // LOW
+ color = style->bg[GTK_STATE_NORMAL];
+ break;
+
+ case URGENCY_CRITICAL: // CRITICAL
+ gdk_color_parse("#CC0000", &color);
+ break;
+
+ case URGENCY_NORMAL: // NORMAL
+ default:
+ color = style->bg[GTK_STATE_SELECTED];
+ break;
+ }
+
+ cairo_rectangle(cr, stripe_x, stripe_y, STRIPE_WIDTH, stripe_height);
+
+#ifdef ENABLE_GRADIENT_LOOK
+ r = color.red / 65535.0;
+ g = color.green / 65535.0;
+ b = color.blue / 65535.0;
+
+ gradient = cairo_pattern_create_linear(stripe_x, 0, STRIPE_WIDTH, 0);
+ cairo_pattern_add_color_stop_rgba(gradient, 0, r, g, b, 1);
+ cairo_pattern_add_color_stop_rgba(gradient, 1, r, g, b, 0);
+ cairo_set_source(cr, gradient);
+ cairo_fill(cr);
+ cairo_pattern_destroy(gradient);
+#else
+ gdk_cairo_set_source_color(cr, &color);
+ cairo_fill(cr);
+#endif
+}
+#else /* !USE_CAIRO */
+static void
draw_stripe(GtkWidget *widget, WindowData *windata)
{
GtkStyle *style = gtk_widget_get_style(widget);
@@ -118,6 +231,7 @@
if (custom_gc)
g_object_unref(G_OBJECT(gc));
}
+#endif
static GtkArrowType
get_notification_arrow_type(GtkWidget *nw)
@@ -250,9 +364,11 @@
ADD_POINT(0, DEFAULT_ARROW_HEIGHT, 0, 0);
if (arrow_offset > 0)
+ {
ADD_POINT(arrow_offset -
(arrow_side2_width > 0 ? 0 : 1),
DEFAULT_ARROW_HEIGHT, 0, 0);
+ }
ADD_POINT(arrow_offset + arrow_side1_width -
(arrow_side2_width > 0 ? 0 : 1),
@@ -347,7 +463,46 @@
g_free(shape_points);
}
+#ifdef USE_CAIRO
static void
+draw_border(GtkWidget *widget, WindowData *windata, cairo_t *cr)
+{
+ cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);
+ cairo_set_line_width(cr, 1.0);
+
+ if (windata->has_arrow)
+ {
+ int i;
+
+ create_border_with_arrow(windata->win, windata);
+
+ cairo_move_to(cr,
+ windata->border_points[0].x + 0.5,
+ windata->border_points[0].y + 0.5);
+
+ for (i = 1; i < windata->num_border_points; i++)
+ {
+ cairo_line_to(cr,
+ windata->border_points[i].x + 0.5,
+ windata->border_points[i].y + 0.5);
+ }
+
+ cairo_close_path(cr);
+ gdk_window_shape_combine_region(windata->win->window,
+ windata->window_region, 0, 0);
+ g_free(windata->border_points);
+ windata->border_points = NULL;
+ }
+ else
+ {
+ cairo_rectangle(cr, 0.5, 0.5,
+ windata->width - 0.5, windata->height - 0.5);
+ }
+
+ cairo_stroke(cr);
+}
+#else /* !USE_CAIRO */
+static void
draw_border(GtkWidget *widget,
WindowData *windata)
{
@@ -379,6 +534,7 @@
}
}
+#endif
static gboolean
paint_window(GtkWidget *widget,
@@ -386,13 +542,38 @@
WindowData *windata)
{
if (windata->width == 0) {
- /* We haven't seen configure_event yet. Bail for now. */
- return FALSE;
+ windata->width = windata->win->allocation.width;
+ windata->height = windata->win->allocation.height;
}
+#ifdef USE_CAIRO
+ cairo_t *context;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ context = gdk_cairo_create(widget->window);
+
+ cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
+ surface = cairo_surface_create_similar(cairo_get_target(context),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ widget->allocation.width,
+ widget->allocation.height);
+ cr = cairo_create(surface);
+
+ fill_background(widget, windata, cr);
+ draw_border(widget, windata, cr);
+ draw_stripe(widget, windata, cr);
+
+ cairo_destroy(cr);
+ cairo_set_source_surface(context, surface, 0, 0);
+ cairo_paint(context);
+ cairo_surface_destroy(surface);
+ cairo_destroy(context);
+#else /* !USE_CAIRO */
fill_background(widget, windata);
draw_border(widget, windata);
draw_stripe(widget, windata);
+#endif
return FALSE;
}
@@ -488,6 +669,10 @@
GtkWidget *alignment;
AtkObject *atkobj;
WindowData *windata;
+#ifdef USE_COMPOSITE
+ GdkColormap *colormap;
+ GdkScreen *screen;
+#endif
windata = g_new0(WindowData, 1);
windata->urgency = URGENCY_NORMAL;
@@ -495,6 +680,19 @@
win = gtk_window_new(GTK_WINDOW_POPUP);
windata->win = win;
+
+ windata->enable_transparency = FALSE;
+#ifdef USE_COMPOSITE
+ screen = gtk_window_get_screen(GTK_WINDOW(win));
+ colormap = gdk_screen_get_rgba_colormap(screen);
+
+ if (colormap != NULL && gdk_screen_is_composited(screen))
+ {
+ gtk_widget_set_colormap(win, colormap);
+ windata->enable_transparency = TRUE;
+ }
+#endif
+
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);
@@ -554,7 +752,7 @@
spacer = gtk_image_new();
gtk_widget_show(spacer);
gtk_box_pack_start(GTK_BOX(hbox), spacer, FALSE, FALSE, 0);
- gtk_widget_set_size_request(spacer, STRIPE_WIDTH, -1);
+ gtk_widget_set_size_request(spacer, SPACER_LEFT, -1);
windata->summary_label = gtk_label_new(NULL);
gtk_widget_show(windata->summary_label);
@@ -740,16 +938,29 @@
{
GtkStyle *style = gtk_widget_get_style(windata->win);
+#ifdef USE_CAIRO
+ cairo_t *context;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ context = gdk_cairo_create(GDK_DRAWABLE(windata->pie_countdown->window));
+ cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
+ surface = cairo_surface_create_similar(
+ cairo_get_target(context),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ pie->allocation.width,
+ pie->allocation.height);
+ cr = cairo_create(surface);
+
+ fill_background(pie, windata, cr);
+#else /* !USE_CAIRO */
fill_background(pie, windata);
+#endif
if (windata->timeout > 0)
{
gdouble pct = (gdouble)windata->remaining / (gdouble)windata->timeout;
-#if GTK_CHECK_VERSION(2, 8, 0)
- cairo_t *cr;
-
- cr = gdk_cairo_create(GDK_DRAWABLE(windata->pie_countdown->window));
+#ifdef USE_CAIRO
gdk_cairo_set_source_color(cr, &style->bg[GTK_STATE_ACTIVE]);
cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS);
@@ -757,7 +968,7 @@
-G_PI_2, -(pct * G_PI * 2) - G_PI_2);
cairo_line_to(cr, PIE_RADIUS, PIE_RADIUS);
cairo_fill(cr);
-#else
+#else /* !USE_CAIRO */
gdk_draw_arc(GDK_DRAWABLE(windata->pie_countdown->window),
style->bg_gc[GTK_STATE_ACTIVE], TRUE,
0, 0, PIE_WIDTH, PIE_HEIGHT,
@@ -765,6 +976,14 @@
#endif
}
+#ifdef USE_CAIRO
+ cairo_destroy(cr);
+ cairo_set_source_surface(context, surface, 0, 0);
+ cairo_paint(context);
+ cairo_surface_destroy(surface);
+ cairo_destroy(context);
+#endif
+
return TRUE;
}
Added: notification-daemon-xfce/trunk/src/themes/standard/xfce.patch
===================================================================
--- notification-daemon-xfce/trunk/src/themes/standard/xfce.patch (rev 0)
+++ notification-daemon-xfce/trunk/src/themes/standard/xfce.patch 2007-01-13 11:05:54 UTC (rev 2352)
@@ -0,0 +1,29 @@
+--- xfce.c 2007-01-13 11:53:06.000000000 +0100
++++ theme.c 2007-01-13 11:52:42.000000000 +0100
+@@ -481,8 +481,10 @@
+ GtkWidget *main_vbox;
+ GtkWidget *hbox;
+ GtkWidget *vbox;
++#ifdef ENABLE_CLOSE_BUTTON
+ GtkWidget *close_button;
+ GtkWidget *image;
++#endif
+ GtkWidget *alignment;
+ AtkObject *atkobj;
+ WindowData *windata;
+@@ -563,6 +565,7 @@
+ atkobj = gtk_widget_get_accessible(windata->summary_label);
+ atk_object_set_description(atkobj, "Notification summary text.");
+
++#ifdef ENABLE_CLOSE_BUTTON
+ /* Add the close button */
+ close_button = gtk_button_new();
+ gtk_widget_show(close_button);
+@@ -582,6 +585,7 @@
+ image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ gtk_widget_show(image);
+ gtk_container_add(GTK_CONTAINER(close_button), image);
++#endif
+
+ windata->content_hbox = gtk_hbox_new(FALSE, 6);
+ gtk_box_pack_start(GTK_BOX(vbox), windata->content_hbox, FALSE, FALSE, 0);
More information about the Goodies-commits
mailing list