diff options
Diffstat (limited to 'src/themes/nodoka/nodoka-theme.c')
-rw-r--r-- | src/themes/nodoka/nodoka-theme.c | 96 |
1 files changed, 64 insertions, 32 deletions
diff --git a/src/themes/nodoka/nodoka-theme.c b/src/themes/nodoka/nodoka-theme.c index 1859f28..10801f5 100644 --- a/src/themes/nodoka/nodoka-theme.c +++ b/src/themes/nodoka/nodoka-theme.c @@ -1,10 +1,7 @@ /* - * nodoka-theme.c - * This file is part of notification-daemon-engine-nodoka - * * Copyright (C) 2012 - Stefano Karapetsas <[email protected]> * Copyright (C) 2008 - Martin Sourada - * Copyright (C) 2012-2021 MATE Developers + * Copyright (C) 2012-2025 MATE Developers * * notification-daemon-engine-nodoka is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as @@ -31,7 +28,6 @@ #include <libxml/xmlmemory.h> #include <libxml/xpath.h> -/* Define basic nodoka types */ typedef void (*ActionInvokedCb)(GtkWindow *nw, const char *key); typedef void (*UrlClickedCb)(GtkWindow *nw, const char *url); @@ -124,6 +120,24 @@ void notification_tick(GtkWindow *nw, glong remaining); /* Support Nodoka Functions */ +static void +get_background_color (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color) +{ + GdkRGBA *c; + + g_return_if_fail (color != NULL); + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + gtk_style_context_get (context, state, + "background-color", &c, + NULL); + + *color = *c; + gdk_rgba_free (c); +} + /* Handle clicking on link */ static gboolean activate_link (GtkLabel *label, const char *url, WindowData *windata) @@ -405,8 +419,12 @@ fill_background(GtkWidget *widget, WindowData *windata, cairo_t *cr) static void draw_stripe(GtkWidget *widget, WindowData *windata, cairo_t *cr) { + int stripe_x = 0; + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) + stripe_x = windata->width - STRIPE_WIDTH - stripe_x; + cairo_save (cr); - cairo_rectangle (cr, 0, 0, STRIPE_WIDTH, windata->height); + cairo_rectangle (cr, stripe_x, 0, STRIPE_WIDTH, windata->height); cairo_clip (cr); gdouble color_mult = 1.0; @@ -514,7 +532,28 @@ draw_pie(GtkWidget *pie, WindowData *windata, cairo_t *cr) return; gdouble arc_angle = 1.0 - (gdouble)windata->remaining / (gdouble)windata->timeout; - cairo_set_source_rgba (cr, 1.0, 0.4, 0.0, 0.3); + GtkStyleContext *context; + GdkRGBA orig, bg; + + // :selected { background-color:#aabbcc; } ignored -> 1.0, 0.4, 0.0, 0.3 + context = gtk_widget_get_style_context (windata->win); + gtk_style_context_save (context); + gtk_style_context_set_state (context, GTK_STATE_FLAG_SELECTED); + get_background_color (context, GTK_STATE_FLAG_SELECTED, &orig); + gtk_style_context_restore (context); + + // .notification-box .countdown:selected { background-color:#aabbcc; } + context = gtk_widget_get_style_context (pie); + gtk_style_context_save (context); + gtk_style_context_set_state (context, GTK_STATE_FLAG_SELECTED); + get_background_color (context, GTK_STATE_FLAG_SELECTED, &bg); + gtk_style_context_restore (context); + + if (gdk_rgba_equal (&orig, &bg)) + cairo_set_source_rgba (cr, 1.0, 0.4, 0.0, 0.3); + else + cairo_set_source_rgba (cr, bg.red, bg.green, bg.blue, bg.alpha); + cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS); cairo_arc_negative(cr, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS, -G_PI/2, (-0.25 + arc_angle)*2*G_PI); @@ -580,11 +619,9 @@ paint_window (GtkWidget *widget, windata->height); cr2 = cairo_create (surface); - - /* transparent background */ - cairo_rectangle (cr2, 0, 0, windata->width, windata->height); - cairo_set_source_rgba (cr2, 0.0, 0.0, 0.0, 0.0); - cairo_fill (cr2); + cairo_rectangle (cr2, 0, 0, windata->width, windata->height); + cairo_set_source_rgba (cr2, 0.0, 0.0, 0.0, 0.0); // transparent background color + cairo_fill (cr2); if (windata->arrow.has_arrow) { nodoka_rounded_rectangle_with_arrow (cr2, 0, 0, @@ -614,7 +651,6 @@ paint_window (GtkWidget *widget, cairo_restore (cr); update_shape_region (surface, windata); - cairo_surface_destroy (surface); } @@ -649,30 +685,21 @@ static void on_composited_changed (GtkWidget* window, WindowData* windata) } static gboolean -countdown_expose_cb(GtkWidget *pie, - cairo_t *cr, - WindowData *windata) +countdown_expose_cb(GtkWidget *pie, cairo_t *cr, WindowData *windata) { cairo_t *cr2; cairo_surface_t *surface; GtkAllocation alloc; - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); gtk_widget_get_allocation (pie, &alloc); - surface = cairo_surface_create_similar (cairo_get_target (cr), - CAIRO_CONTENT_COLOR_ALPHA, - alloc.width, - alloc.height); + surface = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR_ALPHA, alloc.width, alloc.height); cr2 = cairo_create (surface); - - cairo_translate (cr2, -alloc.x, -alloc.y); - fill_background (pie, windata, cr2); - cairo_translate (cr2, alloc.x, alloc.y); - draw_pie (pie, windata, cr2); + cairo_set_source_rgba (cr2, 0.0, 0.0, 0.0, 0.0); // transparent background color + cairo_paint (cr2); + draw_pie (pie, windata, cr2); // countdown cairo_fill (cr2); - cairo_destroy (cr2); cairo_save (cr); @@ -1042,13 +1069,18 @@ add_notification_action(GtkWindow *nw, const char *text, const char *key, if (!windata->pie_countdown) { windata->pie_countdown = gtk_drawing_area_new(); gtk_widget_set_halign (windata->pie_countdown, GTK_ALIGN_END); + gtk_widget_set_valign (windata->pie_countdown, GTK_ALIGN_CENTER); gtk_widget_show(windata->pie_countdown); + #if GTK_CHECK_VERSION (4,0,0) + gtk_widget_add_css_class (windata->pie_countdown, "countdown"); + #else + gtk_style_context_add_class (gtk_widget_get_style_context (windata->pie_countdown), "countdown"); + #endif + gtk_box_pack_end (GTK_BOX (windata->actions_box), windata->pie_countdown, FALSE, TRUE, 0); - gtk_widget_set_size_request(windata->pie_countdown, - PIE_WIDTH, PIE_HEIGHT); - g_signal_connect(G_OBJECT(windata->pie_countdown), "draw", - G_CALLBACK(countdown_expose_cb), windata); + gtk_widget_set_size_request(windata->pie_countdown, PIE_WIDTH, PIE_HEIGHT); + g_signal_connect(G_OBJECT(windata->pie_countdown), "draw", G_CALLBACK(countdown_expose_cb), windata); } } |