source-dialog: use a list of remote sources instead of a single pointer
This commit is contained in:
committed by
Erick Pérez Castellanos
parent
905dcc4268
commit
1c34dc69d8
@@ -78,7 +78,7 @@ typedef struct
|
|||||||
/* flags */
|
/* flags */
|
||||||
GcalSourceDialogMode mode;
|
GcalSourceDialogMode mode;
|
||||||
ESource *source;
|
ESource *source;
|
||||||
ESource *remote_source;
|
GList *remote_sources;
|
||||||
ESource *removed_source;
|
ESource *removed_source;
|
||||||
ESource *old_default_source;
|
ESource *old_default_source;
|
||||||
GBinding *title_bind;
|
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);
|
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
|
static void
|
||||||
@@ -398,6 +416,13 @@ cancel_button_clicked (GtkWidget *button,
|
|||||||
priv->source = NULL;
|
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);
|
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)
|
if (priv->mode == GCAL_SOURCE_DIALOG_MODE_NORMAL && response_id == GTK_RESPONSE_APPLY)
|
||||||
{
|
{
|
||||||
/* save the current page's source */
|
/* save the current page's source */
|
||||||
if (priv->remote_source != NULL)
|
if (priv->remote_sources != NULL)
|
||||||
gcal_manager_save_source (priv->manager, priv->remote_source);
|
{
|
||||||
|
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 */
|
/* Destroy the source when the operation is cancelled */
|
||||||
if (priv->mode == GCAL_SOURCE_DIALOG_MODE_NORMAL && response_id == GTK_RESPONSE_CANCEL)
|
if (priv->mode == GCAL_SOURCE_DIALOG_MODE_NORMAL && response_id == GTK_RESPONSE_CANCEL)
|
||||||
{
|
{
|
||||||
if (priv->remote_source != NULL)
|
if (priv->remote_sources != NULL)
|
||||||
g_clear_object (&(priv->remote_source));
|
{
|
||||||
|
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
|
* Remove any reminescent ESources
|
||||||
* cached before.
|
* cached before.
|
||||||
*/
|
*/
|
||||||
if (priv->remote_source != NULL)
|
if (priv->remote_sources != NULL)
|
||||||
g_clear_pointer (&(priv->remote_source), g_object_unref);
|
{
|
||||||
|
g_list_free_full (priv->remote_sources, g_object_unref);
|
||||||
|
priv->remote_sources = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the hostname and file path from the server
|
// 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);
|
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"))
|
if (g_str_has_suffix (path, ".ics"))
|
||||||
{
|
{
|
||||||
// Set the private source so it saves at closing
|
// 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
|
// Update buttons
|
||||||
gtk_widget_set_sensitive (priv->add_button, source != NULL);
|
gtk_widget_set_sensitive (priv->add_button, source != NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user