1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
/*
 * nodoka-theme.c
 * This file is part of notification-daemon-engine-nodoka
 *
 * Copyright (C) 2012 - Stefano Karapetsas <stefano@karapetsas.com>
 * Copyright (C) 2008 - Martin Sourada
 *
 * 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
 * published by the Free Software Foundation; either version 3 of the License,
 * or (at your option) any later version.
 *
 * notification-daemon-engine-nodoka is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with notification-daemon-engine-nodoka; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301  USA
 */



#include "config.h"

#include <glib/gi18n.h>
#include <ctk/ctk.h>
#include <cdk/cdkx.h>

#include <libxml/xpath.h>

/* Define basic nodoka types */
typedef void (*ActionInvokedCb)(CtkWindow *nw, const char *key);
typedef void (*UrlClickedCb)(CtkWindow *nw, const char *url);

typedef struct
{
	gboolean has_arrow;

	CdkPoint point_begin;
	CdkPoint point_middle;
	CdkPoint point_end;

	int offset;
	CdkPoint position;

} ArrowParameters;

typedef struct
{
	CtkWidget *win;
	CtkWidget *top_spacer;
	CtkWidget *bottom_spacer;
	CtkWidget *main_hbox;
	CtkWidget *iconbox;
	CtkWidget *icon;
	CtkWidget *content_hbox;
	CtkWidget *summary_label;
	CtkWidget *body_label;
	CtkWidget *actions_box;
	CtkWidget *last_sep;<--- struct member 'WindowData::last_sep' is never used.
	CtkWidget *stripe_spacer;<--- struct member 'WindowData::stripe_spacer' is never used.
	CtkWidget *pie_countdown;

	ArrowParameters arrow;

	gboolean composited;
	gboolean action_icons;

	int width;
	int height;
	int last_width;
	int last_height;

	guchar urgency;
	glong timeout;
	glong remaining;

	UrlClickedCb url_clicked;

} WindowData;


enum
{
	URGENCY_LOW,
	URGENCY_NORMAL,
	URGENCY_CRITICAL
};

gboolean theme_check_init(unsigned int major_ver, unsigned int minor_ver,
			  unsigned int micro_ver);
void get_theme_info(char **theme_name, char **theme_ver, char **author,
		    char **homepage);
CtkWindow* create_notification(UrlClickedCb url_clicked);
void set_notification_text(CtkWindow *nw, const char *summary,
			   const char *body);
void set_notification_icon(CtkWindow *nw, GdkPixbuf *pixbuf);
void set_notification_arrow(CtkWidget *nw, gboolean visible, int x, int y);
void add_notification_action(CtkWindow *nw, const char *text, const char *key,
			     ActionInvokedCb cb);
void clear_notification_actions(CtkWindow *nw);
void move_notification(CtkWidget *nw, int x, int y);
void set_notification_timeout(CtkWindow *nw, glong timeout);
void set_notification_hints(CtkWindow *nw, GVariant *hints);
void notification_tick(CtkWindow *nw, glong remaining);

#define STRIPE_WIDTH  32
#define WIDTH         400
#define IMAGE_SIZE    32
#define IMAGE_PADDING 10
#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  (SPACER_LEFT + 12)
#define DEFAULT_ARROW_HEIGHT  14
#define DEFAULT_ARROW_WIDTH   22
#define DEFAULT_ARROW_SKEW    -6
#define BACKGROUND_OPACITY    0.92
#define GRADIENT_CENTER 0.7

/* Support Nodoka Functions */

/* Handle clicking on link */
static gboolean
activate_link (CtkLabel *label, const char *url, WindowData *windata)
{
	windata->url_clicked (CTK_WINDOW (windata->win), url);
	return TRUE;
}

/* Set if we have arrow down or arrow up */
static CtkArrowType
get_notification_arrow_type(CtkWidget *nw)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");<--- Variable 'windata' can be declared as pointer to const
	int screen_height;

	screen_height = HeightOfScreen (cdk_x11_screen_get_xscreen (
		cdk_window_get_screen (ctk_widget_get_window (nw))));

	if (windata->arrow.position.y + windata->height + DEFAULT_ARROW_HEIGHT >
		screen_height)
	{
		return CTK_ARROW_DOWN;
	}
	else
	{
		return CTK_ARROW_UP;
	}
}

