[notification-daemon] Untabify
- From: William Jon McCann <mccann src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [notification-daemon] Untabify
- Date: Sat, 16 Jan 2010 20:45:12 +0000 (UTC)
commit 2518314d7d038a252552939904eb66c49a235a9b
Author: William Jon McCann <jmccann redhat com>
Date: Sat Jan 16 13:22:58 2010 -0500
Untabify
We won't miss you.
src/capplet/notification-properties.c | 835 ++++++------
src/daemon/daemon.c | 2270 ++++++++++++++++----------------
src/daemon/daemon.h | 66 +-
src/daemon/engines.c | 374 +++---
src/daemon/engines.h | 18 +-
src/daemon/sound.c | 14 +-
src/daemon/sound.h | 3 +-
src/daemon/stack.c | 402 +++---
src/daemon/stack.h | 28 +-
src/themes/bubble/theme.c | 48 +-
src/themes/standard/theme.c | 1672 ++++++++++++------------
11 files changed, 2866 insertions(+), 2864 deletions(-)
---
diff --git a/src/capplet/notification-properties.c b/src/capplet/notification-properties.c
index f807809..29cc2b5 100644
--- a/src/capplet/notification-properties.c
+++ b/src/capplet/notification-properties.c
@@ -1,5 +1,4 @@
-/*
- * notification-properties.c - Applet to manage notification settings
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 Jonh Wendell <wendell bani com br>
*
@@ -39,48 +38,48 @@
typedef struct
{
- GladeXML *xml;
- GConfClient *client;
+ GladeXML *xml;
+ GConfClient *client;
- GtkWidget *dialog;
- GtkWidget *position_combo;
- GtkWidget *theme_combo;
- GtkWidget *preview_button;
+ GtkWidget *dialog;
+ GtkWidget *position_combo;
+ GtkWidget *theme_combo;
+ GtkWidget *preview_button;
- NotifyNotification *preview;
+ NotifyNotification *preview;
- guint listeners[N_LISTENERS];
- int n_listeners;
- int expected_listeners;
+ guint listeners[N_LISTENERS];
+ int n_listeners;
+ int expected_listeners;
} NotificationAppletDialog;
enum
{
- NOTIFY_POSITION_LABEL,
- NOTIFY_POSITION_NAME,
- N_COLUMNS_POSITION
+ NOTIFY_POSITION_LABEL,
+ NOTIFY_POSITION_NAME,
+ N_COLUMNS_POSITION
};
enum
{
- NOTIFY_THEME_LABEL,
- NOTIFY_THEME_NAME,
- NOTIFY_THEME_FILENAME,
- N_COLUMNS_THEME
+ NOTIFY_THEME_LABEL,
+ NOTIFY_THEME_NAME,
+ NOTIFY_THEME_FILENAME,
+ N_COLUMNS_THEME
};
const struct
{
- const gchar *identifier;
- const gchar *label;
+ const gchar *identifier;
+ const gchar *label;
} popup_stack_locations[] =
{
- { "top_left", N_("Top Left") },
- { "top_right", N_("Top Right") },
- { "bottom_left", N_("Bottom Left") },
- { "bottom_right", N_("Bottom Right") }
+ { "top_left", N_("Top Left") },
+ { "top_right", N_("Top Right") },
+ { "bottom_left", N_("Bottom Left") },
+ { "bottom_right", N_("Bottom Right") }
};
static void
@@ -89,297 +88,297 @@ notification_properties_location_notify(GConfClient *client,
GConfEntry *entry,
NotificationAppletDialog *dialog)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- const char *location;
- gboolean valid;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- location = gconf_value_get_string(entry->value);
-
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->position_combo));
- valid = gtk_tree_model_get_iter_first(model, &iter);
-
- for (valid = gtk_tree_model_get_iter_first(model, &iter);
- valid;
- valid = gtk_tree_model_iter_next(model, &iter))
- {
- gchar *key;
-
- gtk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &key, -1);
-
- if (g_str_equal(key, location))
- {
- gtk_combo_box_set_active_iter(
- GTK_COMBO_BOX(dialog->position_combo),
- &iter);
- g_free(key);
- break;
- }
-
- g_free(key);
- }
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ const char *location;
+ gboolean valid;
+
+ if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
+ return;
+
+ location = gconf_value_get_string(entry->value);
+
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->position_combo));
+ valid = gtk_tree_model_get_iter_first(model, &iter);
+
+ for (valid = gtk_tree_model_get_iter_first(model, &iter);
+ valid;
+ valid = gtk_tree_model_iter_next(model, &iter))
+ {
+ gchar *key;
+
+ gtk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &key, -1);
+
+ if (g_str_equal(key, location))
+ {
+ gtk_combo_box_set_active_iter(
+ GTK_COMBO_BOX(dialog->position_combo),
+ &iter);
+ g_free(key);
+ break;
+ }
+
+ g_free(key);
+ }
}
static void
notification_properties_location_changed(GtkComboBox *widget,
NotificationAppletDialog *dialog)
{
- char *location;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ char *location;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->position_combo));
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->position_combo));
- if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(dialog->position_combo),
- &iter))
- {
- return;
- }
+ if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(dialog->position_combo),
+ &iter))
+ {
+ return;
+ }
- gtk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &location, -1);
+ gtk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &location, -1);
- gconf_client_set_string(dialog->client, GCONF_KEY_POPUP_LOCATION,
- location, NULL);
- g_free(location);
+ gconf_client_set_string(dialog->client, GCONF_KEY_POPUP_LOCATION,
+ location, NULL);
+ g_free(location);
}
static void
notification_properties_dialog_setup_positions(NotificationAppletDialog *dialog)
{
- NotifyStackLocation i;
- char *location;
- gboolean valid;
- GtkListStore *store;
- GtkTreeIter iter;
-
- dialog->position_combo =
- glade_xml_get_widget(dialog->xml, "position_combo");
- g_return_if_fail(dialog->position_combo != NULL);
-
- store = gtk_list_store_new(N_COLUMNS_POSITION,
- G_TYPE_STRING, G_TYPE_STRING);
-
- for (i = NOTIFY_STACK_LOCATION_TOP_LEFT;
- i <= NOTIFY_STACK_LOCATION_BOTTOM_RIGHT;
- i++)
- {
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- NOTIFY_POSITION_LABEL, _(popup_stack_locations[i].label),
- NOTIFY_POSITION_NAME, popup_stack_locations[i].identifier,
- -1);
- }
-
- gtk_combo_box_set_model(GTK_COMBO_BOX(dialog->position_combo),
- GTK_TREE_MODEL(store));
- g_signal_connect(dialog->position_combo, "changed",
- G_CALLBACK(notification_properties_location_changed),
- dialog);
-
- location = gconf_client_get_string(dialog->client,
- GCONF_KEY_POPUP_LOCATION, NULL);
-
- for (valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
- valid;
- valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter))
- {
- gchar *key;
-
- gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
- NOTIFY_POSITION_NAME, &key,
- -1);
-
- if (g_str_equal(key, location))
- {
- gtk_combo_box_set_active_iter(
- GTK_COMBO_BOX(dialog->position_combo),
- &iter);
- g_free(key);
- break;
- }
-
- g_free(key);
- }
-
- dialog->listeners[dialog->n_listeners] = gconf_client_notify_add(
- dialog->client, GCONF_KEY_POPUP_LOCATION,
- (GConfClientNotifyFunc)notification_properties_location_notify,
- dialog, NULL, NULL);
- dialog->n_listeners++;
- g_free(location);
+ NotifyStackLocation i;
+ char *location;
+ gboolean valid;
+ GtkListStore *store;
+ GtkTreeIter iter;
+
+ dialog->position_combo =
+ glade_xml_get_widget(dialog->xml, "position_combo");
+ g_return_if_fail(dialog->position_combo != NULL);
+
+ store = gtk_list_store_new(N_COLUMNS_POSITION,
+ G_TYPE_STRING, G_TYPE_STRING);
+
+ for (i = NOTIFY_STACK_LOCATION_TOP_LEFT;
+ i <= NOTIFY_STACK_LOCATION_BOTTOM_RIGHT;
+ i++)
+ {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ NOTIFY_POSITION_LABEL, _(popup_stack_locations[i].label),
+ NOTIFY_POSITION_NAME, popup_stack_locations[i].identifier,
+ -1);
+ }
+
+ gtk_combo_box_set_model(GTK_COMBO_BOX(dialog->position_combo),
+ GTK_TREE_MODEL(store));
+ g_signal_connect(dialog->position_combo, "changed",
+ G_CALLBACK(notification_properties_location_changed),
+ dialog);
+
+ location = gconf_client_get_string(dialog->client,
+ GCONF_KEY_POPUP_LOCATION, NULL);
+
+ for (valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
+ valid;
+ valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter))
+ {
+ gchar *key;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
+ NOTIFY_POSITION_NAME, &key,
+ -1);
+
+ if (g_str_equal(key, location))
+ {
+ gtk_combo_box_set_active_iter(
+ GTK_COMBO_BOX(dialog->position_combo),
+ &iter);
+ g_free(key);
+ break;
+ }
+
+ g_free(key);
+ }
+
+ dialog->listeners[dialog->n_listeners] = gconf_client_notify_add(
+ dialog->client, GCONF_KEY_POPUP_LOCATION,
+ (GConfClientNotifyFunc)notification_properties_location_notify,
+ dialog, NULL, NULL);
+ dialog->n_listeners++;
+ g_free(location);
}
static void
notification_properties_theme_notify(GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- NotificationAppletDialog *dialog)
+ guint cnx_id,
+ GConfEntry *entry,
+ NotificationAppletDialog *dialog)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- const char *theme;
- gboolean valid;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ const char *theme;
+ gboolean valid;
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
+ if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
+ return;
- theme = gconf_value_get_string(entry->value);
+ theme = gconf_value_get_string(entry->value);
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->theme_combo));
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->theme_combo));
- for (valid = gtk_tree_model_get_iter_first(model, &iter);
- valid;
- valid = gtk_tree_model_iter_next(model, &iter))
- {
- gchar *theme_name;
+ for (valid = gtk_tree_model_get_iter_first(model, &iter);
+ valid;
+ valid = gtk_tree_model_iter_next(model, &iter))
+ {
+ gchar *theme_name;
- gtk_tree_model_get(model, &iter, NOTIFY_THEME_NAME, &theme_name, -1);
+ gtk_tree_model_get(model, &iter, NOTIFY_THEME_NAME, &theme_name, -1);
- if (g_str_equal(theme_name, theme))
- {
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dialog->theme_combo),
- &iter);
- g_free(theme_name);
- break;
- }
+ if (g_str_equal(theme_name, theme))
+ {
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dialog->theme_combo),
+ &iter);
+ g_free(theme_name);
+ break;
+ }
- g_free(theme_name);
- }
+ g_free(theme_name);
+ }
}
static void
notification_properties_theme_changed(GtkComboBox *widget,
- NotificationAppletDialog *dialog)
+ NotificationAppletDialog *dialog)
{
- char *theme;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ char *theme;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->theme_combo));
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->theme_combo));
- if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(dialog->theme_combo),
- &iter))
- {
- return;
- }
+ if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(dialog->theme_combo),
+ &iter))
+ {
+ return;
+ }
- gtk_tree_model_get(model, &iter, NOTIFY_THEME_NAME, &theme, -1);
- gconf_client_set_string(dialog->client, GCONF_KEY_THEME, theme, NULL);
- g_free(theme);
+ gtk_tree_model_get(model, &iter, NOTIFY_THEME_NAME, &theme, -1);
+ gconf_client_set_string(dialog->client, GCONF_KEY_THEME, theme, NULL);
+ g_free(theme);
}
static gchar *
get_theme_name(const gchar *filename)
{
- gchar *result;
+ gchar *result;
- /* TODO: Remove magic numbers. Strip "lib" and ".so" */
- result = g_strdup(filename + 3);
- result[strlen(result) - 3] = '\0';
- return result;
+ /* TODO: Remove magic numbers. Strip "lib" and ".so" */
+ result = g_strdup(filename + 3);
+ result[strlen(result) - 3] = '\0';
+ return result;
}
static void
notification_properties_dialog_setup_themes(NotificationAppletDialog *dialog)
{
- GDir *dir;
- const gchar *filename;
- char *theme, *theme_name, *theme_label;
- gboolean valid;
- GtkListStore *store;
- GtkTreeIter iter;
-
- dialog->theme_combo = glade_xml_get_widget(dialog->xml, "theme_combo");
- g_assert (dialog->theme_combo != NULL);
-
- store = gtk_list_store_new(N_COLUMNS_THEME,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_STRING);
-
- gtk_combo_box_set_model(GTK_COMBO_BOX(dialog->theme_combo),
- GTK_TREE_MODEL(store));
- g_signal_connect(dialog->theme_combo, "changed",
- G_CALLBACK(notification_properties_theme_changed),
- dialog);
-
- GtkCellRenderer *cell = gtk_cell_renderer_text_new();
- gtk_cell_layout_pack_start(
- GTK_CELL_LAYOUT(GTK_COMBO_BOX(dialog->theme_combo)),
- cell, TRUE);
- gtk_cell_layout_set_attributes(
- GTK_CELL_LAYOUT(GTK_COMBO_BOX(dialog->theme_combo)),
- cell, "text", 0, NULL);
-
- if ((dir = g_dir_open(ENGINES_DIR, 0, NULL)))
- {
- while ((filename = g_dir_read_name(dir)))
- {
- if ( g_str_has_prefix(filename, "lib") &&
- g_str_has_suffix(filename, ".so") )
- {
- theme_name = get_theme_name(filename);
-
- /* FIXME: other solution than hardcode? */
- if (g_str_equal(theme_name, "slider"))
- theme_label = g_strdup(_("Slider"));
- else if (g_str_equal(theme_name, "standard"))
- theme_label = g_strdup(_("Standard theme"));
- else
- theme_label = g_strdup(theme_name);
-
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- NOTIFY_THEME_LABEL, theme_label,
- NOTIFY_THEME_NAME, theme_name,
- NOTIFY_THEME_FILENAME, filename,
- -1);
- g_free(theme_name);
- g_free(theme_label);
- }
- }
-
- g_dir_close(dir);
- }
- else
- {
- g_warning("Error opening themes dir");
- }
-
-
- theme = gconf_client_get_string(dialog->client, GCONF_KEY_THEME, NULL);
-
- for (valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
- valid;
- valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter))
- {
- gchar *key;
-
- gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
- NOTIFY_THEME_NAME, &key,
- -1);
-
- if (g_str_equal(key, theme))
- {
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dialog->theme_combo),
- &iter);
- g_free(key);
- break;
- }
-
- g_free(key);
- }
-
- dialog->listeners[dialog->n_listeners] =
- gconf_client_notify_add(dialog->client,
- GCONF_KEY_THEME,
- (GConfClientNotifyFunc)notification_properties_theme_notify,
- dialog, NULL, NULL);
- dialog->n_listeners++;
- g_free(theme);
+ GDir *dir;
+ const gchar *filename;
+ char *theme, *theme_name, *theme_label;
+ gboolean valid;
+ GtkListStore *store;
+ GtkTreeIter iter;
+
+ dialog->theme_combo = glade_xml_get_widget(dialog->xml, "theme_combo");
+ g_assert (dialog->theme_combo != NULL);
+
+ store = gtk_list_store_new(N_COLUMNS_THEME,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
+ gtk_combo_box_set_model(GTK_COMBO_BOX(dialog->theme_combo),
+ GTK_TREE_MODEL(store));
+ g_signal_connect(dialog->theme_combo, "changed",
+ G_CALLBACK(notification_properties_theme_changed),
+ dialog);
+
+ GtkCellRenderer *cell = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(
+ GTK_CELL_LAYOUT(GTK_COMBO_BOX(dialog->theme_combo)),
+ cell, TRUE);
+ gtk_cell_layout_set_attributes(
+ GTK_CELL_LAYOUT(GTK_COMBO_BOX(dialog->theme_combo)),
+ cell, "text", 0, NULL);
+
+ if ((dir = g_dir_open(ENGINES_DIR, 0, NULL)))
+ {
+ while ((filename = g_dir_read_name(dir)))
+ {
+ if ( g_str_has_prefix(filename, "lib") &&
+ g_str_has_suffix(filename, ".so") )
+ {
+ theme_name = get_theme_name(filename);
+
+ /* FIXME: other solution than hardcode? */
+ if (g_str_equal(theme_name, "slider"))
+ theme_label = g_strdup(_("Slider"));
+ else if (g_str_equal(theme_name, "standard"))
+ theme_label = g_strdup(_("Standard theme"));
+ else
+ theme_label = g_strdup(theme_name);
+
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ NOTIFY_THEME_LABEL, theme_label,
+ NOTIFY_THEME_NAME, theme_name,
+ NOTIFY_THEME_FILENAME, filename,
+ -1);
+ g_free(theme_name);
+ g_free(theme_label);
+ }
+ }
+
+ g_dir_close(dir);
+ }
+ else
+ {
+ g_warning("Error opening themes dir");
+ }
+
+
+ theme = gconf_client_get_string(dialog->client, GCONF_KEY_THEME, NULL);
+
+ for (valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
+ valid;
+ valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter))
+ {
+ gchar *key;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
+ NOTIFY_THEME_NAME, &key,
+ -1);
+
+ if (g_str_equal(key, theme))
+ {
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(dialog->theme_combo),
+ &iter);
+ g_free(key);
+ break;
+ }
+
+ g_free(key);
+ }
+
+ dialog->listeners[dialog->n_listeners] =
+ gconf_client_notify_add(dialog->client,
+ GCONF_KEY_THEME,
+ (GConfClientNotifyFunc)notification_properties_theme_notify,
+ dialog, NULL, NULL);
+ dialog->n_listeners++;
+ g_free(theme);
}
static void
@@ -390,144 +389,144 @@ notification_properties_dialog_help(void)
static void
show_message(NotificationAppletDialog *dialog,
- const gchar *message)
+ const gchar *message)
{
- GtkWidget *d;
-
- d = gtk_message_dialog_new(GTK_WINDOW(dialog->dialog),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- "%s", message);
- gtk_dialog_run(GTK_DIALOG(d));
- gtk_widget_destroy(d);
+ GtkWidget *d;
+
+ d = gtk_message_dialog_new(GTK_WINDOW(dialog->dialog),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s", message);
+ gtk_dialog_run(GTK_DIALOG(d));
+ gtk_widget_destroy(d);
}
static void
notification_properties_dialog_preview_closed(NotifyNotification *preview,
- NotificationAppletDialog *dialog)
+ NotificationAppletDialog *dialog)
{
- if (preview == dialog->preview)
- dialog->preview = NULL;
+ if (preview == dialog->preview)
+ dialog->preview = NULL;
- g_object_unref(preview);
+ g_object_unref(preview);
}
static void
notification_properties_dialog_preview(NotificationAppletDialog *dialog)
{
- GError *error;
-
- if (!notify_is_initted() && !notify_init("n-d"))
- {
- show_message(dialog, _("Error initializing libnotify"));
- return;
- }
-
- error = NULL;
-
- if (dialog->preview)
- {
- notify_notification_close(dialog->preview, NULL);
- g_object_unref(dialog->preview);
- dialog->preview = NULL;
- }
-
- dialog->preview = notify_notification_new(_("Notification Test"),
- _("Just a test"),
- "gnome-util",
- NULL);
-
- if (!notify_notification_show(dialog->preview, &error))
- {
- char *message = g_strdup_printf(
- _("Error while displaying notification: %s"), error->message);
- show_message(dialog, message);
- g_error_free(error);
- g_free(message);
- }
-
- g_signal_connect(dialog->preview, "closed",
- G_CALLBACK(notification_properties_dialog_preview_closed),
- dialog);
+ GError *error;
+
+ if (!notify_is_initted() && !notify_init("n-d"))
+ {
+ show_message(dialog, _("Error initializing libnotify"));
+ return;
+ }
+
+ error = NULL;
+
+ if (dialog->preview)
+ {
+ notify_notification_close(dialog->preview, NULL);
+ g_object_unref(dialog->preview);
+ dialog->preview = NULL;
+ }
+
+ dialog->preview = notify_notification_new(_("Notification Test"),
+ _("Just a test"),
+ "gnome-util",
+ NULL);
+
+ if (!notify_notification_show(dialog->preview, &error))
+ {
+ char *message = g_strdup_printf(
+ _("Error while displaying notification: %s"), error->message);
+ show_message(dialog, message);
+ g_error_free(error);
+ g_free(message);
+ }
+
+ g_signal_connect(dialog->preview, "closed",
+ G_CALLBACK(notification_properties_dialog_preview_closed),
+ dialog);
}
static void
notification_properties_dialog_response(GtkWidget *widget,
- int response,
- NotificationAppletDialog *dialog)
+ int response,
+ NotificationAppletDialog *dialog)
{
- switch (response)
- {
- case GTK_RESPONSE_HELP:
- notification_properties_dialog_help();
- break;
-
- case GTK_RESPONSE_ACCEPT:
- notification_properties_dialog_preview(dialog);
- break;
-
- case GTK_RESPONSE_CLOSE:
- default:
- gtk_widget_destroy(widget);
- break;
- }
+ switch (response)
+ {
+ case GTK_RESPONSE_HELP:
+ notification_properties_dialog_help();
+ break;
+
+ case GTK_RESPONSE_ACCEPT:
+ notification_properties_dialog_preview(dialog);
+ break;
+
+ case GTK_RESPONSE_CLOSE:
+ default:
+ gtk_widget_destroy(widget);
+ break;
+ }
}
static void
notification_properties_dialog_destroyed(GtkWidget *widget,
- NotificationAppletDialog *dialog)
+ NotificationAppletDialog *dialog)
{
- dialog->dialog = NULL;
+ dialog->dialog = NULL;
- gtk_main_quit();
+ gtk_main_quit();
}
static gboolean
notification_properties_dialog_init(NotificationAppletDialog *dialog)
{
#define NOTIFICATION_GLADE_FILE "notification-properties.glade"
- const char *glade_file;
+ const char *glade_file;
- if (g_file_test(NOTIFICATION_GLADE_FILE, G_FILE_TEST_EXISTS))
- glade_file = NOTIFICATION_GLADE_FILE;
- else
- glade_file = NOTIFICATION_GLADEDIR "/" NOTIFICATION_GLADE_FILE;
+ if (g_file_test(NOTIFICATION_GLADE_FILE, G_FILE_TEST_EXISTS))
+ glade_file = NOTIFICATION_GLADE_FILE;
+ else
+ glade_file = NOTIFICATION_GLADEDIR "/" NOTIFICATION_GLADE_FILE;
- dialog->xml = glade_xml_new(glade_file, "dialog", NULL);
+ dialog->xml = glade_xml_new(glade_file, "dialog", NULL);
- if (!dialog->xml)
- {
- g_warning(_("Unable to locate glade file '%s'"), glade_file);
- return FALSE;
- }
+ if (!dialog->xml)
+ {
+ g_warning(_("Unable to locate glade file '%s'"), glade_file);
+ return FALSE;
+ }
- dialog->dialog = glade_xml_get_widget(dialog->xml, "dialog");
- g_assert(dialog->dialog != NULL);
+ dialog->dialog = glade_xml_get_widget(dialog->xml, "dialog");
+ g_assert(dialog->dialog != NULL);
- g_signal_connect(dialog->dialog, "response",
- G_CALLBACK(notification_properties_dialog_response),
- dialog);
- g_signal_connect(dialog->dialog, "destroy",
- G_CALLBACK(notification_properties_dialog_destroyed),
- dialog);
+ g_signal_connect(dialog->dialog, "response",
+ G_CALLBACK(notification_properties_dialog_response),
+ dialog);
+ g_signal_connect(dialog->dialog, "destroy",
+ G_CALLBACK(notification_properties_dialog_destroyed),
+ dialog);
- dialog->client = gconf_client_get_default();
- gconf_client_add_dir(dialog->client, GCONF_KEY_DAEMON,
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ dialog->client = gconf_client_get_default();
+ gconf_client_add_dir(dialog->client, GCONF_KEY_DAEMON,
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
- dialog->expected_listeners = N_LISTENERS;
- dialog->n_listeners = 0;
+ dialog->expected_listeners = N_LISTENERS;
+ dialog->n_listeners = 0;
- notification_properties_dialog_setup_themes(dialog);
- notification_properties_dialog_setup_positions(dialog);
+ notification_properties_dialog_setup_themes(dialog);
+ notification_properties_dialog_setup_positions(dialog);
- g_assert(dialog->n_listeners == dialog->expected_listeners);
- gtk_widget_show(dialog->dialog);
+ g_assert(dialog->n_listeners == dialog->expected_listeners);
+ gtk_widget_show(dialog->dialog);
- dialog->preview = NULL;
+ dialog->preview = NULL;
- return TRUE;
+ return TRUE;
#undef NOTIFICATION_GLADE_FILE
}
@@ -535,66 +534,66 @@ notification_properties_dialog_init(NotificationAppletDialog *dialog)
static void
notification_properties_dialog_finalize(NotificationAppletDialog *dialog)
{
- if (dialog->dialog != NULL)
- {
- gtk_widget_destroy(dialog->dialog);
- dialog->dialog = NULL;
- }
-
- if (dialog->client != NULL)
- {
- int i;
- for (i = 0; i < dialog->n_listeners; i++)
- {
- if (dialog->listeners[i])
- {
- gconf_client_notify_remove(dialog->client,
- dialog->listeners[i]);
- dialog->listeners[i] = 0;
- }
- }
-
- dialog->n_listeners = 0;
- gconf_client_remove_dir(dialog->client, GCONF_KEY_DAEMON, NULL);
- g_object_unref(dialog->client);
- dialog->client = NULL;
- }
-
- if (dialog->xml != NULL)
- {
- g_object_unref(dialog->xml);
- dialog->xml = NULL;
- }
-
- if (dialog->preview)
- {
- notify_notification_close(dialog->preview, NULL);
- dialog->preview = NULL;
- }
+ if (dialog->dialog != NULL)
+ {
+ gtk_widget_destroy(dialog->dialog);
+ dialog->dialog = NULL;
+ }
+
+ if (dialog->client != NULL)
+ {
+ int i;
+ for (i = 0; i < dialog->n_listeners; i++)
+ {
+ if (dialog->listeners[i])
+ {
+ gconf_client_notify_remove(dialog->client,
+ dialog->listeners[i]);
+ dialog->listeners[i] = 0;
+ }
+ }
+
+ dialog->n_listeners = 0;
+ gconf_client_remove_dir(dialog->client, GCONF_KEY_DAEMON, NULL);
+ g_object_unref(dialog->client);
+ dialog->client = NULL;
+ }
+
+ if (dialog->xml != NULL)
+ {
+ g_object_unref(dialog->xml);
+ dialog->xml = NULL;
+ }
+
+ if (dialog->preview)
+ {
+ notify_notification_close(dialog->preview, NULL);
+ dialog->preview = NULL;
+ }
}
int
main(int argc, char **argv)
{
- NotificationAppletDialog dialog = { NULL, };
+ NotificationAppletDialog dialog = { NULL, };
- bindtextdomain(GETTEXT_PACKAGE, NOTIFICATION_LOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
+ bindtextdomain(GETTEXT_PACKAGE, NOTIFICATION_LOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
- gtk_init(&argc, &argv);
+ gtk_init(&argc, &argv);
- notify_init("notification-properties");
+ notify_init("notification-properties");
- if (!notification_properties_dialog_init(&dialog))
- {
- notification_properties_dialog_finalize(&dialog);
- return 1;
- }
+ if (!notification_properties_dialog_init(&dialog))
+ {
+ notification_properties_dialog_finalize(&dialog);
+ return 1;
+ }
- gtk_main();
+ gtk_main();
- notification_properties_dialog_finalize(&dialog);
+ notification_properties_dialog_finalize(&dialog);
- return 0;
+ return 0;
}
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index bbb69a5..2c0075e 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
* daemon.c - Implementation of the destop notification spec
*
* Copyright (C) 2006 Christian Hammond <chipx86 chipx86 com>
@@ -53,147 +53,147 @@
#define IDLE_SECONDS 30
#define NW_GET_NOTIFY_ID(nw) \
- (GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id")))
+ (GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id")))
#define NW_GET_NOTIFY_SENDER(nw) \
- (g_object_get_data(G_OBJECT(nw), "_notify_sender"))
+ (g_object_get_data(G_OBJECT(nw), "_notify_sender"))
#define NW_GET_DAEMON(nw) \
- (g_object_get_data(G_OBJECT(nw), "_notify_daemon"))
+ (g_object_get_data(G_OBJECT(nw), "_notify_daemon"))
typedef struct
{
- NotifyStackLocation type;
- const gchar *identifier;
+ NotifyStackLocation type;
+ const gchar *identifier;
} PopupNotifyStackLocation;
const PopupNotifyStackLocation popup_stack_locations[] =
{
- { NOTIFY_STACK_LOCATION_TOP_LEFT, "top_left" },
- { NOTIFY_STACK_LOCATION_TOP_RIGHT, "top_right" },
- { NOTIFY_STACK_LOCATION_BOTTOM_LEFT, "bottom_left" },
- { NOTIFY_STACK_LOCATION_BOTTOM_RIGHT, "bottom_right" },
- { NOTIFY_STACK_LOCATION_UNKNOWN, NULL }
+ { NOTIFY_STACK_LOCATION_TOP_LEFT, "top_left" },
+ { NOTIFY_STACK_LOCATION_TOP_RIGHT, "top_right" },
+ { NOTIFY_STACK_LOCATION_BOTTOM_LEFT, "bottom_left" },
+ { NOTIFY_STACK_LOCATION_BOTTOM_RIGHT, "bottom_right" },
+ { NOTIFY_STACK_LOCATION_UNKNOWN, NULL }
};
#define POPUP_STACK_DEFAULT_INDEX 3 /* XXX Hack! */
typedef struct
{
- NotifyDaemon *daemon;
- GTimeVal expiration;
- GTimeVal paused_diff;
- gboolean has_timeout;
- gboolean paused;
- guint id;
- GtkWindow *nw;
- Window src_window_xid;
+ NotifyDaemon *daemon;
+ GTimeVal expiration;
+ GTimeVal paused_diff;
+ gboolean has_timeout;
+ gboolean paused;
+ guint id;
+ GtkWindow *nw;
+ Window src_window_xid;
} NotifyTimeout;
struct _NotifyDaemonPrivate
{
- guint next_id;
- guint timeout_source;
- guint exit_timeout_source;
- GHashTable *idle_reposition_notify_ids;
- GHashTable *monitored_window_hash;
- GHashTable *notification_hash;
- gboolean url_clicked_lock;
- NotifyStack **stacks;
- gint stacks_size;
+ guint next_id;
+ guint timeout_source;
+ guint exit_timeout_source;
+ GHashTable *idle_reposition_notify_ids;
+ GHashTable *monitored_window_hash;
+ GHashTable *notification_hash;
+ gboolean url_clicked_lock;
+ NotifyStack **stacks;
+ gint stacks_size;
};
static GConfClient *gconf_client = NULL;
static DBusConnection *dbus_conn = NULL;
#define CHECK_DBUS_VERSION(major, minor) \
- (DBUS_MAJOR_VER > (major) || \
- (DBUS_MAJOR_VER == (major) && DBUS_MINOR_VER >= (minor)))
+ (DBUS_MAJOR_VER > (major) || \
+ (DBUS_MAJOR_VER == (major) && DBUS_MINOR_VER >= (minor)))
#if !CHECK_DBUS_VERSION(0, 60)
/* This is a hack that will go away in time. For now, it's fairly safe. */
struct _DBusGMethodInvocation
{
- DBusGConnection *connection;
- DBusGMessage *message;
- const DBusGObjectInfo *object;
- const DBusGMethodInfo *method;
+ DBusGConnection *connection;
+ DBusGMessage *message;
+ const DBusGObjectInfo *object;
+ const DBusGMethodInfo *method;
};
#endif /* D-BUS < 0.60 */
static void notify_daemon_finalize(GObject *object);
static void _notification_destroyed_cb(GtkWindow *nw, NotifyDaemon *daemon);
static void _close_notification(NotifyDaemon *daemon, guint id,
- gboolean hide_notification,
- NotifydClosedReason reason);
+ gboolean hide_notification,
+ NotifydClosedReason reason);
static GdkFilterReturn _notify_x11_filter(GdkXEvent *xevent,
- GdkEvent *event,
- gpointer user_data);
+ GdkEvent *event,
+ gpointer user_data);
static void _emit_closed_signal(GtkWindow *nw, NotifydClosedReason reason);
static void _action_invoked_cb(GtkWindow *nw, const char *key);
static NotifyStackLocation get_stack_location_from_string(const char *slocation);
static void sync_notification_position(NotifyDaemon *daemon, GtkWindow *nw,
- Window source);
+ Window source);
static void monitor_notification_source_windows(NotifyDaemon *daemon,
- NotifyTimeout *nt,
- Window source);
+ NotifyTimeout *nt,
+ Window source);
G_DEFINE_TYPE(NotifyDaemon, notify_daemon, G_TYPE_OBJECT);
static void
notify_daemon_class_init(NotifyDaemonClass *daemon_class)
{
- GObjectClass *object_class = G_OBJECT_CLASS(daemon_class);
+ GObjectClass *object_class = G_OBJECT_CLASS(daemon_class);
- object_class->finalize = notify_daemon_finalize;
+ object_class->finalize = notify_daemon_finalize;
- g_type_class_add_private(daemon_class, sizeof(NotifyDaemonPrivate));
+ g_type_class_add_private(daemon_class, sizeof(NotifyDaemonPrivate));
}
static void
_notify_timeout_destroy(NotifyTimeout *nt)
{
- /*
- * Disconnect the destroy handler to avoid a loop since the id
- * won't be removed from the hash table before the widget is
- * destroyed.
- */
- g_signal_handlers_disconnect_by_func(nt->nw, _notification_destroyed_cb,
- nt->daemon);
-
- gtk_widget_destroy(GTK_WIDGET(nt->nw));
- g_free(nt);
+ /*
+ * Disconnect the destroy handler to avoid a loop since the id
+ * won't be removed from the hash table before the widget is
+ * destroyed.
+ */
+ g_signal_handlers_disconnect_by_func(nt->nw, _notification_destroyed_cb,
+ nt->daemon);
+
+ gtk_widget_destroy(GTK_WIDGET(nt->nw));
+ g_free(nt);
}
static void
reallocate_stacks (NotifyDaemon *daemon)
{
- GdkDisplay *display;
- GdkScreen *screen;
- gint old_stacks_size;
- GConfClient *client = get_gconf_client();
- NotifyStackLocation location;
- gchar *slocation;
- gint i;
-
- display = gdk_display_get_default();
- screen = gdk_display_get_default_screen(display);
-
- if (daemon->priv->stacks_size < gdk_screen_get_n_monitors (screen)) {
- slocation = gconf_client_get_string(client, GCONF_KEY_POPUP_LOCATION,
- NULL);
- location = get_stack_location_from_string(slocation);
- g_free(slocation);
-
- old_stacks_size = daemon->priv->stacks_size;
- daemon->priv->stacks_size = gdk_screen_get_n_monitors(screen);
- daemon->priv->stacks = g_renew(NotifyStack *, daemon->priv->stacks, daemon->priv->stacks_size);
- for (i = old_stacks_size; i < daemon->priv->stacks_size; i++) {
- daemon->priv->stacks[i] = notify_stack_new(daemon,
- screen,
- i,
- location);
- }
- }
+ GdkDisplay *display;
+ GdkScreen *screen;
+ gint old_stacks_size;
+ GConfClient *client = get_gconf_client();
+ NotifyStackLocation location;
+ gchar *slocation;
+ gint i;
+
+ display = gdk_display_get_default();
+ screen = gdk_display_get_default_screen(display);
+
+ if (daemon->priv->stacks_size < gdk_screen_get_n_monitors (screen)) {
+ slocation = gconf_client_get_string(client, GCONF_KEY_POPUP_LOCATION,
+ NULL);
+ location = get_stack_location_from_string(slocation);
+ g_free(slocation);
+
+ old_stacks_size = daemon->priv->stacks_size;
+ daemon->priv->stacks_size = gdk_screen_get_n_monitors(screen);
+ daemon->priv->stacks = g_renew(NotifyStack *, daemon->priv->stacks, daemon->priv->stacks_size);
+ for (i = old_stacks_size; i < daemon->priv->stacks_size; i++) {
+ daemon->priv->stacks[i] = notify_stack_new(daemon,
+ screen,
+ i,
+ location);
+ }
+ }
}
static gboolean
@@ -207,829 +207,829 @@ do_exit (gpointer user_data)
static void
add_exit_timeout (NotifyDaemon *daemon)
{
- if (daemon->priv->exit_timeout_source > 0)
- return;
- daemon->priv->exit_timeout_source = g_timeout_add_seconds (IDLE_SECONDS, do_exit, NULL);
+ if (daemon->priv->exit_timeout_source > 0)
+ return;
+ daemon->priv->exit_timeout_source = g_timeout_add_seconds (IDLE_SECONDS, do_exit, NULL);
}
static void
remove_exit_timeout (NotifyDaemon *daemon)
{
- if (daemon->priv->exit_timeout_source == 0)
- return;
- g_source_remove (daemon->priv->exit_timeout_source);
- daemon->priv->exit_timeout_source = 0;
+ if (daemon->priv->exit_timeout_source == 0)
+ return;
+ g_source_remove (daemon->priv->exit_timeout_source);
+ daemon->priv->exit_timeout_source = 0;
}
static void
notify_daemon_init(NotifyDaemon *daemon)
{
- daemon->priv = G_TYPE_INSTANCE_GET_PRIVATE(daemon, NOTIFY_TYPE_DAEMON,
- NotifyDaemonPrivate);
+ daemon->priv = G_TYPE_INSTANCE_GET_PRIVATE(daemon, NOTIFY_TYPE_DAEMON,
+ NotifyDaemonPrivate);
- daemon->priv->next_id = 1;
- daemon->priv->timeout_source = 0;
+ daemon->priv->next_id = 1;
+ daemon->priv->timeout_source = 0;
- add_exit_timeout (daemon);
+ add_exit_timeout (daemon);
- daemon->priv->stacks_size = 0;
- daemon->priv->stacks = NULL;
+ daemon->priv->stacks_size = 0;
+ daemon->priv->stacks = NULL;
- reallocate_stacks (daemon);
+ reallocate_stacks (daemon);
- daemon->priv->idle_reposition_notify_ids = g_hash_table_new(NULL, NULL);
- daemon->priv->monitored_window_hash = g_hash_table_new(NULL, NULL);
- daemon->priv->notification_hash =
- g_hash_table_new_full(g_int_hash, g_int_equal, g_free,
- (GDestroyNotify)_notify_timeout_destroy);
+ daemon->priv->idle_reposition_notify_ids = g_hash_table_new(NULL, NULL);
+ daemon->priv->monitored_window_hash = g_hash_table_new(NULL, NULL);
+ daemon->priv->notification_hash =
+ g_hash_table_new_full(g_int_hash, g_int_equal, g_free,
+ (GDestroyNotify)_notify_timeout_destroy);
}
static void
notify_daemon_finalize(GObject *object)
{
- NotifyDaemon *daemon = NOTIFY_DAEMON(object);
- GObjectClass *parent_class = G_OBJECT_CLASS(notify_daemon_parent_class);
+ NotifyDaemon *daemon = NOTIFY_DAEMON(object);
+ GObjectClass *parent_class = G_OBJECT_CLASS(notify_daemon_parent_class);
- if (g_hash_table_size(daemon->priv->monitored_window_hash) > 0)
- gdk_window_remove_filter(NULL, _notify_x11_filter, daemon);
+ if (g_hash_table_size(daemon->priv->monitored_window_hash) > 0)
+ gdk_window_remove_filter(NULL, _notify_x11_filter, daemon);
- remove_exit_timeout (daemon);
+ remove_exit_timeout (daemon);
- g_hash_table_destroy(daemon->priv->monitored_window_hash);
- g_hash_table_destroy(daemon->priv->idle_reposition_notify_ids);
- g_hash_table_destroy(daemon->priv->notification_hash);
- g_free(daemon->priv);
+ g_hash_table_destroy(daemon->priv->monitored_window_hash);
+ g_hash_table_destroy(daemon->priv->idle_reposition_notify_ids);
+ g_hash_table_destroy(daemon->priv->notification_hash);
+ g_free(daemon->priv);
- if (parent_class->finalize != NULL)
- parent_class->finalize(object);
+ if (parent_class->finalize != NULL)
+ parent_class->finalize(object);
}
static NotifyStackLocation
get_stack_location_from_string(const char *slocation)
{
- NotifyStackLocation stack_location = NOTIFY_STACK_LOCATION_DEFAULT;
-
- if (slocation == NULL || *slocation == '\0')
- return NOTIFY_STACK_LOCATION_DEFAULT;
- else
- {
- const PopupNotifyStackLocation *l;
-
- for (l = popup_stack_locations;
- l->type != NOTIFY_STACK_LOCATION_UNKNOWN;
- l++)
- {
- if (!strcmp(slocation, l->identifier))
- stack_location = l->type;
- }
- }
-
- return stack_location;
+ NotifyStackLocation stack_location = NOTIFY_STACK_LOCATION_DEFAULT;
+
+ if (slocation == NULL || *slocation == '\0')
+ return NOTIFY_STACK_LOCATION_DEFAULT;
+ else
+ {
+ const PopupNotifyStackLocation *l;
+
+ for (l = popup_stack_locations;
+ l->type != NOTIFY_STACK_LOCATION_UNKNOWN;
+ l++)
+ {
+ if (!strcmp(slocation, l->identifier))
+ stack_location = l->type;
+ }
+ }
+
+ return stack_location;
}
static DBusMessage *
create_signal(GtkWindow *nw, const char *signal_name)
{
- guint id = NW_GET_NOTIFY_ID(nw);
- gchar *dest = NW_GET_NOTIFY_SENDER(nw);
- DBusMessage *message;
+ guint id = NW_GET_NOTIFY_ID(nw);
+ gchar *dest = NW_GET_NOTIFY_SENDER(nw);
+ DBusMessage *message;
- g_assert(dest != NULL);
+ g_assert(dest != NULL);
- message = dbus_message_new_signal("/org/freedesktop/Notifications",
- "org.freedesktop.Notifications",
- signal_name);
+ message = dbus_message_new_signal("/org/freedesktop/Notifications",
+ "org.freedesktop.Notifications",
+ signal_name);
- dbus_message_set_destination(message, dest);
- dbus_message_append_args(message,
- DBUS_TYPE_UINT32, &id,
- DBUS_TYPE_INVALID);
+ dbus_message_set_destination(message, dest);
+ dbus_message_append_args(message,
+ DBUS_TYPE_UINT32, &id,
+ DBUS_TYPE_INVALID);
- return message;
+ return message;
}
static void
_action_invoked_cb(GtkWindow *nw, const char *key)
{
- NotifyDaemon *daemon = NW_GET_DAEMON(nw);
- guint id = NW_GET_NOTIFY_ID(nw);
- DBusMessage *message;
+ NotifyDaemon *daemon = NW_GET_DAEMON(nw);
+ guint id = NW_GET_NOTIFY_ID(nw);
+ DBusMessage *message;
- message = create_signal(nw, "ActionInvoked");
- dbus_message_append_args(message,
- DBUS_TYPE_STRING, &key,
- DBUS_TYPE_INVALID);
+ message = create_signal(nw, "ActionInvoked");
+ dbus_message_append_args(message,
+ DBUS_TYPE_STRING, &key,
+ DBUS_TYPE_INVALID);
- dbus_connection_send(dbus_conn, message, NULL);
- dbus_message_unref(message);
+ dbus_connection_send(dbus_conn, message, NULL);
+ dbus_message_unref(message);
- _close_notification(daemon, id, TRUE, NOTIFYD_CLOSED_USER);
+ _close_notification(daemon, id, TRUE, NOTIFYD_CLOSED_USER);
}
static void
_emit_closed_signal(GtkWindow *nw, NotifydClosedReason reason)
{
- DBusMessage *message = create_signal(nw, "NotificationClosed");
- dbus_message_append_args(message,
- DBUS_TYPE_UINT32, &reason,
- DBUS_TYPE_INVALID);
- dbus_connection_send(dbus_conn, message, NULL);
- dbus_message_unref(message);
+ DBusMessage *message = create_signal(nw, "NotificationClosed");
+ dbus_message_append_args(message,
+ DBUS_TYPE_UINT32, &reason,
+ DBUS_TYPE_INVALID);
+ dbus_connection_send(dbus_conn, message, NULL);
+ dbus_message_unref(message);
}
static void
_close_notification(NotifyDaemon *daemon,
- guint id,
- gboolean hide_notification,
- NotifydClosedReason reason)
+ guint id,
+ gboolean hide_notification,
+ NotifydClosedReason reason)
{
- NotifyDaemonPrivate *priv = daemon->priv;
- NotifyTimeout *nt;
+ NotifyDaemonPrivate *priv = daemon->priv;
+ NotifyTimeout *nt;
- nt = (NotifyTimeout *)g_hash_table_lookup(priv->notification_hash, &id);
+ nt = (NotifyTimeout *)g_hash_table_lookup(priv->notification_hash, &id);
- if (nt != NULL)
- {
- _emit_closed_signal(nt->nw, reason);
+ if (nt != NULL)
+ {
+ _emit_closed_signal(nt->nw, reason);
- if (hide_notification)
- theme_hide_notification(nt->nw);
+ if (hide_notification)
+ theme_hide_notification(nt->nw);
- g_hash_table_remove(priv->notification_hash, &id);
- if (g_hash_table_size(daemon->priv->notification_hash) == 0)
- add_exit_timeout (daemon);
- }
+ g_hash_table_remove(priv->notification_hash, &id);
+ if (g_hash_table_size(daemon->priv->notification_hash) == 0)
+ add_exit_timeout (daemon);
+ }
}
static void
_notification_destroyed_cb(GtkWindow *nw, NotifyDaemon *daemon)
{
- /*
- * This usually won't happen, but can if notification-daemon dies before
- * all notifications are closed. Mark them as expired.
- */
- _close_notification(daemon, NW_GET_NOTIFY_ID(nw), FALSE,
- NOTIFYD_CLOSED_EXPIRED);
+ /*
+ * This usually won't happen, but can if notification-daemon dies before
+ * all notifications are closed. Mark them as expired.
+ */
+ _close_notification(daemon, NW_GET_NOTIFY_ID(nw), FALSE,
+ NOTIFYD_CLOSED_EXPIRED);
}
typedef struct
{
- NotifyDaemon *daemon;
- gint id;
+ NotifyDaemon *daemon;
+ gint id;
} IdleRepositionData;
static gboolean
idle_reposition_notification(gpointer datap)
{
- IdleRepositionData *data = (IdleRepositionData *)datap;
- NotifyDaemon *daemon = data->daemon;
- NotifyTimeout *nt;
- gint notify_id;
-
- notify_id = data->id;
-
- /* Look up the timeout, if it's completed we don't need to do anything */
- nt = (NotifyTimeout *)g_hash_table_lookup(daemon->priv->notification_hash,
- ¬ify_id);
- if (nt != NULL) {
- sync_notification_position(daemon, nt->nw, nt->src_window_xid);
- }
-
- g_hash_table_remove(daemon->priv->idle_reposition_notify_ids,
- GINT_TO_POINTER(notify_id));
- g_object_unref(daemon);
- g_free(data);
-
- return FALSE;
+ IdleRepositionData *data = (IdleRepositionData *)datap;
+ NotifyDaemon *daemon = data->daemon;
+ NotifyTimeout *nt;
+ gint notify_id;
+
+ notify_id = data->id;
+
+ /* Look up the timeout, if it's completed we don't need to do anything */
+ nt = (NotifyTimeout *)g_hash_table_lookup(daemon->priv->notification_hash,
+ ¬ify_id);
+ if (nt != NULL) {
+ sync_notification_position(daemon, nt->nw, nt->src_window_xid);
+ }
+
+ g_hash_table_remove(daemon->priv->idle_reposition_notify_ids,
+ GINT_TO_POINTER(notify_id));
+ g_object_unref(daemon);
+ g_free(data);
+
+ return FALSE;
}
static void
_queue_idle_reposition_notification(NotifyDaemon *daemon, gint notify_id)
{
- IdleRepositionData *data;
- gpointer orig_key;
- gpointer value;
- guint idle_id;
-
- /* Do we already have an idle update pending? */
- if (g_hash_table_lookup_extended(daemon->priv->idle_reposition_notify_ids,
- GINT_TO_POINTER(notify_id),
- &orig_key, &value))
- {
- return;
- }
-
- data = g_new0(IdleRepositionData, 1);
- data->daemon = g_object_ref(daemon);
- data->id = notify_id;
-
- /* We do this as a short timeout to avoid repositioning spam */
- idle_id = g_timeout_add_full(G_PRIORITY_LOW, 50,
- idle_reposition_notification, data, NULL);
- g_hash_table_insert(daemon->priv->idle_reposition_notify_ids,
- GINT_TO_POINTER(notify_id), GUINT_TO_POINTER(idle_id));
+ IdleRepositionData *data;
+ gpointer orig_key;
+ gpointer value;
+ guint idle_id;
+
+ /* Do we already have an idle update pending? */
+ if (g_hash_table_lookup_extended(daemon->priv->idle_reposition_notify_ids,
+ GINT_TO_POINTER(notify_id),
+ &orig_key, &value))
+ {
+ return;
+ }
+
+ data = g_new0(IdleRepositionData, 1);
+ data->daemon = g_object_ref(daemon);
+ data->id = notify_id;
+
+ /* We do this as a short timeout to avoid repositioning spam */
+ idle_id = g_timeout_add_full(G_PRIORITY_LOW, 50,
+ idle_reposition_notification, data, NULL);
+ g_hash_table_insert(daemon->priv->idle_reposition_notify_ids,
+ GINT_TO_POINTER(notify_id), GUINT_TO_POINTER(idle_id));
}
static GdkFilterReturn
_notify_x11_filter(GdkXEvent *xevent,
- GdkEvent *event,
- gpointer user_data)
+ GdkEvent *event,
+ gpointer user_data)
{
- NotifyDaemon *daemon = NOTIFY_DAEMON(user_data);
- XEvent *xev = (XEvent *)xevent;
- gpointer orig_key;
- gpointer value;
- gint notify_id;
- NotifyTimeout *nt;
-
- if (xev->xany.type == DestroyNotify)
- {
- g_hash_table_remove(daemon->priv->monitored_window_hash,
- GUINT_TO_POINTER(xev->xany.window));
- if (g_hash_table_size(daemon->priv->monitored_window_hash) == 0)
- gdk_window_remove_filter(NULL, _notify_x11_filter, daemon);
- return GDK_FILTER_CONTINUE;
- }
-
- if (!g_hash_table_lookup_extended(daemon->priv->monitored_window_hash,
- GUINT_TO_POINTER(xev->xany.window), &orig_key, &value))
- return GDK_FILTER_CONTINUE;
-
- notify_id = GPOINTER_TO_INT(value);
-
- if (xev->xany.type == ConfigureNotify || xev->xany.type == MapNotify)
- {
- _queue_idle_reposition_notification(daemon, notify_id);
- }
- else if (xev->xany.type == ReparentNotify)
- {
- nt = (NotifyTimeout *)g_hash_table_lookup(daemon->priv->notification_hash, ¬ify_id);
-
- if (nt == NULL)
- return GDK_FILTER_CONTINUE;
-
- /*
- * If the window got reparented, we need to start monitoring the
- * new parents.
- */
- monitor_notification_source_windows(daemon, nt, nt->src_window_xid);
- sync_notification_position(daemon, nt->nw, nt->src_window_xid);
- }
-
- return GDK_FILTER_CONTINUE;
+ NotifyDaemon *daemon = NOTIFY_DAEMON(user_data);
+ XEvent *xev = (XEvent *)xevent;
+ gpointer orig_key;
+ gpointer value;
+ gint notify_id;
+ NotifyTimeout *nt;
+
+ if (xev->xany.type == DestroyNotify)
+ {
+ g_hash_table_remove(daemon->priv->monitored_window_hash,
+ GUINT_TO_POINTER(xev->xany.window));
+ if (g_hash_table_size(daemon->priv->monitored_window_hash) == 0)
+ gdk_window_remove_filter(NULL, _notify_x11_filter, daemon);
+ return GDK_FILTER_CONTINUE;
+ }
+
+ if (!g_hash_table_lookup_extended(daemon->priv->monitored_window_hash,
+ GUINT_TO_POINTER(xev->xany.window), &orig_key, &value))
+ return GDK_FILTER_CONTINUE;
+
+ notify_id = GPOINTER_TO_INT(value);
+
+ if (xev->xany.type == ConfigureNotify || xev->xany.type == MapNotify)
+ {
+ _queue_idle_reposition_notification(daemon, notify_id);
+ }
+ else if (xev->xany.type == ReparentNotify)
+ {
+ nt = (NotifyTimeout *)g_hash_table_lookup(daemon->priv->notification_hash, ¬ify_id);
+
+ if (nt == NULL)
+ return GDK_FILTER_CONTINUE;
+
+ /*
+ * If the window got reparented, we need to start monitoring the
+ * new parents.
+ */
+ monitor_notification_source_windows(daemon, nt, nt->src_window_xid);
+ sync_notification_position(daemon, nt->nw, nt->src_window_xid);
+ }
+
+ return GDK_FILTER_CONTINUE;
}
static void
_mouse_entered_cb(GtkWindow *nw,
- GdkEventCrossing *event,
- NotifyDaemon *daemon)
+ GdkEventCrossing *event,
+ NotifyDaemon *daemon)
{
- NotifyTimeout *nt;
- guint id;
- GTimeVal now;
+ NotifyTimeout *nt;
+ guint id;
+ GTimeVal now;
- if (event->detail == GDK_NOTIFY_INFERIOR)
- return;
+ if (event->detail == GDK_NOTIFY_INFERIOR)
+ return;
- id = NW_GET_NOTIFY_ID(nw);
- nt = (NotifyTimeout *)g_hash_table_lookup(daemon->priv->notification_hash,
- &id);
+ id = NW_GET_NOTIFY_ID(nw);
+ nt = (NotifyTimeout *)g_hash_table_lookup(daemon->priv->notification_hash,
+ &id);
- nt->paused = TRUE;
- g_get_current_time(&now);
+ nt->paused = TRUE;
+ g_get_current_time(&now);
- nt->paused_diff.tv_usec = nt->expiration.tv_usec - now.tv_usec;
- nt->paused_diff.tv_sec = nt->expiration.tv_sec - now.tv_sec;
+ nt->paused_diff.tv_usec = nt->expiration.tv_usec - now.tv_usec;
+ nt->paused_diff.tv_sec = nt->expiration.tv_sec - now.tv_sec;
- if (nt->paused_diff.tv_usec < 0)
- {
- nt->paused_diff.tv_usec += G_USEC_PER_SEC;
- nt->paused_diff.tv_sec--;
- }
+ if (nt->paused_diff.tv_usec < 0)
+ {
+ nt->paused_diff.tv_usec += G_USEC_PER_SEC;
+ nt->paused_diff.tv_sec--;
+ }
}
static void
_mouse_exitted_cb(GtkWindow *nw,
- GdkEventCrossing *event,
- NotifyDaemon *daemon)
+ GdkEventCrossing *event,
+ NotifyDaemon *daemon)
{
- NotifyTimeout *nt;
- guint id;
+ NotifyTimeout *nt;
+ guint id;
- if (event->detail == GDK_NOTIFY_INFERIOR)
- return;
+ if (event->detail == GDK_NOTIFY_INFERIOR)
+ return;
- id = NW_GET_NOTIFY_ID(nw);
- nt = (NotifyTimeout *)g_hash_table_lookup(daemon->priv->notification_hash,
- &id);
+ id = NW_GET_NOTIFY_ID(nw);
+ nt = (NotifyTimeout *)g_hash_table_lookup(daemon->priv->notification_hash,
+ &id);
- nt->paused = FALSE;
+ nt->paused = FALSE;
}
static gboolean
_is_expired(gpointer key, gpointer value, gpointer data)
{
- NotifyTimeout *nt = (NotifyTimeout *)value;
- gboolean *phas_more_timeouts = (gboolean *)data;
- time_t now_time;
- time_t expiration_time;
- GTimeVal now;
-
- if (!nt->has_timeout)
- return FALSE;
-
- g_get_current_time(&now);
-
- expiration_time = (nt->expiration.tv_sec * 1000) +
- (nt->expiration.tv_usec / 1000);
- now_time = (now.tv_sec * 1000) + (now.tv_usec / 1000);
-
- if (now_time > expiration_time)
- {
- theme_notification_tick(nt->nw, 0);
- _emit_closed_signal(nt->nw, NOTIFYD_CLOSED_EXPIRED);
- return TRUE;
- }
- else if (nt->paused)
- {
- nt->expiration.tv_usec = nt->paused_diff.tv_usec + now.tv_usec;
- nt->expiration.tv_sec = nt->paused_diff.tv_sec + now.tv_sec;
-
- if (nt->expiration.tv_usec >= G_USEC_PER_SEC)
- {
- nt->expiration.tv_usec -= G_USEC_PER_SEC;
- nt->expiration.tv_sec++;
- }
- }
- else
- {
- theme_notification_tick(nt->nw, expiration_time - now_time);
- }
-
- *phas_more_timeouts = TRUE;
-
- return FALSE;
+ NotifyTimeout *nt = (NotifyTimeout *)value;
+ gboolean *phas_more_timeouts = (gboolean *)data;
+ time_t now_time;
+ time_t expiration_time;
+ GTimeVal now;
+
+ if (!nt->has_timeout)
+ return FALSE;
+
+ g_get_current_time(&now);
+
+ expiration_time = (nt->expiration.tv_sec * 1000) +
+ (nt->expiration.tv_usec / 1000);
+ now_time = (now.tv_sec * 1000) + (now.tv_usec / 1000);
+
+ if (now_time > expiration_time)
+ {
+ theme_notification_tick(nt->nw, 0);
+ _emit_closed_signal(nt->nw, NOTIFYD_CLOSED_EXPIRED);
+ return TRUE;
+ }
+ else if (nt->paused)
+ {
+ nt->expiration.tv_usec = nt->paused_diff.tv_usec + now.tv_usec;
+ nt->expiration.tv_sec = nt->paused_diff.tv_sec + now.tv_sec;
+
+ if (nt->expiration.tv_usec >= G_USEC_PER_SEC)
+ {
+ nt->expiration.tv_usec -= G_USEC_PER_SEC;
+ nt->expiration.tv_sec++;
+ }
+ }
+ else
+ {
+ theme_notification_tick(nt->nw, expiration_time - now_time);
+ }
+
+ *phas_more_timeouts = TRUE;
+
+ return FALSE;
}
static gboolean
_check_expiration(gpointer data)
{
- NotifyDaemon *daemon = (NotifyDaemon *)data;
- gboolean has_more_timeouts = FALSE;
+ NotifyDaemon *daemon = (NotifyDaemon *)data;
+ gboolean has_more_timeouts = FALSE;
- g_hash_table_foreach_remove(daemon->priv->notification_hash,
- _is_expired, (gpointer)&has_more_timeouts);
+ g_hash_table_foreach_remove(daemon->priv->notification_hash,
+ _is_expired, (gpointer)&has_more_timeouts);
- if (!has_more_timeouts) {
- daemon->priv->timeout_source = 0;
- add_exit_timeout (daemon);
- }
+ if (!has_more_timeouts) {
+ daemon->priv->timeout_source = 0;
+ add_exit_timeout (daemon);
+ }
- return has_more_timeouts;
+ return has_more_timeouts;
}
static void
_calculate_timeout(NotifyDaemon *daemon, NotifyTimeout *nt, int timeout)
{
- if (timeout == 0)
- nt->has_timeout = FALSE;
- else
- {
- glong usec;
-
- nt->has_timeout = TRUE;
-
- if (timeout == -1)
- timeout = NOTIFY_DAEMON_DEFAULT_TIMEOUT;
-
- theme_set_notification_timeout(nt->nw, timeout);
-
- usec = timeout * 1000; /* convert from msec to usec */
-
- /*
- * If it's less than 0, wrap around back to MAXLONG.
- * g_time_val_add() requires a glong, and anything larger than
- * MAXLONG will be treated as a negative value.
- */
- if (usec < 0)
- usec = G_MAXLONG;
-
- g_get_current_time(&nt->expiration);
- g_time_val_add(&nt->expiration, usec);
-
- if (daemon->priv->timeout_source == 0)
- {
- daemon->priv->timeout_source =
- g_timeout_add(100, _check_expiration, daemon);
- }
- }
+ if (timeout == 0)
+ nt->has_timeout = FALSE;
+ else
+ {
+ glong usec;
+
+ nt->has_timeout = TRUE;
+
+ if (timeout == -1)
+ timeout = NOTIFY_DAEMON_DEFAULT_TIMEOUT;
+
+ theme_set_notification_timeout(nt->nw, timeout);
+
+ usec = timeout * 1000; /* convert from msec to usec */
+
+ /*
+ * If it's less than 0, wrap around back to MAXLONG.
+ * g_time_val_add() requires a glong, and anything larger than
+ * MAXLONG will be treated as a negative value.
+ */
+ if (usec < 0)
+ usec = G_MAXLONG;
+
+ g_get_current_time(&nt->expiration);
+ g_time_val_add(&nt->expiration, usec);
+
+ if (daemon->priv->timeout_source == 0)
+ {
+ daemon->priv->timeout_source =
+ g_timeout_add(100, _check_expiration, daemon);
+ }
+ }
}
static NotifyTimeout *
_store_notification(NotifyDaemon *daemon, GtkWindow *nw, int timeout)
{
- NotifyDaemonPrivate *priv = daemon->priv;
- NotifyTimeout *nt;
- guint id = 0;
+ NotifyDaemonPrivate *priv = daemon->priv;
+ NotifyTimeout *nt;
+ guint id = 0;
- do
- {
- id = priv->next_id;
+ do
+ {
+ id = priv->next_id;
- if (id != UINT_MAX)
- priv->next_id++;
- else
- priv->next_id = 1;
+ if (id != UINT_MAX)
+ priv->next_id++;
+ else
+ priv->next_id = 1;
- if (g_hash_table_lookup(priv->notification_hash, &id) != NULL)
- id = 0;
+ if (g_hash_table_lookup(priv->notification_hash, &id) != NULL)
+ id = 0;
- } while (id == 0);
+ } while (id == 0);
- nt = g_new0(NotifyTimeout, 1);
- nt->id = id;
- nt->nw = nw;
- nt->daemon = daemon;
+ nt = g_new0(NotifyTimeout, 1);
+ nt->id = id;
+ nt->nw = nw;
+ nt->daemon = daemon;
- _calculate_timeout(daemon, nt, timeout);
+ _calculate_timeout(daemon, nt, timeout);
- g_hash_table_insert(priv->notification_hash,
- g_memdup(&id, sizeof(guint)), nt);
- remove_exit_timeout (daemon);
+ g_hash_table_insert(priv->notification_hash,
+ g_memdup(&id, sizeof(guint)), nt);
+ remove_exit_timeout (daemon);
- return nt;
+ return nt;
}
static gboolean
_notify_daemon_process_icon_data(NotifyDaemon *daemon,
- GtkWindow *nw,
- GValue *icon_data)
+ GtkWindow *nw,
+ GValue *icon_data)
{
- const guchar *data = NULL;
- gboolean has_alpha;
- int bits_per_sample;
- int width;
- int height;
- int rowstride;
- int n_channels;
- gsize expected_len;
- GdkPixbuf *pixbuf;
- GValueArray *image_struct;
- GValue *value;
- GArray *tmp_array;
+ const guchar *data = NULL;
+ gboolean has_alpha;
+ int bits_per_sample;
+ int width;
+ int height;
+ int rowstride;
+ int n_channels;
+ gsize expected_len;
+ GdkPixbuf *pixbuf;
+ GValueArray *image_struct;
+ GValue *value;
+ GArray *tmp_array;
#if CHECK_DBUS_VERSION(0, 61)
- GType struct_type;
-
- struct_type = dbus_g_type_get_struct("GValueArray",
- G_TYPE_INT,
- G_TYPE_INT,
- G_TYPE_INT,
- G_TYPE_BOOLEAN,
- G_TYPE_INT,
- G_TYPE_INT,
- dbus_g_type_get_collection("GArray", G_TYPE_UCHAR),
- G_TYPE_INVALID);
-
- if (!G_VALUE_HOLDS(icon_data, struct_type))
- {
- g_warning("_notify_daemon_process_icon_data expected a "
- "GValue of type GValueArray");
- return FALSE;
- }
+ GType struct_type;
+
+ struct_type = dbus_g_type_get_struct("GValueArray",
+ G_TYPE_INT,
+ G_TYPE_INT,
+ G_TYPE_INT,
+ G_TYPE_BOOLEAN,
+ G_TYPE_INT,
+ G_TYPE_INT,
+ dbus_g_type_get_collection("GArray", G_TYPE_UCHAR),
+ G_TYPE_INVALID);
+
+ if (!G_VALUE_HOLDS(icon_data, struct_type))
+ {
+ g_warning("_notify_daemon_process_icon_data expected a "
+ "GValue of type GValueArray");
+ return FALSE;
+ }
#endif /* D-BUS >= 0.61 */
- image_struct = (GValueArray *)g_value_get_boxed(icon_data);
- value = g_value_array_get_nth(image_struct, 0);
-
- if (value == NULL)
- {
- g_warning("_notify_daemon_process_icon_data expected position "
- "0 of the GValueArray to exist");
- return FALSE;
- }
-
- if (!G_VALUE_HOLDS(value, G_TYPE_INT))
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 0 of the GValueArray to be of type int");
- return FALSE;
- }
-
- width = g_value_get_int(value);
- value = g_value_array_get_nth(image_struct, 1);
-
- if (value == NULL)
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 1 of the GValueArray to exist");
- return FALSE;
- }
-
- if (!G_VALUE_HOLDS(value, G_TYPE_INT))
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 1 of the GValueArray to be of type int");
- return FALSE;
- }
-
- height = g_value_get_int(value);
- value = g_value_array_get_nth(image_struct, 2);
-
- if (value == NULL)
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 2 of the GValueArray to exist");
- return FALSE;
- }
-
- if (!G_VALUE_HOLDS(value, G_TYPE_INT))
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 2 of the GValueArray to be of type int");
- return FALSE;
- }
-
- rowstride = g_value_get_int(value);
- value = g_value_array_get_nth(image_struct, 3);
-
- if (value == NULL)
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 3 of the GValueArray to exist");
- return FALSE;
- }
-
- if (!G_VALUE_HOLDS(value, G_TYPE_BOOLEAN))
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 3 of the GValueArray to be of type gboolean");
- return FALSE;
- }
-
- has_alpha = g_value_get_boolean(value);
- value = g_value_array_get_nth(image_struct, 4);
-
- if (value == NULL)
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 4 of the GValueArray to exist");
- return FALSE;
- }
-
- if (!G_VALUE_HOLDS(value, G_TYPE_INT))
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 4 of the GValueArray to be of type int");
- return FALSE;
- }
-
- bits_per_sample = g_value_get_int(value);
- value = g_value_array_get_nth(image_struct, 5);
-
- if (value == NULL)
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 5 of the GValueArray to exist");
- return FALSE;
- }
-
- if (!G_VALUE_HOLDS(value, G_TYPE_INT))
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 5 of the GValueArray to be of type int");
- return FALSE;
- }
-
- n_channels = g_value_get_int(value);
- value = g_value_array_get_nth(image_struct, 6);
-
- if (value == NULL)
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 6 of the GValueArray to exist");
- return FALSE;
- }
-
- if (!G_VALUE_HOLDS(value,
- dbus_g_type_get_collection("GArray", G_TYPE_UCHAR)))
- {
- g_warning("_notify_daemon_process_icon_data expected "
- "position 6 of the GValueArray to be of type GArray");
- return FALSE;
- }
-
- tmp_array = (GArray *)g_value_get_boxed(value);
- expected_len = (height - 1) * rowstride + width *
- ((n_channels * bits_per_sample + 7) / 8);
-
- if (expected_len != tmp_array->len)
- {
- g_warning("_notify_daemon_process_icon_data expected image "
- "data to be of length %" G_GSIZE_FORMAT " but got a "
- "length of %u",
- expected_len, tmp_array->len);
- return FALSE;
- }
-
- data = (guchar *)g_memdup(tmp_array->data, tmp_array->len);
- pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, has_alpha,
- bits_per_sample, width, height,
- rowstride,
- (GdkPixbufDestroyNotify)g_free,
- NULL);
- theme_set_notification_icon(nw, pixbuf);
- g_object_unref(G_OBJECT(pixbuf));
-
- return TRUE;
+ image_struct = (GValueArray *)g_value_get_boxed(icon_data);
+ value = g_value_array_get_nth(image_struct, 0);
+
+ if (value == NULL)
+ {
+ g_warning("_notify_daemon_process_icon_data expected position "
+ "0 of the GValueArray to exist");
+ return FALSE;
+ }
+
+ if (!G_VALUE_HOLDS(value, G_TYPE_INT))
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 0 of the GValueArray to be of type int");
+ return FALSE;
+ }
+
+ width = g_value_get_int(value);
+ value = g_value_array_get_nth(image_struct, 1);
+
+ if (value == NULL)
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 1 of the GValueArray to exist");
+ return FALSE;
+ }
+
+ if (!G_VALUE_HOLDS(value, G_TYPE_INT))
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 1 of the GValueArray to be of type int");
+ return FALSE;
+ }
+
+ height = g_value_get_int(value);
+ value = g_value_array_get_nth(image_struct, 2);
+
+ if (value == NULL)
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 2 of the GValueArray to exist");
+ return FALSE;
+ }
+
+ if (!G_VALUE_HOLDS(value, G_TYPE_INT))
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 2 of the GValueArray to be of type int");
+ return FALSE;
+ }
+
+ rowstride = g_value_get_int(value);
+ value = g_value_array_get_nth(image_struct, 3);
+
+ if (value == NULL)
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 3 of the GValueArray to exist");
+ return FALSE;
+ }
+
+ if (!G_VALUE_HOLDS(value, G_TYPE_BOOLEAN))
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 3 of the GValueArray to be of type gboolean");
+ return FALSE;
+ }
+
+ has_alpha = g_value_get_boolean(value);
+ value = g_value_array_get_nth(image_struct, 4);
+
+ if (value == NULL)
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 4 of the GValueArray to exist");
+ return FALSE;
+ }
+
+ if (!G_VALUE_HOLDS(value, G_TYPE_INT))
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 4 of the GValueArray to be of type int");
+ return FALSE;
+ }
+
+ bits_per_sample = g_value_get_int(value);
+ value = g_value_array_get_nth(image_struct, 5);
+
+ if (value == NULL)
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 5 of the GValueArray to exist");
+ return FALSE;
+ }
+
+ if (!G_VALUE_HOLDS(value, G_TYPE_INT))
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 5 of the GValueArray to be of type int");
+ return FALSE;
+ }
+
+ n_channels = g_value_get_int(value);
+ value = g_value_array_get_nth(image_struct, 6);
+
+ if (value == NULL)
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 6 of the GValueArray to exist");
+ return FALSE;
+ }
+
+ if (!G_VALUE_HOLDS(value,
+ dbus_g_type_get_collection("GArray", G_TYPE_UCHAR)))
+ {
+ g_warning("_notify_daemon_process_icon_data expected "
+ "position 6 of the GValueArray to be of type GArray");
+ return FALSE;
+ }
+
+ tmp_array = (GArray *)g_value_get_boxed(value);
+ expected_len = (height - 1) * rowstride + width *
+ ((n_channels * bits_per_sample + 7) / 8);
+
+ if (expected_len != tmp_array->len)
+ {
+ g_warning("_notify_daemon_process_icon_data expected image "
+ "data to be of length %" G_GSIZE_FORMAT " but got a "
+ "length of %u",
+ expected_len, tmp_array->len);
+ return FALSE;
+ }
+
+ data = (guchar *)g_memdup(tmp_array->data, tmp_array->len);
+ pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, has_alpha,
+ bits_per_sample, width, height,
+ rowstride,
+ (GdkPixbufDestroyNotify)g_free,
+ NULL);
+ theme_set_notification_icon(nw, pixbuf);
+ g_object_unref(G_OBJECT(pixbuf));
+
+ return TRUE;
}
static void
window_clicked_cb(GtkWindow *nw, GdkEventButton *button, NotifyDaemon *daemon)
{
- if (daemon->priv->url_clicked_lock)
- {
- daemon->priv->url_clicked_lock = FALSE;
- return;
- }
-
- _action_invoked_cb(nw, "default");
- _close_notification(daemon, NW_GET_NOTIFY_ID(nw), TRUE,
- NOTIFYD_CLOSED_USER);
+ if (daemon->priv->url_clicked_lock)
+ {
+ daemon->priv->url_clicked_lock = FALSE;
+ return;
+ }
+
+ _action_invoked_cb(nw, "default");
+ _close_notification(daemon, NW_GET_NOTIFY_ID(nw), TRUE,
+ NOTIFYD_CLOSED_USER);
}
static void
popup_location_changed_cb(GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
{
- NotifyDaemon *daemon = (NotifyDaemon*)user_data;
- NotifyStackLocation stack_location;
- const char *slocation;
- GConfValue *value;
- gint i;
-
- if (daemon == NULL)
- return;
-
- value = gconf_entry_get_value(entry);
- slocation = (value != NULL ? gconf_value_get_string(value) : NULL);
-
- if (slocation != NULL && *slocation != '\0')
- {
- stack_location = get_stack_location_from_string(slocation);
- }
- else
- {
- gconf_client_set_string(get_gconf_client(),
- "/apps/notification-daemon/popup_location",
- popup_stack_locations[POPUP_STACK_DEFAULT_INDEX].identifier,
- NULL);
-
- stack_location = NOTIFY_STACK_LOCATION_DEFAULT;
- }
-
- for (i = 0; i < daemon->priv->stacks_size; i++)
- notify_stack_set_location(daemon->priv->stacks[i], stack_location);
+ NotifyDaemon *daemon = (NotifyDaemon*)user_data;
+ NotifyStackLocation stack_location;
+ const char *slocation;
+ GConfValue *value;
+ gint i;
+
+ if (daemon == NULL)
+ return;
+
+ value = gconf_entry_get_value(entry);
+ slocation = (value != NULL ? gconf_value_get_string(value) : NULL);
+
+ if (slocation != NULL && *slocation != '\0')
+ {
+ stack_location = get_stack_location_from_string(slocation);
+ }
+ else
+ {
+ gconf_client_set_string(get_gconf_client(),
+ "/apps/notification-daemon/popup_location",
+ popup_stack_locations[POPUP_STACK_DEFAULT_INDEX].identifier,
+ NULL);
+
+ stack_location = NOTIFY_STACK_LOCATION_DEFAULT;
+ }
+
+ for (i = 0; i < daemon->priv->stacks_size; i++)
+ notify_stack_set_location(daemon->priv->stacks[i], stack_location);
}
static void
url_clicked_cb(GtkWindow *nw, const char *url)
{
- NotifyDaemon *daemon = NW_GET_DAEMON(nw);
- char *escaped_url;
- char *cmd = NULL;
-
- /* Somewhat of a hack.. */
- daemon->priv->url_clicked_lock = TRUE;
-
- escaped_url = g_shell_quote(url);
-
- if (g_find_program_in_path("gvfs-open") != NULL)
- {
- cmd = g_strdup_printf("gvfs-open %s", escaped_url);
- }
- else if (g_find_program_in_path("xdg-open") != NULL)
- {
- cmd = g_strdup_printf("xdg-open %s", escaped_url);
- }
- else if (g_find_program_in_path("firefox") != NULL)
- {
- cmd = g_strdup_printf("firefox %s", escaped_url);
- }
- else
- {
- g_warning("Unable to find a browser.");
- }
-
- g_free(escaped_url);
-
- if (cmd != NULL)
- {
- g_spawn_command_line_async(cmd, NULL);
- g_free(cmd);
- }
+ NotifyDaemon *daemon = NW_GET_DAEMON(nw);
+ char *escaped_url;
+ char *cmd = NULL;
+
+ /* Somewhat of a hack.. */
+ daemon->priv->url_clicked_lock = TRUE;
+
+ escaped_url = g_shell_quote(url);
+
+ if (g_find_program_in_path("gvfs-open") != NULL)
+ {
+ cmd = g_strdup_printf("gvfs-open %s", escaped_url);
+ }
+ else if (g_find_program_in_path("xdg-open") != NULL)
+ {
+ cmd = g_strdup_printf("xdg-open %s", escaped_url);
+ }
+ else if (g_find_program_in_path("firefox") != NULL)
+ {
+ cmd = g_strdup_printf("firefox %s", escaped_url);
+ }
+ else
+ {
+ g_warning("Unable to find a browser.");
+ }
+
+ g_free(escaped_url);
+
+ if (cmd != NULL)
+ {
+ g_spawn_command_line_async(cmd, NULL);
+ g_free(cmd);
+ }
}
static gboolean
screensaver_active(GtkWidget *nw)
{
- DBusGConnection *connection;
- DBusGProxy *gs_proxy;
- GError *error;
- gboolean active;
-
- active = FALSE;
-
- error = NULL;
- connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
- if (connection == NULL)
- {
- g_warning ("Failed to get dbus connection: %s", error->message);
- g_error_free(error);
- goto out;
-
- }
- gs_proxy = dbus_g_proxy_new_for_name(connection,
- "org.gnome.ScreenSaver",
- "/",
- "org.gnome.ScreenSaver");
-
- if (!dbus_g_proxy_call(gs_proxy, "GetActive", &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &active,
- G_TYPE_INVALID))
- {
- g_warning("Failed to call gnome-screensaver: %s", error->message);
- g_error_free(error);
- }
+ DBusGConnection *connection;
+ DBusGProxy *gs_proxy;
+ GError *error;
+ gboolean active;
+
+ active = FALSE;
+
+ error = NULL;
+ connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+ if (connection == NULL)
+ {
+ g_warning ("Failed to get dbus connection: %s", error->message);
+ g_error_free(error);
+ goto out;
+
+ }
+ gs_proxy = dbus_g_proxy_new_for_name(connection,
+ "org.gnome.ScreenSaver",
+ "/",
+ "org.gnome.ScreenSaver");
+
+ if (!dbus_g_proxy_call(gs_proxy, "GetActive", &error,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &active,
+ G_TYPE_INVALID))
+ {
+ g_warning("Failed to call gnome-screensaver: %s", error->message);
+ g_error_free(error);
+ }
g_object_unref (gs_proxy);
out:
- return active;
+ return active;
}
static gboolean
fullscreen_window_exists(GtkWidget *nw)
{
- WnckScreen *wnck_screen;
- WnckWorkspace *wnck_workspace;
- GList *l;
-
- wnck_screen = wnck_screen_get(GDK_SCREEN_XNUMBER(
- gdk_drawable_get_screen(GDK_DRAWABLE(GTK_WIDGET(nw)->window))));
- wnck_screen_force_update(wnck_screen);
-
- wnck_workspace = wnck_screen_get_active_workspace(wnck_screen);
-
- for (l = wnck_screen_get_windows_stacked(wnck_screen);
- l != NULL;
- l = l->next)
- {
- WnckWindow *wnck_win = (WnckWindow *)l->data;
-
- if (wnck_window_is_on_workspace(wnck_win, wnck_workspace) &&
- wnck_window_is_fullscreen(wnck_win) &&
- wnck_window_is_active(wnck_win))
- {
- /*
- * Sanity check if the window is _really_ fullscreen to
- * work around a bug in libwnck that doesn't get all
- * unfullscreen events.
- */
- int sw = wnck_screen_get_width(wnck_screen);
- int sh = wnck_screen_get_height(wnck_screen);
- int x, y, w, h;
-
- wnck_window_get_geometry(wnck_win, &x, &y, &w, &h);
-
- if (sw == w && sh == h)
- return TRUE;
- }
- }
-
- return FALSE;
+ WnckScreen *wnck_screen;
+ WnckWorkspace *wnck_workspace;
+ GList *l;
+
+ wnck_screen = wnck_screen_get(GDK_SCREEN_XNUMBER(
+ gdk_drawable_get_screen(GDK_DRAWABLE(GTK_WIDGET(nw)->window))));
+ wnck_screen_force_update(wnck_screen);
+
+ wnck_workspace = wnck_screen_get_active_workspace(wnck_screen);
+
+ for (l = wnck_screen_get_windows_stacked(wnck_screen);
+ l != NULL;
+ l = l->next)
+ {
+ WnckWindow *wnck_win = (WnckWindow *)l->data;
+
+ if (wnck_window_is_on_workspace(wnck_win, wnck_workspace) &&
+ wnck_window_is_fullscreen(wnck_win) &&
+ wnck_window_is_active(wnck_win))
+ {
+ /*
+ * Sanity check if the window is _really_ fullscreen to
+ * work around a bug in libwnck that doesn't get all
+ * unfullscreen events.
+ */
+ int sw = wnck_screen_get_width(wnck_screen);
+ int sh = wnck_screen_get_height(wnck_screen);
+ int x, y, w, h;
+
+ wnck_window_get_geometry(wnck_win, &x, &y, &w, &h);
+
+ if (sw == w && sh == h)
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
static Window
get_window_parent(Display *display,
- Window window,
- Window *root)
+ Window window,
+ Window *root)
{
- Window parent;
- Window *children = NULL;
- guint nchildren;
- gboolean result;
+ Window parent;
+ Window *children = NULL;
+ guint nchildren;
+ gboolean result;
- gdk_error_trap_push();
- result = XQueryTree(display, window, root, &parent, &children, &nchildren);
- if (gdk_error_trap_pop() || !result)
- return None;
+ gdk_error_trap_push();
+ result = XQueryTree(display, window, root, &parent, &children, &nchildren);
+ if (gdk_error_trap_pop() || !result)
+ return None;
- if (children)
- XFree(children);
+ if (children)
+ XFree(children);
- return parent;
+ return parent;
}
/*
@@ -1038,489 +1038,489 @@ get_window_parent(Display *display,
*/
static void
monitor_notification_source_windows(NotifyDaemon *daemon,
- NotifyTimeout *nt,
- Window source)
+ NotifyTimeout *nt,
+ Window source)
{
- Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
- Window root = None;
- Window parent;
+ Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
+ Window root = None;
+ Window parent;
- /* Start monitoring events if necessary. We don't want to
+ /* Start monitoring events if necessary. We don't want to
filter events unless we absolutely have to. */
- if (g_hash_table_size(daemon->priv->monitored_window_hash) == 0)
- gdk_window_add_filter(NULL, _notify_x11_filter, daemon);
+ if (g_hash_table_size(daemon->priv->monitored_window_hash) == 0)
+ gdk_window_add_filter(NULL, _notify_x11_filter, daemon);
- /* Store the window in the timeout */
- g_assert(nt != NULL);
- nt->src_window_xid = source;
+ /* Store the window in the timeout */
+ g_assert(nt != NULL);
+ nt->src_window_xid = source;
- for (parent = get_window_parent(display, source, &root);
- parent != None && root != parent;
- parent = get_window_parent(display, parent, &root)) {
+ for (parent = get_window_parent(display, source, &root);
+ parent != None && root != parent;
+ parent = get_window_parent(display, parent, &root)) {
- XSelectInput(display, parent, StructureNotifyMask);
- g_hash_table_insert(daemon->priv->monitored_window_hash,
- GUINT_TO_POINTER(parent), GINT_TO_POINTER(nt->id));
- }
+ XSelectInput(display, parent, StructureNotifyMask);
+ g_hash_table_insert(daemon->priv->monitored_window_hash,
+ GUINT_TO_POINTER(parent), GINT_TO_POINTER(nt->id));
+ }
}
/* Use a source X Window ID to reposition a notification. */
static void
sync_notification_position(NotifyDaemon *daemon,
- GtkWindow *nw,
- Window source)
+ GtkWindow *nw,
+ Window source)
{
- Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
- Status result;
- Window root;
- Window child;
- int x, y;
- unsigned int width, height;
- unsigned int border_width, depth;
-
- gdk_error_trap_push();
-
- /* Get the root for this window */
- result = XGetGeometry(display, source, &root, &x, &y,
- &width, &height, &border_width, &depth);
- if (gdk_error_trap_pop() || !result)
- return;
-
- /*
- * Now calculate the offset coordinates for the source window from
- * the root.
- */
- gdk_error_trap_push ();
- result = XTranslateCoordinates(display, source, root, 0, 0,
- &x, &y, &child);
- if (gdk_error_trap_pop() || !result)
- return;
-
- x += width / 2;
- y += height / 2;
-
- theme_set_notification_arrow(nw, TRUE, x, y);
- theme_move_notification(nw, x, y);
- theme_show_notification(nw);
-
- /*
- * We need to manually queue a draw here as the default theme recalculates
- * its position in the draw handler and moves the window (which seems
- * fairly broken), so just calling move/show above isn't enough to cause
- * its position to be calculated.
- */
- gtk_widget_queue_draw(GTK_WIDGET(nw));
+ Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
+ Status result;
+ Window root;
+ Window child;
+ int x, y;
+ unsigned int width, height;
+ unsigned int border_width, depth;
+
+ gdk_error_trap_push();
+
+ /* Get the root for this window */
+ result = XGetGeometry(display, source, &root, &x, &y,
+ &width, &height, &border_width, &depth);
+ if (gdk_error_trap_pop() || !result)
+ return;
+
+ /*
+ * Now calculate the offset coordinates for the source window from
+ * the root.
+ */
+ gdk_error_trap_push ();
+ result = XTranslateCoordinates(display, source, root, 0, 0,
+ &x, &y, &child);
+ if (gdk_error_trap_pop() || !result)
+ return;
+
+ x += width / 2;
+ y += height / 2;
+
+ theme_set_notification_arrow(nw, TRUE, x, y);
+ theme_move_notification(nw, x, y);
+ theme_show_notification(nw);
+
+ /*
+ * We need to manually queue a draw here as the default theme recalculates
+ * its position in the draw handler and moves the window (which seems
+ * fairly broken), so just calling move/show above isn't enough to cause
+ * its position to be calculated.
+ */
+ gtk_widget_queue_draw(GTK_WIDGET(nw));
}
GQuark
notify_daemon_error_quark(void)
{
- static GQuark q = 0;
+ static GQuark q = 0;
- if (q == 0)
- q = g_quark_from_static_string("notification-daemon-error-quark");
+ if (q == 0)
+ q = g_quark_from_static_string("notification-daemon-error-quark");
- return q;
+ return q;
}
gboolean
notify_daemon_notify_handler(NotifyDaemon *daemon,
- const gchar *app_name,
- guint id,
- const gchar *icon,
- const gchar *summary,
- const gchar *body,
- gchar **actions,
- GHashTable *hints,
- int timeout,
- DBusGMethodInvocation *context)
+ const gchar *app_name,
+ guint id,
+ const gchar *icon,
+ const gchar *summary,
+ const gchar *body,
+ gchar **actions,
+ GHashTable *hints,
+ int timeout,
+ DBusGMethodInvocation *context)
{
- NotifyDaemonPrivate *priv = daemon->priv;
- NotifyTimeout *nt = NULL;
- GtkWindow *nw = NULL;
- GValue *data;
- gboolean use_pos_data = FALSE;
- gboolean new_notification = FALSE;
- gint x = 0;
- gint y = 0;
- Window window_xid = None;
- guint return_id;
- gchar *sender;
- gchar *sound_file = NULL;
- gboolean sound_enabled;
- gint i;
-
- if (id > 0)
- {
- nt = (NotifyTimeout *)g_hash_table_lookup(priv->notification_hash,
- &id);
-
- if (nt != NULL)
- nw = nt->nw;
- else
- id = 0;
- }
-
- if (nw == NULL)
- {
- nw = theme_create_notification(url_clicked_cb);
- g_object_set_data(G_OBJECT(nw), "_notify_daemon", daemon);
- gtk_widget_realize(GTK_WIDGET(nw));
- new_notification = TRUE;
-
- g_signal_connect(G_OBJECT(nw), "button-release-event",
- G_CALLBACK(window_clicked_cb), daemon);
- g_signal_connect(G_OBJECT(nw), "destroy",
- G_CALLBACK(_notification_destroyed_cb), daemon);
- g_signal_connect(G_OBJECT(nw), "enter-notify-event",
- G_CALLBACK(_mouse_entered_cb), daemon);
- g_signal_connect(G_OBJECT(nw), "leave-notify-event",
- G_CALLBACK(_mouse_exitted_cb), daemon);
- }
- else
- {
- theme_clear_notification_actions(nw);
- }
-
- theme_set_notification_text(nw, summary, body);
- theme_set_notification_hints(nw, hints);
-
- /*
- *XXX This needs to handle file URIs and all that.
- */
-
-
- if ((data = (GValue *)g_hash_table_lookup(hints, "window-xid")) != NULL)
- {
- window_xid = (Window)g_value_get_uint(data);
- }
- /* deal with x, and y hints */
- else if ((data = (GValue *)g_hash_table_lookup(hints, "x")) != NULL)
- {
- x = g_value_get_int(data);
-
- if ((data = (GValue *)g_hash_table_lookup(hints, "y")) != NULL)
- {
- y = g_value_get_int(data);
- use_pos_data = TRUE;
- }
- }
-
- /* Deal with sound hints */
- sound_enabled = gconf_client_get_bool(gconf_client,
- GCONF_KEY_SOUND_ENABLED, NULL);
- data = (GValue *)g_hash_table_lookup(hints, "suppress-sound");
-
- if (data != NULL)
- {
- if (G_VALUE_HOLDS_BOOLEAN(data))
- sound_enabled = !g_value_get_boolean(data);
- else if (G_VALUE_HOLDS_INT(data))
- sound_enabled = (g_value_get_int(data) != 0);
- else
- {
- g_warning("suppress-sound is of type %s (expected bool or int)\n",
- g_type_name(G_VALUE_TYPE(data)));
- }
- }
-
- if (sound_enabled)
- {
- data = (GValue *)g_hash_table_lookup(hints, "sound-file");
-
- if (data != NULL)
- {
- sound_file = g_value_dup_string(data);
-
- if (*sound_file == '\0' ||
- !g_file_test(sound_file, G_FILE_TEST_EXISTS))
- {
- g_free(sound_file);
- sound_file = NULL;
- }
- }
- }
-
- /* set up action buttons */
- for (i = 0; actions[i] != NULL; i += 2)
- {
- gchar *l = actions[i + 1];
-
- if (l == NULL)
- {
- g_warning("Label not found for action %s. "
- "The protocol specifies that a label must "
- "follow an action in the actions array", actions[i]);
-
- break;
- }
-
- if (strcasecmp(actions[i], "default"))
- {
- theme_add_notification_action(nw, l, actions[i],
- G_CALLBACK(_action_invoked_cb));
- }
- }
-
- /* check for icon_data if icon == "" */
- if (*icon == '\0')
- {
- data = (GValue *)g_hash_table_lookup(hints, "icon_data");
-
- if (data)
- _notify_daemon_process_icon_data(daemon, nw, data);
- }
- else
- {
- GdkPixbuf *pixbuf = NULL;
-
- if (!strncmp(icon, "file://", 7) || *icon == '/')
- {
- if (!strncmp(icon, "file://", 7))
- icon += 7;
-
- /* Load file */
- pixbuf = gdk_pixbuf_new_from_file(icon, NULL);
- }
- else
- {
- /* Load icon theme icon */
- GtkIconTheme *theme = gtk_icon_theme_get_default();
- GtkIconInfo *icon_info =
- gtk_icon_theme_lookup_icon(theme, icon, IMAGE_SIZE,
- GTK_ICON_LOOKUP_USE_BUILTIN);
-
- if (icon_info != NULL)
- {
- gint icon_size = MIN(IMAGE_SIZE,
- gtk_icon_info_get_base_size(icon_info));
-
- if (icon_size == 0)
- icon_size = IMAGE_SIZE;
-
- pixbuf = gtk_icon_theme_load_icon(theme, icon, icon_size,
- GTK_ICON_LOOKUP_USE_BUILTIN,
- NULL);
-
- gtk_icon_info_free(icon_info);
- }
-
- if (pixbuf == NULL)
- {
- /* Well... maybe this is a file afterall. */
- pixbuf = gdk_pixbuf_new_from_file(icon, NULL);
- }
- }
-
- if (pixbuf != NULL)
- {
- theme_set_notification_icon(nw, pixbuf);
- g_object_unref(G_OBJECT(pixbuf));
- }
- }
-
-
- if (window_xid != None && !theme_get_always_stack(nw))
- {
- /*
- * Do nothing here if we were passed an XID; we'll call
- * sync_notification_position later.
- */
- }
- else if (use_pos_data && !theme_get_always_stack(nw))
- {
- /*
- * Typically, the theme engine will set its own position based on
- * the arrow X, Y hints. However, in case, move the notification to
- * that position.
- */
- theme_set_notification_arrow(nw, TRUE, x, y);
- theme_move_notification(nw, x, y);
- }
- else
- {
- gint monitor;
- GdkScreen *screen;
- gint x, y;
-
- theme_set_notification_arrow(nw, FALSE, 0, 0);
-
- gdk_display_get_pointer(gdk_display_get_default(),
- &screen, &x, &y, NULL);
- monitor = gdk_screen_get_monitor_at_point(screen, x, y);
- if (monitor >= priv->stacks_size) {
- reallocate_stacks (daemon);
- }
-
- notify_stack_add_window(priv->stacks[monitor], nw, new_notification);
- }
-
- if (id == 0)
- {
- nt = _store_notification(daemon, nw, timeout);
- return_id = nt->id;
- }
- else
- return_id = id;
-
- /*
- * If we have a source Window XID, start monitoring the tree
- * for changes, and reposition the window based on the source
- * window. We need to do this after return_id is calculated.
- */
- if (window_xid != None && !theme_get_always_stack(nw))
- {
- monitor_notification_source_windows(daemon, nt, window_xid);
- sync_notification_position(daemon, nw, window_xid);
- }
-
- if (!screensaver_active(GTK_WIDGET(nw)) &&
- !fullscreen_window_exists(GTK_WIDGET(nw)))
- {
- theme_show_notification(nw);
- if (sound_file != NULL)
- sound_play_file(GTK_WIDGET(nw), sound_file);
- }
-
- g_free(sound_file);
+ NotifyDaemonPrivate *priv = daemon->priv;
+ NotifyTimeout *nt = NULL;
+ GtkWindow *nw = NULL;
+ GValue *data;
+ gboolean use_pos_data = FALSE;
+ gboolean new_notification = FALSE;
+ gint x = 0;
+ gint y = 0;
+ Window window_xid = None;
+ guint return_id;
+ gchar *sender;
+ gchar *sound_file = NULL;
+ gboolean sound_enabled;
+ gint i;
+
+ if (id > 0)
+ {
+ nt = (NotifyTimeout *)g_hash_table_lookup(priv->notification_hash,
+ &id);
+
+ if (nt != NULL)
+ nw = nt->nw;
+ else
+ id = 0;
+ }
+
+ if (nw == NULL)
+ {
+ nw = theme_create_notification(url_clicked_cb);
+ g_object_set_data(G_OBJECT(nw), "_notify_daemon", daemon);
+ gtk_widget_realize(GTK_WIDGET(nw));
+ new_notification = TRUE;
+
+ g_signal_connect(G_OBJECT(nw), "button-release-event",
+ G_CALLBACK(window_clicked_cb), daemon);
+ g_signal_connect(G_OBJECT(nw), "destroy",
+ G_CALLBACK(_notification_destroyed_cb), daemon);
+ g_signal_connect(G_OBJECT(nw), "enter-notify-event",
+ G_CALLBACK(_mouse_entered_cb), daemon);
+ g_signal_connect(G_OBJECT(nw), "leave-notify-event",
+ G_CALLBACK(_mouse_exitted_cb), daemon);
+ }
+ else
+ {
+ theme_clear_notification_actions(nw);
+ }
+
+ theme_set_notification_text(nw, summary, body);
+ theme_set_notification_hints(nw, hints);
+
+ /*
+ *XXX This needs to handle file URIs and all that.
+ */
+
+
+ if ((data = (GValue *)g_hash_table_lookup(hints, "window-xid")) != NULL)
+ {
+ window_xid = (Window)g_value_get_uint(data);
+ }
+ /* deal with x, and y hints */
+ else if ((data = (GValue *)g_hash_table_lookup(hints, "x")) != NULL)
+ {
+ x = g_value_get_int(data);
+
+ if ((data = (GValue *)g_hash_table_lookup(hints, "y")) != NULL)
+ {
+ y = g_value_get_int(data);
+ use_pos_data = TRUE;
+ }
+ }
+
+ /* Deal with sound hints */
+ sound_enabled = gconf_client_get_bool(gconf_client,
+ GCONF_KEY_SOUND_ENABLED, NULL);
+ data = (GValue *)g_hash_table_lookup(hints, "suppress-sound");
+
+ if (data != NULL)
+ {
+ if (G_VALUE_HOLDS_BOOLEAN(data))
+ sound_enabled = !g_value_get_boolean(data);
+ else if (G_VALUE_HOLDS_INT(data))
+ sound_enabled = (g_value_get_int(data) != 0);
+ else
+ {
+ g_warning("suppress-sound is of type %s (expected bool or int)\n",
+ g_type_name(G_VALUE_TYPE(data)));
+ }
+ }
+
+ if (sound_enabled)
+ {
+ data = (GValue *)g_hash_table_lookup(hints, "sound-file");
+
+ if (data != NULL)
+ {
+ sound_file = g_value_dup_string(data);
+
+ if (*sound_file == '\0' ||
+ !g_file_test(sound_file, G_FILE_TEST_EXISTS))
+ {
+ g_free(sound_file);
+ sound_file = NULL;
+ }
+ }
+ }
+
+ /* set up action buttons */
+ for (i = 0; actions[i] != NULL; i += 2)
+ {
+ gchar *l = actions[i + 1];
+
+ if (l == NULL)
+ {
+ g_warning("Label not found for action %s. "
+ "The protocol specifies that a label must "
+ "follow an action in the actions array", actions[i]);
+
+ break;
+ }
+
+ if (strcasecmp(actions[i], "default"))
+ {
+ theme_add_notification_action(nw, l, actions[i],
+ G_CALLBACK(_action_invoked_cb));
+ }
+ }
+
+ /* check for icon_data if icon == "" */
+ if (*icon == '\0')
+ {
+ data = (GValue *)g_hash_table_lookup(hints, "icon_data");
+
+ if (data)
+ _notify_daemon_process_icon_data(daemon, nw, data);
+ }
+ else
+ {
+ GdkPixbuf *pixbuf = NULL;
+
+ if (!strncmp(icon, "file://", 7) || *icon == '/')
+ {
+ if (!strncmp(icon, "file://", 7))
+ icon += 7;
+
+ /* Load file */
+ pixbuf = gdk_pixbuf_new_from_file(icon, NULL);
+ }
+ else
+ {
+ /* Load icon theme icon */
+ GtkIconTheme *theme = gtk_icon_theme_get_default();
+ GtkIconInfo *icon_info =
+ gtk_icon_theme_lookup_icon(theme, icon, IMAGE_SIZE,
+ GTK_ICON_LOOKUP_USE_BUILTIN);
+
+ if (icon_info != NULL)
+ {
+ gint icon_size = MIN(IMAGE_SIZE,
+ gtk_icon_info_get_base_size(icon_info));
+
+ if (icon_size == 0)
+ icon_size = IMAGE_SIZE;
+
+ pixbuf = gtk_icon_theme_load_icon(theme, icon, icon_size,
+ GTK_ICON_LOOKUP_USE_BUILTIN,
+ NULL);
+
+ gtk_icon_info_free(icon_info);
+ }
+
+ if (pixbuf == NULL)
+ {
+ /* Well... maybe this is a file afterall. */
+ pixbuf = gdk_pixbuf_new_from_file(icon, NULL);
+ }
+ }
+
+ if (pixbuf != NULL)
+ {
+ theme_set_notification_icon(nw, pixbuf);
+ g_object_unref(G_OBJECT(pixbuf));
+ }
+ }
+
+
+ if (window_xid != None && !theme_get_always_stack(nw))
+ {
+ /*
+ * Do nothing here if we were passed an XID; we'll call
+ * sync_notification_position later.
+ */
+ }
+ else if (use_pos_data && !theme_get_always_stack(nw))
+ {
+ /*
+ * Typically, the theme engine will set its own position based on
+ * the arrow X, Y hints. However, in case, move the notification to
+ * that position.
+ */
+ theme_set_notification_arrow(nw, TRUE, x, y);
+ theme_move_notification(nw, x, y);
+ }
+ else
+ {
+ gint monitor;
+ GdkScreen *screen;
+ gint x, y;
+
+ theme_set_notification_arrow(nw, FALSE, 0, 0);
+
+ gdk_display_get_pointer(gdk_display_get_default(),
+ &screen, &x, &y, NULL);
+ monitor = gdk_screen_get_monitor_at_point(screen, x, y);
+ if (monitor >= priv->stacks_size) {
+ reallocate_stacks (daemon);
+ }
+
+ notify_stack_add_window(priv->stacks[monitor], nw, new_notification);
+ }
+
+ if (id == 0)
+ {
+ nt = _store_notification(daemon, nw, timeout);
+ return_id = nt->id;
+ }
+ else
+ return_id = id;
+
+ /*
+ * If we have a source Window XID, start monitoring the tree
+ * for changes, and reposition the window based on the source
+ * window. We need to do this after return_id is calculated.
+ */
+ if (window_xid != None && !theme_get_always_stack(nw))
+ {
+ monitor_notification_source_windows(daemon, nt, window_xid);
+ sync_notification_position(daemon, nw, window_xid);
+ }
+
+ if (!screensaver_active(GTK_WIDGET(nw)) &&
+ !fullscreen_window_exists(GTK_WIDGET(nw)))
+ {
+ theme_show_notification(nw);
+ if (sound_file != NULL)
+ sound_play_file(GTK_WIDGET(nw), sound_file);
+ }
+
+ g_free(sound_file);
#if CHECK_DBUS_VERSION(0, 60)
- sender = dbus_g_method_get_sender(context);
+ sender = dbus_g_method_get_sender(context);
#else
- sender = g_strdup(dbus_message_get_sender(
- dbus_g_message_get_message(context->message)));
+ sender = g_strdup(dbus_message_get_sender(
+ dbus_g_message_get_message(context->message)));
#endif
- g_object_set_data(G_OBJECT(nw), "_notify_id",
- GUINT_TO_POINTER(return_id));
- g_object_set_data_full(G_OBJECT(nw), "_notify_sender", sender,
- (GDestroyNotify)g_free);
+ g_object_set_data(G_OBJECT(nw), "_notify_id",
+ GUINT_TO_POINTER(return_id));
+ g_object_set_data_full(G_OBJECT(nw), "_notify_sender", sender,
+ (GDestroyNotify)g_free);
- if (nt)
- _calculate_timeout(daemon, nt, timeout);
+ if (nt)
+ _calculate_timeout(daemon, nt, timeout);
- dbus_g_method_return(context, return_id);
+ dbus_g_method_return(context, return_id);
- return TRUE;
+ return TRUE;
}
gboolean
notify_daemon_close_notification_handler(NotifyDaemon *daemon,
- guint id, GError **error)
+ guint id, GError **error)
{
- if (id == 0)
- {
- g_set_error(error, notify_daemon_error_quark(), 100,
- _("%u is not a valid notification ID"), id);
- return FALSE;
- } else {
- _close_notification(daemon, id, TRUE, NOTIFYD_CLOSED_API);
- return TRUE;
- }
+ if (id == 0)
+ {
+ g_set_error(error, notify_daemon_error_quark(), 100,
+ _("%u is not a valid notification ID"), id);
+ return FALSE;
+ } else {
+ _close_notification(daemon, id, TRUE, NOTIFYD_CLOSED_API);
+ return TRUE;
+ }
}
gboolean
notify_daemon_get_capabilities(NotifyDaemon *daemon, char ***caps)
{
- *caps = g_new0(char *, 6);
+ *caps = g_new0(char *, 6);
- (*caps)[0] = g_strdup("actions");
- (*caps)[1] = g_strdup("body");
- (*caps)[2] = g_strdup("body-hyperlinks");
- (*caps)[3] = g_strdup("body-markup");
- (*caps)[4] = g_strdup("icon-static");
- (*caps)[5] = NULL;
+ (*caps)[0] = g_strdup("actions");
+ (*caps)[1] = g_strdup("body");
+ (*caps)[2] = g_strdup("body-hyperlinks");
+ (*caps)[3] = g_strdup("body-markup");
+ (*caps)[4] = g_strdup("icon-static");
+ (*caps)[5] = NULL;
- return TRUE;
+ return TRUE;
}
gboolean
notify_daemon_get_server_information(NotifyDaemon *daemon,
- char **out_name,
- char **out_vendor,
- char **out_version,
- char **out_spec_ver)
+ char **out_name,
+ char **out_vendor,
+ char **out_version,
+ char **out_spec_ver)
{
- *out_name = g_strdup("Notification Daemon");
- *out_vendor = g_strdup("Galago Project");
- *out_version = g_strdup(VERSION);
- *out_spec_ver = g_strdup("1.0");
+ *out_name = g_strdup("Notification Daemon");
+ *out_vendor = g_strdup("Galago Project");
+ *out_version = g_strdup(VERSION);
+ *out_spec_ver = g_strdup("1.0");
- return TRUE;
+ return TRUE;
}
GConfClient *
get_gconf_client(void)
{
- return gconf_client;
+ return gconf_client;
}
int
main(int argc, char **argv)
{
- NotifyDaemon *daemon;
- DBusGConnection *connection;
- DBusGProxy *bus_proxy;
- GError *error;
- guint request_name_result;
+ NotifyDaemon *daemon;
+ DBusGConnection *connection;
+ DBusGProxy *bus_proxy;
+ GError *error;
+ guint request_name_result;
- g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
+ g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
- gtk_init(&argc, &argv);
- gconf_init(argc, argv, NULL);
+ gtk_init(&argc, &argv);
+ gconf_init(argc, argv, NULL);
- gconf_client = gconf_client_get_default();
- gconf_client_add_dir(gconf_client, GCONF_KEY_DAEMON,
- GCONF_CLIENT_PRELOAD_NONE, NULL);
+ gconf_client = gconf_client_get_default();
+ gconf_client_add_dir(gconf_client, GCONF_KEY_DAEMON,
+ GCONF_CLIENT_PRELOAD_NONE, NULL);
- error = NULL;
+ error = NULL;
- connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+ connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
- if (connection == NULL)
- {
- g_printerr("Failed to open connection to bus: %s\n",
- error->message);
- g_error_free(error);
- exit(1);
- }
+ if (connection == NULL)
+ {
+ g_printerr("Failed to open connection to bus: %s\n",
+ error->message);
+ g_error_free(error);
+ exit(1);
+ }
- dbus_conn = dbus_g_connection_get_connection(connection);
+ dbus_conn = dbus_g_connection_get_connection(connection);
- dbus_g_object_type_install_info(NOTIFY_TYPE_DAEMON,
- &dbus_glib_notification_daemon_object_info);
+ dbus_g_object_type_install_info(NOTIFY_TYPE_DAEMON,
+ &dbus_glib_notification_daemon_object_info);
- bus_proxy = dbus_g_proxy_new_for_name(connection,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus");
+ bus_proxy = dbus_g_proxy_new_for_name(connection,
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus");
- if (!dbus_g_proxy_call(bus_proxy, "RequestName", &error,
- G_TYPE_STRING, "org.freedesktop.Notifications",
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &request_name_result,
- G_TYPE_INVALID))
- {
- g_error("Could not aquire name: %s", error->message);
- }
+ if (!dbus_g_proxy_call(bus_proxy, "RequestName", &error,
+ G_TYPE_STRING, "org.freedesktop.Notifications",
+ G_TYPE_UINT, 0,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &request_name_result,
+ G_TYPE_INVALID))
+ {
+ g_error("Could not aquire name: %s", error->message);
+ }
- daemon = g_object_new(NOTIFY_TYPE_DAEMON, NULL);
+ daemon = g_object_new(NOTIFY_TYPE_DAEMON, NULL);
- gconf_client_notify_add(gconf_client, GCONF_KEY_POPUP_LOCATION,
- popup_location_changed_cb, daemon,
- NULL, NULL);
+ gconf_client_notify_add(gconf_client, GCONF_KEY_POPUP_LOCATION,
+ popup_location_changed_cb, daemon,
+ NULL, NULL);
- /* Emit signal to verify/set current key */
- gconf_client_notify(gconf_client, GCONF_KEY_POPUP_LOCATION);
+ /* Emit signal to verify/set current key */
+ gconf_client_notify(gconf_client, GCONF_KEY_POPUP_LOCATION);
- dbus_g_connection_register_g_object(connection,
- "/org/freedesktop/Notifications",
- G_OBJECT(daemon));
+ dbus_g_connection_register_g_object(connection,
+ "/org/freedesktop/Notifications",
+ G_OBJECT(daemon));
- gtk_main();
+ gtk_main();
- g_object_unref(G_OBJECT(gconf_client));
+ g_object_unref(G_OBJECT(gconf_client));
- return 0;
+ return 0;
}
diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h
index 8bd61ce..43378eb 100644
--- a/src/daemon/daemon.h
+++ b/src/daemon/daemon.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* daemon.h - Implementation of the destop notification spec
*
@@ -38,31 +38,31 @@
#define NOTIFY_TYPE_DAEMON (notify_daemon_get_type())
#define NOTIFY_DAEMON(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), NOTIFY_TYPE_DAEMON, NotifyDaemon))
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), NOTIFY_TYPE_DAEMON, NotifyDaemon))
#define NOTIFY_DAEMON_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), NOTIFY_TYPE_DAEMON, NotifyDaemonClass))
+ (G_TYPE_CHECK_CLASS_CAST ((klass), NOTIFY_TYPE_DAEMON, NotifyDaemonClass))
#define NOTIFY_IS_DAEMON(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NOTIFY_TYPE_DAEMON))
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NOTIFY_TYPE_DAEMON))
#define NOTIFY_IS_DAEMON_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), NOTIFY_TYPE_DAEMON))
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), NOTIFY_TYPE_DAEMON))
#define NOTIFY_DAEMON_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), NOTIFY_TYPE_DAEMON, NotifyDaemonClass))
+ (G_TYPE_INSTANCE_GET_CLASS((obj), NOTIFY_TYPE_DAEMON, NotifyDaemonClass))
#define NOTIFY_DAEMON_DEFAULT_TIMEOUT 7000
enum
{
- URGENCY_LOW,
- URGENCY_NORMAL,
- URGENCY_CRITICAL
+ URGENCY_LOW,
+ URGENCY_NORMAL,
+ URGENCY_CRITICAL
};
typedef enum
{
- NOTIFYD_CLOSED_EXPIRED = 1,
- NOTIFYD_CLOSED_USER = 2,
- NOTIFYD_CLOSED_API = 3,
- NOTIFYD_CLOSED_RESERVED = 4
+ NOTIFYD_CLOSED_EXPIRED = 1,
+ NOTIFYD_CLOSED_USER = 2,
+ NOTIFYD_CLOSED_API = 3,
+ NOTIFYD_CLOSED_RESERVED = 4
} NotifydClosedReason;
@@ -72,15 +72,15 @@ typedef struct _NotifyDaemonPrivate NotifyDaemonPrivate;
struct _NotifyDaemon
{
- GObject parent;
+ GObject parent;
- /*< private > */
- NotifyDaemonPrivate *priv;
+ /*< private > */
+ NotifyDaemonPrivate *priv;
};
struct _NotifyDaemonClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
G_BEGIN_DECLS
@@ -90,28 +90,28 @@ GType notify_daemon_get_type(void);
GQuark notify_daemon_error_quark(void);
gboolean notify_daemon_notify_handler(NotifyDaemon *daemon,
- const gchar *app_name,
- guint id,
- const gchar *icon,
- const gchar *summary,
- const gchar *body,
- gchar **actions,
- GHashTable *hints,
- int timeout,
- DBusGMethodInvocation *context);
+ const gchar *app_name,
+ guint id,
+ const gchar *icon,
+ const gchar *summary,
+ const gchar *body,
+ gchar **actions,
+ GHashTable *hints,
+ int timeout,
+ DBusGMethodInvocation *context);
gboolean notify_daemon_close_notification_handler(NotifyDaemon *daemon,
- guint id,
- GError **error);
+ guint id,
+ GError **error);
gboolean notify_daemon_get_capabilities(NotifyDaemon *daemon,
- char ***out_caps);
+ char ***out_caps);
gboolean notify_daemon_get_server_information(NotifyDaemon *daemon,
- char **out_name,
- char **out_vendor,
- char **out_version,
- char **out_spec_ver);
+ char **out_name,
+ char **out_vendor,
+ char **out_version,
+ char **out_spec_ver);
GConfClient *get_gconf_client(void);
diff --git a/src/daemon/engines.c b/src/daemon/engines.c
index 31e0b33..7fbc7be 100644
--- a/src/daemon/engines.c
+++ b/src/daemon/engines.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
#include "config.h"
@@ -8,33 +8,33 @@
typedef struct
{
- GModule *module;
- guint ref_count;
-
- 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);
- GtkWindow *(*create_notification)(UrlClickedCb url_clicked_cb);
- 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_text)(GtkWindow *nw, const char *summary,
+ GModule *module;
+ guint ref_count;
+
+ 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);
+ GtkWindow *(*create_notification)(UrlClickedCb url_clicked_cb);
+ 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_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,
+ void (*set_notification_icon)(GtkWindow *nw, GdkPixbuf *pixbuf);
+ void (*set_notification_arrow)(GtkWindow *nw, gboolean visible,
int x, int y);
- void (*add_notification_action)(GtkWindow *nw, const char *label,
+ void (*add_notification_action)(GtkWindow *nw, const char *label,
const char *key, GCallback cb);
- void (*clear_notification_actions)(GtkWindow *nw);
- void (*move_notification)(GtkWindow *nw, int x, int y);
- void (*set_notification_timeout)(GtkWindow *nw, glong timeout);
- void (*notification_tick)(GtkWindow *nw, glong timeout);
- gboolean (*get_always_stack)(GtkWindow *nw);
+ void (*clear_notification_actions)(GtkWindow *nw);
+ void (*move_notification)(GtkWindow *nw, int x, int y);
+ void (*set_notification_timeout)(GtkWindow *nw, glong timeout);
+ void (*notification_tick)(GtkWindow *nw, glong timeout);
+ gboolean (*get_always_stack)(GtkWindow *nw);
} ThemeEngine;
@@ -44,229 +44,229 @@ static ThemeEngine *active_engine = NULL;
static ThemeEngine *
load_theme_engine(const char *name)
{
- ThemeEngine *engine;
- char *filename;
- char *path;
+ ThemeEngine *engine;
+ char *filename;
+ char *path;
- filename = g_strdup_printf("lib%s.so", name);
- path = g_build_filename(ENGINES_DIR, filename, NULL);
- g_free(filename);
+ filename = g_strdup_printf("lib%s.so", name);
+ path = g_build_filename(ENGINES_DIR, filename, NULL);
+ g_free(filename);
- engine = g_new0(ThemeEngine, 1);
- engine->ref_count = 1;
- engine->module = g_module_open(path, G_MODULE_BIND_LAZY);
+ engine = g_new0(ThemeEngine, 1);
+ engine->ref_count = 1;
+ engine->module = g_module_open(path, G_MODULE_BIND_LAZY);
- g_free(path);
+ g_free(path);
- if (engine->module == NULL)
- goto error;
+ if (engine->module == NULL)
+ goto error;
#define BIND_REQUIRED_FUNC(name) \
- if (!g_module_symbol(engine->module, #name, (gpointer *)&engine->name)) \
- { \
- /* Too harsh! Fall back to default. */ \
- g_warning("Theme doesn't provide the required function '%s'", #name); \
- goto error; \
- }
+ if (!g_module_symbol(engine->module, #name, (gpointer *)&engine->name)) \
+ { \
+ /* Too harsh! Fall back to default. */ \
+ g_warning("Theme doesn't provide the required function '%s'", #name); \
+ goto error; \
+ }
#define BIND_OPTIONAL_FUNC(name) \
- g_module_symbol(engine->module, #name, (gpointer *)&engine->name);
-
- BIND_REQUIRED_FUNC(theme_check_init);
- BIND_REQUIRED_FUNC(get_theme_info);
- BIND_REQUIRED_FUNC(create_notification);
- BIND_REQUIRED_FUNC(set_notification_text);
- BIND_REQUIRED_FUNC(set_notification_icon);
- BIND_REQUIRED_FUNC(set_notification_arrow);
- BIND_REQUIRED_FUNC(add_notification_action);
- BIND_REQUIRED_FUNC(clear_notification_actions);
- BIND_REQUIRED_FUNC(move_notification);
-
- BIND_OPTIONAL_FUNC(destroy_notification);
- BIND_OPTIONAL_FUNC(show_notification);
- BIND_OPTIONAL_FUNC(hide_notification);
- BIND_OPTIONAL_FUNC(set_notification_timeout);
- BIND_OPTIONAL_FUNC(set_notification_hints);
- BIND_OPTIONAL_FUNC(notification_tick);
- BIND_OPTIONAL_FUNC(get_always_stack);
-
- if (!engine->theme_check_init(NOTIFICATION_DAEMON_MAJOR_VERSION,
- NOTIFICATION_DAEMON_MINOR_VERSION,
- NOTIFICATION_DAEMON_MICRO_VERSION))
- {
- g_warning("Theme doesn't work with this version of notification-daemon");
- goto error;
- }
-
- return engine;
+ g_module_symbol(engine->module, #name, (gpointer *)&engine->name);
+
+ BIND_REQUIRED_FUNC(theme_check_init);
+ BIND_REQUIRED_FUNC(get_theme_info);
+ BIND_REQUIRED_FUNC(create_notification);
+ BIND_REQUIRED_FUNC(set_notification_text);
+ BIND_REQUIRED_FUNC(set_notification_icon);
+ BIND_REQUIRED_FUNC(set_notification_arrow);
+ BIND_REQUIRED_FUNC(add_notification_action);
+ BIND_REQUIRED_FUNC(clear_notification_actions);
+ BIND_REQUIRED_FUNC(move_notification);
+
+ BIND_OPTIONAL_FUNC(destroy_notification);
+ BIND_OPTIONAL_FUNC(show_notification);
+ BIND_OPTIONAL_FUNC(hide_notification);
+ BIND_OPTIONAL_FUNC(set_notification_timeout);
+ BIND_OPTIONAL_FUNC(set_notification_hints);
+ BIND_OPTIONAL_FUNC(notification_tick);
+ BIND_OPTIONAL_FUNC(get_always_stack);
+
+ if (!engine->theme_check_init(NOTIFICATION_DAEMON_MAJOR_VERSION,
+ NOTIFICATION_DAEMON_MINOR_VERSION,
+ NOTIFICATION_DAEMON_MICRO_VERSION))
+ {
+ g_warning("Theme doesn't work with this version of notification-daemon");
+ goto error;
+ }
+
+ return engine;
error:
- if (engine->module != NULL && !g_module_close(engine->module))
- g_warning("%s: %s", filename, g_module_error());
+ if (engine->module != NULL && !g_module_close(engine->module))
+ g_warning("%s: %s", filename, g_module_error());
- g_free(engine);
- return NULL;
+ g_free(engine);
+ return NULL;
}
static void
destroy_engine(ThemeEngine *engine)
{
- g_assert(engine->ref_count == 0);
+ g_assert(engine->ref_count == 0);
- if (active_engine == engine)
- active_engine = NULL;
+ if (active_engine == engine)
+ active_engine = NULL;
- g_module_close(engine->module);
- g_free(engine);
+ g_module_close(engine->module);
+ g_free(engine);
}
static gboolean
theme_engine_destroy(ThemeEngine *engine)
{
- destroy_engine(engine);
- return FALSE;
+ destroy_engine(engine);
+ return FALSE;
}
static void
theme_engine_unref(ThemeEngine *engine)
{
- engine->ref_count--;
-
- if (engine->ref_count == 0)
- /*
- * Destroy the engine in an idle loop since the last reference
- * might have been the one of a notification which is being
- * destroyed and that still has references to the engine
- * module. This way, we're sure the notification is completely
- * destroyed before the engine is.
- */
- g_idle_add((GSourceFunc) theme_engine_destroy, engine);
+ engine->ref_count--;
+
+ if (engine->ref_count == 0)
+ /*
+ * Destroy the engine in an idle loop since the last reference
+ * might have been the one of a notification which is being
+ * destroyed and that still has references to the engine
+ * module. This way, we're sure the notification is completely
+ * destroyed before the engine is.
+ */
+ g_idle_add((GSourceFunc) theme_engine_destroy, engine);
}
static void
theme_changed_cb(GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
{
- if (active_engine == NULL)
- return;
+ if (active_engine == NULL)
+ return;
- theme_engine_unref(active_engine);
+ theme_engine_unref(active_engine);
- /* This is no longer the true active engine, so reset this. */
- active_engine = NULL;
+ /* This is no longer the true active engine, so reset this. */
+ active_engine = NULL;
}
static ThemeEngine *
get_theme_engine(void)
{
- if (active_engine == NULL)
- {
- GConfClient *client = get_gconf_client();
- char *enginename = gconf_client_get_string(client, GCONF_KEY_THEME,
- NULL);
-
- if (theme_prop_notify_id == 0)
- {
- theme_prop_notify_id = gconf_client_notify_add(client,
- "/apps/notification-daemon/theme", theme_changed_cb, NULL,
- NULL, NULL);
- }
-
- if (enginename == NULL)
- {
- active_engine = load_theme_engine("standard");
- g_assert(active_engine != NULL);
- }
- else
- {
- active_engine = load_theme_engine(enginename);
-
- if (active_engine == NULL)
- {
- g_warning("Unable to load theme engine '%s'", enginename);
- active_engine = load_theme_engine("standard");
- }
-
- g_free(enginename);
-
- g_assert(active_engine != NULL);
- }
- }
-
- return active_engine;
+ if (active_engine == NULL)
+ {
+ GConfClient *client = get_gconf_client();
+ char *enginename = gconf_client_get_string(client, GCONF_KEY_THEME,
+ NULL);
+
+ if (theme_prop_notify_id == 0)
+ {
+ theme_prop_notify_id = gconf_client_notify_add(client,
+ "/apps/notification-daemon/theme", theme_changed_cb, NULL,
+ NULL, NULL);
+ }
+
+ if (enginename == NULL)
+ {
+ active_engine = load_theme_engine("standard");
+ g_assert(active_engine != NULL);
+ }
+ else
+ {
+ active_engine = load_theme_engine(enginename);
+
+ if (active_engine == NULL)
+ {
+ g_warning("Unable to load theme engine '%s'", enginename);
+ active_engine = load_theme_engine("standard");
+ }
+
+ g_free(enginename);
+
+ g_assert(active_engine != NULL);
+ }
+ }
+
+ return active_engine;
}
GtkWindow *
theme_create_notification(UrlClickedCb url_clicked_cb)
{
- ThemeEngine *engine = get_theme_engine();
- GtkWindow *nw = engine->create_notification(url_clicked_cb);
- g_object_set_data_full(G_OBJECT(nw), "_theme_engine", engine,
- (GDestroyNotify)theme_engine_unref);
- engine->ref_count++;
- return nw;
+ ThemeEngine *engine = get_theme_engine();
+ GtkWindow *nw = engine->create_notification(url_clicked_cb);
+ g_object_set_data_full(G_OBJECT(nw), "_theme_engine", engine,
+ (GDestroyNotify)theme_engine_unref);
+ engine->ref_count++;
+ return nw;
}
void
theme_destroy_notification(GtkWindow *nw)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- if (engine->destroy_notification != NULL)
- engine->destroy_notification(nw);
- else
- gtk_widget_destroy(GTK_WIDGET(nw));
+ if (engine->destroy_notification != NULL)
+ engine->destroy_notification(nw);
+ else
+ gtk_widget_destroy(GTK_WIDGET(nw));
}
void
theme_show_notification(GtkWindow *nw)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- if (engine->show_notification != NULL)
- engine->show_notification(nw);
- else
- gtk_widget_show(GTK_WIDGET(nw));
+ if (engine->show_notification != NULL)
+ engine->show_notification(nw);
+ else
+ gtk_widget_show(GTK_WIDGET(nw));
}
void
theme_hide_notification(GtkWindow *nw)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- if (engine->hide_notification != NULL)
- engine->hide_notification(nw);
- else
- gtk_widget_hide(GTK_WIDGET(nw));
+ if (engine->hide_notification != NULL)
+ engine->hide_notification(nw);
+ else
+ gtk_widget_hide(GTK_WIDGET(nw));
}
void
theme_set_notification_hints(GtkWindow *nw, GHashTable *hints)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- if (engine->set_notification_hints != NULL)
- engine->set_notification_hints(nw, hints);
+ if (engine->set_notification_hints != NULL)
+ engine->set_notification_hints(nw, hints);
}
void
theme_set_notification_timeout(GtkWindow *nw, glong timeout)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- if (engine->set_notification_timeout != NULL)
- engine->set_notification_timeout(nw, timeout);
+ if (engine->set_notification_timeout != NULL)
+ engine->set_notification_timeout(nw, timeout);
}
void
theme_notification_tick(GtkWindow *nw, glong remaining)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- if (engine->notification_tick != NULL)
- engine->notification_tick(nw, remaining);
+ if (engine->notification_tick != NULL)
+ engine->notification_tick(nw, remaining);
}
void
@@ -274,55 +274,55 @@ theme_set_notification_text(GtkWindow *nw,
const char *summary,
const char *body)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- engine->set_notification_text(nw, summary, body);
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ engine->set_notification_text(nw, summary, body);
}
void
theme_set_notification_icon(GtkWindow *nw, GdkPixbuf *pixbuf)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- engine->set_notification_icon(nw, pixbuf);
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ engine->set_notification_icon(nw, pixbuf);
}
void
theme_set_notification_arrow(GtkWindow *nw, gboolean visible, int x, int y)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- engine->set_notification_arrow(nw, visible, x, y);
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ engine->set_notification_arrow(nw, visible, x, y);
}
void
theme_add_notification_action(GtkWindow *nw,
- const char *label,
- const char *key,
- GCallback cb)
+ const char *label,
+ const char *key,
+ GCallback cb)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- engine->add_notification_action(nw, label, key, cb);
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ engine->add_notification_action(nw, label, key, cb);
}
void
theme_clear_notification_actions(GtkWindow *nw)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- engine->clear_notification_actions(nw);
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ engine->clear_notification_actions(nw);
}
void
theme_move_notification(GtkWindow *nw, int x, int y)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- engine->move_notification(nw, x, y);
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ engine->move_notification(nw, x, y);
}
gboolean
theme_get_always_stack(GtkWindow *nw)
{
- ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+ ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
- if (engine->get_always_stack != NULL)
- return engine->get_always_stack(nw);
- else
- return FALSE;
+ if (engine->get_always_stack != NULL)
+ return engine->get_always_stack(nw);
+ else
+ return FALSE;
}
diff --git a/src/daemon/engines.h b/src/daemon/engines.h
index 8f875c0..8325338 100644
--- a/src/daemon/engines.h
+++ b/src/daemon/engines.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
#ifndef _ENGINES_H_
#define _ENGINES_H_
@@ -15,17 +15,17 @@ void theme_set_notification_hints(GtkWindow *nw, GHashTable *hints);
void theme_set_notification_timeout(GtkWindow *nw, glong timeout);
void theme_notification_tick(GtkWindow *nw, glong remaining);
void theme_set_notification_text(GtkWindow *nw,
- const char *summary,
- const char *body);
+ const char *summary,
+ const char *body);
void theme_set_notification_icon(GtkWindow *nw, GdkPixbuf *pixbuf);
void theme_set_notification_arrow(GtkWindow *nw,
- gboolean visible,
- int x,
- int y);
+ gboolean visible,
+ int x,
+ int y);
void theme_add_notification_action(GtkWindow *nw,
- const char *label,
- const char *key,
- GCallback cb);
+ const char *label,
+ const char *key,
+ GCallback cb);
void theme_clear_notification_actions(GtkWindow *nw);
void theme_move_notification(GtkWindow *nw, int x, int y);
gboolean theme_get_always_stack(GtkWindow *nw);
diff --git a/src/daemon/sound.c b/src/daemon/sound.c
index a524e98..fa83121 100644
--- a/src/daemon/sound.c
+++ b/src/daemon/sound.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* sound.c - Sound support portion of the destop notification spec
*
@@ -28,12 +28,12 @@
void
sound_play_file(GtkWidget *widget,
- const char *filename)
+ const char *filename)
{
- ca_gtk_play_for_widget (widget, 0,
- CA_PROP_MEDIA_ROLE, "event",
- CA_PROP_MEDIA_FILENAME, filename,
- CA_PROP_EVENT_DESCRIPTION, _("Notification"),
- NULL);
+ ca_gtk_play_for_widget (widget, 0,
+ CA_PROP_MEDIA_ROLE, "event",
+ CA_PROP_MEDIA_FILENAME, filename,
+ CA_PROP_EVENT_DESCRIPTION, _("Notification"),
+ NULL);
}
diff --git a/src/daemon/sound.h b/src/daemon/sound.h
index ca687b3..bf52f17 100644
--- a/src/daemon/sound.h
+++ b/src/daemon/sound.h
@@ -1,5 +1,4 @@
-/*
- * sound.h - Sound support portion of the destop notification spec
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 Jim Ramsay <i am jimramsay com>
*
diff --git a/src/daemon/stack.c b/src/daemon/stack.c
index 2ad65df..ec3d377 100644
--- a/src/daemon/stack.c
+++ b/src/daemon/stack.c
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* stack.c - Notification stack groups.
*
@@ -33,256 +33,256 @@
struct _NotifyStack
{
- NotifyDaemon *daemon;
- GdkScreen *screen;
- guint monitor;
- NotifyStackLocation location;
- GSList *windows;
+ NotifyDaemon *daemon;
+ GdkScreen *screen;
+ guint monitor;
+ NotifyStackLocation location;
+ GSList *windows;
};
static gboolean
get_work_area(GtkWidget *nw, GdkRectangle *rect)
{
- Atom workarea = XInternAtom(GDK_DISPLAY(), "_NET_WORKAREA", True);
- Atom type;
- Window win;
- int format;
- gulong num, leftovers;
- gulong max_len = 4 * 32;
- guchar *ret_workarea;
- long *workareas;
- int result;
- GdkScreen *screen;
- int disp_screen;
-
- gtk_widget_realize(nw);
- screen = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window));
- disp_screen = GDK_SCREEN_XNUMBER(screen);
-
- /* Defaults in case of error */
- rect->x = 0;
- rect->y = 0;
- rect->width = gdk_screen_get_width(screen);
- rect->height = gdk_screen_get_height(screen);
-
- if (workarea == None)
- return FALSE;
-
- win = XRootWindow(GDK_DISPLAY(), disp_screen);
- result = XGetWindowProperty(GDK_DISPLAY(), win, workarea, 0,
- max_len, False, AnyPropertyType,
- &type, &format, &num, &leftovers,
- &ret_workarea);
-
- if (result != Success || type == None || format == 0 || leftovers ||
- num % 4)
- {
- return FALSE;
- }
-
- workareas = (long *)ret_workarea;
- rect->x = workareas[disp_screen * 4];
- rect->y = workareas[disp_screen * 4 + 1];
- rect->width = workareas[disp_screen * 4 + 2];
- rect->height = workareas[disp_screen * 4 + 3];
-
- XFree(ret_workarea);
-
- return TRUE;
+ Atom workarea = XInternAtom(GDK_DISPLAY(), "_NET_WORKAREA", True);
+ Atom type;
+ Window win;
+ int format;
+ gulong num, leftovers;
+ gulong max_len = 4 * 32;
+ guchar *ret_workarea;
+ long *workareas;
+ int result;
+ GdkScreen *screen;
+ int disp_screen;
+
+ gtk_widget_realize(nw);
+ screen = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window));
+ disp_screen = GDK_SCREEN_XNUMBER(screen);
+
+ /* Defaults in case of error */
+ rect->x = 0;
+ rect->y = 0;
+ rect->width = gdk_screen_get_width(screen);
+ rect->height = gdk_screen_get_height(screen);
+
+ if (workarea == None)
+ return FALSE;
+
+ win = XRootWindow(GDK_DISPLAY(), disp_screen);
+ result = XGetWindowProperty(GDK_DISPLAY(), win, workarea, 0,
+ max_len, False, AnyPropertyType,
+ &type, &format, &num, &leftovers,
+ &ret_workarea);
+
+ if (result != Success || type == None || format == 0 || leftovers ||
+ num % 4)
+ {
+ return FALSE;
+ }
+
+ workareas = (long *)ret_workarea;
+ rect->x = workareas[disp_screen * 4];
+ rect->y = workareas[disp_screen * 4 + 1];
+ rect->width = workareas[disp_screen * 4 + 2];
+ rect->height = workareas[disp_screen * 4 + 3];
+
+ XFree(ret_workarea);
+
+ return TRUE;
}
static void
get_origin_coordinates(NotifyStackLocation stack_location,
- GdkRectangle *workarea,
- gint *x, gint *y,
- gint *shiftx, gint *shifty,
- gint width, gint height)
+ GdkRectangle *workarea,
+ gint *x, gint *y,
+ gint *shiftx, gint *shifty,
+ gint width, gint height)
{
- switch (stack_location)
- {
- case NOTIFY_STACK_LOCATION_TOP_LEFT:
- *x = workarea->x;
- *y = workarea->y;
- *shifty = height;
- break;
-
- case NOTIFY_STACK_LOCATION_TOP_RIGHT:
- *x = workarea->x + workarea->width - width;
- *y = workarea->y;
- *shifty = height;
- break;
-
- case NOTIFY_STACK_LOCATION_BOTTOM_LEFT:
- *x = workarea->x;
- *y = workarea->y + workarea->height - height;
- break;
-
- case NOTIFY_STACK_LOCATION_BOTTOM_RIGHT:
- *x = workarea->x + workarea->width - width;
- *y = workarea->y + workarea->height - height;
- break;
-
- default:
- g_assert_not_reached();
- }
+ switch (stack_location)
+ {
+ case NOTIFY_STACK_LOCATION_TOP_LEFT:
+ *x = workarea->x;
+ *y = workarea->y;
+ *shifty = height;
+ break;
+
+ case NOTIFY_STACK_LOCATION_TOP_RIGHT:
+ *x = workarea->x + workarea->width - width;
+ *y = workarea->y;
+ *shifty = height;
+ break;
+
+ case NOTIFY_STACK_LOCATION_BOTTOM_LEFT:
+ *x = workarea->x;
+ *y = workarea->y + workarea->height - height;
+ break;
+
+ case NOTIFY_STACK_LOCATION_BOTTOM_RIGHT:
+ *x = workarea->x + workarea->width - width;
+ *y = workarea->y + workarea->height - height;
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
}
static void
translate_coordinates(NotifyStackLocation stack_location,
- GdkRectangle *workarea,
- gint *x, gint *y,
- gint *shiftx, gint *shifty,
- gint width, gint height,
- gint index)
+ GdkRectangle *workarea,
+ gint *x, gint *y,
+ gint *shiftx, gint *shifty,
+ gint width, gint height,
+ gint index)
{
- switch (stack_location)
- {
- case NOTIFY_STACK_LOCATION_TOP_LEFT:
- *x = workarea->x;
- *y += *shifty;
- *shifty = height;
- break;
-
- case NOTIFY_STACK_LOCATION_TOP_RIGHT:
- *x = workarea->x + workarea->width - width;
- *y += *shifty;
- *shifty = height;
- break;
-
- case NOTIFY_STACK_LOCATION_BOTTOM_LEFT:
- *x = workarea->x;
- *y -= height;
- break;
-
- case NOTIFY_STACK_LOCATION_BOTTOM_RIGHT:
- *x = workarea->x + workarea->width - width;
- *y -= height;
- break;
-
- default:
- g_assert_not_reached();
- }
+ switch (stack_location)
+ {
+ case NOTIFY_STACK_LOCATION_TOP_LEFT:
+ *x = workarea->x;
+ *y += *shifty;
+ *shifty = height;
+ break;
+
+ case NOTIFY_STACK_LOCATION_TOP_RIGHT:
+ *x = workarea->x + workarea->width - width;
+ *y += *shifty;
+ *shifty = height;
+ break;
+
+ case NOTIFY_STACK_LOCATION_BOTTOM_LEFT:
+ *x = workarea->x;
+ *y -= height;
+ break;
+
+ case NOTIFY_STACK_LOCATION_BOTTOM_RIGHT:
+ *x = workarea->x + workarea->width - width;
+ *y -= height;
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
}
NotifyStack *
notify_stack_new(NotifyDaemon *daemon,
- GdkScreen *screen,
- guint monitor,
- NotifyStackLocation location)
+ GdkScreen *screen,
+ guint monitor,
+ NotifyStackLocation location)
{
- NotifyStack *stack;
+ NotifyStack *stack;
- g_assert(daemon != NULL);
- g_assert(screen != NULL && GDK_IS_SCREEN(screen));
- g_assert(monitor < gdk_screen_get_n_monitors(screen));
- g_assert(location != NOTIFY_STACK_LOCATION_UNKNOWN);
+ g_assert(daemon != NULL);
+ g_assert(screen != NULL && GDK_IS_SCREEN(screen));
+ g_assert(monitor < gdk_screen_get_n_monitors(screen));
+ g_assert(location != NOTIFY_STACK_LOCATION_UNKNOWN);
- stack = g_new0(NotifyStack, 1);
- stack->daemon = daemon;
- stack->screen = screen;
- stack->monitor = monitor;
- stack->location = location;
+ stack = g_new0(NotifyStack, 1);
+ stack->daemon = daemon;
+ stack->screen = screen;
+ stack->monitor = monitor;
+ stack->location = location;
- return stack;
+ return stack;
}
void
notify_stack_destroy(NotifyStack *stack)
{
- g_assert(stack != NULL);
+ g_assert(stack != NULL);
- g_slist_free(stack->windows);
- g_free(stack);
+ g_slist_free(stack->windows);
+ g_free(stack);
}
void
notify_stack_set_location(NotifyStack *stack,
- NotifyStackLocation location)
+ NotifyStackLocation location)
{
- stack->location = location;
+ stack->location = location;
}
static void
notify_stack_shift_notifications(NotifyStack *stack,
- GtkWindow *nw,
- GSList **nw_l,
- gint init_width,
- gint init_height,
- gint *nw_x,
- gint *nw_y)
+ GtkWindow *nw,
+ GSList **nw_l,
+ gint init_width,
+ gint init_height,
+ gint *nw_x,
+ gint *nw_y)
{
- GdkRectangle workarea;
- GdkRectangle monitor;
- GSList *l;
- gint x, y, shiftx = 0, shifty = 0, index = 1;
-
- get_work_area(GTK_WIDGET(nw), &workarea);
- gdk_screen_get_monitor_geometry (stack->screen, stack->monitor, &monitor);
- gdk_rectangle_intersect (&monitor, &workarea, &workarea);
-
- get_origin_coordinates(stack->location, &workarea, &x, &y,
- &shiftx, &shifty, init_width, init_height);
-
- if (nw_x != NULL)
- *nw_x = x;
-
- if (nw_y != NULL)
- *nw_y = y;
-
- for (l = stack->windows; l != NULL; l = l->next)
- {
- GtkWindow *nw2 = GTK_WINDOW(l->data);
- GtkRequisition req;
-
- if (nw2 != nw)
- {
- gtk_widget_size_request(GTK_WIDGET(nw2), &req);
-
- translate_coordinates(stack->location, &workarea, &x, &y,
- &shiftx, &shifty, req.width + NOTIFY_STACK_SPACING, req.height + NOTIFY_STACK_SPACING,
- index++);
- theme_move_notification(nw2, x, y);
- }
- else if (nw_l != NULL)
- {
- *nw_l = l;
- }
- }
+ GdkRectangle workarea;
+ GdkRectangle monitor;
+ GSList *l;
+ gint x, y, shiftx = 0, shifty = 0, index = 1;
+
+ get_work_area(GTK_WIDGET(nw), &workarea);
+ gdk_screen_get_monitor_geometry (stack->screen, stack->monitor, &monitor);
+ gdk_rectangle_intersect (&monitor, &workarea, &workarea);
+
+ get_origin_coordinates(stack->location, &workarea, &x, &y,
+ &shiftx, &shifty, init_width, init_height);
+
+ if (nw_x != NULL)
+ *nw_x = x;
+
+ if (nw_y != NULL)
+ *nw_y = y;
+
+ for (l = stack->windows; l != NULL; l = l->next)
+ {
+ GtkWindow *nw2 = GTK_WINDOW(l->data);
+ GtkRequisition req;
+
+ if (nw2 != nw)
+ {
+ gtk_widget_size_request(GTK_WIDGET(nw2), &req);
+
+ translate_coordinates(stack->location, &workarea, &x, &y,
+ &shiftx, &shifty, req.width + NOTIFY_STACK_SPACING, req.height + NOTIFY_STACK_SPACING,
+ index++);
+ theme_move_notification(nw2, x, y);
+ }
+ else if (nw_l != NULL)
+ {
+ *nw_l = l;
+ }
+ }
}
void
notify_stack_add_window(NotifyStack *stack,
- GtkWindow *nw,
- gboolean new_notification)
+ GtkWindow *nw,
+ gboolean new_notification)
{
- GtkRequisition req;
- gint x, y;
-
- gtk_widget_size_request(GTK_WIDGET(nw), &req);
- notify_stack_shift_notifications(stack, nw, NULL,
- req.width + NOTIFY_STACK_SPACING, req.height + NOTIFY_STACK_SPACING, &x, &y);
- theme_move_notification(nw, x, y);
-
- if (new_notification)
- {
- g_signal_connect_swapped(G_OBJECT(nw), "destroy",
- G_CALLBACK(notify_stack_remove_window),
- stack);
- stack->windows = g_slist_prepend(stack->windows, nw);
- }
+ GtkRequisition req;
+ gint x, y;
+
+ gtk_widget_size_request(GTK_WIDGET(nw), &req);
+ notify_stack_shift_notifications(stack, nw, NULL,
+ req.width + NOTIFY_STACK_SPACING, req.height + NOTIFY_STACK_SPACING, &x, &y);
+ theme_move_notification(nw, x, y);
+
+ if (new_notification)
+ {
+ g_signal_connect_swapped(G_OBJECT(nw), "destroy",
+ G_CALLBACK(notify_stack_remove_window),
+ stack);
+ stack->windows = g_slist_prepend(stack->windows, nw);
+ }
}
void
notify_stack_remove_window(NotifyStack *stack,
- GtkWindow *nw)
+ GtkWindow *nw)
{
- GSList *remove_l = NULL;
+ GSList *remove_l = NULL;
- notify_stack_shift_notifications(stack, nw, &remove_l, 0, 0, NULL, NULL);
+ notify_stack_shift_notifications(stack, nw, &remove_l, 0, 0, NULL, NULL);
- if (remove_l != NULL)
- stack->windows = g_slist_delete_link(stack->windows, remove_l);
+ if (remove_l != NULL)
+ stack->windows = g_slist_delete_link(stack->windows, remove_l);
- if (GTK_WIDGET_REALIZED(GTK_WIDGET(nw)))
- gtk_widget_unrealize(GTK_WIDGET(nw));
+ if (GTK_WIDGET_REALIZED(GTK_WIDGET(nw)))
+ gtk_widget_unrealize(GTK_WIDGET(nw));
}
diff --git a/src/daemon/stack.h b/src/daemon/stack.h
index c35ac45..d7c8429 100644
--- a/src/daemon/stack.h
+++ b/src/daemon/stack.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* stack.h - Notification stack groups.
*
@@ -27,29 +27,29 @@
typedef enum
{
- NOTIFY_STACK_LOCATION_UNKNOWN = -1,
- NOTIFY_STACK_LOCATION_TOP_LEFT,
- NOTIFY_STACK_LOCATION_TOP_RIGHT,
- NOTIFY_STACK_LOCATION_BOTTOM_LEFT,
- NOTIFY_STACK_LOCATION_BOTTOM_RIGHT,
- NOTIFY_STACK_LOCATION_DEFAULT = NOTIFY_STACK_LOCATION_BOTTOM_RIGHT
+ NOTIFY_STACK_LOCATION_UNKNOWN = -1,
+ NOTIFY_STACK_LOCATION_TOP_LEFT,
+ NOTIFY_STACK_LOCATION_TOP_RIGHT,
+ NOTIFY_STACK_LOCATION_BOTTOM_LEFT,
+ NOTIFY_STACK_LOCATION_BOTTOM_RIGHT,
+ NOTIFY_STACK_LOCATION_DEFAULT = NOTIFY_STACK_LOCATION_BOTTOM_RIGHT
} NotifyStackLocation;
typedef struct _NotifyStack NotifyStack;
NotifyStack *notify_stack_new(NotifyDaemon *daemon,
- GdkScreen *screen,
- guint monitor,
- NotifyStackLocation stack_location);
+ GdkScreen *screen,
+ guint monitor,
+ NotifyStackLocation stack_location);
void notify_stack_destroy(NotifyStack *stack);
void notify_stack_set_location(NotifyStack *stack,
- NotifyStackLocation location);
+ NotifyStackLocation location);
void notify_stack_add_window(NotifyStack *stack,
- GtkWindow *nw,
- gboolean new_notification);
+ GtkWindow *nw,
+ gboolean new_notification);
void notify_stack_remove_window(NotifyStack *stack,
- GtkWindow *nw);
+ GtkWindow *nw);
#endif /* _NOTIFY_STACK_H_ */
diff --git a/src/themes/bubble/theme.c b/src/themes/bubble/theme.c
index cddf419..5f15656 100644
--- a/src/themes/bubble/theme.c
+++ b/src/themes/bubble/theme.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+
#include <gtk/gtk.h>
#include "eggnotificationbubblewidget.h"
@@ -6,75 +8,75 @@ typedef void (*ActionInvokedCb)(GtkWindow *nw, const char *key);
GtkWindow *
create_notification(void)
{
- return GTK_WINDOW(egg_notification_bubble_widget_new());
+ return GTK_WINDOW(egg_notification_bubble_widget_new());
}
void
show_notification(GtkWindow *nw)
{
- egg_notification_bubble_widget_show(EGG_NOTIFICATION_BUBBLE_WIDGET(nw));
+ egg_notification_bubble_widget_show(EGG_NOTIFICATION_BUBBLE_WIDGET(nw));
}
void
hide_notification(GtkWindow *nw)
{
- egg_notification_bubble_widget_hide(EGG_NOTIFICATION_BUBBLE_WIDGET(nw));
+ egg_notification_bubble_widget_hide(EGG_NOTIFICATION_BUBBLE_WIDGET(nw));
}
void
set_notification_hints(GtkWindow *nw, GHashTable *hints)
{
- egg_notification_bubble_widget_set_hints(
- EGG_NOTIFICATION_BUBBLE_WIDGET(nw), hints);
+ egg_notification_bubble_widget_set_hints(
+ EGG_NOTIFICATION_BUBBLE_WIDGET(nw), hints);
}
void
set_notification_text(GtkWindow *nw, const char *summary, const char *body)
{
- egg_notification_bubble_widget_set(EGG_NOTIFICATION_BUBBLE_WIDGET(nw),
- summary, NULL, body);
+ egg_notification_bubble_widget_set(EGG_NOTIFICATION_BUBBLE_WIDGET(nw),
+ summary, NULL, body);
}
void
set_notification_icon(GtkWindow *nw, GdkPixbuf *pixbuf)
{
- EggNotificationBubbleWidget *bubble = EGG_NOTIFICATION_BUBBLE_WIDGET(nw);
+ EggNotificationBubbleWidget *bubble = EGG_NOTIFICATION_BUBBLE_WIDGET(nw);
- gtk_image_set_from_pixbuf(GTK_IMAGE(bubble->icon), pixbuf);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(bubble->icon), pixbuf);
}
void
set_notification_arrow(GtkWindow *nw, gboolean visible, int x, int y)
{
- egg_notification_bubble_widget_set_draw_arrow(
- EGG_NOTIFICATION_BUBBLE_WIDGET(nw), visible);
+ egg_notification_bubble_widget_set_draw_arrow(
+ EGG_NOTIFICATION_BUBBLE_WIDGET(nw), visible);
}
static void
action_clicked_cb(GtkWidget *w, ActionInvokedCb action_cb)
{
- GtkWindow *nw = g_object_get_data(G_OBJECT(w), "_nw");
- const char *key = g_object_get_data(G_OBJECT(w), "_action_key");
+ GtkWindow *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);
+ action_cb(nw, key);
}
void
add_notification_action(GtkWindow *nw, const char *label, const char *key,
- ActionInvokedCb cb)
+ ActionInvokedCb cb)
{
- GtkWidget *b = egg_notification_bubble_widget_create_button(
- EGG_NOTIFICATION_BUBBLE_WIDGET(nw), label);
- g_object_set_data(G_OBJECT(b), "_nw", nw);
- g_object_set_data_full(G_OBJECT(b), "_action_key", g_strdup(key), g_free);
+ GtkWidget *b = egg_notification_bubble_widget_create_button(
+ EGG_NOTIFICATION_BUBBLE_WIDGET(nw), label);
+ g_object_set_data(G_OBJECT(b), "_nw", nw);
+ g_object_set_data_full(G_OBJECT(b), "_action_key", g_strdup(key), g_free);
- g_signal_connect(G_OBJECT(b), "clicked",
- G_CALLBACK(action_clicked_cb), cb);
+ g_signal_connect(G_OBJECT(b), "clicked",
+ G_CALLBACK(action_clicked_cb), cb);
}
void
move_notification(GtkWindow *nw, int x, int y)
{
- egg_notification_bubble_widget_set_pos(EGG_NOTIFICATION_BUBBLE_WIDGET(nw),
- x, y);
+ egg_notification_bubble_widget_set_pos(EGG_NOTIFICATION_BUBBLE_WIDGET(nw),
+ x, y);
}
diff --git a/src/themes/standard/theme.c b/src/themes/standard/theme.c
index 52bf86d..78dfccc 100644
--- a/src/themes/standard/theme.c
+++ b/src/themes/standard/theme.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+
#include "config.h"
#include <gtk/gtk.h>
@@ -7,55 +9,55 @@ typedef void (*UrlClickedCb)(GtkWindow *nw, const char *url);
typedef struct
{
- GtkWidget *win;
- GtkWidget *top_spacer;
- GtkWidget *bottom_spacer;
- GtkWidget *main_hbox;
- GtkWidget *iconbox;
- GtkWidget *icon;
- GtkWidget *content_hbox;
- GtkWidget *summary_label;
- GtkWidget *close_button;
- GtkWidget *body_label;
- GtkWidget *actions_box;
- GtkWidget *last_sep;
- GtkWidget *stripe_spacer;
- GtkWidget *pie_countdown;
-
- gboolean has_arrow;
- gboolean enable_transparency;
-
- int point_x;
- int point_y;
-
- int drawn_arrow_begin_x;
- int drawn_arrow_begin_y;
- int drawn_arrow_middle_x;
- int drawn_arrow_middle_y;
- int drawn_arrow_end_x;
- int drawn_arrow_end_y;
-
- int width;
- int height;
-
- GdkGC *gc;
- GdkPoint *border_points;
- size_t num_border_points;
- GdkRegion *window_region;
-
- guchar urgency;
- glong timeout;
- glong remaining;
-
- UrlClickedCb url_clicked;
+ GtkWidget *win;
+ GtkWidget *top_spacer;
+ GtkWidget *bottom_spacer;
+ GtkWidget *main_hbox;
+ GtkWidget *iconbox;
+ GtkWidget *icon;
+ GtkWidget *content_hbox;
+ GtkWidget *summary_label;
+ GtkWidget *close_button;
+ GtkWidget *body_label;
+ GtkWidget *actions_box;
+ GtkWidget *last_sep;
+ GtkWidget *stripe_spacer;
+ GtkWidget *pie_countdown;
+
+ gboolean has_arrow;
+ gboolean enable_transparency;
+
+ int point_x;
+ int point_y;
+
+ int drawn_arrow_begin_x;
+ int drawn_arrow_begin_y;
+ int drawn_arrow_middle_x;
+ int drawn_arrow_middle_y;
+ int drawn_arrow_end_x;
+ int drawn_arrow_end_y;
+
+ int width;
+ int height;
+
+ GdkGC *gc;
+ GdkPoint *border_points;
+ size_t num_border_points;
+ GdkRegion *window_region;
+
+ guchar urgency;
+ glong timeout;
+ glong remaining;
+
+ UrlClickedCb url_clicked;
} WindowData;
enum
{
- URGENCY_LOW,
- URGENCY_NORMAL,
- URGENCY_CRITICAL
+ URGENCY_LOW,
+ URGENCY_NORMAL,
+ URGENCY_CRITICAL
};
//#define ENABLE_GRADIENT_LOOK
@@ -88,967 +90,967 @@ enum
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];
+ 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;
+ 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);
+ 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);
+ /* 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
}
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;
+ 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;
+ cairo_pattern_t *gradient;
+ double r, g, b;
#endif
- switch (windata->urgency)
- {
- case URGENCY_LOW: // LOW
- color = style->bg[GTK_STATE_NORMAL];
- break;
+ 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_CRITICAL: // CRITICAL
+ gdk_color_parse("#CC0000", &color);
+ break;
- case URGENCY_NORMAL: // NORMAL
- default:
- color = style->bg[GTK_STATE_SELECTED];
- break;
- }
+ case URGENCY_NORMAL: // NORMAL
+ default:
+ color = style->bg[GTK_STATE_SELECTED];
+ break;
+ }
- cairo_rectangle(cr, stripe_x, stripe_y, STRIPE_WIDTH, stripe_height);
+ 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);
+ 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);
+ gdk_cairo_set_source_color(cr, &color);
+ cairo_fill(cr);
#endif
}
static GtkArrowType
get_notification_arrow_type(GtkWidget *nw)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- GdkScreen *screen;
- GdkRectangle monitor_geometry;
- int monitor;
-
- screen = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window));
- monitor = gdk_screen_get_monitor_at_point(screen, windata->point_x,
- windata->point_y);
- gdk_screen_get_monitor_geometry(screen, monitor, &monitor_geometry);
-
- if (windata->point_y - monitor_geometry.y + windata->height +
- DEFAULT_ARROW_HEIGHT > monitor_geometry.height)
- {
- return GTK_ARROW_DOWN;
- }
- else
- {
- return GTK_ARROW_UP;
- }
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+ GdkScreen *screen;
+ GdkRectangle monitor_geometry;
+ int monitor;
+
+ screen = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window));
+ monitor = gdk_screen_get_monitor_at_point(screen, windata->point_x,
+ windata->point_y);
+ gdk_screen_get_monitor_geometry(screen, monitor, &monitor_geometry);
+
+ if (windata->point_y - monitor_geometry.y + windata->height +
+ DEFAULT_ARROW_HEIGHT > monitor_geometry.height)
+ {
+ return GTK_ARROW_DOWN;
+ }
+ else
+ {
+ return GTK_ARROW_UP;
+ }
}
#define ADD_POINT(_x, _y, shapeoffset_x, shapeoffset_y) \
- G_STMT_START { \
- windata->border_points[i].x = (_x); \
- windata->border_points[i].y = (_y); \
- shape_points[i].x = (_x) + (shapeoffset_x); \
- shape_points[i].y = (_y) + (shapeoffset_y); \
- i++;\
- } G_STMT_END
+ G_STMT_START { \
+ windata->border_points[i].x = (_x); \
+ windata->border_points[i].y = (_y); \
+ shape_points[i].x = (_x) + (shapeoffset_x); \
+ shape_points[i].y = (_y) + (shapeoffset_y); \
+ i++;\
+ } G_STMT_END
static void
create_border_with_arrow(GtkWidget *nw, WindowData *windata)
{
- int width;
- int height;
- int y;
- int norm_point_x;
- int norm_point_y;
- GtkArrowType arrow_type;
- GdkScreen *screen;
- int arrow_side1_width = DEFAULT_ARROW_WIDTH / 2;
- int arrow_side2_width = DEFAULT_ARROW_WIDTH / 2;
- int arrow_offset = DEFAULT_ARROW_OFFSET;
- GdkPoint *shape_points = NULL;
- int i = 0;
- int monitor;
- GdkRectangle monitor_geometry;
-
- width = windata->width;
- height = windata->height;
-
- screen = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window));
- monitor = gdk_screen_get_monitor_at_point(screen,
- windata->point_x,
- windata->point_y);
- gdk_screen_get_monitor_geometry(screen, monitor, &monitor_geometry);
-
- windata->num_border_points = 5;
-
- arrow_type = get_notification_arrow_type(windata->win);
-
- norm_point_x = windata->point_x - monitor_geometry.x;
- norm_point_y = windata->point_y - monitor_geometry.y;
-
- /* Handle the offset and such */
- switch (arrow_type)
- {
- case GTK_ARROW_UP:
- case GTK_ARROW_DOWN:
- if (norm_point_x < arrow_side1_width)
- {
- arrow_side1_width = 0;
- arrow_offset = 0;
- }
- else if (norm_point_x > monitor_geometry.width - arrow_side2_width)
- {
- arrow_side2_width = 0;
- arrow_offset = width - arrow_side1_width;
- }
- else
- {
- if (norm_point_x - arrow_side2_width + width >=
- monitor_geometry.width)
- {
- arrow_offset = width - monitor_geometry.width +
- norm_point_x;
- }
- else
- {
- arrow_offset = MIN(norm_point_x - arrow_side1_width,
- DEFAULT_ARROW_OFFSET);
- }
-
- if (arrow_offset == 0 ||
- arrow_offset == width - arrow_side1_width)
- {
- windata->num_border_points++;
- }
- else
- windata->num_border_points += 2;
- }
-
- /*
- * Why risk this for official builds? If it's somehow off the
- * screen, it won't horribly impact the user. Definitely less
- * than an assertion would...
- */
+ int width;
+ int height;
+ int y;
+ int norm_point_x;
+ int norm_point_y;
+ GtkArrowType arrow_type;
+ GdkScreen *screen;
+ int arrow_side1_width = DEFAULT_ARROW_WIDTH / 2;
+ int arrow_side2_width = DEFAULT_ARROW_WIDTH / 2;
+ int arrow_offset = DEFAULT_ARROW_OFFSET;
+ GdkPoint *shape_points = NULL;
+ int i = 0;
+ int monitor;
+ GdkRectangle monitor_geometry;
+
+ width = windata->width;
+ height = windata->height;
+
+ screen = gdk_drawable_get_screen(GDK_DRAWABLE(nw->window));
+ monitor = gdk_screen_get_monitor_at_point(screen,
+ windata->point_x,
+ windata->point_y);
+ gdk_screen_get_monitor_geometry(screen, monitor, &monitor_geometry);
+
+ windata->num_border_points = 5;
+
+ arrow_type = get_notification_arrow_type(windata->win);
+
+ norm_point_x = windata->point_x - monitor_geometry.x;
+ norm_point_y = windata->point_y - monitor_geometry.y;
+
+ /* Handle the offset and such */
+ switch (arrow_type)
+ {
+ case GTK_ARROW_UP:
+ case GTK_ARROW_DOWN:
+ if (norm_point_x < arrow_side1_width)
+ {
+ arrow_side1_width = 0;
+ arrow_offset = 0;
+ }
+ else if (norm_point_x > monitor_geometry.width - arrow_side2_width)
+ {
+ arrow_side2_width = 0;
+ arrow_offset = width - arrow_side1_width;
+ }
+ else
+ {
+ if (norm_point_x - arrow_side2_width + width >=
+ monitor_geometry.width)
+ {
+ arrow_offset = width - monitor_geometry.width +
+ norm_point_x;
+ }
+ else
+ {
+ arrow_offset = MIN(norm_point_x - arrow_side1_width,
+ DEFAULT_ARROW_OFFSET);
+ }
+
+ if (arrow_offset == 0 ||
+ arrow_offset == width - arrow_side1_width)
+ {
+ windata->num_border_points++;
+ }
+ else
+ windata->num_border_points += 2;
+ }
+
+ /*
+ * Why risk this for official builds? If it's somehow off the
+ * screen, it won't horribly impact the user. Definitely less
+ * than an assertion would...
+ */
#if 0
- g_assert(arrow_offset + arrow_side1_width >= 0);
- g_assert(arrow_offset + arrow_side1_width + arrow_side2_width <=
- width);
+ g_assert(arrow_offset + arrow_side1_width >= 0);
+ g_assert(arrow_offset + arrow_side1_width + arrow_side2_width <=
+ width);
#endif
- windata->border_points = g_new0(GdkPoint,
- windata->num_border_points);
- shape_points = g_new0(GdkPoint, windata->num_border_points);
-
- windata->drawn_arrow_begin_x = arrow_offset;
- windata->drawn_arrow_middle_x = arrow_offset + arrow_side1_width;
- windata->drawn_arrow_end_x = arrow_offset + arrow_side1_width +
- arrow_side2_width;
- if (arrow_type == GTK_ARROW_UP)
- {
- windata->drawn_arrow_begin_y = DEFAULT_ARROW_HEIGHT;
- windata->drawn_arrow_middle_y = 0;
- windata->drawn_arrow_end_y = DEFAULT_ARROW_HEIGHT;
-
- if (arrow_side1_width == 0)
- {
- ADD_POINT(0, 0, 0, 0);
- }
- else
- {
- 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),
- 0, 0, 0);
- }
-
- if (arrow_side2_width > 0)
- {
- ADD_POINT(windata->drawn_arrow_end_x,
- windata->drawn_arrow_end_y, 1, 0);
- ADD_POINT(width - 1, DEFAULT_ARROW_HEIGHT, 1, 0);
- }
-
- ADD_POINT(width - 1, height - 1, 1, 1);
- ADD_POINT(0, height - 1, 0, 1);
-
- y = windata->point_y;
- }
- else
- {
- windata->drawn_arrow_begin_y = height - DEFAULT_ARROW_HEIGHT;
- windata->drawn_arrow_middle_y = height;
- windata->drawn_arrow_end_y = height - DEFAULT_ARROW_HEIGHT;
-
- ADD_POINT(0, 0, 0, 0);
- ADD_POINT(width - 1, 0, 1, 0);
-
- if (arrow_side2_width == 0)
- {
- ADD_POINT(width - 1, height,
- (arrow_side1_width > 0 ? 0 : 1), 0);
- }
- else
- {
- ADD_POINT(width - 1, height - DEFAULT_ARROW_HEIGHT, 1, 1);
-
- if (arrow_offset < width - arrow_side1_width)
- {
- ADD_POINT(arrow_offset + arrow_side1_width +
- arrow_side2_width,
- height - DEFAULT_ARROW_HEIGHT, 0, 1);
- }
-
- ADD_POINT(arrow_offset + arrow_side1_width, height, 0, 1);
- }
-
- if (arrow_side1_width > 0)
- {
- ADD_POINT(windata->drawn_arrow_begin_x -
- (arrow_side2_width > 0 ? 0 : 1),
- windata->drawn_arrow_begin_y, 0, 0);
- ADD_POINT(0, height - DEFAULT_ARROW_HEIGHT, 0, 1);
- }
-
- y = windata->point_y - height;
- }
+ windata->border_points = g_new0(GdkPoint,
+ windata->num_border_points);
+ shape_points = g_new0(GdkPoint, windata->num_border_points);
+
+ windata->drawn_arrow_begin_x = arrow_offset;
+ windata->drawn_arrow_middle_x = arrow_offset + arrow_side1_width;
+ windata->drawn_arrow_end_x = arrow_offset + arrow_side1_width +
+ arrow_side2_width;
+ if (arrow_type == GTK_ARROW_UP)
+ {
+ windata->drawn_arrow_begin_y = DEFAULT_ARROW_HEIGHT;
+ windata->drawn_arrow_middle_y = 0;
+ windata->drawn_arrow_end_y = DEFAULT_ARROW_HEIGHT;
+
+ if (arrow_side1_width == 0)
+ {
+ ADD_POINT(0, 0, 0, 0);
+ }
+ else
+ {
+ 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),
+ 0, 0, 0);
+ }
+
+ if (arrow_side2_width > 0)
+ {
+ ADD_POINT(windata->drawn_arrow_end_x,
+ windata->drawn_arrow_end_y, 1, 0);
+ ADD_POINT(width - 1, DEFAULT_ARROW_HEIGHT, 1, 0);
+ }
+
+ ADD_POINT(width - 1, height - 1, 1, 1);
+ ADD_POINT(0, height - 1, 0, 1);
+
+ y = windata->point_y;
+ }
+ else
+ {
+ windata->drawn_arrow_begin_y = height - DEFAULT_ARROW_HEIGHT;
+ windata->drawn_arrow_middle_y = height;
+ windata->drawn_arrow_end_y = height - DEFAULT_ARROW_HEIGHT;
+
+ ADD_POINT(0, 0, 0, 0);
+ ADD_POINT(width - 1, 0, 1, 0);
+
+ if (arrow_side2_width == 0)
+ {
+ ADD_POINT(width - 1, height,
+ (arrow_side1_width > 0 ? 0 : 1), 0);
+ }
+ else
+ {
+ ADD_POINT(width - 1, height - DEFAULT_ARROW_HEIGHT, 1, 1);
+
+ if (arrow_offset < width - arrow_side1_width)
+ {
+ ADD_POINT(arrow_offset + arrow_side1_width +
+ arrow_side2_width,
+ height - DEFAULT_ARROW_HEIGHT, 0, 1);
+ }
+
+ ADD_POINT(arrow_offset + arrow_side1_width, height, 0, 1);
+ }
+
+ if (arrow_side1_width > 0)
+ {
+ ADD_POINT(windata->drawn_arrow_begin_x -
+ (arrow_side2_width > 0 ? 0 : 1),
+ windata->drawn_arrow_begin_y, 0, 0);
+ ADD_POINT(0, height - DEFAULT_ARROW_HEIGHT, 0, 1);
+ }
+
+ y = windata->point_y - height;
+ }
#if 0
- g_assert(i == windata->num_border_points);
- g_assert(windata->point_x - arrow_offset - arrow_side1_width >= 0);
+ g_assert(i == windata->num_border_points);
+ g_assert(windata->point_x - arrow_offset - arrow_side1_width >= 0);
#endif
- gtk_window_move(GTK_WINDOW(windata->win),
- windata->point_x - arrow_offset -
- arrow_side1_width,
- y);
-
- break;
-
- case GTK_ARROW_LEFT:
- case GTK_ARROW_RIGHT:
- if (norm_point_y < arrow_side1_width)
- {
- arrow_side1_width = 0;
- arrow_offset = norm_point_y;
- }
- else if (norm_point_y > monitor_geometry.height - arrow_side2_width)
- {
- arrow_side2_width = 0;
- arrow_offset = norm_point_y - arrow_side1_width;
- }
- break;
-
- default:
- g_assert_not_reached();
- }
-
- g_assert(shape_points != NULL);
-
- windata->window_region =
- gdk_region_polygon(shape_points, windata->num_border_points,
- GDK_EVEN_ODD_RULE);
- g_free(shape_points);
+ gtk_window_move(GTK_WINDOW(windata->win),
+ windata->point_x - arrow_offset -
+ arrow_side1_width,
+ y);
+
+ break;
+
+ case GTK_ARROW_LEFT:
+ case GTK_ARROW_RIGHT:
+ if (norm_point_y < arrow_side1_width)
+ {
+ arrow_side1_width = 0;
+ arrow_offset = norm_point_y;
+ }
+ else if (norm_point_y > monitor_geometry.height - arrow_side2_width)
+ {
+ arrow_side2_width = 0;
+ arrow_offset = norm_point_y - arrow_side1_width;
+ }
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
+
+ g_assert(shape_points != NULL);
+
+ windata->window_region =
+ gdk_region_polygon(shape_points, windata->num_border_points,
+ GDK_EVEN_ODD_RULE);
+ g_free(shape_points);
}
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);
+ 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);
}
static gboolean
paint_window(GtkWidget *widget,
- GdkEventExpose *event,
- WindowData *windata)
+ GdkEventExpose *event,
+ WindowData *windata)
{
- cairo_t *context;
- cairo_surface_t *surface;
- cairo_t *cr;
-
- if (windata->width == 0) {
- windata->width = windata->win->allocation.width;
- windata->height = windata->win->allocation.height;
- }
-
- 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);
-
- return FALSE;
+ cairo_t *context;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ if (windata->width == 0) {
+ windata->width = windata->win->allocation.width;
+ windata->height = windata->win->allocation.height;
+ }
+
+ 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);
+
+ return FALSE;
}
static void
destroy_windata(WindowData *windata)
{
- if (windata->gc != NULL)
- g_object_unref(G_OBJECT(windata->gc));
+ if (windata->gc != NULL)
+ g_object_unref(G_OBJECT(windata->gc));
- if (windata->window_region != NULL)
- gdk_region_destroy(windata->window_region);
+ if (windata->window_region != NULL)
+ gdk_region_destroy(windata->window_region);
- g_free(windata);
+ g_free(windata);
}
static void
update_spacers(GtkWidget *nw)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
-
- if (windata->has_arrow)
- {
- switch (get_notification_arrow_type(GTK_WIDGET(nw)))
- {
- case GTK_ARROW_UP:
- gtk_widget_show(windata->top_spacer);
- gtk_widget_hide(windata->bottom_spacer);
- break;
-
- case GTK_ARROW_DOWN:
- gtk_widget_hide(windata->top_spacer);
- gtk_widget_show(windata->bottom_spacer);
- break;
-
- default:
- g_assert_not_reached();
- }
- }
- else
- {
- gtk_widget_hide(windata->top_spacer);
- gtk_widget_hide(windata->bottom_spacer);
- }
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+
+ if (windata->has_arrow)
+ {
+ switch (get_notification_arrow_type(GTK_WIDGET(nw)))
+ {
+ case GTK_ARROW_UP:
+ gtk_widget_show(windata->top_spacer);
+ gtk_widget_hide(windata->bottom_spacer);
+ break;
+
+ case GTK_ARROW_DOWN:
+ gtk_widget_hide(windata->top_spacer);
+ gtk_widget_show(windata->bottom_spacer);
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
+ }
+ else
+ {
+ gtk_widget_hide(windata->top_spacer);
+ gtk_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 (GTK_WIDGET_VISIBLE(windata->icon) ||
- GTK_WIDGET_VISIBLE(windata->body_label) ||
- GTK_WIDGET_VISIBLE(windata->actions_box))
- {
- gtk_widget_show(windata->content_hbox);
- }
- else
- {
- gtk_widget_hide(windata->content_hbox);
- }
+ /*
+ * This is all a hack, but until we have a libview-style ContentBox,
+ * it'll just have to do.
+ */
+ if (GTK_WIDGET_VISIBLE(windata->icon) ||
+ GTK_WIDGET_VISIBLE(windata->body_label) ||
+ GTK_WIDGET_VISIBLE(windata->actions_box))
+ {
+ gtk_widget_show(windata->content_hbox);
+ }
+ else
+ {
+ gtk_widget_hide(windata->content_hbox);
+ }
}
static gboolean
configure_event_cb(GtkWidget *nw,
- GdkEventConfigure *event,
- WindowData *windata)
+ GdkEventConfigure *event,
+ WindowData *windata)
{
- windata->width = event->width;
- windata->height = event->height;
+ windata->width = event->width;
+ windata->height = event->height;
- update_spacers(nw);
- gtk_widget_queue_draw(nw);
+ update_spacers(nw);
+ gtk_widget_queue_draw(nw);
- return FALSE;
+ return FALSE;
}
static gboolean
activate_link (GtkLabel *label, const char *url, WindowData *windata)
{
- windata->url_clicked (GTK_WINDOW(windata->win), url);
+ windata->url_clicked (GTK_WINDOW(windata->win), url);
- return TRUE;
+ return TRUE;
}
GtkWindow *
create_notification(UrlClickedCb url_clicked)
{
- GtkWidget *spacer;
- GtkWidget *win;
- GtkWidget *drawbox;
- GtkWidget *main_vbox;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *close_button;
- GtkWidget *image;
- GtkWidget *alignment;
- AtkObject *atkobj;
- GtkRcStyle *rcstyle;
- WindowData *windata;
+ GtkWidget *spacer;
+ GtkWidget *win;
+ GtkWidget *drawbox;
+ GtkWidget *main_vbox;
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *close_button;
+ GtkWidget *image;
+ GtkWidget *alignment;
+ AtkObject *atkobj;
+ GtkRcStyle *rcstyle;
+ WindowData *windata;
#ifdef USE_COMPOSITE
- GdkColormap *colormap;
- GdkScreen *screen;
+ GdkColormap *colormap;
+ GdkScreen *screen;
#endif
- windata = g_new0(WindowData, 1);
- windata->urgency = URGENCY_NORMAL;
- windata->url_clicked = url_clicked;
+ windata = g_new0(WindowData, 1);
+ windata->urgency = URGENCY_NORMAL;
+ windata->url_clicked = url_clicked;
- win = gtk_window_new(GTK_WINDOW_POPUP);
- windata->win = win;
+ win = gtk_window_new(GTK_WINDOW_POPUP);
+ windata->win = win;
- windata->enable_transparency = FALSE;
+ 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;
- }
+ 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_window_set_type_hint(GTK_WINDOW(win),
- GDK_WINDOW_TYPE_HINT_NOTIFICATION);
- gtk_widget_add_events(win, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
- gtk_widget_realize(win);
- gtk_widget_set_size_request(win, WIDTH, -1);
-
- g_object_set_data_full(G_OBJECT(win), "windata", windata,
- (GDestroyNotify)destroy_windata);
- atk_object_set_role(gtk_widget_get_accessible(win), ATK_ROLE_ALERT);
-
- g_signal_connect(G_OBJECT(win), "configure_event",
- G_CALLBACK(configure_event_cb), windata);
-
- /*
- * For some reason, there are occasionally graphics glitches when
- * repainting the window. Despite filling the window with a background
- * color, parts of the other windows on the screen or the shadows around
- * notifications will appear on the notification. Somehow, adding this
- * eventbox makes that problem just go away. Whatever works for now.
- */
- drawbox = gtk_event_box_new();
- gtk_widget_show(drawbox);
- gtk_container_add(GTK_CONTAINER(win), drawbox);
-
- main_vbox = gtk_vbox_new(FALSE, 0);
- gtk_widget_show(main_vbox);
- gtk_container_add(GTK_CONTAINER(drawbox), main_vbox);
- gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 1);
-
- g_signal_connect(G_OBJECT(main_vbox), "expose_event",
- G_CALLBACK(paint_window), windata);
-
- windata->top_spacer = gtk_image_new();
- gtk_box_pack_start(GTK_BOX(main_vbox), windata->top_spacer,
- FALSE, FALSE, 0);
- gtk_widget_set_size_request(windata->top_spacer, -1, DEFAULT_ARROW_HEIGHT);
-
- windata->main_hbox = gtk_hbox_new(FALSE, 0);
- gtk_widget_show(windata->main_hbox);
- gtk_box_pack_start(GTK_BOX(main_vbox), windata->main_hbox,
- FALSE, FALSE, 0);
-
- windata->bottom_spacer = gtk_image_new();
- gtk_box_pack_start(GTK_BOX(main_vbox), windata->bottom_spacer,
- FALSE, FALSE, 0);
- gtk_widget_set_size_request(windata->bottom_spacer, -1,
- DEFAULT_ARROW_HEIGHT);
-
- vbox = gtk_vbox_new(FALSE, 6);
- gtk_widget_show(vbox);
- gtk_box_pack_start(GTK_BOX(windata->main_hbox), vbox, TRUE, TRUE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
-
- hbox = gtk_hbox_new(FALSE, 6);
- gtk_widget_show(hbox);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
- 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, SPACER_LEFT, -1);
-
- windata->summary_label = gtk_label_new(NULL);
- gtk_widget_show(windata->summary_label);
- gtk_box_pack_start(GTK_BOX(hbox), windata->summary_label, TRUE, TRUE, 0);
- gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0, 0);
- gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE);
-
- atkobj = gtk_widget_get_accessible(windata->summary_label);
- atk_object_set_description(atkobj, "Notification summary text.");
-
- /* Add the close button */
- alignment = gtk_alignment_new(1, 0, 0, 0);
- gtk_widget_show(alignment);
- gtk_box_pack_start(GTK_BOX(hbox), alignment, FALSE, FALSE, 0);
-
- close_button = gtk_button_new();
- windata->close_button = close_button;
- gtk_widget_show(close_button);
- gtk_container_add(GTK_CONTAINER(alignment), close_button);
- gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
- gtk_container_set_border_width(GTK_CONTAINER(close_button), 0);
- //gtk_widget_set_size_request(close_button, 20, 20);
- g_signal_connect_swapped(G_OBJECT(close_button), "clicked",
- G_CALLBACK(gtk_widget_destroy), win);
-
- rcstyle = gtk_rc_style_new();
- rcstyle->xthickness = rcstyle->ythickness = 0;
- gtk_widget_modify_style(close_button, rcstyle);
- g_object_unref(rcstyle);
-
- atkobj = gtk_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 = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
- gtk_widget_show(image);
- gtk_container_add(GTK_CONTAINER(close_button), image);
-
- windata->content_hbox = gtk_hbox_new(FALSE, 6);
- gtk_box_pack_start(GTK_BOX(vbox), windata->content_hbox, FALSE, FALSE, 0);
-
- windata->iconbox = gtk_hbox_new(FALSE, 0);
- gtk_widget_show(windata->iconbox);
- gtk_box_pack_start(GTK_BOX(windata->content_hbox), windata->iconbox,
- FALSE, FALSE, 0);
- gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1);
-
- windata->icon = gtk_image_new();
- gtk_box_pack_start(GTK_BOX(windata->iconbox), windata->icon,
- TRUE, TRUE, 0);
- gtk_misc_set_alignment(GTK_MISC(windata->icon), 0.5, 0.0);
-
- vbox = gtk_vbox_new(FALSE, 6);
- gtk_widget_show(vbox);
- gtk_box_pack_start(GTK_BOX(windata->content_hbox), vbox, TRUE, TRUE, 0);
-
- windata->body_label = gtk_label_new (NULL);
- gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0);
- gtk_misc_set_alignment(GTK_MISC(windata->body_label), 0, 0);
- gtk_label_set_line_wrap(GTK_LABEL(windata->body_label), TRUE);
- g_signal_connect(G_OBJECT(windata->body_label), "activate-link",
+ gtk_window_set_title(GTK_WINDOW(win), "Notification");
+ gtk_window_set_type_hint(GTK_WINDOW(win),
+ GDK_WINDOW_TYPE_HINT_NOTIFICATION);
+ gtk_widget_add_events(win, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
+ gtk_widget_realize(win);
+ gtk_widget_set_size_request(win, WIDTH, -1);
+
+ g_object_set_data_full(G_OBJECT(win), "windata", windata,
+ (GDestroyNotify)destroy_windata);
+ atk_object_set_role(gtk_widget_get_accessible(win), ATK_ROLE_ALERT);
+
+ g_signal_connect(G_OBJECT(win), "configure_event",
+ G_CALLBACK(configure_event_cb), windata);
+
+ /*
+ * For some reason, there are occasionally graphics glitches when
+ * repainting the window. Despite filling the window with a background
+ * color, parts of the other windows on the screen or the shadows around
+ * notifications will appear on the notification. Somehow, adding this
+ * eventbox makes that problem just go away. Whatever works for now.
+ */
+ drawbox = gtk_event_box_new();
+ gtk_widget_show(drawbox);
+ gtk_container_add(GTK_CONTAINER(win), drawbox);
+
+ main_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_widget_show(main_vbox);
+ gtk_container_add(GTK_CONTAINER(drawbox), main_vbox);
+ gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 1);
+
+ g_signal_connect(G_OBJECT(main_vbox), "expose_event",
+ G_CALLBACK(paint_window), windata);
+
+ windata->top_spacer = gtk_image_new();
+ gtk_box_pack_start(GTK_BOX(main_vbox), windata->top_spacer,
+ FALSE, FALSE, 0);
+ gtk_widget_set_size_request(windata->top_spacer, -1, DEFAULT_ARROW_HEIGHT);
+
+ windata->main_hbox = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(windata->main_hbox);
+ gtk_box_pack_start(GTK_BOX(main_vbox), windata->main_hbox,
+ FALSE, FALSE, 0);
+
+ windata->bottom_spacer = gtk_image_new();
+ gtk_box_pack_start(GTK_BOX(main_vbox), windata->bottom_spacer,
+ FALSE, FALSE, 0);
+ gtk_widget_set_size_request(windata->bottom_spacer, -1,
+ DEFAULT_ARROW_HEIGHT);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+ gtk_widget_show(vbox);
+ gtk_box_pack_start(GTK_BOX(windata->main_hbox), vbox, TRUE, TRUE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
+
+ hbox = gtk_hbox_new(FALSE, 6);
+ gtk_widget_show(hbox);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+ 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, SPACER_LEFT, -1);
+
+ windata->summary_label = gtk_label_new(NULL);
+ gtk_widget_show(windata->summary_label);
+ gtk_box_pack_start(GTK_BOX(hbox), windata->summary_label, TRUE, TRUE, 0);
+ gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0, 0);
+ gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE);
+
+ atkobj = gtk_widget_get_accessible(windata->summary_label);
+ atk_object_set_description(atkobj, "Notification summary text.");
+
+ /* Add the close button */
+ alignment = gtk_alignment_new(1, 0, 0, 0);
+ gtk_widget_show(alignment);
+ gtk_box_pack_start(GTK_BOX(hbox), alignment, FALSE, FALSE, 0);
+
+ close_button = gtk_button_new();
+ windata->close_button = close_button;
+ gtk_widget_show(close_button);
+ gtk_container_add(GTK_CONTAINER(alignment), close_button);
+ gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
+ gtk_container_set_border_width(GTK_CONTAINER(close_button), 0);
+ //gtk_widget_set_size_request(close_button, 20, 20);
+ g_signal_connect_swapped(G_OBJECT(close_button), "clicked",
+ G_CALLBACK(gtk_widget_destroy), win);
+
+ rcstyle = gtk_rc_style_new();
+ rcstyle->xthickness = rcstyle->ythickness = 0;
+ gtk_widget_modify_style(close_button, rcstyle);
+ g_object_unref(rcstyle);
+
+ atkobj = gtk_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 = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ gtk_widget_show(image);
+ gtk_container_add(GTK_CONTAINER(close_button), image);
+
+ windata->content_hbox = gtk_hbox_new(FALSE, 6);
+ gtk_box_pack_start(GTK_BOX(vbox), windata->content_hbox, FALSE, FALSE, 0);
+
+ windata->iconbox = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(windata->iconbox);
+ gtk_box_pack_start(GTK_BOX(windata->content_hbox), windata->iconbox,
+ FALSE, FALSE, 0);
+ gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1);
+
+ windata->icon = gtk_image_new();
+ gtk_box_pack_start(GTK_BOX(windata->iconbox), windata->icon,
+ TRUE, TRUE, 0);
+ gtk_misc_set_alignment(GTK_MISC(windata->icon), 0.5, 0.0);
+
+ vbox = gtk_vbox_new(FALSE, 6);
+ gtk_widget_show(vbox);
+ gtk_box_pack_start(GTK_BOX(windata->content_hbox), vbox, TRUE, TRUE, 0);
+
+ windata->body_label = gtk_label_new (NULL);
+ gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0);
+ gtk_misc_set_alignment(GTK_MISC(windata->body_label), 0, 0);
+ gtk_label_set_line_wrap(GTK_LABEL(windata->body_label), TRUE);
+ g_signal_connect(G_OBJECT(windata->body_label), "activate-link",
G_CALLBACK(activate_link), windata);
- atkobj = gtk_widget_get_accessible(windata->body_label);
- atk_object_set_description(atkobj, "Notification body text.");
+ atkobj = gtk_widget_get_accessible(windata->body_label);
+ atk_object_set_description(atkobj, "Notification body text.");
- alignment = gtk_alignment_new(1, 0.5, 0, 0);
- gtk_widget_show(alignment);
- gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0);
+ alignment = gtk_alignment_new(1, 0.5, 0, 0);
+ gtk_widget_show(alignment);
+ gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0);
- windata->actions_box = gtk_hbox_new(FALSE, 6);
- gtk_container_add(GTK_CONTAINER(alignment), windata->actions_box);
+ windata->actions_box = gtk_hbox_new(FALSE, 6);
+ gtk_container_add(GTK_CONTAINER(alignment), windata->actions_box);
- return GTK_WINDOW(win);
+ return GTK_WINDOW(win);
}
void
set_notification_hints(GtkWindow *nw, GHashTable *hints)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- GValue *value;
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+ GValue *value;
- g_assert(windata != NULL);
+ g_assert(windata != NULL);
- value = (GValue *)g_hash_table_lookup(hints, "urgency");
+ value = (GValue *)g_hash_table_lookup(hints, "urgency");
- if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
- {
- windata->urgency = g_value_get_uchar(value);
+ if (value != NULL && G_VALUE_HOLDS_UCHAR(value))
+ {
+ windata->urgency = g_value_get_uchar(value);
- if (windata->urgency == URGENCY_CRITICAL) {
- gtk_window_set_title(GTK_WINDOW(nw), "Critical Notification");
- } else {
- gtk_window_set_title(GTK_WINDOW(nw), "Notification");
- }
- }
+ if (windata->urgency == URGENCY_CRITICAL) {
+ gtk_window_set_title(GTK_WINDOW(nw), "Critical Notification");
+ } else {
+ gtk_window_set_title(GTK_WINDOW(nw), "Notification");
+ }
+ }
}
void
set_notification_timeout(GtkWindow *nw, glong timeout)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- g_assert(windata != NULL);
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+ g_assert(windata != NULL);
- windata->timeout = timeout;
+ windata->timeout = timeout;
}
void
notification_tick(GtkWindow *nw, glong remaining)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- windata->remaining = remaining;
-
- if (windata->pie_countdown != NULL)
- {
- gtk_widget_queue_draw_area(windata->pie_countdown, 0, 0,
- PIE_WIDTH, PIE_HEIGHT);
- }
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+ windata->remaining = remaining;
+
+ if (windata->pie_countdown != NULL)
+ {
+ gtk_widget_queue_draw_area(windata->pie_countdown, 0, 0,
+ PIE_WIDTH, PIE_HEIGHT);
+ }
}
void
set_notification_text(GtkWindow *nw, const char *summary, const char *body)
{
- char *str, *quoted;
- GtkRequisition req;
- 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("<b><big>%s</big></b>", quoted);
- g_free(quoted);
-
- gtk_label_set_markup(GTK_LABEL(windata->summary_label), str);
- g_free(str);
-
- gtk_label_set_markup(GTK_LABEL(windata->body_label), body);
-
- if (body == NULL || *body == '\0')
- gtk_widget_hide(windata->body_label);
- else
- gtk_widget_show(windata->body_label);
-
- update_content_hbox_visibility(windata);
-
- if (body != NULL && *body != '\0')
- {
- gtk_widget_size_request (windata->iconbox, &req);
- gtk_widget_set_size_request(
- windata->body_label,
- /* -1: border width for
- -6: spacing for hbox */
- WIDTH - (1*2) - (10*2) - req.width - 6,
- -1);
- }
-
- gtk_widget_size_request (windata->close_button, &req);
- gtk_widget_set_size_request(
- windata->summary_label,
- /* -1: main_vbox border width
- -10: vbox border width
- -6: spacing for hbox */
- WIDTH - (1*2) - (10*2) - SPACER_LEFT - req.width - (6*2),
- -1);
+ char *str, *quoted;
+ GtkRequisition req;
+ 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("<b><big>%s</big></b>", quoted);
+ g_free(quoted);
+
+ gtk_label_set_markup(GTK_LABEL(windata->summary_label), str);
+ g_free(str);
+
+ gtk_label_set_markup(GTK_LABEL(windata->body_label), body);
+
+ if (body == NULL || *body == '\0')
+ gtk_widget_hide(windata->body_label);
+ else
+ gtk_widget_show(windata->body_label);
+
+ update_content_hbox_visibility(windata);
+
+ if (body != NULL && *body != '\0')
+ {
+ gtk_widget_size_request (windata->iconbox, &req);
+ gtk_widget_set_size_request(
+ windata->body_label,
+ /* -1: border width for
+ -6: spacing for hbox */
+ WIDTH - (1*2) - (10*2) - req.width - 6,
+ -1);
+ }
+
+ gtk_widget_size_request (windata->close_button, &req);
+ gtk_widget_set_size_request(
+ windata->summary_label,
+ /* -1: main_vbox border width
+ -10: vbox border width
+ -6: spacing for hbox */
+ WIDTH - (1*2) - (10*2) - SPACER_LEFT - req.width - (6*2),
+ -1);
}
void
set_notification_icon(GtkWindow *nw, GdkPixbuf *pixbuf)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- g_assert(windata != NULL);
-
- gtk_image_set_from_pixbuf(GTK_IMAGE(windata->icon), pixbuf);
-
- if (pixbuf != NULL)
- {
- int pixbuf_width = gdk_pixbuf_get_width(pixbuf);
-
- gtk_widget_show(windata->icon);
- gtk_widget_set_size_request(windata->iconbox,
- MAX(BODY_X_OFFSET, pixbuf_width), -1);
- }
- else
- {
- gtk_widget_hide(windata->icon);
- gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1);
- }
-
- update_content_hbox_visibility(windata);
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+ g_assert(windata != NULL);
+
+ gtk_image_set_from_pixbuf(GTK_IMAGE(windata->icon), pixbuf);
+
+ if (pixbuf != NULL)
+ {
+ int pixbuf_width = gdk_pixbuf_get_width(pixbuf);
+
+ gtk_widget_show(windata->icon);
+ gtk_widget_set_size_request(windata->iconbox,
+ MAX(BODY_X_OFFSET, pixbuf_width), -1);
+ }
+ else
+ {
+ gtk_widget_hide(windata->icon);
+ gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1);
+ }
+
+ update_content_hbox_visibility(windata);
}
void
set_notification_arrow(GtkWidget *nw, gboolean visible, int x, int y)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- g_assert(windata != NULL);
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+ g_assert(windata != NULL);
- windata->has_arrow = visible;
- windata->point_x = x;
- windata->point_y = y;
+ windata->has_arrow = visible;
+ windata->point_x = x;
+ windata->point_y = y;
- update_spacers(nw);
+ update_spacers(nw);
}
static gboolean
countdown_expose_cb(GtkWidget *pie, GdkEventExpose *event,
- WindowData *windata)
+ WindowData *windata)
{
- GtkStyle *style = gtk_widget_get_style(windata->win);
- 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);
-
- if (windata->timeout > 0)
- {
- gdouble pct = (gdouble)windata->remaining / (gdouble)windata->timeout;
-
- gdk_cairo_set_source_color(cr, &style->bg[GTK_STATE_ACTIVE]);
-
- cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS);
- cairo_arc_negative(cr, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS,
- -G_PI_2, -(pct * G_PI * 2) - G_PI_2);
- cairo_line_to(cr, PIE_RADIUS, PIE_RADIUS);
- cairo_fill(cr);
- }
-
- cairo_destroy(cr);
- cairo_set_source_surface(context, surface, 0, 0);
- cairo_paint(context);
- cairo_surface_destroy(surface);
- cairo_destroy(context);
-
- return TRUE;
+ GtkStyle *style = gtk_widget_get_style(windata->win);
+ 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);
+
+ if (windata->timeout > 0)
+ {
+ gdouble pct = (gdouble)windata->remaining / (gdouble)windata->timeout;
+
+ gdk_cairo_set_source_color(cr, &style->bg[GTK_STATE_ACTIVE]);
+
+ cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS);
+ cairo_arc_negative(cr, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS,
+ -G_PI_2, -(pct * G_PI * 2) - G_PI_2);
+ cairo_line_to(cr, PIE_RADIUS, PIE_RADIUS);
+ cairo_fill(cr);
+ }
+
+ cairo_destroy(cr);
+ cairo_set_source_surface(context, surface, 0, 0);
+ cairo_paint(context);
+ cairo_surface_destroy(surface);
+ cairo_destroy(context);
+
+ return TRUE;
}
static void
action_clicked_cb(GtkWidget *w, GdkEventButton *event,
- ActionInvokedCb action_cb)
+ ActionInvokedCb action_cb)
{
- GtkWindow *nw = g_object_get_data(G_OBJECT(w), "_nw");
- const char *key = g_object_get_data(G_OBJECT(w), "_action_key");
+ GtkWindow *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);
+ action_cb(nw, key);
}
void
add_notification_action(GtkWindow *nw, const char *text, const char *key,
- ActionInvokedCb cb)
+ ActionInvokedCb cb)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- GtkWidget *label;
- GtkWidget *button;
- GtkWidget *hbox;
- GdkPixbuf *pixbuf;
- char *buf;
-
- g_assert(windata != NULL);
-
- if (!GTK_WIDGET_VISIBLE(windata->actions_box))
- {
- GtkWidget *alignment;
-
- gtk_widget_show(windata->actions_box);
- update_content_hbox_visibility(windata);
-
- alignment = gtk_alignment_new(1, 0.5, 0, 0);
- gtk_widget_show(alignment);
- gtk_box_pack_end(GTK_BOX(windata->actions_box), alignment,
- FALSE, TRUE, 0);
-
- windata->pie_countdown = gtk_drawing_area_new();
- gtk_widget_show(windata->pie_countdown);
- gtk_container_add(GTK_CONTAINER(alignment), windata->pie_countdown);
- gtk_widget_set_size_request(windata->pie_countdown,
- PIE_WIDTH, PIE_HEIGHT);
- g_signal_connect(G_OBJECT(windata->pie_countdown), "expose_event",
- G_CALLBACK(countdown_expose_cb), windata);
- }
-
- button = gtk_button_new();
- gtk_widget_show(button);
- gtk_box_pack_start(GTK_BOX(windata->actions_box), button, FALSE, FALSE, 0);
-
- hbox = gtk_hbox_new(FALSE, 6);
- gtk_widget_show(hbox);
- gtk_container_add(GTK_CONTAINER(button), hbox);
-
- /* Try to be smart and find a suitable icon. */
- buf = g_strdup_printf("stock_%s", key);
- pixbuf = gtk_icon_theme_load_icon(
- gtk_icon_theme_get_for_screen(
- gdk_drawable_get_screen(GTK_WIDGET(nw)->window)),
- buf, 16, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
- g_free(buf);
-
- if (pixbuf != NULL)
- {
- GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf);
- gtk_widget_show(image);
- gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
- gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.5);
- }
-
- label = gtk_label_new(NULL);
- gtk_widget_show(label);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- buf = g_strdup_printf("<small>%s</small>", text);
- gtk_label_set_markup(GTK_LABEL(label), buf);
- g_free(buf);
-
- 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);
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+ GtkWidget *label;
+ GtkWidget *button;
+ GtkWidget *hbox;
+ GdkPixbuf *pixbuf;
+ char *buf;
+
+ g_assert(windata != NULL);
+
+ if (!GTK_WIDGET_VISIBLE(windata->actions_box))
+ {
+ GtkWidget *alignment;
+
+ gtk_widget_show(windata->actions_box);
+ update_content_hbox_visibility(windata);
+
+ alignment = gtk_alignment_new(1, 0.5, 0, 0);
+ gtk_widget_show(alignment);
+ gtk_box_pack_end(GTK_BOX(windata->actions_box), alignment,
+ FALSE, TRUE, 0);
+
+ windata->pie_countdown = gtk_drawing_area_new();
+ gtk_widget_show(windata->pie_countdown);
+ gtk_container_add(GTK_CONTAINER(alignment), windata->pie_countdown);
+ gtk_widget_set_size_request(windata->pie_countdown,
+ PIE_WIDTH, PIE_HEIGHT);
+ g_signal_connect(G_OBJECT(windata->pie_countdown), "expose_event",
+ G_CALLBACK(countdown_expose_cb), windata);
+ }
+
+ button = gtk_button_new();
+ gtk_widget_show(button);
+ gtk_box_pack_start(GTK_BOX(windata->actions_box), button, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new(FALSE, 6);
+ gtk_widget_show(hbox);
+ gtk_container_add(GTK_CONTAINER(button), hbox);
+
+ /* Try to be smart and find a suitable icon. */
+ buf = g_strdup_printf("stock_%s", key);
+ pixbuf = gtk_icon_theme_load_icon(
+ gtk_icon_theme_get_for_screen(
+ gdk_drawable_get_screen(GTK_WIDGET(nw)->window)),
+ buf, 16, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
+ g_free(buf);
+
+ if (pixbuf != NULL)
+ {
+ GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf);
+ gtk_widget_show(image);
+ gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
+ gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.5);
+ }
+
+ label = gtk_label_new(NULL);
+ gtk_widget_show(label);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+ buf = g_strdup_printf("<small>%s</small>", text);
+ gtk_label_set_markup(GTK_LABEL(label), buf);
+ g_free(buf);
+
+ 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);
}
void
clear_notification_actions(GtkWindow *nw)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- windata->pie_countdown = NULL;
+ windata->pie_countdown = NULL;
- gtk_widget_hide(windata->actions_box);
- gtk_container_foreach(GTK_CONTAINER(windata->actions_box),
- (GtkCallback)gtk_object_destroy, NULL);
+ gtk_widget_hide(windata->actions_box);
+ gtk_container_foreach(GTK_CONTAINER(windata->actions_box),
+ (GtkCallback)gtk_object_destroy, NULL);
}
void
move_notification(GtkWidget *nw, int x, int y)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- g_assert(windata != NULL);
-
- if (windata->has_arrow)
- {
- gtk_widget_queue_resize(nw);
- }
- else
- {
- gtk_window_move(GTK_WINDOW(nw), x, y);
- }
+ WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+ g_assert(windata != NULL);
+
+ if (windata->has_arrow)
+ {
+ gtk_widget_queue_resize(nw);
+ }
+ else
+ {
+ gtk_window_move(GTK_WINDOW(nw), x, y);
+ }
}
void
get_theme_info(char **theme_name,
- char **theme_ver,
- char **author,
- char **homepage)
+ char **theme_ver,
+ char **author,
+ char **homepage)
{
- *theme_name = g_strdup("Standard");
- *theme_ver = g_strdup_printf("%d.%d.%d",
- NOTIFICATION_DAEMON_MAJOR_VERSION,
- NOTIFICATION_DAEMON_MINOR_VERSION,
- NOTIFICATION_DAEMON_MICRO_VERSION);
- *author = g_strdup("Christian Hammond");
- *homepage = g_strdup("http://www.galago-project.org/");
+ *theme_name = g_strdup("Standard");
+ *theme_ver = g_strdup_printf("%d.%d.%d",
+ NOTIFICATION_DAEMON_MAJOR_VERSION,
+ NOTIFICATION_DAEMON_MINOR_VERSION,
+ NOTIFICATION_DAEMON_MICRO_VERSION);
+ *author = g_strdup("Christian Hammond");
+ *homepage = g_strdup("http://www.galago-project.org/");
}
gboolean
theme_check_init(unsigned int major_ver, unsigned int minor_ver,
- unsigned int micro_ver)
+ unsigned int micro_ver)
{
- return major_ver == NOTIFICATION_DAEMON_MAJOR_VERSION &&
- minor_ver == NOTIFICATION_DAEMON_MINOR_VERSION &&
- micro_ver == NOTIFICATION_DAEMON_MICRO_VERSION;
+ return major_ver == NOTIFICATION_DAEMON_MAJOR_VERSION &&
+ minor_ver == NOTIFICATION_DAEMON_MINOR_VERSION &&
+ micro_ver == NOTIFICATION_DAEMON_MICRO_VERSION;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]