aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c73
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.h5
-rw-r--r--calendar/gui/alarm-notify/notify-main.c53
3 files changed, 52 insertions, 79 deletions
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index 2a75d7943c..26c84bb056 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -25,15 +25,20 @@
#endif
#include <string.h>
+#include <camel/camel.h>
#include <libedataserver/e-url.h>
#include <libedataserver/e-data-server-util.h>
#include <libedataserverui/e-passwords.h>
#include <libecal/e-cal.h>
+
+#include "alarm.h"
#include "alarm-notify.h"
#include "alarm-queue.h"
#include "config-data.h"
#include "common/authentication.h"
+#define APPLICATION_ID "org.gnome.EvolutionAlarmNotify"
+
struct _AlarmNotifyPrivate {
/* Mapping from EUri's to LoadedClient structures */
/* FIXME do we need per source type uri hashes? or perhaps we
@@ -50,7 +55,7 @@ typedef struct {
GList *removals;
} ProcessRemovalsData;
-static gpointer parent_class;
+G_DEFINE_TYPE (AlarmNotify, alarm_notify, GTK_TYPE_APPLICATION)
static void
process_removal_in_hash (const gchar *uri,
@@ -214,23 +219,53 @@ alarm_notify_finalize (GObject *object)
}
alarm_queue_done ();
+ alarm_done ();
+
+ e_passwords_shutdown ();
g_mutex_free (priv->mutex);
/* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (alarm_notify_parent_class)->finalize (object);
+}
+
+static void
+alarm_notify_startup (GApplication *application)
+{
+ GtkIconTheme *icon_theme;
+
+ /* Chain up to parent's startup() method. */
+ G_APPLICATION_CLASS (alarm_notify_parent_class)->startup (application);
+
+ /* Keep the application running. */
+ g_application_hold (application);
+
+ config_data_init_debugging ();
+
+ /* FIXME Ideally we should not use Camel libraries in calendar,
+ * though it is the case currently for attachments. Remove
+ * this once that is fixed. */
+
+ /* Initialize Camel's type system. */
+ camel_object_get_type ();
+
+ icon_theme = gtk_icon_theme_get_default ();
+ gtk_icon_theme_append_search_path (icon_theme, EVOLUTION_ICONDIR);
}
static void
alarm_notify_class_init (AlarmNotifyClass *class)
{
GObjectClass *object_class;
+ GApplicationClass *application_class;
- parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (AlarmNotifyPrivate));
- object_class = (GObjectClass *) class;
+ object_class = G_OBJECT_CLASS (class);
object_class->finalize = alarm_notify_finalize;
+
+ application_class = G_APPLICATION_CLASS (class);
+ application_class->startup = alarm_notify_startup;
}
static void
@@ -262,32 +297,6 @@ alarm_notify_get_selected_calendars (AlarmNotify *an)
return an->priv->selected_calendars;
}
-GType
-alarm_notify_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- const GTypeInfo type_info = {
- sizeof (AlarmNotifyClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) alarm_notify_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (AlarmNotify),
- 0, /* n_preallocs */
- (GInstanceInitFunc) alarm_notify_init,
- NULL /* value_table */
- };
-
- type = g_type_register_static (
- G_TYPE_OBJECT, "AlarmNotify", &type_info, 0);
- }
-
- return type;
-}
-
/**
* alarm_notify_new:
*
@@ -298,7 +307,9 @@ alarm_notify_get_type (void)
AlarmNotify *
alarm_notify_new (void)
{
- return g_object_new (TYPE_ALARM_NOTIFY, NULL);
+ return g_object_new (
+ TYPE_ALARM_NOTIFY,
+ "application-id", APPLICATION_ID, NULL);
}
static void
diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h
index b3fb47990a..de7e0398a6 100644
--- a/calendar/gui/alarm-notify/alarm-notify.h
+++ b/calendar/gui/alarm-notify/alarm-notify.h
@@ -26,6 +26,7 @@
#ifndef ALARM_NOTIFY_H
#define ALARM_NOTIFY_H
+#include <gtk/gtk.h>
#include <libecal/e-cal.h>
/* Standard GObject macros */
@@ -54,12 +55,12 @@ typedef struct _AlarmNotifyClass AlarmNotifyClass;
typedef struct _AlarmNotifyPrivate AlarmNotifyPrivate;
struct _AlarmNotify {
- GObject parent;
+ GtkApplication parent;
AlarmNotifyPrivate *priv;
};
struct _AlarmNotifyClass {
- GObjectClass parent_class;
+ GtkApplicationClass parent_class;
};
GType alarm_notify_get_type (void);
diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c
index 848323b7a5..db74af8e9a 100644
--- a/calendar/gui/alarm-notify/notify-main.c
+++ b/calendar/gui/alarm-notify/notify-main.c
@@ -23,22 +23,10 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <gtk/gtk.h>
+#include <config.h>
#include <glib/gi18n.h>
-#include <camel/camel.h>
-#include <unique/unique.h>
-#include <libedataserver/e-source.h>
-#include <libedataserverui/e-passwords.h>
-#include "alarm.h"
-#include "alarm-queue.h"
#include "alarm-notify.h"
-#include "config-data.h"
#ifdef G_OS_WIN32
#include <windows.h>
@@ -56,9 +44,8 @@
gint
main (gint argc, gchar **argv)
{
- GtkIconTheme *icon_theme;
AlarmNotify *alarm_notify_service;
- UniqueApp *app;
+ gint exit_status;
#ifdef G_OS_WIN32
gchar *path;
@@ -87,7 +74,7 @@ main (gint argc, gchar **argv)
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- g_thread_init (NULL);
+ gtk_init (&argc, &argv);
#ifdef G_OS_WIN32
path = g_build_path (";", _e_get_bindir (), g_getenv ("PATH"), NULL);
@@ -96,38 +83,12 @@ main (gint argc, gchar **argv)
g_warning ("Could not set PATH for Evolution Alarm Notifier");
#endif
- gtk_init (&argc, &argv);
-
- app = unique_app_new ("org.gnome.EvolutionAlarmNotify", NULL);
-
- if (unique_app_is_running (app))
- goto exit;
-
- config_data_init_debugging ();
-
alarm_notify_service = alarm_notify_new ();
- /* FIXME Ideally we should not use camel libraries in calendar,
- * though it is the case currently for attachments. Remove
- * this once that is fixed. */
-
- /* Initialize Camel's type system. */
- camel_object_get_type ();
-
- icon_theme = gtk_icon_theme_get_default ();
- gtk_icon_theme_append_search_path (icon_theme, EVOLUTION_ICONDIR);
-
- gtk_main ();
-
- if (alarm_notify_service != NULL)
- g_object_unref (alarm_notify_service);
-
- alarm_done ();
-
- e_passwords_shutdown ();
+ exit_status = g_application_run (
+ G_APPLICATION (alarm_notify_service), argc, argv);
-exit:
- g_object_unref (app);
+ g_object_unref (alarm_notify_service);
- return 0;
+ return exit_status;
}