/* Set arrow parameters like offset and position */
static void
set_arrow_parameters (WindowData *windata)
{
	int screen_width;
	int x,y;
	CtkArrowType arrow_type;

	screen_width = WidthOfScreen (cdk_x11_screen_get_xscreen (
		cdk_window_get_screen (ctk_widget_get_window (windata->win))));

	/* Set arrow offset */
	CtkAllocation alloc;
	ctk_widget_get_allocation(windata->win, &alloc);

	if ((windata->arrow.position.x - DEFAULT_ARROW_SKEW -
		DEFAULT_ARROW_OFFSET + alloc.width) >
			screen_width)
	{
		windata->arrow.offset = windata->arrow.position.x -
					DEFAULT_ARROW_SKEW -
					(screen_width -
						alloc.width);
	}
	else if ((windata->arrow.position.x - DEFAULT_ARROW_SKEW -
		DEFAULT_ARROW_OFFSET < 0))
	{
		windata->arrow.offset = windata->arrow.position.x -
					DEFAULT_ARROW_SKEW;
	}
	else
	{
		windata->arrow.offset = DEFAULT_ARROW_OFFSET;
	}

	if (windata->arrow.offset < 6)
	{
		windata->arrow.offset = 6;
		windata->arrow.position.x += 6;
	}
	else if (windata->arrow.offset + DEFAULT_ARROW_WIDTH + 6 >
			alloc.width)
	{
		windata->arrow.offset = alloc.width - 6 -
					DEFAULT_ARROW_WIDTH;
		windata->arrow.position.x -= 6;
	}

	/* Set arrow points X position */
	windata->arrow.point_begin.x = windata->arrow.offset;
	windata->arrow.point_middle.x = windata->arrow.offset +
					DEFAULT_ARROW_SKEW;
	windata->arrow.point_end.x = windata->arrow.offset +
					DEFAULT_ARROW_WIDTH;
	x = windata->arrow.position.x - DEFAULT_ARROW_SKEW - windata->arrow.offset;

	/* Set arrow points Y position */
	arrow_type = get_notification_arrow_type(windata->win);

	switch (arrow_type)
	{
		case CTK_ARROW_UP:
			windata->arrow.point_begin.y = DEFAULT_ARROW_HEIGHT;
			windata->arrow.point_middle.y = 0;
			windata->arrow.point_end.y = DEFAULT_ARROW_HEIGHT;
			y = windata->arrow.position.y;
			break;
		case CTK_ARROW_DOWN:
			windata->arrow.point_begin.y =
				alloc.height -
					DEFAULT_ARROW_HEIGHT;
			windata->arrow.point_middle.y =
				alloc.height;
			windata->arrow.point_end.y =
				alloc.height -
					DEFAULT_ARROW_HEIGHT;
			y = windata->arrow.position.y - alloc.height;
			break;
		default:
			g_assert_not_reached();
	}

	/* Move window to requested position */
	ctk_window_move(CTK_WINDOW(windata->win), x, y);
}

static void
destroy_windata(WindowData *windata)
{
	g_free(windata);
}

static void
update_spacers(CtkWidget *nw)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");

	if (windata->arrow.has_arrow)
	{
		switch (get_notification_arrow_type(CTK_WIDGET(nw)))
		{
			case CTK_ARROW_UP:
				ctk_widget_show(windata->top_spacer);
				ctk_widget_hide(windata->bottom_spacer);
				break;

			case CTK_ARROW_DOWN:
				ctk_widget_hide(windata->top_spacer);
				ctk_widget_show(windata->bottom_spacer);
				break;

			default:
				g_assert_not_reached();
		}
	}
	else
	{
		ctk_widget_hide(windata->top_spacer);
		ctk_widget_hide(windata->bottom_spacer);
	}
}

static void
update_content_hbox_visibility(WindowData *windata)
{
	/*
	 * This is all a hack, but until we have a libview-style ContentBox,
	 * it'll just have to do.
	 */
	if (ctk_widget_get_visible(windata->icon) ||
		ctk_widget_get_visible(windata->body_label) ||
		ctk_widget_get_visible(windata->actions_box))
	{
		ctk_widget_show(windata->content_hbox);
	}
	else
	{
		ctk_widget_hide(windata->content_hbox);
	}
}

/* Draw fuctions */
/* Standard rounded rectangle */
static void
nodoka_rounded_rectangle (cairo_t * cr,
							  double x, double y, double w, double h,
							  int radius)
{
	cairo_move_to (cr, x + radius, y);
	cairo_arc (cr, x + w - radius, y + radius, radius, G_PI * 1.5, G_PI * 2);
	cairo_arc (cr, x + w - radius, y + h - radius, radius, 0, G_PI * 0.5);
	cairo_arc (cr, x + radius, y + h - radius, radius, G_PI * 0.5, G_PI);
	cairo_arc (cr, x + radius, y + radius, radius, G_PI, G_PI * 1.5);
}

