Skip to content

Commit dccffbc

Browse files
yetistraveit65
authored and
raveit65
committed
Use GVariant
1 parent 960df18 commit dccffbc

File tree

6 files changed

+39
-41
lines changed

6 files changed

+39
-41
lines changed

src/daemon/engines.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef struct {
3737
void (*destroy_notification) (GtkWindow* nw);
3838
void (*show_notification) (GtkWindow* nw);
3939
void (*hide_notification) (GtkWindow* nw);
40-
void (*set_notification_hints) (GtkWindow* nw, GHashTable* hints);
40+
void (*set_notification_hints) (GtkWindow* nw, GVariant *hints);
4141
void (*set_notification_text) (GtkWindow* nw, const char* summary, const char* body);
4242
void (*set_notification_icon) (GtkWindow* nw, GdkPixbuf* pixbuf);
4343
void (*set_notification_arrow) (GtkWindow* nw, gboolean visible, int x, int y);
@@ -251,7 +251,7 @@ void theme_hide_notification(GtkWindow* nw)
251251
}
252252
}
253253

254-
void theme_set_notification_hints(GtkWindow* nw, GHashTable* hints)
254+
void theme_set_notification_hints(GtkWindow* nw, GVariant *hints)
255255
{
256256
ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
257257

src/daemon/engines.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void theme_destroy_notification (GtkWindow *nw);
3333
void theme_show_notification (GtkWindow *nw);
3434
void theme_hide_notification (GtkWindow *nw);
3535
void theme_set_notification_hints (GtkWindow *nw,
36-
GHashTable *hints);
36+
GVariant *hints);
3737
void theme_set_notification_timeout (GtkWindow *nw,
3838
glong timeout);
3939
void theme_notification_tick (GtkWindow *nw,

src/themes/coco/coco-theme.c

+9-10
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void add_notification_action(GtkWindow *nw, const char *text, const char *key,
8585
void clear_notification_actions(GtkWindow *nw);
8686
void move_notification(GtkWidget *nw, int x, int y);
8787
void set_notification_timeout(GtkWindow *nw, glong timeout);
88-
void set_notification_hints(GtkWindow *nw, GHashTable *hints);
88+
void set_notification_hints(GtkWindow *nw, GVariant *hints);
8989
void notification_tick(GtkWindow *nw, glong remaining);
9090

9191
#define STRIPE_WIDTH 32
@@ -677,20 +677,19 @@ set_notification_timeout(GtkWindow *nw, glong timeout)
677677
}
678678

679679
/* Set notification hints */
680-
void
681-
set_notification_hints(GtkWindow *nw, GHashTable *hints)
680+
void set_notification_hints(GtkWindow *nw, GVariant *hints)
682681
{
683682
WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
684-
GValue *value = NULL, *icon_value = NULL;
683+
GVariant *value = NULL, *icon_value = NULL;
685684

686685
g_assert(windata != NULL);
687686

688-
value = (GValue *)g_hash_table_lookup(hints, "urgency");
689-
icon_value = (GValue *)g_hash_table_lookup(hints, "action-icons");
687+
g_variant_lookup(hints, "urgency", "v", &value);
688+
g_variant_lookup(hints, "action-icons", "v", &icon_value);
690689

691-
if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
690+
if (value != NULL && g_variant_get_type(value) == G_VARIANT_TYPE_BYTE)
692691
{
693-
windata->urgency = g_value_get_uchar(value);
692+
windata->urgency = g_variant_get_byte(value);
694693

695694
if (windata->urgency == URGENCY_CRITICAL) {
696695
gtk_window_set_title(GTK_WINDOW(nw), "Critical Notification");
@@ -700,9 +699,9 @@ set_notification_hints(GtkWindow *nw, GHashTable *hints)
700699
}
701700

702701
/* Determine if action-icons have been requested */
703-
if (icon_value != NULL && G_VALUE_HOLDS_BOOLEAN(icon_value))
702+
if (icon_value != NULL && g_variant_get_type(icon_value) == G_VARIANT_TYPE_BOOLEAN)
704703
{
705-
windata->action_icons = g_value_get_boolean(icon_value);
704+
windata->action_icons = g_variant_get_boolean(icon_value);
706705
}
707706
}
708707

src/themes/nodoka/nodoka-theme.c

+9-10
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void add_notification_action(GtkWindow *nw, const char *text, const char *key,
102102
void clear_notification_actions(GtkWindow *nw);
103103
void move_notification(GtkWidget *nw, int x, int y);
104104
void set_notification_timeout(GtkWindow *nw, glong timeout);
105-
void set_notification_hints(GtkWindow *nw, GHashTable *hints);
105+
void set_notification_hints(GtkWindow *nw, GVariant *hints);
106106
void notification_tick(GtkWindow *nw, glong remaining);
107107

108108
#define STRIPE_WIDTH 32
@@ -1082,20 +1082,19 @@ set_notification_timeout(GtkWindow *nw, glong timeout)
10821082
}
10831083

10841084
/* Set notification hints */
1085-
void
1086-
set_notification_hints(GtkWindow *nw, GHashTable *hints)
1085+
void set_notification_hints(GtkWindow *nw, GVariant *hints)
10871086
{
10881087
WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
1089-
GValue *value = NULL, *icon_value = NULL;
1088+
GVariant *value = NULL, *icon_value = NULL;
10901089

10911090
g_assert(windata != NULL);
10921091

1093-
value = (GValue *)g_hash_table_lookup(hints, "urgency");
1094-
icon_value = (GValue *)g_hash_table_lookup(hints, "action-icons");
1092+
g_variant_lookup(hints, "urgency", "v", &value);
1093+
g_variant_lookup(hints, "action-icons", "v", &icon_value);
10951094

1096-
if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
1095+
if (value != NULL && g_variant_get_type(value) == G_VARIANT_TYPE_BYTE)
10971096
{
1098-
windata->urgency = g_value_get_uchar(value);
1097+
windata->urgency = g_variant_get_byte(value);
10991098

11001099
if (windata->urgency == URGENCY_CRITICAL) {
11011100
gtk_window_set_title(GTK_WINDOW(nw), "Critical Notification");
@@ -1105,9 +1104,9 @@ set_notification_hints(GtkWindow *nw, GHashTable *hints)
11051104
}
11061105

11071106
/* Determine if action-icons have been requested */
1108-
if (icon_value != NULL && G_VALUE_HOLDS_BOOLEAN(icon_value))
1107+
if (icon_value != NULL && g_variant_get_type(icon_value) == G_VARIANT_TYPE_BOOLEAN)
11091108
{
1110-
windata->action_icons = g_value_get_boolean(icon_value);
1109+
windata->action_icons = g_variant_get_boolean(icon_value);
11111110
}
11121111
}
11131112

src/themes/slider/theme.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void add_notification_action(GtkWindow *nw, const char *text, const char *key,
7676
void clear_notification_actions(GtkWindow *nw);
7777
void move_notification(GtkWidget *nw, int x, int y);
7878
void set_notification_timeout(GtkWindow *nw, glong timeout);
79-
void set_notification_hints(GtkWindow *nw, GHashTable *hints);
79+
void set_notification_hints(GtkWindow *nw, GVariant *hints);
8080
void notification_tick(GtkWindow *nw, glong remaining);
8181
gboolean get_always_stack(GtkWidget* nw);
8282

@@ -443,19 +443,19 @@ GtkWindow* create_notification(UrlClickedCb url_clicked)
443443
return GTK_WINDOW(win);
444444
}
445445

446-
void set_notification_hints(GtkWindow *nw, GHashTable *hints)
446+
void set_notification_hints(GtkWindow *nw, GVariant *hints)
447447
{
448448
WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
449-
GValue *value = NULL, *icon_value = NULL;
449+
GVariant *value = NULL, *icon_value = NULL;
450450

451451
g_assert(windata != NULL);
452452

453-
value = (GValue *)g_hash_table_lookup(hints, "urgency");
454-
icon_value = (GValue *)g_hash_table_lookup(hints, "action-icons");
453+
g_variant_lookup(hints, "urgency", "v", &value);
454+
g_variant_lookup(hints, "action-icons", "v", &icon_value);
455455

456-
if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
456+
if (value != NULL && g_variant_get_type(value) == G_VARIANT_TYPE_BYTE)
457457
{
458-
windata->urgency = g_value_get_uchar(value);
458+
windata->urgency = g_variant_get_byte(value);
459459

460460
if (windata->urgency == URGENCY_CRITICAL) {
461461
gtk_window_set_title(GTK_WINDOW(nw), "Critical Notification");
@@ -465,9 +465,9 @@ void set_notification_hints(GtkWindow *nw, GHashTable *hints)
465465
}
466466

467467
/* Determine if action-icons have been requested */
468-
if (icon_value != NULL && G_VALUE_HOLDS_BOOLEAN(icon_value))
468+
if (icon_value != NULL && g_variant_get_type(icon_value) == G_VARIANT_TYPE_BOOLEAN)
469469
{
470-
windata->action_icons = g_value_get_boolean(icon_value);
470+
windata->action_icons = g_variant_get_boolean(icon_value);
471471
}
472472
}
473473

src/themes/standard/theme.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void add_notification_action(GtkWindow *nw, const char *text, const char *key,
9393
void clear_notification_actions(GtkWindow *nw);
9494
void move_notification(GtkWidget *nw, int x, int y);
9595
void set_notification_timeout(GtkWindow *nw, glong timeout);
96-
void set_notification_hints(GtkWindow *nw, GHashTable *hints);
96+
void set_notification_hints(GtkWindow *nw, GVariant *hints);
9797
void notification_tick(GtkWindow *nw, glong remaining);
9898

9999
//#define ENABLE_GRADIENT_LOOK
@@ -793,19 +793,19 @@ GtkWindow* create_notification(UrlClickedCb url_clicked)
793793
return GTK_WINDOW(win);
794794
}
795795

796-
void set_notification_hints(GtkWindow *nw, GHashTable *hints)
796+
void set_notification_hints(GtkWindow *nw, GVariant *hints)
797797
{
798798
WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
799-
GValue *value = NULL, *icon_value = NULL;
799+
GVariant *value = NULL, *icon_value = NULL;
800800

801801
g_assert(windata != NULL);
802802

803-
value = (GValue *)g_hash_table_lookup(hints, "urgency");
804-
icon_value = (GValue *)g_hash_table_lookup(hints, "action-icons");
803+
g_variant_lookup(hints, "urgency", "v", &value);
804+
g_variant_lookup(hints, "action-icons", "v", &icon_value);
805805

806-
if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
806+
if (value != NULL && g_variant_get_type(value) == G_VARIANT_TYPE_BYTE)
807807
{
808-
windata->urgency = g_value_get_uchar(value);
808+
windata->urgency = g_variant_get_byte(value);
809809

810810
if (windata->urgency == URGENCY_CRITICAL) {
811811
gtk_window_set_title(GTK_WINDOW(nw), "Critical Notification");
@@ -815,9 +815,9 @@ void set_notification_hints(GtkWindow *nw, GHashTable *hints)
815815
}
816816

817817
/* Determine if action-icons have been requested */
818-
if (icon_value != NULL && G_VALUE_HOLDS_BOOLEAN(icon_value))
818+
if (icon_value != NULL && g_variant_get_type(icon_value) == G_VARIANT_TYPE_BOOLEAN)
819819
{
820-
windata->action_icons = g_value_get_boolean(icon_value);
820+
windata->action_icons = g_variant_get_boolean(icon_value);
821821
}
822822
}
823823

0 commit comments

Comments
 (0)