[gnome-calendar/calendar-editor] source-dialog: clear pages before showing the dialog in creation mode



commit 64ebc4e299114ce3597e1ef11fd0df2d9a4c8af0
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Feb 10 14:28:08 2015 -0200

    source-dialog: clear pages before showing the dialog in creation mode

 src/gcal-source-dialog.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index cdbd04e..6ec838a 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -39,6 +39,7 @@ typedef struct
 
   /* new source details */
   GtkWidget          *author_label;
+  GtkWidget          *calendar_address_entry;
   GtkWidget          *details_frame;
   GtkWidget          *local_source_grid;
   GtkWidget          *new_calendar_name_entry;
@@ -67,6 +68,8 @@ struct _GcalSourceDialog
 static void       action_widget_activated               (GtkWidget            *widget,
                                                          gpointer              user_data);
 
+static void       clear_pages                           (GcalSourceDialog     *dialog);
+
 static void       color_set                             (GtkColorButton       *button,
                                                          gpointer              user_data);
 
@@ -130,6 +133,30 @@ action_widget_activated (GtkWidget *widget,
   gtk_dialog_response (GTK_DIALOG (user_data), response);
 }
 
+/**
+ * clear_pages:
+ *
+ * Clear local and web pages.
+ *
+ * Returns:
+ */
+static void
+clear_pages (GcalSourceDialog *dialog)
+{
+  GcalSourceDialogPrivate *priv = dialog->priv;
+
+  gtk_button_set_label (GTK_BUTTON (priv->select_file_button), _("Select Calendar Fileā€¦"));
+
+  gtk_entry_set_text (GTK_ENTRY (priv->calendar_address_entry), "");
+
+  gtk_widget_set_sensitive (priv->add_button, FALSE);
+
+  /* details frame */
+  if (gtk_widget_get_parent (priv->details_frame) != NULL)
+    gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (priv->details_frame)), priv->details_frame);
+  gtk_widget_hide (priv->details_frame);
+}
+
 static void
 color_set (GtkColorButton *button,
            gpointer        user_data)
@@ -514,6 +541,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
 
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, add_button);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, author_label);
+  gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, calendar_address_entry);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, calendar_color_button);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, cancel_button);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, default_check);
@@ -607,6 +635,8 @@ gcal_source_dialog_set_mode (GcalSourceDialog    *dialog,
       gtk_window_resize (GTK_WINDOW (dialog), 550, 500);
       gtk_header_bar_set_title (GTK_HEADER_BAR (priv->headerbar), _("Add Calendar"));
       gtk_header_bar_set_subtitle (GTK_HEADER_BAR (priv->headerbar), "");
+
+      clear_pages (dialog);
     }
   else
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]