[gnome-panel] [clock] Validate input in add location dialog
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] [clock] Validate input in add location dialog
- Date: Tue, 9 Mar 2010 05:03:35 +0000 (UTC)
commit 6478fe0099de086a7a6df0c2111a4848c7a5fdfa
Author: Philippe Gauthier <philippe gauthier deuxpi ca>
Date: Tue Feb 2 22:08:27 2010 -0500
[clock] Validate input in add location dialog
Make the OK button sensitive only when a city name and a timezone are
defined.
https://bugzilla.gnome.org/show_bug.cgi?id=608830
applets/clock/clock.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index b1dead3..0a59ff2 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -3027,6 +3027,27 @@ fill_timezone_combo_from_location (ClockData *cd, ClockLocation *loc)
}
static void
+location_update_ok_sensitivity (ClockData *cd)
+{
+ GtkWidget *ok_button;
+ const gchar *timezone;
+ gchar *name;
+
+ ok_button = _clock_get_widget (cd, "edit-location-ok-button");
+
+ timezone = gweather_timezone_menu_get_tzid (cd->zone_combo);
+ name = gtk_editable_get_chars (GTK_EDITABLE (cd->location_entry), 0, -1);
+
+ if (timezone && name && name[0] != '\0') {
+ gtk_widget_set_sensitive (ok_button, TRUE);
+ } else {
+ gtk_widget_set_sensitive (ok_button, FALSE);
+ }
+
+ g_free (name);
+}
+
+static void
location_changed (GObject *object, GParamSpec *param, ClockData *cd)
{
GWeatherLocationEntry *entry = GWEATHER_LOCATION_ENTRY (object);
@@ -3053,6 +3074,18 @@ location_changed (GObject *object, GParamSpec *param, ClockData *cd)
}
static void
+location_name_changed (GObject *object, ClockData *cd)
+{
+ location_update_ok_sensitivity (cd);
+}
+
+static void
+location_timezone_changed (GObject *object, GParamSpec *param, ClockData *cd)
+{
+ location_update_ok_sensitivity (cd);
+}
+
+static void
edit_clear (ClockData *cd)
{
GtkWidget *lat_entry = _clock_get_widget (cd, "edit-location-latitude-entry");
@@ -3166,6 +3199,8 @@ run_prefs_locations_add (GtkButton *button, ClockData *cd)
GINT_TO_POINTER (g_signal_connect (edit_window, "delete_event", G_CALLBACK (edit_delete), cd)));
}
+ location_update_ok_sensitivity (cd);
+
gtk_widget_grab_focus (GTK_WIDGET (cd->location_entry));
gtk_editable_set_position (GTK_EDITABLE (cd->location_entry), -1);
@@ -3228,6 +3263,8 @@ edit_tree_row (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpoint
gtk_combo_box_set_active (GTK_COMBO_BOX (lon_combo), 1);
}
+ location_update_ok_sensitivity (cd);
+
g_object_set_data (G_OBJECT (edit_window), "clock-location", loc);
gtk_widget_grab_focus (GTK_WIDGET (cd->location_entry));
@@ -3510,6 +3547,8 @@ ensure_prefs_window_is_created (ClockData *cd)
g_signal_connect (G_OBJECT (cd->location_entry), "notify::location",
G_CALLBACK (location_changed), cd);
+ g_signal_connect (G_OBJECT (cd->location_entry), "changed",
+ G_CALLBACK (location_name_changed), cd);
zone_box = _clock_get_widget (cd, "edit-location-timezone-box");
cd->zone_combo = GWEATHER_TIMEZONE_MENU (gweather_timezone_menu_new (world));
@@ -3518,6 +3557,9 @@ ensure_prefs_window_is_created (ClockData *cd)
gtk_label_set_mnemonic_widget (GTK_LABEL (timezone_label),
GTK_WIDGET (cd->zone_combo));
+ g_signal_connect (G_OBJECT (cd->zone_combo), "notify::tzid",
+ G_CALLBACK (location_timezone_changed), cd);
+
gweather_location_unref (world);
g_signal_connect (G_OBJECT (edit_cancel_button), "clicked",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]