/* Rounded rectangle with arrow */
static void
nodoka_rounded_rectangle_with_arrow (cairo_t * cr,
				double x, double y, double w, double h,
				int radius, ArrowParameters * arrow)
{
	gboolean arrow_up;
	arrow_up = (arrow->point_begin.y > arrow->point_middle.y);

	cairo_translate (cr, x, y);

	cairo_rectangle_int_t rect;
	rect.x = 0;
	rect.width = w;
	if (arrow_up)
		rect.y = 0 + DEFAULT_ARROW_HEIGHT;
	else
		rect.y = 0;
	rect.height = h - DEFAULT_ARROW_HEIGHT;

	cairo_move_to (cr, rect.x + radius, rect.y);

	if (arrow_up)
	{
		cairo_line_to (cr, rect.x + arrow->point_begin.x,
				rect.y);
		cairo_line_to (cr, rect.x + arrow->point_middle.x,
				rect.y - DEFAULT_ARROW_HEIGHT);
		cairo_line_to (cr, rect.x + arrow->point_end.x,
				rect.y);
	}

	cairo_arc (cr, rect.x + rect.width - radius, rect.y + radius, radius,
			G_PI * 1.5, G_PI * 2);
	cairo_arc (cr, rect.x + rect.width - radius,
			rect.y + rect.height - radius, radius, 0, G_PI * 0.5);

	if (!arrow_up)
	{
		cairo_line_to (cr, rect.x + arrow->point_end.x,
				rect.y + rect.height);
		cairo_line_to (cr, rect.x + arrow->point_middle.x,
				rect.y + rect.height + DEFAULT_ARROW_HEIGHT);
		cairo_line_to (cr, rect.x + arrow->point_begin.x,
				rect.y + rect.height);
	}

	cairo_arc (cr, rect.x + radius, rect.y + rect.height - radius,
			radius, G_PI * 0.5, G_PI);
	cairo_arc (cr, rect.x + radius, rect.y + radius, radius, G_PI,
			G_PI * 1.5);

	cairo_translate (cr, -x, -y);

}

/* Fill background */
static void
fill_background(CtkWidget *widget, WindowData *windata, cairo_t *cr)
{
	float alpha;
	if (windata->composited)
		alpha = BACKGROUND_OPACITY;
	else
		alpha = 1.0;

	cairo_pattern_t *pattern;
	pattern = cairo_pattern_create_linear (0, 0, 0, windata->height);
	cairo_pattern_add_color_stop_rgba (pattern, 0, 0.996, 0.996, 0.89, alpha);
	cairo_pattern_add_color_stop_rgba (pattern, GRADIENT_CENTER, 0.988, 0.988, 0.714, alpha);
	cairo_pattern_add_color_stop_rgba (pattern, 1, 0.984, 0.984, 0.663, alpha);
	cairo_set_source (cr, pattern);
	cairo_pattern_destroy (pattern);

	if (windata->arrow.has_arrow)
		nodoka_rounded_rectangle_with_arrow (cr, 0, 0,
			windata->width, windata->height, 6, & (windata->arrow));
	else
		nodoka_rounded_rectangle (cr, 0, 0, windata->width,
			windata->height, 6);
	cairo_fill (cr);
}


static void
draw_stripe(CtkWidget *widget, WindowData *windata, cairo_t *cr)
{
	cairo_save (cr);
	cairo_rectangle (cr, 0, 0, STRIPE_WIDTH, windata->height);
	cairo_clip (cr);

	gdouble  color_mult = 1.0;
	CdkRGBA  top_color;
	CdkRGBA  center_color;
	CdkRGBA  bottom_color;

	float alpha;
	if (windata->composited)
		alpha = BACKGROUND_OPACITY;
	else
		alpha = 1.0;

	switch (windata->urgency)
	{
		case URGENCY_LOW: // LOW
			alpha = alpha * 0.5;
			top_color.red = 221 / 255.0 * color_mult;
			top_color.green = top_color.red;
			top_color.blue = top_color.red;
			center_color.red = 192 / 255.0 * color_mult;
			center_color.green = center_color.red;<--- Variable 'center_color.green' is assigned a value that is never used.
			center_color.blue = center_color.red;<--- Variable 'center_color.blue' is assigned a value that is never used.
			bottom_color.red = 167 / 255.0 * color_mult;
			bottom_color.green = center_color.red;
			bottom_color.blue = center_color.red;
			break;

		case URGENCY_CRITICAL: // CRITICAL
			top_color.red = 255 / 255.0 * color_mult;
			top_color.green = 11 / 255.0 * color_mult;
			top_color.blue = top_color.green;
			center_color.red = 205 / 255.0 * color_mult;<--- Variable 'center_color.red' is assigned a value that is never used.
			center_color.green = 0;<--- Variable 'center_color.green' is assigned a value that is never used.
			center_color.blue = 0;<--- Variable 'center_color.blue' is assigned a value that is never used.
			bottom_color.red = 145 / 255.0 * color_mult;
			bottom_color.green = 0;
			bottom_color.blue = 0;
			break;

		case URGENCY_NORMAL: // NORMAL
		default:
			top_color.red = 20 / 255.0 * color_mult;
			top_color.green = 175 / 255.0 * color_mult;
			top_color.blue = color_mult;
			center_color.red = 9 / 255.0 * color_mult;<--- Variable 'center_color.red' is assigned a value that is never used.
			center_color.green = 139 / 255.0 * color_mult;<--- Variable 'center_color.green' is assigned a value that is never used.
			center_color.blue = 207 / 255.0 * color_mult;<--- Variable 'center_color.blue' is assigned a value that is never used.
			bottom_color.red = 0;
			bottom_color.green = 97 / 255.0 * color_mult;
			bottom_color.blue = 147 / 255.0 * color_mult;
			break;
	}


	cairo_pattern_t *pattern;
	pattern = cairo_pattern_create_linear (0, 0, 0, windata->height);
	cairo_pattern_add_color_stop_rgba (pattern, 0, top_color.red / color_mult, top_color.green / color_mult, top_color.blue / color_mult, alpha);
	cairo_pattern_add_color_stop_rgba (pattern, GRADIENT_CENTER, bottom_color.red / color_mult, bottom_color.green / color_mult, bottom_color.blue / color_mult, alpha);
	cairo_pattern_add_color_stop_rgba (pattern, 1, bottom_color.red / color_mult, bottom_color.green / color_mult, bottom_color.blue / color_mult, alpha);
	cairo_set_source (cr, pattern);
	cairo_pattern_destroy (pattern);

	if (windata->arrow.has_arrow)
		nodoka_rounded_rectangle_with_arrow (cr, 1, 1,
			windata->width - 2, windata->height - 2, 5, & (windata->arrow));
	else
		nodoka_rounded_rectangle (cr, 1, 1, windata->width - 2,
			windata->height - 2, 5);
	cairo_fill (cr);

	cairo_restore (cr);
}

