Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use GVariant
  • Loading branch information
yetist authored and raveit65 committed Jun 6, 2018
1 parent 960df18 commit dccffbc
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/daemon/engines.c
Expand Up @@ -37,7 +37,7 @@ typedef struct {
void (*destroy_notification) (GtkWindow* nw);
void (*show_notification) (GtkWindow* nw);
void (*hide_notification) (GtkWindow* nw);
void (*set_notification_hints) (GtkWindow* nw, GHashTable* hints);
void (*set_notification_hints) (GtkWindow* nw, GVariant *hints);
void (*set_notification_text) (GtkWindow* nw, const char* summary, const char* body);
void (*set_notification_icon) (GtkWindow* nw, GdkPixbuf* pixbuf);
void (*set_notification_arrow) (GtkWindow* nw, gboolean visible, int x, int y);
Expand Down Expand Up @@ -251,7 +251,7 @@ void theme_hide_notification(GtkWindow* nw)
}
}

void theme_set_notification_hints(GtkWindow* nw, GHashTable* hints)
void theme_set_notification_hints(GtkWindow* nw, GVariant *hints)
{
ThemeEngine* engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");

Expand Down
2 changes: 1 addition & 1 deletion src/daemon/engines.h
Expand Up @@ -33,7 +33,7 @@ void theme_destroy_notification (GtkWindow *nw);
void theme_show_notification (GtkWindow *nw);
void theme_hide_notification (GtkWindow *nw);
void theme_set_notification_hints (GtkWindow *nw,
GHashTable *hints);
GVariant *hints);
void theme_set_notification_timeout (GtkWindow *nw,
glong timeout);
void theme_notification_tick (GtkWindow *nw,
Expand Down
19 changes: 9 additions & 10 deletions src/themes/coco/coco-theme.c
Expand Up @@ -85,7 +85,7 @@ void add_notification_action(GtkWindow *nw, const char *text, const char *key,
void clear_notification_actions(GtkWindow *nw);
void move_notification(GtkWidget *nw, int x, int y);
void set_notification_timeout(GtkWindow *nw, glong timeout);
void set_notification_hints(GtkWindow *nw, GHashTable *hints);
void set_notification_hints(GtkWindow *nw, GVariant *hints);
void notification_tick(GtkWindow *nw, glong remaining);

#define STRIPE_WIDTH 32
Expand Down Expand Up @@ -677,20 +677,19 @@ set_notification_timeout(GtkWindow *nw, glong timeout)
}

/* Set notification hints */
void
set_notification_hints(GtkWindow *nw, GHashTable *hints)
void set_notification_hints(GtkWindow *nw, GVariant *hints)
{
WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
GValue *value = NULL, *icon_value = NULL;
GVariant *value = NULL, *icon_value = NULL;

g_assert(windata != NULL);

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

if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
if (value != NULL && g_variant_get_type(value) == G_VARIANT_TYPE_BYTE)
{
windata->urgency = g_value_get_uchar(value);
windata->urgency = g_variant_get_byte(value);

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

/* Determine if action-icons have been requested */
if (icon_value != NULL && G_VALUE_HOLDS_BOOLEAN(icon_value))
if (icon_value != NULL && g_variant_get_type(icon_value) == G_VARIANT_TYPE_BOOLEAN)
{
windata->action_icons = g_value_get_boolean(icon_value);
windata->action_icons = g_variant_get_boolean(icon_value);
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/themes/nodoka/nodoka-theme.c
Expand Up @@ -102,7 +102,7 @@ void add_notification_action(GtkWindow *nw, const char *text, const char *key,
void clear_notification_actions(GtkWindow *nw);
void move_notification(GtkWidget *nw, int x, int y);
void set_notification_timeout(GtkWindow *nw, glong timeout);
void set_notification_hints(GtkWindow *nw, GHashTable *hints);
void set_notification_hints(GtkWindow *nw, GVariant *hints);
void notification_tick(GtkWindow *nw, glong remaining);

#define STRIPE_WIDTH 32
Expand Down Expand Up @@ -1082,20 +1082,19 @@ set_notification_timeout(GtkWindow *nw, glong timeout)
}

/* Set notification hints */
void
set_notification_hints(GtkWindow *nw, GHashTable *hints)
void set_notification_hints(GtkWindow *nw, GVariant *hints)
{
WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
GValue *value = NULL, *icon_value = NULL;
GVariant *value = NULL, *icon_value = NULL;

g_assert(windata != NULL);

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

if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
if (value != NULL && g_variant_get_type(value) == G_VARIANT_TYPE_BYTE)
{
windata->urgency = g_value_get_uchar(value);
windata->urgency = g_variant_get_byte(value);

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

/* Determine if action-icons have been requested */
if (icon_value != NULL && G_VALUE_HOLDS_BOOLEAN(icon_value))
if (icon_value != NULL && g_variant_get_type(icon_value) == G_VARIANT_TYPE_BOOLEAN)
{
windata->action_icons = g_value_get_boolean(icon_value);
windata->action_icons = g_variant_get_boolean(icon_value);
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/themes/slider/theme.c
Expand Up @@ -76,7 +76,7 @@ void add_notification_action(GtkWindow *nw, const char *text, const char *key,
void clear_notification_actions(GtkWindow *nw);
void move_notification(GtkWidget *nw, int x, int y);
void set_notification_timeout(GtkWindow *nw, glong timeout);
void set_notification_hints(GtkWindow *nw, GHashTable *hints);
void set_notification_hints(GtkWindow *nw, GVariant *hints);
void notification_tick(GtkWindow *nw, glong remaining);
gboolean get_always_stack(GtkWidget* nw);

Expand Down Expand Up @@ -443,19 +443,19 @@ GtkWindow* create_notification(UrlClickedCb url_clicked)
return GTK_WINDOW(win);
}

void set_notification_hints(GtkWindow *nw, GHashTable *hints)
void set_notification_hints(GtkWindow *nw, GVariant *hints)
{
WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
GValue *value = NULL, *icon_value = NULL;
GVariant *value = NULL, *icon_value = NULL;

g_assert(windata != NULL);

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

if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
if (value != NULL && g_variant_get_type(value) == G_VARIANT_TYPE_BYTE)
{
windata->urgency = g_value_get_uchar(value);
windata->urgency = g_variant_get_byte(value);

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

/* Determine if action-icons have been requested */
if (icon_value != NULL && G_VALUE_HOLDS_BOOLEAN(icon_value))
if (icon_value != NULL && g_variant_get_type(icon_value) == G_VARIANT_TYPE_BOOLEAN)
{
windata->action_icons = g_value_get_boolean(icon_value);
windata->action_icons = g_variant_get_boolean(icon_value);
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/themes/standard/theme.c
Expand Up @@ -93,7 +93,7 @@ void add_notification_action(GtkWindow *nw, const char *text, const char *key,
void clear_notification_actions(GtkWindow *nw);
void move_notification(GtkWidget *nw, int x, int y);
void set_notification_timeout(GtkWindow *nw, glong timeout);
void set_notification_hints(GtkWindow *nw, GHashTable *hints);
void set_notification_hints(GtkWindow *nw, GVariant *hints);
void notification_tick(GtkWindow *nw, glong remaining);

//#define ENABLE_GRADIENT_LOOK
Expand Down Expand Up @@ -793,19 +793,19 @@ GtkWindow* create_notification(UrlClickedCb url_clicked)
return GTK_WINDOW(win);
}

void set_notification_hints(GtkWindow *nw, GHashTable *hints)
void set_notification_hints(GtkWindow *nw, GVariant *hints)
{
WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
GValue *value = NULL, *icon_value = NULL;
GVariant *value = NULL, *icon_value = NULL;

g_assert(windata != NULL);

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

if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
if (value != NULL && g_variant_get_type(value) == G_VARIANT_TYPE_BYTE)
{
windata->urgency = g_value_get_uchar(value);
windata->urgency = g_variant_get_byte(value);

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

/* Determine if action-icons have been requested */
if (icon_value != NULL && G_VALUE_HOLDS_BOOLEAN(icon_value))
if (icon_value != NULL && g_variant_get_type(icon_value) == G_VARIANT_TYPE_BOOLEAN)
{
windata->action_icons = g_value_get_boolean(icon_value);
windata->action_icons = g_variant_get_boolean(icon_value);
}
}

Expand Down

0 comments on commit dccffbc

Please sign in to comment.