[gnome-calendar] manager: add :load-completed signal
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] manager: add :load-completed signal
- Date: Fri, 6 Feb 2015 14:25:48 +0000 (UTC)
commit 8f7d9313408c37a26c6b255cfa35894087bc0cc1
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Sun Feb 1 16:39:43 2015 -0500
manager: add :load-completed signal
:load-completed signals the end of the opening of the sources initially
read from ESourceRegistry.
src/gcal-manager.c | 27 ++++++++++++++++++++++-----
src/gcal-manager.h | 1 +
2 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
index 4cb5d5b..108a375 100644
--- a/src/gcal-manager.c
+++ b/src/gcal-manager.c
@@ -52,7 +52,10 @@ typedef struct
GCancellable *async_ops;
+ /* state flags */
gchar **disabled_sources;
+ gint sources_at_launch;
+
/* timezone */
icaltimezone *system_timezone;
@@ -82,6 +85,7 @@ enum
SOURCE_ACTIVATED,
SOURCE_ADDED,
SOURCE_REMOVED,
+ LOAD_COMPLETED,
NUM_SIGNALS
};
@@ -303,6 +307,10 @@ on_client_connected (GObject *source_object,
priv = gcal_manager_get_instance_private (GCAL_MANAGER (user_data));
source = e_client_get_source (E_CLIENT (source_object));
+ priv->sources_at_launch--;
+ if (priv->sources_at_launch == 0)
+ g_signal_emit (user_data, signals[LOAD_COMPLETED], 0);
+
error = NULL;
client = E_CAL_CLIENT (e_cal_client_connect_finish (result, &error));
if (error == NULL)
@@ -531,6 +539,11 @@ gcal_manager_class_init (GcalManagerClass *klass)
G_STRUCT_OFFSET (GcalManagerClass, source_removed),
NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ signals[LOAD_COMPLETED] = g_signal_new ("load-completed", GCAL_TYPE_MANAGER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalManagerClass, load_completed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
}
static void
@@ -566,11 +579,6 @@ gcal_manager_constructed (GObject *object)
return;
}
- sources = e_source_registry_list_enabled (priv->source_registry, E_SOURCE_EXTENSION_CALENDAR);
- for (l = sources; l != NULL; l = l->next)
- load_source (GCAL_MANAGER (object), l->data);
- g_list_free (sources);
-
g_signal_connect_swapped (priv->source_registry, "source-added", G_CALLBACK (load_source), object);
g_signal_connect_swapped (priv->source_registry, "source-removed", G_CALLBACK (remove_source), object);
@@ -582,6 +590,15 @@ gcal_manager_constructed (GObject *object)
e_cal_data_model_set_timezone (priv->e_data_model, priv->system_timezone);
e_cal_data_model_set_expand_recurrences (priv->search_data_model, TRUE);
e_cal_data_model_set_timezone (priv->search_data_model, priv->system_timezone);
+
+ g_signal_connect_swapped (priv->search_data_model, "view-state-changed", G_CALLBACK (model_state_changed),
object);
+
+ sources = e_source_registry_list_enabled (priv->source_registry, E_SOURCE_EXTENSION_CALENDAR);
+ priv->sources_at_launch = g_list_length (sources);
+
+ for (l = sources; l != NULL; l = l->next)
+ load_source (GCAL_MANAGER (object), l->data);
+ g_list_free (sources);
}
static void
diff --git a/src/gcal-manager.h b/src/gcal-manager.h
index b0d7b22..c34b808 100644
--- a/src/gcal-manager.h
+++ b/src/gcal-manager.h
@@ -49,6 +49,7 @@ struct _GcalManagerClass
void (*source_activated) (GcalManager *manager, ESource *source, gboolean active);
void (*source_added) (GcalManager *manager, ESource *source, gboolean enabled);
void (*source_removed) (GcalManager *manager, ESource *source);
+ void (*load_completed) (GcalManager *manager);
};
typedef struct
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]