[gnome-calendar] manager: notify when sources are enabled/disabled
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] manager: notify when sources are enabled/disabled
- Date: Mon, 25 May 2015 17:01:55 +0000 (UTC)
commit 2b4e46a4b6e8916656b192dc9c5a4925ec055480
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat May 2 08:28:50 2015 -0300
manager: notify when sources are enabled/disabled
Add the new signal for GcalManager::source-enabled that
notifies connected widgets about the source change. With
that, we can keep checkboxes syncronizes.
src/gcal-manager.c | 10 ++++++++++
src/gcal-manager.h | 1 +
src/gcal-source-dialog.c | 5 +++++
src/gcal-window.c | 33 +++++++++++++++++++++++++++++++++
4 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
index a210aca..e9b51ee 100644
--- a/src/gcal-manager.c
+++ b/src/gcal-manager.c
@@ -103,6 +103,7 @@ enum
SOURCE_ACTIVATED,
SOURCE_ADDED,
SOURCE_REMOVED,
+ SOURCE_ENABLED,
LOAD_COMPLETED,
QUERY_COMPLETED,
GOA_CLIENT_READY,
@@ -670,6 +671,11 @@ gcal_manager_class_init (GcalManagerClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_POINTER);
+ signals[SOURCE_ENABLED] = g_signal_new ("source-enabled", GCAL_TYPE_MANAGER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalManagerClass, source_enabled),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 2, E_TYPE_SOURCE, G_TYPE_BOOLEAN);
+
signals[LOAD_COMPLETED] = g_signal_new ("load-completed", GCAL_TYPE_MANAGER, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GcalManagerClass, load_completed),
NULL, NULL, NULL,
@@ -1246,6 +1252,8 @@ gcal_manager_enable_source (GcalManager *manager,
g_strfreev (priv->disabled_sources);
priv->disabled_sources = new_disabled_sources;
+ g_signal_emit (manager, signals[SOURCE_ENABLED], 0, source, TRUE);
+
/* sync settings value */
g_settings_set_strv (priv->settings, "disabled-sources", (const gchar * const *) priv->disabled_sources);
}
@@ -1290,6 +1298,8 @@ gcal_manager_disable_source (GcalManager *manager,
g_strfreev (priv->disabled_sources);
priv->disabled_sources = new_disabled_sources;
+ g_signal_emit (manager, signals[SOURCE_ENABLED], 0, source, FALSE);
+
/* sync settings value */
g_settings_set_strv (priv->settings, "disabled-sources", (const gchar * const *) priv->disabled_sources);
}
diff --git a/src/gcal-manager.h b/src/gcal-manager.h
index 364244b..beee500 100644
--- a/src/gcal-manager.h
+++ b/src/gcal-manager.h
@@ -50,6 +50,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 (*source_enabled) (GcalManager *manager, ESource *source, gboolean enabled);
void (*load_completed) (GcalManager *manager);
void (*query_completed) (GcalManager *manager);
void (*goa_client_ready) (GcalManager *manager, GoaClient *client);
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 7c77be1..5023852 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -2247,6 +2247,7 @@ gcal_source_dialog_set_mode (GcalSourceDialog *dialog,
GcalSourceDialogMode mode)
{
GcalSourceDialogPrivate *priv = dialog->priv;
+ GcalSourceDialogMode previous_mode = priv->mode;
priv->mode = mode;
@@ -2297,6 +2298,10 @@ gcal_source_dialog_set_mode (GcalSourceDialog *dialog,
default:
g_assert_not_reached ();
}
+
+ if (previous_mode == mode)
+ stack_visible_child_name_changed (G_OBJECT (priv->stack), NULL, dialog);
+
}
/**
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 12eb551..9f6e3ad 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -206,6 +206,12 @@ static void source_row_activated (GtkListBox *l
GtkListBoxRow *row,
gpointer user_data);
+static void source_enabled (GcalManager *manager,
+ ESource *source,
+ gboolean enabled,
+ gpointer user_data);
+
+
static void on_calendar_toggled (GObject *object,
GParamSpec *pspec,
gpointer user_data);
@@ -931,6 +937,32 @@ source_row_activated (GtkListBox *listbox,
}
static void
+source_enabled (GcalManager *manager,
+ ESource *source,
+ gboolean enabled,
+ gpointer user_data)
+{
+ GcalWindowPrivate *priv = gcal_window_get_instance_private (GCAL_WINDOW (user_data));
+ GList *children, *aux;
+
+ children = gtk_container_get_children (GTK_CONTAINER (priv->calendar_listbox));
+
+ for (aux = children; aux != NULL; aux = aux->next)
+ {
+ ESource *child_source = g_object_get_data (G_OBJECT (aux->data), "source");
+
+ if (child_source != NULL && child_source == source)
+ {
+ gtk_widget_destroy (aux->data);
+ add_source (manager, source, enabled, user_data);
+ break;
+ }
+ }
+
+ g_list_free (children);
+}
+
+static void
on_calendar_toggled (GObject *object,
GParamSpec *pspec,
gpointer user_data)
@@ -1556,6 +1588,7 @@ gcal_window_set_property (GObject *object,
case PROP_MANAGER:
priv->manager = g_value_get_pointer (value);
g_signal_connect (priv->manager, "source-added", G_CALLBACK (add_source), object);
+ g_signal_connect (priv->manager, "source-enabled", G_CALLBACK (source_enabled), object);
g_signal_connect (priv->manager, "source-removed", G_CALLBACK (remove_source), object);
gcal_year_view_set_manager (GCAL_YEAR_VIEW (priv->year_view), priv->manager);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]