static void
draw_border(CtkWidget *widget, WindowData *windata, cairo_t *cr)
{
	float alpha;
	if (windata->composited)
		alpha = BACKGROUND_OPACITY;
	else
		alpha = 1.0;

	cairo_pattern_t *pattern;
	pattern = cairo_pattern_create_linear (0, 0, 0, windata->height);
	cairo_pattern_add_color_stop_rgba (pattern, 0, 0.62, 0.584, 0.341, alpha);
	cairo_pattern_add_color_stop_rgba (pattern, 1, 0.776, 0.757, 0.596, alpha);
	cairo_set_source (cr, pattern);
	cairo_pattern_destroy (pattern);

	if (windata->arrow.has_arrow)
		nodoka_rounded_rectangle_with_arrow (cr, 0.5, 0.5,
			windata->width -1, windata->height -1, 6, & (windata->arrow));
	else
		nodoka_rounded_rectangle (cr, 0.5, 0.5, windata->width -1,
			windata->height -1, 6);

	cairo_set_line_width (cr, 1.0);
	cairo_stroke (cr);
}

static void
draw_pie(CtkWidget *pie, WindowData *windata, cairo_t *cr)
{
	if (windata->timeout == 0)
		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);
	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);
	cairo_line_to(cr, PIE_RADIUS, PIE_RADIUS);

	cairo_fill (cr);
}

static void
update_shape_region (cairo_surface_t *surface,
		     WindowData      *windata)
{
	if (windata->width == windata->last_width && windata->height == windata->last_height)
	{
		return;
	}

	if (windata->width == 0 || windata->height == 0)
	{
		CtkAllocation allocation;
		ctk_widget_get_allocation (windata->win, &allocation);

		windata->width = MAX (allocation.width, 1);
		windata->height = MAX (allocation.height, 1);
	}

	if (!windata->composited) {
		cairo_region_t *region;

		region = cdk_cairo_region_create_from_surface (surface);
		ctk_widget_shape_combine_region (windata->win, region);
		cairo_region_destroy (region);
	} else {
		ctk_widget_shape_combine_region (windata->win, NULL);
		return;
	}

	windata->last_width = windata->width;
	windata->last_height = windata->height;
}

static void
paint_window (CtkWidget  *widget,
	      cairo_t    *cr,
	      WindowData *windata)
{
	cairo_t *cr2;
	cairo_surface_t *surface;
	CtkAllocation allocation;

	if (windata->width == 0 || windata->height == 0) {
		ctk_widget_get_allocation (windata->win, &allocation);
		windata->width = allocation.width;
		windata->height = allocation.height;
	}

	if (windata->arrow.has_arrow)
		set_arrow_parameters (windata);

	surface = cairo_surface_create_similar (cairo_get_target (cr),
						CAIRO_CONTENT_COLOR_ALPHA,
						windata->width,
						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);

	if (windata->arrow.has_arrow) {
		nodoka_rounded_rectangle_with_arrow (cr2, 0, 0,
						     windata->width,
						     windata->height,
						     6,
						     & (windata->arrow));
	} else {
		nodoka_rounded_rectangle (cr2, 0, 0,
					  windata->width,
					  windata->height,
					  6);
	}

	cairo_fill (cr2);

	fill_background(widget, windata, cr2);
	draw_border(widget, windata, cr2);
	draw_stripe(widget, windata, cr2);

	cairo_destroy (cr2);

	cairo_save (cr);
	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_surface (cr, surface, 0, 0);
	cairo_paint (cr);
	cairo_restore (cr);

	update_shape_region (surface, windata);

	cairo_surface_destroy (surface);
}

static gboolean
on_draw (CtkWidget *widget, cairo_t *cr, WindowData *windata)
{
	paint_window (widget, cr, windata);

	return FALSE;
}

