[gnome-calendar/calendar-editor] source-dialog: stub validation query
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/calendar-editor] source-dialog: stub validation query
- Date: Fri, 13 Feb 2015 20:22:38 +0000 (UTC)
commit c00b363c9cc760160e4d7549cbc1723e7562c4b7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Feb 13 18:22:08 2015 -0200
source-dialog: stub validation query
data/ui/source-dialog.ui | 1 +
src/gcal-source-dialog.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui
index a5f38f4..708e978 100644
--- a/data/ui/source-dialog.ui
+++ b/data/ui/source-dialog.ui
@@ -179,6 +179,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
+ <signal name="notify::text" handler="url_entry_text_changed"
object="GcalSourceDialog" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 6ec838a..9139077 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -45,6 +45,8 @@ typedef struct
GtkWidget *new_calendar_name_entry;
GtkWidget *web_source_grid;
+ gint validate_url_resource_id;
+
/* flags */
GcalSourceDialogMode mode;
ESource *source;
@@ -100,6 +102,12 @@ static void select_calendar_file (GtkButton *bu
static void setup_source_details (GcalSourceDialog *dialog,
ESource *source);
+static void url_entry_text_changed (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data);
+
+static gboolean validate_url_cb (GcalSourceDialog *dialog);
+
G_DEFINE_TYPE_WITH_PRIVATE (GcalSourceDialog, gcal_source_dialog, GTK_TYPE_DIALOG)
enum {
@@ -459,6 +467,59 @@ setup_source_details (GcalSourceDialog *dialog,
gtk_widget_show_all (priv->details_frame);
}
+/**
+ * url_entry_text_changed:
+ *
+ * Performs a validation of the URL
+ * 1 second after the user inputs.
+ *
+ * Returns:
+ */
+static void
+url_entry_text_changed (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
+ const gchar* text;
+
+ text = gtk_entry_get_text (GTK_ENTRY (priv->calendar_address_entry));
+
+ if (g_utf8_strlen (text, -1) != 0)
+ {
+ // Remove any previous unreleased resource
+ if (priv->validate_url_resource_id != 0)
+ g_source_remove (priv->validate_url_resource_id);
+
+ priv->validate_url_resource_id = g_timeout_add_seconds (1, validate_url_cb, user_data);
+ }
+ else
+ {
+ /* remove entry's icon */
+ gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (priv->calendar_address_entry), GTK_ENTRY_ICON_SECONDARY,
NULL);
+ }
+}
+
+/**
+ * validate_url_cb:
+ *
+ * Query the given URL for possible
+ * calendar data.
+ *
+ * Returns:FALSE
+ */
+static gboolean
+validate_url_cb (GcalSourceDialog *dialog)
+{
+ GcalSourceDialogPrivate *priv = dialog->priv;
+
+ priv->validate_url_resource_id = 0;
+
+ g_message ("stub");
+
+ return FALSE;
+}
+
GcalSourceDialog *
gcal_source_dialog_new (void)
{
@@ -565,6 +626,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, url_entry_text_changed);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]