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.
This commit is contained in:
committed by
Erick Pérez Castellanos
parent
023a79a90f
commit
2b4e46a4b6
@@ -103,6 +103,7 @@ enum
|
|||||||
SOURCE_ACTIVATED,
|
SOURCE_ACTIVATED,
|
||||||
SOURCE_ADDED,
|
SOURCE_ADDED,
|
||||||
SOURCE_REMOVED,
|
SOURCE_REMOVED,
|
||||||
|
SOURCE_ENABLED,
|
||||||
LOAD_COMPLETED,
|
LOAD_COMPLETED,
|
||||||
QUERY_COMPLETED,
|
QUERY_COMPLETED,
|
||||||
GOA_CLIENT_READY,
|
GOA_CLIENT_READY,
|
||||||
@@ -670,6 +671,11 @@ gcal_manager_class_init (GcalManagerClass *klass)
|
|||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
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,
|
signals[LOAD_COMPLETED] = g_signal_new ("load-completed", GCAL_TYPE_MANAGER, G_SIGNAL_RUN_LAST,
|
||||||
G_STRUCT_OFFSET (GcalManagerClass, load_completed),
|
G_STRUCT_OFFSET (GcalManagerClass, load_completed),
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
@@ -1246,6 +1252,8 @@ gcal_manager_enable_source (GcalManager *manager,
|
|||||||
g_strfreev (priv->disabled_sources);
|
g_strfreev (priv->disabled_sources);
|
||||||
priv->disabled_sources = new_disabled_sources;
|
priv->disabled_sources = new_disabled_sources;
|
||||||
|
|
||||||
|
g_signal_emit (manager, signals[SOURCE_ENABLED], 0, source, TRUE);
|
||||||
|
|
||||||
/* sync settings value */
|
/* sync settings value */
|
||||||
g_settings_set_strv (priv->settings, "disabled-sources", (const gchar * const *) priv->disabled_sources);
|
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);
|
g_strfreev (priv->disabled_sources);
|
||||||
priv->disabled_sources = new_disabled_sources;
|
priv->disabled_sources = new_disabled_sources;
|
||||||
|
|
||||||
|
g_signal_emit (manager, signals[SOURCE_ENABLED], 0, source, FALSE);
|
||||||
|
|
||||||
/* sync settings value */
|
/* sync settings value */
|
||||||
g_settings_set_strv (priv->settings, "disabled-sources", (const gchar * const *) priv->disabled_sources);
|
g_settings_set_strv (priv->settings, "disabled-sources", (const gchar * const *) priv->disabled_sources);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ struct _GcalManagerClass
|
|||||||
void (*source_activated) (GcalManager *manager, ESource *source, gboolean active);
|
void (*source_activated) (GcalManager *manager, ESource *source, gboolean active);
|
||||||
void (*source_added) (GcalManager *manager, ESource *source, gboolean enabled);
|
void (*source_added) (GcalManager *manager, ESource *source, gboolean enabled);
|
||||||
void (*source_removed) (GcalManager *manager, ESource *source);
|
void (*source_removed) (GcalManager *manager, ESource *source);
|
||||||
|
void (*source_enabled) (GcalManager *manager, ESource *source, gboolean enabled);
|
||||||
void (*load_completed) (GcalManager *manager);
|
void (*load_completed) (GcalManager *manager);
|
||||||
void (*query_completed) (GcalManager *manager);
|
void (*query_completed) (GcalManager *manager);
|
||||||
void (*goa_client_ready) (GcalManager *manager, GoaClient *client);
|
void (*goa_client_ready) (GcalManager *manager, GoaClient *client);
|
||||||
|
|||||||
@@ -2247,6 +2247,7 @@ gcal_source_dialog_set_mode (GcalSourceDialog *dialog,
|
|||||||
GcalSourceDialogMode mode)
|
GcalSourceDialogMode mode)
|
||||||
{
|
{
|
||||||
GcalSourceDialogPrivate *priv = dialog->priv;
|
GcalSourceDialogPrivate *priv = dialog->priv;
|
||||||
|
GcalSourceDialogMode previous_mode = priv->mode;
|
||||||
|
|
||||||
priv->mode = mode;
|
priv->mode = mode;
|
||||||
|
|
||||||
@@ -2297,6 +2298,10 @@ gcal_source_dialog_set_mode (GcalSourceDialog *dialog,
|
|||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (previous_mode == mode)
|
||||||
|
stack_visible_child_name_changed (G_OBJECT (priv->stack), NULL, dialog);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -206,6 +206,12 @@ static void source_row_activated (GtkListBox *l
|
|||||||
GtkListBoxRow *row,
|
GtkListBoxRow *row,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void source_enabled (GcalManager *manager,
|
||||||
|
ESource *source,
|
||||||
|
gboolean enabled,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
static void on_calendar_toggled (GObject *object,
|
static void on_calendar_toggled (GObject *object,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -930,6 +936,32 @@ source_row_activated (GtkListBox *listbox,
|
|||||||
gtk_widget_hide (priv->source_dialog);
|
gtk_widget_hide (priv->source_dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
on_calendar_toggled (GObject *object,
|
on_calendar_toggled (GObject *object,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
@@ -1556,6 +1588,7 @@ gcal_window_set_property (GObject *object,
|
|||||||
case PROP_MANAGER:
|
case PROP_MANAGER:
|
||||||
priv->manager = g_value_get_pointer (value);
|
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-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);
|
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);
|
gcal_year_view_set_manager (GCAL_YEAR_VIEW (priv->year_view), priv->manager);
|
||||||
|
|||||||
Reference in New Issue
Block a user