/* Event handlers */
static gboolean
configure_event_cb(CtkWidget *nw,
				   CdkEventConfigure *event,<--- Parameter 'event' can be declared as pointer to const
				   WindowData *windata)
{
	windata->width = event->width;
	windata->height = event->height;

	update_spacers(nw);
	ctk_widget_queue_draw(nw);

	return FALSE;
}

static void on_composited_changed (CtkWidget* window, WindowData* windata)
{
	windata->composited = cdk_screen_is_composited (ctk_widget_get_screen(window));

	ctk_widget_queue_draw (window);
}

static gboolean
countdown_expose_cb(CtkWidget *pie,
		    cairo_t *cr,
		    WindowData *windata)
{
	cairo_t *cr2;
	cairo_surface_t *surface;
	CtkAllocation alloc;

	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);

	ctk_widget_get_allocation (pie, &alloc);

	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_fill (cr2);

	cairo_destroy (cr2);

	cairo_save (cr);
	cairo_set_source_surface (cr, surface, 0, 0);
	cairo_paint (cr);
	cairo_restore (cr);

	cairo_surface_destroy (surface);
	return TRUE;
}

static void
action_clicked_cb(CtkWidget *w, CdkEventButton *event,
				  ActionInvokedCb action_cb)
{
	CtkWindow *nw   = g_object_get_data(G_OBJECT(w), "_nw");
	const char *key = g_object_get_data(G_OBJECT(w), "_action_key");

	action_cb(nw, key);
}



/* Required functions */

/* Checking if we support this notification daemon version */
gboolean
theme_check_init(unsigned int major_ver, unsigned int minor_ver,
				 unsigned int micro_ver)
{
	return major_ver == NOTIFICATION_DAEMON_MAJOR_VERSION && minor_ver == NOTIFICATION_DAEMON_MINOR_VERSION && micro_ver == NOTIFICATION_DAEMON_MICRO_VERSION;
}

/* Sending theme info to the notification daemon */
void
get_theme_info(char **theme_name,
			   char **theme_ver,
			   char **author,
			   char **homepage)
{
	*theme_name = g_strdup("Nodoka");
	*theme_ver  = g_strdup_printf("%d.%d.%d", NOTIFICATION_DAEMON_MAJOR_VERSION,
                                                  NOTIFICATION_DAEMON_MINOR_VERSION,
						  NOTIFICATION_DAEMON_MICRO_VERSION);
	*author = g_strdup("Martin Sourada");
	*homepage = g_strdup("https://nodoka.fedorahosted.org/");
}

