[gnome-calendar] manager: implemented GcalManager::source-added and GcalManager::source-removed signals
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] manager: implemented GcalManager::source-added and GcalManager::source-removed signals
- Date: Tue, 16 Dec 2014 13:14:06 +0000 (UTC)
commit 0cefc9f5eaf64ebf1c0d9937c38705579a901b09
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Dec 15 15:58:59 2014 -0200
manager: implemented GcalManager::source-added and GcalManager::source-removed signals
src/gcal-manager.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/gcal-manager.h | 4 ++++
2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
index f082e65..5fb20bd 100644
--- a/src/gcal-manager.c
+++ b/src/gcal-manager.c
@@ -66,6 +66,16 @@ struct _MoveEventData
typedef struct _MoveEventData MoveEventData;
+enum
+{
+ SOURCE_ACTIVATE,
+ SOURCE_ADDED,
+ SOURCE_REMOVED,
+ NUM_SIGNALS
+};
+
+static guint signals[NUM_SIGNALS] = { 0, };
+
static void free_async_ops_data (AsyncOpsData *data);
static void free_unit_data (GcalManagerUnit *data);
@@ -77,6 +87,10 @@ static void on_client_connected (GObject *sour
GAsyncResult *result,
gpointer user_data);
+static void on_client_readonly_changed (EClient *client,
+ GParamSpec *pspec,
+ gpointer user_data);
+
static void on_client_refreshed (GObject *source_object,
GAsyncResult *result,
gpointer user_data);
@@ -259,11 +273,16 @@ on_client_connected (GObject *source_object,
unit->enabled = TRUE;
g_hash_table_insert (priv->clients, source, unit);
+ g_signal_emit (GCAL_MANAGER (user_data), signals[SOURCE_ADDED], 0, source);
g_debug ("Source %s (%s) connected",
e_source_get_display_name (source),
e_source_get_uid (source));
+ /* notify the readonly property */
+ g_signal_connect (client, "notify::readonly",
+ G_CALLBACK (on_client_readonly_changed), user_data);
+
e_cal_data_model_add_client (priv->e_data_model, client);
e_cal_data_model_add_client (priv->search_data_model, client);
g_clear_object (&client);
@@ -283,6 +302,20 @@ on_client_connected (GObject *source_object,
}
}
+static void
+on_client_readonly_changed (EClient *client,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ ESource *source;
+ gboolean readonly;
+
+ source = e_client_get_source (client);
+ readonly = e_client_is_readonly (client);
+
+ g_signal_emit (GCAL_MANAGER (user_data), signals[SOURCE_ACTIVATE], 0, source, !readonly);
+}
+
static void
on_client_refreshed (GObject *source_object,
@@ -404,12 +437,29 @@ remove_source (GcalManager *manager,
e_cal_data_model_remove_client (priv->search_data_model,
e_source_get_uid (source));
g_hash_table_remove (priv->clients, source);
+ g_signal_emit (manager, signals[SOURCE_REMOVED], 0, source);
}
static void
gcal_manager_class_init (GcalManagerClass *klass)
{
G_OBJECT_CLASS (klass)->finalize = gcal_manager_finalize;
+
+ /* signals */
+ signals[SOURCE_ACTIVATE] = g_signal_new ("source-activate", GCAL_TYPE_MANAGER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalManagerClass, source_activate),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+
+ signals[SOURCE_ADDED] = g_signal_new ("source-added", GCAL_TYPE_MANAGER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalManagerClass, source_added),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ signals[SOURCE_REMOVED] = g_signal_new ("source-removed", GCAL_TYPE_MANAGER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalManagerClass, source_removed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
}
static void
diff --git a/src/gcal-manager.h b/src/gcal-manager.h
index a4c20ee..8783d15 100644
--- a/src/gcal-manager.h
+++ b/src/gcal-manager.h
@@ -44,6 +44,10 @@ struct _GcalManager
struct _GcalManagerClass
{
GObjectClass parent_class;
+
+ /* signals */
+ void (*source_added) (GcalManager *manager, ESource *source);
+ void (*source_removed) (GcalManager *manager, ESource *source);
};
typedef struct
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]