[Goodies-commits] r7601 - in xfce4-weather-plugin/trunk: . panel-plugin po
Colin Leroy
colin at xfce.org
Wed Jun 17 20:14:47 CEST 2009
Author: colin
Date: 2009-06-17 18:14:47 +0000 (Wed, 17 Jun 2009)
New Revision: 7601
Modified:
xfce4-weather-plugin/trunk/ChangeLog
xfce4-weather-plugin/trunk/panel-plugin/weather-config.c
xfce4-weather-plugin/trunk/panel-plugin/weather-config.h
xfce4-weather-plugin/trunk/panel-plugin/weather-search.c
xfce4-weather-plugin/trunk/panel-plugin/weather-search.h
xfce4-weather-plugin/trunk/panel-plugin/weather.c
xfce4-weather-plugin/trunk/panel-plugin/weather.h
xfce4-weather-plugin/trunk/po/xfce4-weather-plugin.pot
Log:
2009-06-17 Colin Leroy <colin at colino.net>
* panel-plugin/*: Some fixes to the location handling: better search
dialog with buttons that enable/disable when appropriate, focus handling
to allow for a quick search. Display the location name instead of code
in the configuration panel (and make it non-editable once chosen), and
store the display name along the location code (which could help us
migrate to/add another provider transparently if ever needed).
Modified: xfce4-weather-plugin/trunk/ChangeLog
===================================================================
--- xfce4-weather-plugin/trunk/ChangeLog 2009-06-16 19:25:03 UTC (rev 7600)
+++ xfce4-weather-plugin/trunk/ChangeLog 2009-06-17 18:14:47 UTC (rev 7601)
@@ -1,3 +1,12 @@
+2009-06-17 Colin Leroy <colin at colino.net>
+
+ * panel-plugin/*: Some fixes to the location handling: better search
+ dialog with buttons that enable/disable when appropriate, focus handling
+ to allow for a quick search. Display the location name instead of code
+ in the configuration panel (and make it non-editable once chosen), and
+ store the display name along the location code (which could help us
+ migrate to/add another provider transparently if ever needed).
+
2009-06-16 Colin Leroy <colin at colino.net>
Release 0.6.4
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-config.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-config.c 2009-06-16 19:25:03 UTC (rev 7600)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-config.c 2009-06-17 18:14:47 UTC (rev 7601)
@@ -177,9 +177,15 @@
if (data->location_code)
g_free (data->location_code);
+ if (data->location_name)
+ g_free (data->location_name);
+
data->location_code =
g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->txt_loc_code)));
+ data->location_name =
+ g_strdup (gtk_label_get_text (GTK_LABEL (dialog->txt_loc_name)));
+
/* call labels_clear() here */
if (data->labels && data->labels->len > 0)
g_array_free (data->labels, TRUE);
@@ -280,9 +286,13 @@
dialog->wd->proxy_host,
dialog->wd->proxy_port);
- if (run_search_dialog (sdialog))
+ if (run_search_dialog (sdialog)) {
gtk_entry_set_text (GTK_ENTRY (dialog->txt_loc_code), sdialog->result);
-
+ gtk_label_set_text (GTK_LABEL (dialog->txt_loc_name), sdialog->result_name);
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(dialog->txt_loc_name,sdialog->result_name);
+#endif
+ }
free_search_dialog (sdialog);
return FALSE;
@@ -335,25 +345,48 @@
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- label = gtk_label_new (_("Location code:"));
+ label = gtk_label_new (_("Location:"));
dialog->txt_loc_code = gtk_entry_new ();
+ dialog->txt_loc_name = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-
+ gtk_misc_set_alignment (GTK_MISC (dialog->txt_loc_name), 0, 0.5);
+
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_label_set_ellipsize (GTK_LABEL(dialog->txt_loc_name), PANGO_ELLIPSIZE_END);
+#endif
if (dialog->wd->location_code != NULL)
gtk_entry_set_text (GTK_ENTRY (dialog->txt_loc_code),
dialog->wd->location_code);
+
+ if (dialog->wd->location_name != NULL)
+ gtk_label_set_text (GTK_LABEL (dialog->txt_loc_name),
+ dialog->wd->location_name);
+ else if (dialog->wd->weatherdata &&
+ get_data (dialog->wd->weatherdata, DNAM) != NULL &&
+ strlen (get_data (dialog->wd->weatherdata, DNAM)) > 1)
+ gtk_label_set_text (GTK_LABEL (dialog->txt_loc_name),
+ get_data (dialog->wd->weatherdata, DNAM));
+ else
+ gtk_label_set_text (GTK_LABEL (dialog->txt_loc_name),
+ dialog->wd->location_code);
+
+#if GTK_CHECK_VERSION(2,12,0)
+ gtk_widget_set_tooltip_text(dialog->txt_loc_name,
+ gtk_label_get_text(GTK_LABEL(dialog->txt_loc_name)));
+#endif
+
gtk_size_group_add_widget (sg, label);
- button = gtk_button_new ();
+ button = gtk_button_new_with_label(_("Change..."));
image = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_BUTTON);
- gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_button_set_image (GTK_BUTTON (button), image);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (cb_findlocation), dialog);
hbox = gtk_hbox_new (FALSE, BORDER);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), dialog->txt_loc_code, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), dialog->txt_loc_name, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-config.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-config.h 2009-06-16 19:25:03 UTC (rev 7600)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-config.h 2009-06-17 18:14:47 UTC (rev 7601)
@@ -34,6 +34,7 @@
GtkWidget *dialog;
GtkWidget *opt_unit;
GtkWidget *txt_loc_code;
+ GtkWidget *txt_loc_name;
GtkWidget *txt_proxy_host;
GtkWidget *txt_proxy_port;
GtkWidget *chk_proxy_use;
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-search.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-search.c 2009-06-16 19:25:03 UTC (rev 7600)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-search.c 2009-06-17 18:14:47 UTC (rev 7601)
@@ -59,11 +59,6 @@
{
if (g_ascii_isspace (c))
g_string_append (retstr, "%20");
- else if (g_ascii_isalnum (c) == FALSE)
- {
- g_string_free (retstr, TRUE);
- return NULL;
- }
else
g_string_append_c (retstr, c);
}
@@ -86,11 +81,21 @@
xmlDoc *doc;
xmlNode *cur_node;
gchar *id, *city;
+ gboolean found = FALSE;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ gtk_widget_set_sensitive(dialog->find_button, TRUE);
+
if (!succeed || received == NULL)
return;
- doc = xmlParseMemory (received, strlen (received));
+ if (g_utf8_validate(received, -1, NULL)) {
+ /* force parsing as UTF-8, the XML encoding header may lie */
+ doc = xmlReadMemory (received, strlen (received), NULL, "UTF-8", 0);
+ } else {
+ doc = xmlParseMemory (received, strlen(received));
+ }
g_free (received);
if (!doc)
@@ -118,6 +123,7 @@
}
append_result (dialog->result_mdl, id, city);
+ found = TRUE;
g_free (id);
g_free (city);
}
@@ -126,6 +132,13 @@
xmlFreeDoc (doc);
+ if (found) {
+ if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL (dialog->result_mdl), &iter)) {
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->result_list));
+ gtk_tree_selection_select_iter(selection, &iter);
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog->dialog), GTK_RESPONSE_ACCEPT, TRUE);
+ }
+ }
return;
}
@@ -138,17 +151,31 @@
search_dialog *dialog = (search_dialog *) user_data;
gchar *sane_str, *url;
const gchar *str;
-
str = gtk_entry_get_text (GTK_ENTRY (dialog->search_entry));
if (strlen (str) == 0)
return;
+ if (dialog->last_search && !strcmp(str, dialog->last_search)) {
+ GtkTreeSelection *selection;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->result_list));
+ if (gtk_tree_selection_count_selected_rows(selection) == 1) {
+ gtk_dialog_response(GTK_DIALOG(dialog->dialog), GTK_RESPONSE_ACCEPT);
+ return;
+ }
+ }
+
+ g_free(dialog->last_search);
+ dialog->last_search = g_strdup(str);
+
gtk_list_store_clear (GTK_LIST_STORE (dialog->result_mdl));
if ((sane_str = sanitize_str (str)) == NULL)
return;
+ gtk_widget_set_sensitive(dialog->find_button, FALSE);
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog->dialog), GTK_RESPONSE_ACCEPT, FALSE);
+
url = g_strdup_printf ("/search/search?where=%s", sane_str);
g_free (sane_str);
@@ -177,7 +204,7 @@
gchar *proxy_host,
gint proxy_port)
{
- GtkWidget *vbox, *button, *hbox, *scroll, *frame;
+ GtkWidget *vbox, *hbox, *scroll, *frame;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
search_dialog *dialog;
@@ -197,6 +224,8 @@
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog->dialog), GTK_RESPONSE_ACCEPT, FALSE);
+
gtk_window_set_icon_name (GTK_WINDOW (dialog->dialog), GTK_STOCK_FIND);
vbox = gtk_vbox_new (FALSE, BORDER);
@@ -215,9 +244,9 @@
g_signal_connect (G_OBJECT (dialog->search_entry), "activate",
G_CALLBACK (search_cb), dialog);
- button = gtk_button_new_from_stock (GTK_STOCK_FIND);
- gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
+ dialog->find_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
+ gtk_box_pack_start (GTK_BOX (hbox), dialog->find_button, TRUE, TRUE, 0);
+ g_signal_connect (G_OBJECT (dialog->find_button), "clicked",
G_CALLBACK (search_cb), dialog);
frame = gtk_frame_new (NULL);
@@ -265,6 +294,12 @@
g_value_unset (&value);
+ gtk_tree_model_get_value (GTK_TREE_MODEL (dialog->result_mdl),
+ &iter, 0, &value);
+ dialog->result_name = g_strdup (g_value_get_string (&value));
+
+ g_value_unset (&value);
+
return TRUE;
}
}
@@ -278,6 +313,8 @@
free_search_dialog (search_dialog * dialog)
{
g_free (dialog->result);
+ g_free (dialog->result_name);
+ g_free (dialog->last_search);
gtk_widget_destroy (dialog->dialog);
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-search.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-search.h 2009-06-16 19:25:03 UTC (rev 7600)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-search.h 2009-06-17 18:14:47 UTC (rev 7601)
@@ -31,12 +31,16 @@
GtkWidget *dialog;
GtkWidget *search_entry;
GtkWidget *result_list;
+ GtkWidget *find_button;
GtkListStore *result_mdl;
gchar *result;
+ gchar *result_name;
gchar *proxy_host;
gint proxy_port;
+
+ gchar *last_search;
}
search_dialog;
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather.c 2009-06-16 19:25:03 UTC (rev 7600)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather.c 2009-06-17 18:14:47 UTC (rev 7601)
@@ -325,7 +325,12 @@
if (G_LIKELY (succeed && result))
{
- doc = xmlParseMemory (result, strlen (result));
+ if (g_utf8_validate(result, -1, NULL)) {
+ /* force parsing as UTF-8, the XML encoding header may lie */
+ doc = xmlReadMemory (result, strlen (result), NULL, "UTF-8", 0);
+ } else {
+ doc = xmlParseMemory (result, strlen(result));
+ }
g_free (result);
@@ -447,6 +452,16 @@
data->location_code = g_strdup (value);
}
+ value = xfce_rc_read_entry (rc, "loc_name", NULL);
+
+ if (value)
+ {
+ if (data->location_name)
+ g_free (data->location_name);
+
+ data->location_name = g_strdup (value);
+ }
+
if (xfce_rc_read_bool_entry (rc, "celcius", TRUE))
data->unit = METRIC;
else
@@ -535,6 +550,9 @@
if (data->location_code)
xfce_rc_write_entry (rc, "loc_code", data->location_code);
+ if (data->location_name)
+ xfce_rc_write_entry (rc, "loc_name", data->location_name);
+
xfce_rc_write_bool_entry (rc, "proxy_fromenv", data->proxy_fromenv);
if (data->proxy_host)
@@ -865,6 +883,7 @@
/* Free chars */
g_free (data->location_code);
+ g_free (data->location_name);
g_free (data->proxy_host);
/* Free Array */
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather.h 2009-06-16 19:25:03 UTC (rev 7600)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather.h 2009-06-17 18:14:47 UTC (rev 7601)
@@ -52,6 +52,7 @@
gint updatetimeout;
gchar *location_code;
+ gchar *location_name;
units unit;
xml_weather *weatherdata;
Modified: xfce4-weather-plugin/trunk/po/xfce4-weather-plugin.pot
===================================================================
--- xfce4-weather-plugin/trunk/po/xfce4-weather-plugin.pot 2009-06-16 19:25:03 UTC (rev 7600)
+++ xfce4-weather-plugin/trunk/po/xfce4-weather-plugin.pot 2009-06-17 18:14:47 UTC (rev 7601)
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-06-16 09:35+0200\n"
+"POT-Creation-Date: 2009-06-17 20:13+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
@@ -56,22 +56,22 @@
msgid "WG"
msgstr ""
-#: ../panel-plugin/weather.c:259 ../panel-plugin/weather.c:727
+#: ../panel-plugin/weather.c:259 ../panel-plugin/weather.c:745
msgid "Cannot update weather data"
msgstr ""
-#: ../panel-plugin/weather.c:660
+#: ../panel-plugin/weather.c:678
#, c-format
msgid "Unable to open the following url: %s"
msgstr ""
-#: ../panel-plugin/weather.c:688 ../panel-plugin/weather-summary.c:556
+#: ../panel-plugin/weather.c:706 ../panel-plugin/weather-summary.c:556
#: ../panel-plugin/weather.desktop.in.in.h:2
msgid "Weather Update"
msgstr ""
#. add refresh button to right click menu, for people who missed the middle mouse click feature
-#: ../panel-plugin/weather.c:808
+#: ../panel-plugin/weather.c:826
msgid "_Forecast"
msgstr ""
@@ -119,44 +119,48 @@
msgid "Dewpoint (DP)"
msgstr ""
-#: ../panel-plugin/weather-config.c:232
+#: ../panel-plugin/weather-config.c:238
msgid "Please enter proxy settings"
msgstr ""
-#: ../panel-plugin/weather-config.c:315
+#: ../panel-plugin/weather-config.c:325
msgid "Measurement unit:"
msgstr ""
-#: ../panel-plugin/weather-config.c:321
+#: ../panel-plugin/weather-config.c:331
msgid "Imperial"
msgstr ""
-#: ../panel-plugin/weather-config.c:323
+#: ../panel-plugin/weather-config.c:333
msgid "Metric"
msgstr ""
-#: ../panel-plugin/weather-config.c:338
-msgid "Location code:"
+#: ../panel-plugin/weather-config.c:348
+msgid "Location:"
msgstr ""
+#: ../panel-plugin/weather-config.c:381
+msgid "Change..."
+msgstr ""
+
#. proxy
-#: ../panel-plugin/weather-config.c:361
+#: ../panel-plugin/weather-config.c:394
msgid "Proxy server:"
msgstr ""
-#: ../panel-plugin/weather-config.c:364
+#: ../panel-plugin/weather-config.c:397
msgid "Use proxy server"
msgstr ""
-#: ../panel-plugin/weather-config.c:366
+#: ../panel-plugin/weather-config.c:399
msgid "Auto-detect from environment"
msgstr ""
-#: ../panel-plugin/weather-config.c:438
+#: ../panel-plugin/weather-config.c:471
msgid "Labels to display"
msgstr ""
-#: ../panel-plugin/weather-config.c:487
+#: ../panel-plugin/weather-config.c:520
msgid "Animate transitions between labels"
msgstr ""
@@ -223,15 +227,15 @@
msgid "No content received."
msgstr ""
-#: ../panel-plugin/weather-search.c:194
+#: ../panel-plugin/weather-search.c:221
msgid "Search weather location code"
msgstr ""
-#: ../panel-plugin/weather-search.c:208
+#: ../panel-plugin/weather-search.c:237
msgid "Enter a city name or zip code"
msgstr ""
-#: ../panel-plugin/weather-search.c:234
+#: ../panel-plugin/weather-search.c:263
msgid "Results"
msgstr ""
More information about the Goodies-commits
mailing list