/* Create new notification */
CtkWindow *
create_notification(UrlClickedCb url_clicked)
{
	CtkWidget *spacer;
	CtkWidget *win;
	CtkWidget *main_vbox;
	CtkWidget *hbox;
	CtkWidget *vbox;
	CtkWidget *close_button;
	CtkWidget *image;
	AtkObject *atkobj;
	WindowData *windata;
	CdkVisual *visual;
	CdkScreen *screen;

	windata = g_new0(WindowData, 1);
	windata->urgency = URGENCY_NORMAL;
	windata->url_clicked = url_clicked;

	win = ctk_window_new(CTK_WINDOW_POPUP);
	ctk_window_set_resizable(CTK_WINDOW(win), FALSE);
	windata->win = win;

	windata->composited = FALSE;
	screen = ctk_window_get_screen(CTK_WINDOW(win));
	visual = cdk_screen_get_rgba_visual(screen);

	if (visual != NULL)
	{
		ctk_widget_set_visual(win, visual);
		if (cdk_screen_is_composited(screen))
			windata->composited = TRUE;
	}

	ctk_window_set_title(CTK_WINDOW(win), "Notification");
	ctk_window_set_type_hint(CTK_WINDOW(win), CDK_WINDOW_TYPE_HINT_NOTIFICATION);
	ctk_widget_add_events(win, CDK_BUTTON_PRESS_MASK | CDK_BUTTON_RELEASE_MASK);
	ctk_widget_realize(win);
	ctk_widget_set_size_request(win, WIDTH, -1);

	g_object_set_data_full(G_OBJECT(win), "windata", windata,
						   (GDestroyNotify)destroy_windata);
	atk_object_set_role(ctk_widget_get_accessible(win), ATK_ROLE_ALERT);

	g_signal_connect(G_OBJECT(win), "configure_event",
					 G_CALLBACK(configure_event_cb), windata);<--- You might need to cast the function pointer here

	g_signal_connect (G_OBJECT (win), "composited-changed", G_CALLBACK (on_composited_changed), windata);

	main_vbox = ctk_box_new(CTK_ORIENTATION_VERTICAL, 0);
	ctk_widget_show(main_vbox);
	ctk_container_add(CTK_CONTAINER(win), main_vbox);

	g_signal_connect (G_OBJECT (main_vbox), "draw", G_CALLBACK (on_draw), windata);

	windata->top_spacer = ctk_image_new();
	ctk_box_pack_start(CTK_BOX(main_vbox), windata->top_spacer,
					   FALSE, FALSE, 0);
	ctk_widget_set_size_request(windata->top_spacer, -1, DEFAULT_ARROW_HEIGHT);

	windata->main_hbox = ctk_box_new(CTK_ORIENTATION_HORIZONTAL, 0);
	ctk_widget_show(windata->main_hbox);
	ctk_box_pack_start(CTK_BOX(main_vbox), windata->main_hbox,
					   FALSE, FALSE, 0);

	windata->bottom_spacer = ctk_image_new();
	ctk_box_pack_start(CTK_BOX(main_vbox), windata->bottom_spacer,
					   FALSE, FALSE, 0);
	ctk_widget_set_size_request(windata->bottom_spacer, -1,
								DEFAULT_ARROW_HEIGHT);

	vbox = ctk_box_new(CTK_ORIENTATION_VERTICAL, 6);
	ctk_widget_show(vbox);
	ctk_box_pack_start(CTK_BOX(windata->main_hbox), vbox, TRUE, TRUE, 0);
	ctk_container_set_border_width(CTK_CONTAINER(vbox), 10);

	hbox = ctk_box_new(CTK_ORIENTATION_HORIZONTAL, 6);
	ctk_widget_show(hbox);
	ctk_box_pack_start(CTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	spacer = ctk_image_new();
	ctk_widget_show(spacer);
	ctk_box_pack_start(CTK_BOX(hbox), spacer, FALSE, FALSE, 0);
	ctk_widget_set_size_request(spacer, SPACER_LEFT, -1);

	windata->summary_label = ctk_label_new(NULL);
	ctk_widget_show(windata->summary_label);
	ctk_box_pack_start(CTK_BOX(hbox), windata->summary_label, TRUE, TRUE, 0);
	ctk_label_set_xalign (CTK_LABEL (windata->summary_label), 0.0);
	ctk_label_set_yalign (CTK_LABEL (windata->summary_label), 0.0);
	ctk_label_set_line_wrap(CTK_LABEL(windata->summary_label), TRUE);
	ctk_label_set_line_wrap_mode (CTK_LABEL (windata->summary_label), PANGO_WRAP_WORD_CHAR);

	atkobj = ctk_widget_get_accessible(windata->summary_label);
	atk_object_set_description (atkobj, _("Notification summary text."));

	/* Add the close button */
	close_button = ctk_button_new();
	ctk_widget_show(close_button);
	ctk_box_pack_start(CTK_BOX(hbox), close_button, FALSE, FALSE, 0);
	ctk_button_set_relief(CTK_BUTTON(close_button), CTK_RELIEF_NONE);
	ctk_container_set_border_width(CTK_CONTAINER(close_button), 0);
	ctk_widget_set_size_request(close_button, 24, 24);
	g_signal_connect_swapped(G_OBJECT(close_button), "clicked",
							 G_CALLBACK(ctk_widget_destroy), win);

	atkobj = ctk_widget_get_accessible(close_button);
	atk_action_set_description(ATK_ACTION(atkobj), 0,
							   _("Closes the notification."));
	atk_object_set_name(atkobj, "");
	atk_object_set_description (atkobj, _("Closes the notification."));

	image = ctk_image_new_from_icon_name ("window-close", CTK_ICON_SIZE_MENU);
	ctk_widget_show(image);
	ctk_container_add(CTK_CONTAINER(close_button), image);

	windata->content_hbox = ctk_box_new(CTK_ORIENTATION_HORIZONTAL, 6);
	ctk_box_pack_start(CTK_BOX(vbox), windata->content_hbox, FALSE, FALSE, 0);

	windata->iconbox = ctk_box_new(CTK_ORIENTATION_HORIZONTAL, 0);
	ctk_widget_show(windata->iconbox);
	ctk_box_pack_start(CTK_BOX(windata->content_hbox), windata->iconbox,
					   FALSE, FALSE, 0);
	ctk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1);

	windata->icon = ctk_image_new();
	ctk_box_pack_start(CTK_BOX(windata->iconbox), windata->icon,
					   TRUE, TRUE, 0);
	ctk_widget_set_halign (image, CTK_ALIGN_CENTER);
	ctk_widget_set_valign (image, CTK_ALIGN_CENTER);

	vbox = ctk_box_new(CTK_ORIENTATION_VERTICAL, 6);
	ctk_widget_show(vbox);
	ctk_box_pack_start(CTK_BOX(windata->content_hbox), vbox, TRUE, TRUE, 0);

	windata->body_label = ctk_label_new(NULL);
	ctk_box_pack_start(CTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0);
	ctk_label_set_xalign (CTK_LABEL (windata->body_label), 0.0);
	ctk_label_set_yalign (CTK_LABEL (windata->body_label), 0.0);
	ctk_label_set_line_wrap(CTK_LABEL(windata->body_label), TRUE);
	ctk_label_set_line_wrap_mode (CTK_LABEL (windata->body_label), PANGO_WRAP_WORD_CHAR);
    ctk_label_set_max_width_chars (CTK_LABEL (windata->body_label), 50);

	g_signal_connect(G_OBJECT(windata->body_label), "activate-link",
                         G_CALLBACK(activate_link), windata);

	atkobj = ctk_widget_get_accessible(windata->body_label);
	atk_object_set_description (atkobj, _("Notification body text."));

	windata->actions_box = ctk_box_new(CTK_ORIENTATION_HORIZONTAL, 6);
	ctk_widget_set_halign (windata->actions_box, CTK_ALIGN_END);
	ctk_widget_show(windata->actions_box);
	ctk_box_pack_start(CTK_BOX(vbox), windata->actions_box, FALSE, TRUE, 0);

	return CTK_WINDOW(win);
}

