GNOME Bugzilla – Bug 724416
'Add' button is sensitive for unavailable location in new location dialog box
Last modified: 2014-02-17 21:36:28 UTC
When user enters invalid or unavailable location in GtkLocationEntry, the "Add" button remains sensitive and if user presses add then the dialog box gets destroyed and affects nothing. Instead of this User should not be able to press "Add" button when entered location is not available or nothing is entered.
If I press return without entering any location in the new location dialog box, t shows segfault and crashes down.
Created attachment 269216 [details] [review] this changes sensitivity of "Add" button in new location dialog box whenever it needs to be changed. This patch might have an issue with the look of ADD button when it is not sensitive but that has to do with gnome-themes-standard(dark theme) and not gnome-weather.
Review of attachment 269216 [details] [review]: ::: src/window.js @@ +54,2 @@ dialog.connect('response', Lang.bind(this, this._onResponse)); + entry.connect('search-changed', Lang.bind(this, this._location_changed)); search-changed only happens after a timeout. You should use notify::location instead. @@ +77,3 @@ + }, + + _location_changed: function() { Please use lowerCamelCase, following the gjs convention. @@ +80,3 @@ + var empty = this._entry.get_text().localeCompare("") == 0; + + if (!this._entry.location || empty) { This empty check is not needed anymore, the libgweather crash was fixed. @@ +81,3 @@ + + if (!this._entry.location || empty) { + this._dialog.set_default_response(Gtk.ResponseType.CANCEL); Mh, so if I make a typo searching and press enter it cancels? This does not look like an improvement from before... I'd keep the default response to OK, and make it insensitive when location == null.
Let's not change default response as it is not making much sense but we have to check for empty location entry because if user enters some location and then erase it completely then also the add button remains sensitive as user entered one valid location before so we have to manually set location to null whenever location entry is emptied.
Connect "notify::location" signal causes some problem to locationentry dialog-box. Clicking on new button tries to open the new location dialog box but the box is blacked out and after that I've to do force-quit. Connecting this signal from glade doesn't work and I already have this experience.
Delay for 'search-change' emission after last change is only 150 milliseconds. I guess this would not make any major difference.
Created attachment 269396 [details] [review] Corrected patch Using "notify::location" messes up with new location entry dialog box(make it totally black) and I've to force quit the app. We have to check for empty condition as to set the entry.location to null if user entered valid location before the empty condition otherwise it'll show that the entry.location is set to the previously entered location.
Created attachment 269398 [details] [review] Corrected patch Using "notify::location" messes up with new location entry dialog box(make it totally black) and I've to force quit the app. We have to check for empty condition as to set the entry.location to null if user entered valid location before the empty condition otherwise it'll show that the entry.location is set to the previously entered location.
Pushed with the notify::location change, after testing that it works.
*** Bug 724459 has been marked as a duplicate of this bug. ***