[gnome-calendar] source-dialog: show a spinner when it should be validating
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] source-dialog: show a spinner when it should be validating
- Date: Mon, 25 May 2015 16:50:32 +0000 (UTC)
commit b59da7e2e0f9a611d1a0438a872122ea0895df0a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Feb 13 18:59:38 2015 -0200
source-dialog: show a spinner when it should be validating
data/theme/gtk-styles.css | 4 ++++
data/ui/source-dialog.ui | 13 +++++++++++++
src/gcal-source-dialog.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/data/theme/gtk-styles.css b/data/theme/gtk-styles.css
index cb82818..dbfaf3d 100644
--- a/data/theme/gtk-styles.css
+++ b/data/theme/gtk-styles.css
@@ -232,3 +232,7 @@ GcalEventWidget.color-light:backdrop {
.details-frame {
background-color: rgba(0, 0, 0, 0);
}
+
+.spinner-offscreen {
+ background-color: transparent;
+}
diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui
index 708e978..68504b0 100644
--- a/data/ui/source-dialog.ui
+++ b/data/ui/source-dialog.ui
@@ -428,4 +428,17 @@
<class name="details-frame"/>
</style>
</object>
+ <object class="GtkOffscreenWindow" id="spinner_window">
+ <property name="visible">True</property>
+ <signal name="damage-event" handler="spinner_damaged" object="GcalSourceDialog" swapped="no"/>
+ <style>
+ <class name="spinner-offscreen" />
+ </style>
+ <child>
+ <object class="GtkSpinner" id="spinner">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 9139077..a993753 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -33,6 +33,8 @@ typedef struct
GtkWidget *headerbar;
GtkWidget *name_entry;
GtkWidget *notebook;
+ GtkWidget *spinner;
+ GtkWidget *spinner_window;
GtkWidget *remove_button;
GtkWidget *select_file_button;
GtkWidget *stack;
@@ -102,6 +104,10 @@ static void select_calendar_file (GtkButton *bu
static void setup_source_details (GcalSourceDialog *dialog,
ESource *source);
+static gboolean spinner_damaged (GtkWidget *spinner,
+ GdkEvent *event,
+ gpointer user_data);
+
static void url_entry_text_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data);
@@ -468,6 +474,29 @@ setup_source_details (GcalSourceDialog *dialog,
}
/**
+ * spinner_damaged:
+ *
+ * Update the url's entry with
+ * the spinner icon.
+ *
+ * Returns: FALSE
+ */
+static gboolean
+spinner_damaged (GtkWidget *spinner,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
+ GdkPixbuf *pix;
+
+ pix = gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (priv->spinner_window));
+
+ gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (priv->calendar_address_entry), GTK_ENTRY_ICON_SECONDARY, pix);
+
+ return FALSE;
+}
+
+/**
* url_entry_text_changed:
*
* Performs a validation of the URL
@@ -496,6 +525,7 @@ url_entry_text_changed (GObject *object,
else
{
/* remove entry's icon */
+ gtk_spinner_stop (GTK_SPINNER (priv->spinner));
gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (priv->calendar_address_entry), GTK_ENTRY_ICON_SECONDARY,
NULL);
}
}
@@ -515,6 +545,8 @@ validate_url_cb (GcalSourceDialog *dialog)
priv->validate_url_resource_id = 0;
+ gtk_spinner_start (GTK_SPINNER (priv->spinner));
+
g_message ("stub");
return FALSE;
@@ -615,6 +647,8 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, notebook);
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, remove_button);
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, select_file_button);
+ gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, spinner);
+ gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, spinner_window);
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, stack);
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, web_source_grid);
@@ -626,6 +660,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
gtk_widget_class_bind_template_callback (widget_class, notebook_page_switched);
gtk_widget_class_bind_template_callback (widget_class, response_signal);
gtk_widget_class_bind_template_callback (widget_class, select_calendar_file);
+ gtk_widget_class_bind_template_callback (widget_class, spinner_damaged);
gtk_widget_class_bind_template_callback (widget_class, url_entry_text_changed);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]