/* Set the notification text */
void
set_notification_text(CtkWindow *nw, const char *summary, const char *body)
{
	char *str;
	char* quoted;
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
	g_assert(windata != NULL);

	quoted = g_markup_escape_text(summary, -1);
	str = g_strdup_printf(
		"<span color=\"#000000\"><b><big>%s</big></b></span>", quoted);
	g_free(quoted);
	ctk_label_set_markup(CTK_LABEL(windata->summary_label), str);
	g_free(str);

	/* body */
	xmlDocPtr doc;
	xmlInitParser();
	str = g_strconcat ("<markup>", "<span color=\"#000000\">", body, "</span>", "</markup>", NULL);
	/* parse notification body */
	doc = xmlReadMemory(str, strlen (str), "noname.xml", NULL, 0);
	g_free (str);
	if (doc != NULL) {
		xmlXPathContextPtr xpathCtx;
		xmlXPathObjectPtr  xpathObj;
		xmlNodeSetPtr      nodes;
		const char        *body_label_text;
		int i, size;

		/* filterout img nodes */
		xpathCtx = xmlXPathNewContext(doc);
		xpathObj = xmlXPathEvalExpression((unsigned char *)"//img", xpathCtx);
		nodes = xpathObj->nodesetval;
		size = (nodes) ? nodes->nodeNr : 0;
		for(i = size - 1; i >= 0; i--) {
			xmlUnlinkNode (nodes->nodeTab[i]);
			xmlFreeNode (nodes->nodeTab[i]);
		}

		/* write doc to string */
		xmlBufferPtr buf = xmlBufferCreate();
		(void) xmlNodeDump(buf, doc, xmlDocGetRootElement (doc), 0, 0);
		str = (char *)buf->content;
		ctk_label_set_markup (CTK_LABEL (windata->body_label), str);

		/* cleanup */
		xmlBufferFree (buf);
		xmlXPathFreeObject (xpathObj);
		xmlXPathFreeContext (xpathCtx);
		xmlFreeDoc (doc);

		/* Does it render properly? */
		body_label_text = ctk_label_get_text (CTK_LABEL (windata->body_label));
		if ((body_label_text == NULL) || (strlen (body_label_text) == 0)) {
			goto render_fail;
		}
		goto renrer_ok;
	}

render_fail:
	/* could not parse notification body */
	quoted = g_markup_escape_text(body, -1);
	str = g_strconcat ("<span color=\"#000000\">", quoted, "</span>", NULL);
	ctk_label_set_markup (CTK_LABEL (windata->body_label), str);
	g_free (quoted);
	g_free (str);

renrer_ok:
	xmlCleanupParser ();

	if (body == NULL || *body == '\0')
		ctk_widget_hide(windata->body_label);
	else
		ctk_widget_show(windata->body_label);

	update_content_hbox_visibility(windata);

	ctk_widget_set_size_request(
		((body != NULL && *body == '\0')
		 ? windata->body_label : windata->summary_label),
		WIDTH - (IMAGE_SIZE + IMAGE_PADDING) - 10,
		-1);
}

/* Set notification icon */
void
set_notification_icon(CtkWindow *nw, GdkPixbuf *pixbuf)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
	g_assert(windata != NULL);

	ctk_image_set_from_pixbuf(CTK_IMAGE(windata->icon), pixbuf);

	if (pixbuf != NULL)
	{
		int pixbuf_width = gdk_pixbuf_get_width(pixbuf);

		ctk_widget_show(windata->icon);
		ctk_widget_set_size_request(windata->iconbox,
									MAX(BODY_X_OFFSET, pixbuf_width), -1);
	}
	else
	{
		ctk_widget_hide(windata->icon);
		ctk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1);
	}

	update_content_hbox_visibility(windata);
}

/* Set notification arrow */
void
set_notification_arrow(CtkWidget *nw, gboolean visible, int x, int y)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
	g_assert(windata != NULL);

	windata->arrow.has_arrow = visible;
	windata->arrow.position.x = x;
	windata->arrow.position.y = y;

	update_spacers(nw);
}

