[gnome-calendar] source-dialog: use a list of remote sources instead of a single pointer
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] source-dialog: use a list of remote sources instead of a single pointer
- Date: Mon, 25 May 2015 16:58:17 +0000 (UTC)
commit 1c34dc69d8cf8de7381fe2eba5c432cb03c6f496
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Apr 19 11:18:46 2015 -0300
source-dialog: use a list of remote sources instead of a single pointer
src/gcal-source-dialog.c | 59 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 51 insertions(+), 8 deletions(-)
---
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index f30da4d..6318984 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -78,7 +78,7 @@ typedef struct
/* flags */
GcalSourceDialogMode mode;
ESource *source;
- ESource *remote_source;
+ GList *remote_sources;
ESource *removed_source;
ESource *old_default_source;
GBinding *title_bind;
@@ -234,6 +234,24 @@ add_button_clicked (GtkWidget *button,
gcal_source_dialog_set_mode (GCAL_SOURCE_DIALOG (user_data), GCAL_SOURCE_DIALOG_MODE_NORMAL);
}
+
+ if (priv->remote_sources != NULL)
+ {
+ GList *l;
+
+ for (l = priv->remote_sources; l != NULL; l = l->next)
+ {
+ // Commit each new remote source
+ gcal_manager_save_source (priv->manager, l->data);
+ }
+
+ g_list_free (priv->remote_sources);
+
+ priv->remote_sources = NULL;
+
+ // Go back to overview
+ gcal_source_dialog_set_mode (GCAL_SOURCE_DIALOG (user_data), GCAL_SOURCE_DIALOG_MODE_NORMAL);
+ }
}
static void
@@ -398,6 +416,13 @@ cancel_button_clicked (GtkWidget *button,
priv->source = NULL;
}
+ // Cleanup detected remote sources that weren't added
+ if (priv->remote_sources != NULL)
+ {
+ g_list_free_full (priv->remote_sources, g_object_unref);
+ priv->remote_sources = NULL;
+ }
+
gcal_source_dialog_set_mode (GCAL_SOURCE_DIALOG (user_data), GCAL_SOURCE_DIALOG_MODE_NORMAL);
}
@@ -683,15 +708,30 @@ response_signal (GtkDialog *dialog,
if (priv->mode == GCAL_SOURCE_DIALOG_MODE_NORMAL && response_id == GTK_RESPONSE_APPLY)
{
/* save the current page's source */
- if (priv->remote_source != NULL)
- gcal_manager_save_source (priv->manager, priv->remote_source);
+ if (priv->remote_sources != NULL)
+ {
+ GList *l;
+
+ for (l = priv->remote_sources; l != NULL; l = l->next)
+ {
+ // Commit each new remote source
+ gcal_manager_save_source (priv->manager, l->data);
+ }
+
+ g_list_free (priv->remote_sources);
+
+ priv->remote_sources = NULL;
+ }
}
/* Destroy the source when the operation is cancelled */
if (priv->mode == GCAL_SOURCE_DIALOG_MODE_NORMAL && response_id == GTK_RESPONSE_CANCEL)
{
- if (priv->remote_source != NULL)
- g_clear_object (&(priv->remote_source));
+ if (priv->remote_sources != NULL)
+ {
+ g_list_free_full (priv->remote_sources, g_object_unref);
+ priv->remote_sources = NULL;
+ }
}
}
@@ -1169,8 +1209,11 @@ validate_url_cb (GcalSourceDialog *dialog)
* Remove any reminescent ESources
* cached before.
*/
- if (priv->remote_source != NULL)
- g_clear_pointer (&(priv->remote_source), g_object_unref);
+ if (priv->remote_sources != NULL)
+ {
+ g_list_free_full (priv->remote_sources, g_object_unref);
+ priv->remote_sources = NULL;
+ }
// Get the hostname and file path from the server
uri_valid = uri_get_fields (gtk_entry_get_text (GTK_ENTRY (priv->calendar_address_entry)), NULL, &host,
&path);
@@ -1206,7 +1249,7 @@ validate_url_cb (GcalSourceDialog *dialog)
if (g_str_has_suffix (path, ".ics"))
{
// Set the private source so it saves at closing
- priv->remote_source = source;
+ priv->remote_sources = g_list_append (priv->remote_sources, source);
// Update buttons
gtk_widget_set_sensitive (priv->add_button, source != NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]