/* Add notification action */
void
add_notification_action(CtkWindow *nw, const char *text, const char *key,
						ActionInvokedCb cb)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
	CtkWidget *label;
	CtkWidget *button;
	CtkWidget *hbox;
	GdkPixbuf *pixbuf;
	char *buf;

	g_assert(windata != NULL);

	if (ctk_widget_get_visible(windata->actions_box))
	{
		ctk_widget_show(windata->actions_box);
		update_content_hbox_visibility(windata);

		/* Don't try to re-add a pie_countdown */
		if (!windata->pie_countdown) {
			windata->pie_countdown = ctk_drawing_area_new();
			ctk_widget_set_halign (windata->pie_countdown, CTK_ALIGN_END);
			ctk_widget_show(windata->pie_countdown);

			ctk_box_pack_end (CTK_BOX (windata->actions_box), windata->pie_countdown, FALSE, TRUE, 0);
			ctk_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);
		}
	}

	if (windata->action_icons) {
		button = ctk_button_new_from_icon_name(key, CTK_ICON_SIZE_BUTTON);
		goto add_button;
	}

	button = ctk_button_new();

	hbox = ctk_box_new(CTK_ORIENTATION_HORIZONTAL, 6);
	ctk_widget_show(hbox);
	ctk_container_add(CTK_CONTAINER(button), hbox);

	/* Try to be smart and find a suitable icon. */
	buf = g_strdup_printf("stock_%s", key);
	pixbuf = ctk_icon_theme_load_icon(
		ctk_icon_theme_get_for_screen(
			cdk_window_get_screen(ctk_widget_get_window(CTK_WIDGET(nw)))),
		buf, 16, CTK_ICON_LOOKUP_USE_BUILTIN, NULL);
	g_free(buf);

	if (pixbuf != NULL)
	{
		CtkWidget *image = ctk_image_new_from_pixbuf(pixbuf);
		ctk_widget_show(image);
		ctk_box_pack_start(CTK_BOX(hbox), image, FALSE, FALSE, 0);
		ctk_widget_set_halign (image, CTK_ALIGN_CENTER);
		ctk_widget_set_valign (image, CTK_ALIGN_CENTER);
	}

	label = ctk_label_new(NULL);
	ctk_widget_show(label);
	ctk_box_pack_start(CTK_BOX(hbox), label, FALSE, FALSE, 0);
	ctk_label_set_xalign (CTK_LABEL (label), 0.0);
	ctk_label_set_yalign (CTK_LABEL (label), 0.5);
	buf = g_strdup_printf("<small>%s</small>", text);
	ctk_label_set_markup(CTK_LABEL(label), buf);
	g_free(buf);

add_button:
	ctk_widget_show(button);
	ctk_box_pack_start(CTK_BOX(windata->actions_box), button, FALSE, FALSE, 0);

	g_object_set_data(G_OBJECT(button), "_nw", nw);
	g_object_set_data_full(G_OBJECT(button),
						   "_action_key", g_strdup(key), g_free);
	g_signal_connect(G_OBJECT(button), "button-release-event",
					 G_CALLBACK(action_clicked_cb), cb);

	ctk_widget_show_all(windata->actions_box);
}

/* Clear notification actions */
void
clear_notification_actions(CtkWindow *nw)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");

	windata->pie_countdown = NULL;

	ctk_widget_hide(windata->actions_box);
	ctk_container_foreach(CTK_CONTAINER(windata->actions_box),
						  (CtkCallback)ctk_widget_destroy, NULL);
}

/* Move notification window */
void
move_notification(CtkWidget *nw, int x, int y)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");<--- Variable 'windata' can be declared as pointer to const
	g_assert(windata != NULL);

	if (windata->arrow.has_arrow)
	{
		ctk_widget_queue_resize(nw);
	}
	else
	{
		ctk_window_move(CTK_WINDOW(nw), x, y);
	}
}


/* Optional Functions */

/* Destroy notification */

/* Show notification */

/* Hide notification */

/* Set notification timeout */
void
set_notification_timeout(CtkWindow *nw, glong timeout)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
	g_assert(windata != NULL);

	windata->timeout = timeout;
}

/* Set notification hints */
void set_notification_hints(CtkWindow *nw, GVariant *hints)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
	guint8 urgency;
	gboolean action_icons;

	g_assert(windata != NULL);

	if (g_variant_lookup(hints, "urgency", "y", &urgency))
	{
		windata->urgency = urgency;

		if (windata->urgency == URGENCY_CRITICAL) {
			ctk_window_set_title(CTK_WINDOW(nw), "Critical Notification");
		} else {
			ctk_window_set_title(CTK_WINDOW(nw), "Notification");
		}
	}

	/* Determine if action-icons have been requested */
	if (g_variant_lookup(hints, "action-icons", "b", &action_icons))
	{
		windata->action_icons = action_icons;
	}
}

/* Notification tick */
void
notification_tick(CtkWindow *nw, glong remaining)
{
	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
	windata->remaining = remaining;

	if (windata->pie_countdown != NULL)
	{
		ctk_widget_queue_draw_area(windata->pie_countdown, 0, 0,
								   PIE_WIDTH, PIE_HEIGHT);
	}
}