[Goodies-commits] r2236 - xfce4-weather-plugin/trunk/panel-plugin

Nick Schermer nick at xfce.org
Sat Dec 16 14:02:07 CET 2006


Author: nick
Date: 2006-12-16 13:02:07 +0000 (Sat, 16 Dec 2006)
New Revision: 2236

Added:
   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-data.c
   xfce4-weather-plugin/trunk/panel-plugin/weather-data.h
   xfce4-weather-plugin/trunk/panel-plugin/weather-http.c
   xfce4-weather-plugin/trunk/panel-plugin/weather-http.h
   xfce4-weather-plugin/trunk/panel-plugin/weather-icon.c
   xfce4-weather-plugin/trunk/panel-plugin/weather-icon.h
   xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.c
   xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.h
   xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.c
   xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.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-summary.c
   xfce4-weather-plugin/trunk/panel-plugin/weather-summary.h
   xfce4-weather-plugin/trunk/panel-plugin/weather-translate.c
   xfce4-weather-plugin/trunk/panel-plugin/weather-translate.h
   xfce4-weather-plugin/trunk/panel-plugin/weather.c
   xfce4-weather-plugin/trunk/panel-plugin/weather.h
Removed:
   xfce4-weather-plugin/trunk/panel-plugin/config_dialog.c
   xfce4-weather-plugin/trunk/panel-plugin/config_dialog.h
   xfce4-weather-plugin/trunk/panel-plugin/get_data.c
   xfce4-weather-plugin/trunk/panel-plugin/get_data.h
   xfce4-weather-plugin/trunk/panel-plugin/http_client.c
   xfce4-weather-plugin/trunk/panel-plugin/http_client.h
   xfce4-weather-plugin/trunk/panel-plugin/icon.c
   xfce4-weather-plugin/trunk/panel-plugin/icon.h
   xfce4-weather-plugin/trunk/panel-plugin/parsers.c
   xfce4-weather-plugin/trunk/panel-plugin/parsers.h
   xfce4-weather-plugin/trunk/panel-plugin/plugin.c
   xfce4-weather-plugin/trunk/panel-plugin/plugin.h
   xfce4-weather-plugin/trunk/panel-plugin/scrollbox.c
   xfce4-weather-plugin/trunk/panel-plugin/scrollbox.h
   xfce4-weather-plugin/trunk/panel-plugin/search_dialog.c
   xfce4-weather-plugin/trunk/panel-plugin/search_dialog.h
   xfce4-weather-plugin/trunk/panel-plugin/summary_window.c
   xfce4-weather-plugin/trunk/panel-plugin/summary_window.h
   xfce4-weather-plugin/trunk/panel-plugin/translate.c
   xfce4-weather-plugin/trunk/panel-plugin/translate.h
Modified:
   xfce4-weather-plugin/trunk/panel-plugin/Makefile.am
Log:
Improve file names

Modified: xfce4-weather-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/Makefile.am	2006-12-15 13:53:10 UTC (rev 2235)
+++ xfce4-weather-plugin/trunk/panel-plugin/Makefile.am	2006-12-16 13:02:07 UTC (rev 2236)
@@ -4,26 +4,26 @@
 plugin_PROGRAMS = xfce4-weather-plugin
 
 xfce4_weather_plugin_SOURCES =						\
-	scrollbox.h							\
-	scrollbox.c							\
-	parsers.h							\
-	parsers.c							\
-	get_data.h							\
-	get_data.c 							\
-	http_client.c							\
-	http_client.h							\
-	plugin.h							\
-	plugin.c							\
-	config_dialog.h							\
-	config_dialog.c							\
-	summary_window.h						\
-	summary_window.c						\
-	icon.h								\
-	icon.c								\
-	search_dialog.h							\
-	search_dialog.c							\
-	translate.h							\
-	translate.c
+	weather.c							\
+	weather.h							\
+	weather-config.c						\
+	weather-config.h						\
+	weather-data.c							\
+	weather-data.h							\
+	weather-http.c							\
+	weather-http.h							\
+	weather-icon.c							\
+	weather-icon.h							\
+	weather-parsers.c						\
+	weather-parsers.h						\
+	weather-scrollbox.c						\
+	weather-scrollbox.h						\
+	weather-search.c						\
+	weather-search.h						\
+	weather-summary.c						\
+	weather-summary.h						\
+	weather-translate.c						\
+	weather-translate.h
 
 xfce4_weather_plugin_CFLAGS =						\
         -I$(top_srcdir)                                         	\

Deleted: xfce4-weather-plugin/trunk/panel-plugin/config_dialog.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/config_dialog.h

Deleted: xfce4-weather-plugin/trunk/panel-plugin/get_data.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/get_data.h

Deleted: xfce4-weather-plugin/trunk/panel-plugin/http_client.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/http_client.h

Deleted: xfce4-weather-plugin/trunk/panel-plugin/icon.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/icon.h

Deleted: xfce4-weather-plugin/trunk/panel-plugin/parsers.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/parsers.h

Deleted: xfce4-weather-plugin/trunk/panel-plugin/plugin.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/plugin.h

Deleted: xfce4-weather-plugin/trunk/panel-plugin/scrollbox.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/scrollbox.h

Deleted: xfce4-weather-plugin/trunk/panel-plugin/search_dialog.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/search_dialog.h

Deleted: xfce4-weather-plugin/trunk/panel-plugin/summary_window.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/summary_window.h

Deleted: xfce4-weather-plugin/trunk/panel-plugin/translate.c

Deleted: xfce4-weather-plugin/trunk/panel-plugin/translate.h

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-config.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/config_dialog.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-config.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-config.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,442 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+#include "weather-parsers.h"
+#include "weather-data.h"
+#include "weather.h"
+
+#include "weather-config.h"
+#include "weather-search.h"
+
+#define OPTIONS_N 11
+#define BORDER    8
+
+const static labeloption labeloptions[OPTIONS_N] = {
+        {N_("Windchill (F)"), FLIK},
+        {N_("Temperature (T)"), TEMP},
+        {N_("Atmosphere pressure (P)"), BAR_R},
+        {N_("Atmosphere state (P)"), BAR_D},
+        {N_("Wind speed (WS)"), WIND_SPEED},
+        {N_("Wind gust (WG)"), WIND_GUST},
+        {N_("Wind direction (WD)"), WIND_DIRECTION},
+        {N_("Humidity (H)"), HMID},
+        {N_("Visibility (V)"), VIS},
+        {N_("UV Index (UV)"), UV_INDEX},
+        {N_("Dewpoint (DP)"), DEWP},
+};
+
+typedef void(*cb_function)(xfceweather_data *);
+static cb_function cb = NULL;
+
+static void
+add_mdl_option (GtkListStore *mdl,
+                int           opt)
+{
+    GtkTreeIter iter;
+
+    gtk_list_store_append (mdl, &iter);
+    gtk_list_store_set (mdl, &iter,
+            0, _(labeloptions[opt].name),
+            1, labeloptions[opt].number,
+            -1);
+}
+
+static gboolean
+cb_addoption (GtkWidget *widget,
+              gpointer   data)
+{
+    xfceweather_dialog *dialog  = (xfceweather_dialog *) data;
+    gint                history = gtk_option_menu_get_history (GTK_OPTION_MENU (dialog->opt_xmloption));
+
+    add_mdl_option (dialog->mdl_xmloption, history);
+
+    return FALSE;
+}
+
+static gboolean
+cb_deloption (GtkWidget *widget,
+              gpointer   data)
+{
+    xfceweather_dialog *dialog    = (xfceweather_dialog *)data;
+    GtkTreeIter         iter;
+    GtkTreeSelection   *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->lst_xmloption));
+
+    if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+        gtk_list_store_remove (GTK_LIST_STORE (dialog->mdl_xmloption), &iter);
+
+    return FALSE;
+}
+
+static gboolean
+cb_toggle (GtkWidget *widget,
+           gpointer   data)
+{
+    GtkWidget *target = (GtkWidget *)data;
+
+    gtk_widget_set_sensitive (target,
+            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
+
+    return FALSE;
+}
+
+static gboolean
+cb_not_toggle (GtkWidget *widget,
+               gpointer   data)
+{
+    GtkWidget *target = (GtkWidget *)data;
+
+    gtk_widget_set_sensitive (target,
+            !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
+
+    return FALSE;
+}
+
+static
+GtkWidget *make_label (void)
+{
+    guint      i;
+    GtkWidget *widget, *menu;
+
+    menu = gtk_menu_new ();
+    widget = gtk_option_menu_new ();
+
+    for (i = 0; i < 11; i++)
+    {
+        labeloption opt = labeloptions[i];
+
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+                gtk_menu_item_new_with_label (_(opt.name)));
+    }
+
+    gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);
+
+    return widget;
+}
+
+void
+apply_options (xfceweather_dialog *dialog)
+{
+    gint         history = 0;
+    gboolean     hasiter = FALSE;
+    GtkTreeIter  iter;
+    gchar       *text;
+
+    xfceweather_data *data = (xfceweather_data *) dialog->wd;
+
+    history = gtk_option_menu_get_history (GTK_OPTION_MENU (dialog->opt_unit));
+
+    if (history == 0)
+        data->unit = IMPERIAL;
+    else
+        data->unit = METRIC;
+
+    if (data->location_code)
+        g_free (data->location_code);
+
+    data->location_code = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->txt_loc_code)));
+
+    /* call labels_clear() here */
+    if (data->labels && data->labels->len > 0)
+        g_array_free (data->labels, TRUE);
+
+    data->labels = g_array_new (FALSE, TRUE, sizeof(datas));
+
+    for (hasiter = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->mdl_xmloption), &iter);
+            hasiter == TRUE; hasiter = gtk_tree_model_iter_next (
+                GTK_TREE_MODEL (dialog->mdl_xmloption), &iter))
+    {
+        gint option;
+        GValue value = {0, };
+
+        gtk_tree_model_get_value (GTK_TREE_MODEL(dialog->mdl_xmloption), &iter, 1, &value);
+        option = g_value_get_int (&value);
+        g_array_append_val (data->labels, option);
+        g_value_unset (&value);
+    }
+
+    if (data->proxy_host)
+    {
+        g_free (data->proxy_host);
+        data->proxy_host = NULL;
+    }
+
+    if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->chk_proxy_use)))
+        data->proxy_fromenv = FALSE;
+    else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->chk_proxy_fromenv)))
+    {
+        data->proxy_fromenv = TRUE;
+        check_envproxy(&data->proxy_host, &data->proxy_port);
+    }
+    else /* use provided proxy settings */
+    {
+        data->proxy_fromenv = FALSE;
+        text = g_strdup (gtk_entry_get_text (GTK_ENTRY(dialog->txt_proxy_host)));
+
+        if (strlen (text) == 0)
+        {
+            xfce_err(_("Please enter proxy settings"));
+            gtk_widget_grab_focus (dialog->txt_proxy_host);
+            return;
+        }
+
+        data->proxy_host = g_strdup(text);
+        data->proxy_port = gtk_spin_button_get_value (
+                GTK_SPIN_BUTTON (dialog->txt_proxy_port));
+
+        if (data->saved_proxy_host)
+            g_free (data->saved_proxy_host);
+
+        data->saved_proxy_host = g_strdup(text);
+        data->saved_proxy_port = data->proxy_port;
+
+	g_free (text);
+    }
+
+    if (cb)
+        cb(data);
+}
+
+static int
+option_i (datas opt)
+{
+    guint i;
+
+    for (i = 0; i < OPTIONS_N; i++)
+    {
+        if (labeloptions[i].number == opt)
+            return i;
+    }
+
+    return -1;
+}
+
+static gboolean
+cb_findlocation (GtkButton *button,
+                 gpointer   user_data)
+{
+    xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
+    search_dialog *sdialog     = create_search_dialog(NULL,
+            dialog->wd->proxy_host, dialog->wd->proxy_port);
+
+    if (run_search_dialog(sdialog))
+        gtk_entry_set_text (GTK_ENTRY(dialog->txt_loc_code), sdialog->result);
+
+    free_search_dialog(sdialog);
+
+    return FALSE;
+}
+
+
+xfceweather_dialog *
+create_config_dialog (xfceweather_data *data,
+                      GtkWidget        *vbox)
+{
+    xfceweather_dialog *dialog;
+    GtkWidget *vbox2, *vbox3, *hbox, *hbox2, *label,
+          *menu, *button_add,
+          *button_del, *image, *button, *scroll;
+    GtkSizeGroup *sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+    GtkSizeGroup *sg_buttons = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    dialog = panel_slice_new0 (xfceweather_dialog);
+
+    dialog->wd = (xfceweather_data *)data;
+    dialog->dialog = gtk_widget_get_toplevel (vbox);
+
+    label = gtk_label_new (_("Measurement unit:"));
+    gtk_misc_set_alignment (GTK_MISC(label), 0, 0.5);
+    menu = gtk_menu_new ();
+    dialog->opt_unit = gtk_option_menu_new ();
+
+    gtk_menu_shell_append  ((GtkMenuShell *)(GTK_MENU(menu)),
+                (gtk_menu_item_new_with_label (_("Imperial"))));
+    gtk_menu_shell_append  ((GtkMenuShell *)(GTK_MENU(menu)),
+                (gtk_menu_item_new_with_label (_("Metric"))));
+    gtk_option_menu_set_menu(GTK_OPTION_MENU(dialog->opt_unit), menu);
+
+    if (dialog->wd->unit == IMPERIAL)
+        gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->opt_unit), 0);
+    else
+        gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->opt_unit), 1);
+    gtk_size_group_add_widget (sg, label);
+
+    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->opt_unit, TRUE, TRUE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+
+    label = gtk_label_new (_("Location code:"));
+    dialog->txt_loc_code = gtk_entry_new ();
+
+    gtk_misc_set_alignment (GTK_MISC(label), 0, 0.5);
+
+    if (dialog->wd->location_code != NULL)
+        gtk_entry_set_text (GTK_ENTRY(dialog->txt_loc_code),
+                dialog->wd->location_code);
+    gtk_size_group_add_widget (sg, label);
+
+    button = gtk_button_new ();
+    image = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_BUTTON);
+    gtk_container_add(GTK_CONTAINER (button), image);
+    g_signal_connect (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), button, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+    /* proxy */
+    label = gtk_label_new (_("Proxy server:"));
+    dialog->txt_proxy_host = gtk_entry_new ();
+    dialog->chk_proxy_use = gtk_check_button_new_with_label (_("Use proxy server"));
+    dialog->chk_proxy_fromenv =
+        gtk_check_button_new_with_label (_("Auto-detect from environment"));
+    dialog->txt_proxy_port = gtk_spin_button_new_with_range (0, 65536, 1);
+
+    gtk_misc_set_alignment (GTK_MISC(label), 0, 0);
+
+    gtk_size_group_add_widget (sg, label);
+
+    vbox3 = gtk_vbox_new (FALSE, BORDER);
+    gtk_box_pack_start (GTK_BOX (vbox3), dialog->chk_proxy_use, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox3), dialog->chk_proxy_fromenv, FALSE, FALSE, 0);
+
+    hbox = gtk_hbox_new (FALSE, BORDER);
+    gtk_box_pack_start (GTK_BOX (hbox), dialog->txt_proxy_host, TRUE, TRUE, 0);
+    gtk_box_pack_start (GTK_BOX (hbox), dialog->txt_proxy_port, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
+
+
+    hbox2 = gtk_hbox_new (FALSE, BORDER);
+    gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (hbox2), vbox3, TRUE, TRUE, 0);
+
+    gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
+
+    g_signal_connect (dialog->chk_proxy_use, "toggled", G_CALLBACK (cb_toggle),
+            (gpointer)dialog->txt_proxy_host);
+    g_signal_connect (dialog->chk_proxy_use, "toggled", G_CALLBACK (cb_toggle),
+            (gpointer)dialog->txt_proxy_port);
+    g_signal_connect (dialog->chk_proxy_use, "toggled", G_CALLBACK (cb_toggle),
+            (gpointer)dialog->chk_proxy_fromenv);
+
+    g_signal_connect (dialog->chk_proxy_fromenv, "toggled", G_CALLBACK (cb_not_toggle),
+            (gpointer)dialog->txt_proxy_host);
+    g_signal_connect (dialog->chk_proxy_fromenv, "toggled", G_CALLBACK (cb_not_toggle),
+            (gpointer)dialog->txt_proxy_port);
+
+    if (dialog->wd->saved_proxy_host != NULL)
+    {
+        gtk_entry_set_text (GTK_ENTRY (dialog->txt_proxy_host),
+                dialog->wd->saved_proxy_host);
+
+        gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->txt_proxy_port),
+                dialog->wd->saved_proxy_port);
+    }
+
+    if (dialog->wd->proxy_host || dialog->wd->proxy_fromenv)
+    {
+        gtk_toggle_button_set_active (
+                GTK_TOGGLE_BUTTON (dialog->chk_proxy_use), TRUE);
+
+        if (dialog->wd->proxy_fromenv)
+            gtk_toggle_button_set_active (
+                    GTK_TOGGLE_BUTTON (dialog->chk_proxy_fromenv), TRUE);
+    }
+    else
+    {
+        gtk_toggle_button_set_active (
+                GTK_TOGGLE_BUTTON (dialog->chk_proxy_use), TRUE);
+        gtk_toggle_button_set_active (
+                GTK_TOGGLE_BUTTON (dialog->chk_proxy_use), FALSE);
+    }
+
+
+    /* labels */
+
+    dialog->opt_xmloption = make_label ();
+    dialog->mdl_xmloption = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
+    dialog->lst_xmloption = gtk_tree_view_new_with_model (GTK_TREE_MODEL(dialog->mdl_xmloption));
+
+    renderer = gtk_cell_renderer_text_new ();
+    column = gtk_tree_view_column_new_with_attributes (_("Labels to display"), renderer,
+            "text", 0, NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW(dialog->lst_xmloption), column);
+
+    button_add = gtk_button_new_from_stock(GTK_STOCK_ADD);
+    gtk_size_group_add_widget (sg_buttons, button_add);
+    hbox = gtk_hbox_new (FALSE, BORDER);
+    gtk_box_pack_start (GTK_BOX (hbox), dialog->opt_xmloption, TRUE, TRUE, 0);
+    gtk_box_pack_start (GTK_BOX (hbox), button_add, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+    button_del = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
+    gtk_size_group_add_widget (sg_buttons, button_del);
+    hbox = gtk_hbox_new (FALSE, BORDER);
+    scroll = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER,
+            GTK_POLICY_AUTOMATIC);
+    gtk_container_add(GTK_CONTAINER(scroll), dialog->lst_xmloption);
+    gtk_box_pack_start (GTK_BOX (hbox), scroll, TRUE, TRUE, 0);
+
+    vbox2 = gtk_vbox_new (FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox2), button_del, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+    gtk_widget_set_size_request (dialog->lst_xmloption, -1, 120);
+
+
+    if (data->labels->len > 0)
+    {
+        datas opt;
+        guint i;
+        gint  n;
+
+        for (i = 0; i < data->labels->len; i++)
+        {
+            opt = g_array_index (data->labels, datas, i);
+
+            if ((n = option_i(opt)) != -1)
+                add_mdl_option (dialog->mdl_xmloption, n);
+        }
+    }
+
+    g_signal_connect (button_add, "clicked", G_CALLBACK (cb_addoption), dialog);
+    g_signal_connect (button_del, "clicked", G_CALLBACK (cb_deloption), dialog);
+
+    gtk_widget_show_all (vbox);
+
+    return dialog;
+}
+
+void
+set_callback_config_dialog (xfceweather_dialog *dialog,
+                            cb_function         cb_new)
+{
+    cb = cb_new;
+}

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-config.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/config_dialog.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-config.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-config.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,60 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef CONFIG_DIALOG_H
+#define CONFIG_DIALOG_H
+
+G_BEGIN_DECLS
+
+typedef struct {
+        gchar           *name;
+        datas            number;
+}
+labeloption;
+
+typedef struct {
+        GtkWidget        *dialog;
+        GtkWidget        *opt_unit;
+        GtkWidget        *txt_loc_code;
+        GtkWidget        *txt_proxy_host;
+        GtkWidget        *txt_proxy_port;
+        GtkWidget        *chk_proxy_use;
+        GtkWidget        *chk_proxy_fromenv;
+
+        GtkWidget        *tooltip_yes;
+        GtkWidget        *tooltip_no;
+
+        GtkWidget        *opt_xmloption;
+        GtkWidget        *lst_xmloption;
+        GtkListStore     *mdl_xmloption;
+
+        xfceweather_data *wd;
+}
+xfceweather_dialog;
+
+xfceweather_dialog *
+create_config_dialog       (xfceweather_data *data, GtkWidget *vbox);
+
+void
+set_callback_config_dialog (xfceweather_dialog *dialog, void(cb)(xfceweather_data *));
+
+void
+apply_options              (xfceweather_dialog *dialog);
+
+G_END_DECLS
+
+#endif

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-data.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/get_data.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-data.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-data.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,323 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <libxfce4util/libxfce4util.h>
+
+#include "weather-parsers.h"
+#include "weather-data.h"
+#include "weather.h"
+
+#define DATAS_CC    0x0100
+#define DATAS_LOC   0x0200
+#define DATAS_DAYF  0x0300
+#define KILL_RING_S 5
+
+#define EMPTY_STRING g_strdup("-")
+#define CHK_NULL(str) str ? g_strdup(str) : EMPTY_STRING;
+gchar *kill_ring[KILL_RING_S] = {NULL, };
+
+#define debug_print printf
+static gchar *
+copy_buffer (gchar *str)
+{
+    static gint p = 0;
+    gchar *s;
+
+    if (!str)
+    {
+        DBG ("copy_buffer: received NULL pointer");
+        return EMPTY_STRING;
+    }
+
+    if (p >= KILL_RING_S)
+        p = 0;
+
+    if (kill_ring[p])
+        g_free(kill_ring[p]);
+
+    s = g_strdup(str);
+
+    kill_ring[p++] = s;
+
+    return s;
+}
+
+void
+free_get_data_buffer (void)
+{
+    guint i;
+
+    for (i = 0; i < KILL_RING_S; i++)
+    {
+        if (kill_ring[i])
+            g_free(kill_ring[i]);
+    }
+}
+
+static gchar *
+get_data_uv (xml_uv   *data,
+             datas_uv  type)
+{
+    gchar *str = NULL;
+
+    if (!data)
+    {
+        DBG ("get_data_bar: xml-uv not present");
+        return EMPTY_STRING;
+    }
+
+    switch(type)
+    {
+        case _UV_INDEX: str = data->i; break;
+        case _UV_TRANS: str = data->t; break;
+    }
+
+    return CHK_NULL(str);
+}
+
+
+static gchar *
+get_data_bar (xml_bar   *data,
+              datas_bar  type)
+{
+    gchar *str = NULL;
+
+    if (!data)
+    {
+        DBG ("get_data_bar: xml-wind not present");
+        return EMPTY_STRING;
+    }
+
+    switch(type)
+    {
+        case _BAR_R: str = data->r; break;
+        case _BAR_D: str = data->d; break;
+    }
+
+    return CHK_NULL(str);
+}
+
+static gchar *
+get_data_wind (xml_wind   *data,
+           datas_wind  type)
+{
+    gchar *str = NULL;
+
+    if (!data)
+    {
+        DBG ("get_data_wind: xml-wind not present");
+        return EMPTY_STRING;
+    }
+
+       DBG ("starting");
+
+    switch(type)
+    {
+        case _WIND_SPEED: str = data->s; break;
+        case _WIND_GUST: str = data->gust; break;
+        case _WIND_DIRECTION: str = data->t; break;
+        case _WIND_TRANS: str = data->d; break;
+    }
+
+       DBG ("print %p", data->d);
+
+       DBG ("%s", str);
+
+    return CHK_NULL(str);
+}
+
+/* -- This is not the same as the previous functions */
+static gchar *
+get_data_cc (xml_cc *data,
+             datas   type)
+{
+    gchar *str = NULL;
+
+    if (!data)
+    {
+        DBG ("get_data_cc: xml-cc not present");
+        return EMPTY_STRING;
+    }
+
+    switch(type)
+    {
+        case LSUP: str = data->lsup; break;
+        case OBST: str = data->obst; break;
+        case FLIK: str = data->flik; break;
+        case TRANS:    str = data->t; break;
+        case TEMP:  str = data->tmp; break;
+        case HMID: str = data->hmid; break;
+        case VIS:  str = data->vis; break;
+        case UV_INDEX:   return get_data_uv(data->uv, _UV_INDEX);
+        case UV_TRANS:   return get_data_uv(data->uv, _UV_TRANS);
+        case WIND_SPEED: return get_data_wind(data->wind, _WIND_SPEED);
+        case WIND_GUST: return get_data_wind(data->wind, _WIND_GUST);
+        case WIND_DIRECTION: return get_data_wind(data->wind, _WIND_DIRECTION);
+        case WIND_TRANS: return get_data_wind(data->wind, _WIND_TRANS);
+        case BAR_R:  return get_data_bar(data->bar, _BAR_R);
+        case BAR_D: return get_data_bar(data->bar, _BAR_D);
+        case DEWP: str = data->dewp; break;
+        case WICON: str = data->icon; break;
+    }
+
+    return CHK_NULL(str);
+}
+
+static gchar *
+get_data_loc (xml_loc   *data,
+              datas_loc  type)
+{
+    gchar *str = NULL;
+
+    if (!data)
+    {
+        DBG ("get_data_loc: xml-loc not present");
+        return EMPTY_STRING;
+    }
+
+    switch(type)
+    {
+        case DNAM: str = data->dnam; break;
+        case SUNR: str = data->sunr; break;
+        case SUNS: str = data->suns; break;
+    }
+
+    return CHK_NULL(str);
+}
+
+
+const gchar *
+get_data (xml_weather *data,
+          datas        type)
+{
+    gchar *str = NULL;
+    gchar *p;
+
+    if (!data)
+        str = EMPTY_STRING;
+    else
+    {
+
+        switch (type & 0xFF00)
+        {
+            case DATAS_CC: str = get_data_cc(data->cc, type); break;
+            case DATAS_LOC: str = get_data_loc(data->loc, type); break;
+            default: str = EMPTY_STRING;
+        }
+    }
+
+    p = copy_buffer(str);
+    g_free(str);
+
+    return p;
+}
+
+static gchar *
+get_data_part (xml_part *data,
+               forecast  type)
+{
+       gchar *str = NULL;
+
+       DBG ("now here %s", data->ppcp);
+
+       if (!data)
+           return EMPTY_STRING;
+
+    switch (type & 0x000F)
+    {
+        case F_ICON: str = data->icon; break;
+        case F_TRANS: str = data->t; break;
+        case F_PPCP: str = data->ppcp; break;
+        case F_W_SPEED: str = get_data_wind(data->wind, _WIND_SPEED); break;
+        case F_W_DIRECTION: str = get_data_wind(data->wind, _WIND_DIRECTION); break;
+    }
+
+    return str;
+}
+
+const gchar *
+get_data_f (xml_dayf *data,
+            forecast  type)
+{
+    gchar *p, *str = NULL;
+
+    if (data)
+    {
+        switch (type & 0x0F00)
+        {
+            case ITEMS:
+                switch(type)
+                {
+                    case WDAY: str = data->day; break;
+                    case TEMP_MIN: str = data->low; break;
+                    case TEMP_MAX: str = data->hi; break;
+                    default: str = g_strdup("-"); break;
+                }
+                break;
+            case NPART:
+                str = get_data_part(data->part[1], type);
+                break;
+            case DPART:
+                str = get_data_part(data->part[0], type);
+                break;
+        }
+    }
+
+    if (!str)
+        str = "-";
+
+
+    p = copy_buffer(str);
+    DBG ("value: %s", p);
+
+    return p;
+}
+
+const gchar *
+get_unit (units unit,
+          datas type)
+{
+    gchar *str;
+
+    switch (type & 0x00F0)
+    {
+        case 0x0020:
+            str = (unit == METRIC ? "\302\260C" : "\302\260F");
+            break;
+        case 0x0030:
+            str = "%";
+            break;
+        case 0x0040:
+            str = (unit == METRIC ? _("km/h") : _("mph"));
+            break;
+        case 0x0050:
+            str = (unit == METRIC ? _("hPa") : _("in"));
+            break;
+        case 0x0060:
+            str = (unit == METRIC ? _("km") : _("mi"));
+            break;
+        default:
+            str = "";
+    }
+
+    return copy_buffer (str);
+}
+

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-data.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/get_data.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-data.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-data.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,126 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GET_DATA_H
+#define GET_DATA_H
+
+G_BEGIN_DECLS
+
+typedef enum {
+        _WIND_SPEED,
+        _WIND_GUST,
+        _WIND_DIRECTION,
+        _WIND_TRANS
+}
+datas_wind;
+
+typedef enum {
+        _BAR_R,
+        _BAR_D
+}
+datas_bar;
+
+typedef enum {
+        _UV_INDEX,
+        _UV_TRANS
+}
+datas_uv;
+
+typedef enum {
+        /* cc */
+        LSUP            = 0x0101,
+        OBST            = 0x0102,
+        TRANS           = 0x0103,
+        UV_INDEX        = 0x0105,
+        UV_TRANS        = 0x0106,
+        WIND_DIRECTION  = 0x0107,
+        BAR_D           = 0x0108,
+        WIND_TRANS      = 0x0109,
+        WICON           = 0x0110,
+
+        FLIK            = 0x0120,
+        TEMP            = 0x0121,
+        DEWP            = 0x0122,
+
+        HMID            = 0x0130,
+
+        WIND_SPEED      = 0x0140,
+        WIND_GUST       = 0x0141,
+
+
+        BAR_R           = 0x0150,
+
+        VIS             = 0x0160
+}
+datas;
+
+typedef enum {
+        DNAM            = 0x0201,
+        SUNR            = 0x0202,
+        SUNS            = 0x0203
+}
+datas_loc;
+
+typedef enum {
+        ITEMS           = 0x0100,
+        WDAY            = 0x0101,
+        TEMP_MIN        = 0x0102,
+        TEMP_MAX        = 0x0103,
+
+        F_ICON          = 0x0001,
+        F_PPCP          = 0x0002,
+        F_W_DIRECTION   = 0x0003,
+        F_W_SPEED       = 0x0004,
+        F_TRANS         = 0x0005,
+
+        NPART           = 0x0200,
+        ICON_N          = 0x0201,
+        PPCP_N          = 0x0202,
+        W_DIRECTION_N   = 0x0203,
+        W_SPEED_N       = 0x0204,
+        TRANS_N         = 0x0205,
+
+        DPART           = 0x0300,
+        ICON_D          = 0x0301,
+        PPCP_D          = 0x0302,
+        W_DIRECTION_D   = 0x0303,
+        W_SPEED_D       = 0x0304,
+        TRANS_D         = 0x0305
+}
+forecast;
+
+typedef enum {
+        METRIC,
+        IMPERIAL
+}
+units;
+
+const gchar *
+get_data             (xml_weather *data, datas type);
+
+const gchar *
+get_data_f           (xml_dayf * , forecast type);
+
+const gchar *
+get_unit             (units unit, datas type);
+
+void
+free_get_data_buffer (void);
+
+G_END_DECLS
+
+#endif

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-http.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/http_client.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-http.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-http.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,350 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <string.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfce4panel/xfce-panel-macros.h>
+
+#include "weather-http.h"
+
+struct request_data
+{
+    int    fd;
+
+    FILE      *save_fp;
+    gchar     *save_filename;
+    gchar    **save_buffer;
+
+    gboolean   has_header;
+    gchar      last_chars[4];
+
+    gchar     *request_buffer;
+    gint       offset;
+    gint       size;
+
+    CB_TYPE    cb_function;
+    gpointer   cb_data;
+};
+
+static gboolean
+keep_receiving (gpointer data);
+
+
+static int
+http_connect (gchar *hostname,
+          gint   port)
+{
+    struct sockaddr_in dest_host;
+    struct hostent *host_address;
+    gint fd;
+
+    if ((host_address = gethostbyname(hostname)) == NULL)
+        return -1;
+
+    if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
+        return -1;
+
+    dest_host.sin_family = AF_INET;
+    dest_host.sin_port = htons(port);
+    dest_host.sin_addr = *((struct in_addr *)host_address->h_addr);
+    memset(&(dest_host.sin_zero), '\0', 8);
+    fcntl(fd, F_SETFL, O_NONBLOCK);
+
+    if ((connect(fd, (struct sockaddr *)&dest_host, sizeof(struct sockaddr)) == -1)
+            && errno != EINPROGRESS)
+    {
+        perror("http_connect()");
+        return -1;
+    }
+    else
+        return fd;
+
+}
+
+static void
+request_free (struct request_data *request)
+{
+    if (request->request_buffer)
+        g_free(request->request_buffer);
+
+    if (request->save_filename)
+        g_free(request->save_filename);
+
+    if (request->save_fp)
+        fclose(request->save_fp);
+
+    if (request->fd)
+        close(request->fd);
+
+    panel_slice_free (struct request_data, request);
+}
+
+static void
+request_save (struct request_data *request,
+              const gchar     *buffer)
+{
+    DBG ("Request Save");
+
+    if (request->save_filename)
+    {
+        if (!request->save_fp &&
+            (request->save_fp = fopen(request->save_filename, "w")) == NULL)
+                return;
+        else
+            if (fwrite (buffer, sizeof(gchar), strlen(buffer), request->save_fp) == 0);
+    }
+    else
+    {
+        if (*request->save_buffer)
+        {
+            gchar *newbuff = g_strconcat(*request->save_buffer, buffer, NULL);
+            g_free(*request->save_buffer);
+            *request->save_buffer = newbuff;
+        }
+        else
+            *request->save_buffer = g_strdup(buffer);
+    }
+}
+
+static gboolean
+keep_sending (gpointer data)
+{
+    struct request_data *request = (struct request_data *)data;
+    gint n;
+
+    if (!request)
+    {
+        DBG ("keep_sending(): empty request data");
+        return FALSE;
+    }
+
+    if ((n = send(request->fd, request->request_buffer + request->offset,
+                    request->size - request->offset,
+                    0)) != -1)
+    {
+        request->offset += n;
+
+        DBG ("now at offset: %d", request->offset);
+        DBG ("now at byte: %d", n);
+
+        if (request->offset == request->size)
+        {
+            DBG ("keep_sending(): ok data sent");
+            g_idle_add(keep_receiving, (gpointer) request);
+            return FALSE;
+        }
+    }
+    else if (errno != EAGAIN) /* some other error happened */
+    {
+#if DEBUG
+        perror("keep_sending()");
+#endif
+
+	DBG ("file desc: %d", request->fd);
+
+        request_free(request);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+static gboolean
+keep_receiving (gpointer data)
+{
+    struct request_data *request = (struct request_data *)data;
+    gchar recvbuffer[1024];
+    gint n;
+    gchar *p;
+    gchar *str = NULL;
+
+    if (!request)
+    {
+        DBG ("keep_receiving(): empty request data ");
+        return FALSE;
+    }
+
+    if ((n = recv(request->fd, recvbuffer, sizeof(recvbuffer) -
+                    sizeof(char), 0)) > 0)
+    {
+        recvbuffer[n] = '\0';
+
+        DBG ("keep_receiving(): bytes recv: %d", n);
+
+        if (!request->has_header)
+        {
+            if (request->last_chars != '\0')
+                str = g_strconcat(request->last_chars,
+                        recvbuffer, NULL);
+
+            if ((p = strstr(str, "\r\n\r\n")))
+            {
+                request_save(request, p + 4);
+                request->has_header = TRUE;
+                DBG ("keep_receiving(): got header");
+            }
+            else
+            {
+                DBG ("keep_receiving(): no header yet\n\n%s\n..\n",
+                        recvbuffer);
+                memcpy(request->last_chars, recvbuffer + (n - 4),
+                        sizeof(char) * 3);
+            }
+
+            g_free(str);
+        }
+        else
+            request_save(request, recvbuffer);
+    }
+    else if (n == 0)
+    {
+        CB_TYPE callback = request->cb_function;
+        gpointer data = request->cb_data;
+        DBG ("keep_receiving(): ending with succes");
+        request_free(request);
+
+        callback(TRUE, data);
+        return FALSE;
+    }
+    else if (errno != EAGAIN)
+    {
+        perror("keep_receiving()");
+        request->cb_function(FALSE, request->cb_data);
+        request_free(request);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+
+
+static gboolean
+http_get (gchar     *url,
+      gchar     *hostname,
+      gboolean   savefile,
+      gchar    **fname_buff,
+      gchar     *proxy_host,
+      gint       proxy_port,
+      CB_TYPE    callback,
+      gpointer   data)
+{
+    struct request_data *request = panel_slice_new0 (struct request_data);
+
+    if (!request)
+    {
+#if DEBUG
+        perror("http_get(): empty request");
+#endif
+        return FALSE;
+    }
+
+    request->has_header = FALSE;
+    request->cb_function = callback;
+    request->cb_data = data;
+
+    if (proxy_host)
+    {
+        DBG ("using proxy %s", proxy_host);
+        request->fd = http_connect(proxy_host, proxy_port);
+    }
+    else
+    {
+        DBG ("Not USING PROXY");
+        request->fd = http_connect(hostname, 80);
+    }
+
+    if (request->fd == -1)
+    {
+        DBG ("http_get(): fd = -1 returned");
+        request_free(request);
+        return FALSE;
+    }
+
+    if (proxy_host)
+        request->request_buffer = g_strdup_printf(
+                "GET http://%s%s HTTP/1.0\r\n\r\n",
+                hostname, url);
+    else
+        request->request_buffer = g_strdup_printf("GET %s HTTP/1.0\r\n"
+                "Host: %s\r\n\r\n", url, hostname);
+
+    if (request->request_buffer == NULL)
+    {
+#if DEBUG
+        perror("http_get(): empty request buffer\n");
+#endif
+        close(request->fd);
+        panel_slice_free(struct request_data, request);
+        return FALSE;
+    }
+
+    request->size = strlen (request->request_buffer);
+
+    if (savefile)
+        request->save_filename = g_strdup (*fname_buff);
+    else
+        request->save_buffer = fname_buff;
+
+    DBG ("http_get(): adding idle function");
+
+    (void)g_idle_add ((GSourceFunc)keep_sending, (gpointer)request);
+
+    DBG ("http_get(): request added");
+
+    return TRUE;
+}
+
+gboolean
+http_get_file (gchar   *url,
+               gchar   *hostname,
+               gchar   *filename,
+               gchar   *proxy_host,
+               gint     proxy_port,
+               CB_TYPE  callback,
+               gpointer data)
+{
+    return http_get (url, hostname, TRUE, &filename, proxy_host, proxy_port,
+            callback, data);
+}
+
+gboolean
+http_get_buffer (gchar    *url,
+                 gchar    *hostname,
+                 gchar    *proxy_host,
+                 gint      proxy_port,
+                 gchar   **buffer,
+                 CB_TYPE   callback,
+                 gpointer  data)
+{
+    return http_get (url, hostname, FALSE, buffer, proxy_host, proxy_port,
+            callback, data);
+}

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-http.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/http_client.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-http.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-http.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,37 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef HTTP_CLIENT_H
+#define HTTP_CLIENT_H
+
+G_BEGIN_DECLS
+
+typedef void(*CB_TYPE)(gboolean, gpointer);
+
+gboolean
+http_get_file  (gchar *url, gchar *hostname,
+                gchar *filename, gchar *proxy_host, gint proxy_port,
+                CB_TYPE callback, gpointer data);
+
+gboolean
+http_get_buffer (gchar *url, gchar *hostname,
+                 gchar *proxy_host, gint proxy_port, gchar **buffer,
+                 CB_TYPE callback, gpointer data);
+
+G_END_DECLS
+
+#endif

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-icon.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/icon.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-icon.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-icon.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,54 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "weather-icon.h"
+
+#define DEFAULT_W_THEME "liquid"
+
+GdkPixbuf *
+get_icon (const gchar *number,
+          GtkIconSize  size)
+{
+    GdkPixbuf *image = NULL;
+    gchar     *filename;
+    gint       width, height;
+
+    gtk_icon_size_lookup (size, &width, &height);
+
+    filename = g_strdup_printf ("%s%s%s%s%s.png",
+            THEMESDIR, G_DIR_SEPARATOR_S,
+            DEFAULT_W_THEME, G_DIR_SEPARATOR_S,
+            number);
+
+    image = gdk_pixbuf_new_from_file_at_scale (filename,
+	    width, height,
+            TRUE, NULL);
+
+    g_free (filename);
+
+    if (!image)
+        g_warning ("Weather Plugin: No image found");
+
+    return image;
+}

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-icon.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/icon.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-icon.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-icon.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,28 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef ICON_H
+#define ICON_H
+
+G_BEGIN_DECLS
+
+GdkPixbuf *
+get_icon         (const gchar *icon, GtkIconSize size);
+
+G_END_DECLS
+
+#endif

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/parsers.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,405 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "weather-parsers.h"
+#include <libxfce4panel/xfce-panel-macros.h>
+
+xml_weather *
+parse_weather (xmlNode *cur_node)
+{
+    xml_weather *ret;
+
+    if (!NODE_IS_TYPE (cur_node, "weather")) {
+        return NULL;
+    }
+
+    if ((ret = panel_slice_new0 (xml_weather)) == NULL)
+        return NULL;
+
+    for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+    {
+        if (cur_node->type != XML_ELEMENT_NODE)
+            continue;
+
+        if (NODE_IS_TYPE (cur_node, "cc"))
+            ret->cc = parse_cc(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "loc"))
+            ret->loc = parse_loc(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "dayf"))
+        {
+            xmlNode *child_node;
+            guint i = 0;
+
+            for (child_node = cur_node->children; child_node; child_node = child_node->next)
+            {
+                if (NODE_IS_TYPE (child_node, "day"))
+                {
+                    if (i >= XML_WEATHER_DAYF_N)
+                        break;
+
+                    ret->dayf[i] = parse_dayf(child_node);
+
+                    i++;
+                }
+            }
+        }
+    }
+
+    return ret;
+}
+
+xml_loc *
+parse_loc (xmlNode *cur_node)
+{
+    xml_loc *ret;
+
+    if ((ret = panel_slice_new0 (xml_loc)) == NULL)
+        return NULL;
+
+
+    for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+    {
+        if (cur_node->type != XML_ELEMENT_NODE)
+            continue;
+
+        if (NODE_IS_TYPE (cur_node, "dnam"))
+            ret->dnam = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "sunr"))
+            ret->sunr = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "suns"))
+            ret->suns = DATA(cur_node);
+    }
+
+    return ret;
+}
+
+static xml_uv *
+parse_uv (xmlNode *cur_node)
+{
+    xml_uv *ret;
+
+    if ((ret = panel_slice_new0 (xml_uv)) == NULL)
+        return NULL;
+
+    for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+    {
+        if (cur_node->type != XML_ELEMENT_NODE)
+            continue;
+
+        if (NODE_IS_TYPE (cur_node, "i"))
+            ret->i = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "t"))
+            ret->t = DATA(cur_node);
+    }
+
+    return ret;
+}
+
+static xml_bar *
+parse_bar (xmlNode *cur_node)
+{
+    xml_bar *ret;
+
+    if ((ret = panel_slice_new0 (xml_bar)) == NULL)
+        return NULL;
+
+    for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+    {
+        if (cur_node->type != XML_ELEMENT_NODE)
+            continue;
+
+        if (NODE_IS_TYPE (cur_node, "r"))
+            ret->r = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "d"))
+            ret->d = DATA(cur_node);
+    }
+
+    return ret;
+}
+
+static xml_wind *
+parse_wind (xmlNode *cur_node)
+{
+    xml_wind *ret;
+
+    if ((ret = panel_slice_new0 (xml_wind)) == NULL)
+        return NULL;
+
+    for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+    {
+        if (cur_node->type != XML_ELEMENT_NODE)
+            continue;
+
+        if (NODE_IS_TYPE (cur_node, "s"))
+            ret->s = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "gust"))
+            ret->gust = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "d"))
+            ret->d = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "t"))
+            ret->t = DATA(cur_node);
+    }
+
+    return ret;
+}
+
+xml_cc *
+parse_cc (xmlNode *cur_node)
+{
+    xml_cc *ret;
+
+    if ((ret = panel_slice_new0 (xml_cc)) == NULL)
+        return NULL;
+
+    for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+    {
+        if (cur_node->type != XML_ELEMENT_NODE)
+            continue;
+
+        if (NODE_IS_TYPE (cur_node, "tmp"))
+            ret->tmp = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "icon"))
+            ret->icon = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "t"))
+            ret->t = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "flik"))
+            ret->flik = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "bar"))
+            ret->bar = parse_bar(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "wind"))
+            ret->wind = parse_wind(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "hmid"))
+            ret->hmid = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "vis"))
+            ret->vis = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "uv"))
+            ret->uv = parse_uv(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "dewp"))
+            ret->dewp = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "lsup"))
+            ret->lsup = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "obst"))
+            ret->obst = DATA(cur_node);
+    }
+
+    return ret;
+}
+
+static xml_part *
+parse_part (xmlNode *cur_node)
+{
+    xml_part *ret;
+
+    if ((ret = panel_slice_new0 (xml_part)) == NULL)
+        return NULL;
+
+    for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+    {
+        if (cur_node->type != XML_ELEMENT_NODE)
+            continue;
+
+        if (NODE_IS_TYPE (cur_node, "icon"))
+            ret->icon = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "t"))
+            ret->t = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "wind"))
+            ret->wind = parse_wind(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "ppcp"))
+            ret->ppcp = DATA(cur_node);
+        else if (NODE_IS_TYPE (cur_node, "hmid"))
+            ret->hmid = DATA(cur_node);
+    }
+
+    return ret;
+}
+
+
+
+xml_dayf *
+parse_dayf (xmlNode *cur_node)
+{
+    xml_dayf *ret;
+    gchar *value;
+
+    if ((ret = panel_slice_new0 (xml_dayf)) == NULL)
+        return NULL;
+
+    ret->day  = (gchar *) xmlGetProp (cur_node, (const xmlChar *) "t");
+    ret->date = (gchar *) xmlGetProp (cur_node, (const xmlChar *) "dt");
+
+    for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+    {
+        if (cur_node->type != XML_ELEMENT_NODE)
+            continue;
+
+        if (NODE_IS_TYPE (cur_node, "hi"))
+        {
+            ret->hi = DATA(cur_node);
+            g_assert(ret->hi != NULL);
+        }
+        else if (NODE_IS_TYPE (cur_node, "low"))
+        {
+            ret->low = DATA(cur_node);
+        }
+        else if (NODE_IS_TYPE (cur_node, "part"))
+        {
+            value = (gchar *)  xmlGetProp (cur_node, (const xmlChar *) "p");
+
+            if (xmlStrEqual ((const xmlChar *)value, (const xmlChar *)"d"))
+                ret->part[0] = parse_part(cur_node);
+            else if (xmlStrEqual ((const xmlChar *)value, (const xmlChar *)"n"))
+                ret->part[1] = parse_part(cur_node);
+
+            g_free(value);
+        }
+    }
+
+    return ret;
+}
+
+#define CHK_FREE(this) if (this)\
+              g_free(this);
+
+static void
+xml_uv_free (xml_uv *data)
+{
+    CHK_FREE (data->i);
+    CHK_FREE (data->t);
+
+    panel_slice_free (xml_uv, data);
+}
+
+static void
+xml_wind_free (xml_wind *data)
+{
+    CHK_FREE (data->s);
+    CHK_FREE (data->gust);
+    CHK_FREE (data->d);
+    CHK_FREE (data->t);
+
+    panel_slice_free (xml_wind, data);
+}
+
+static void
+xml_bar_free (xml_bar *data)
+{
+    CHK_FREE (data->r);
+    CHK_FREE (data->d);
+
+    panel_slice_free (xml_bar, data);
+}
+
+static void
+xml_cc_free (xml_cc *data)
+{
+    CHK_FREE (data->obst);
+    CHK_FREE (data->lsup);
+    CHK_FREE (data->flik);
+    CHK_FREE (data->t);
+    CHK_FREE (data->icon);
+    CHK_FREE (data->tmp);
+    CHK_FREE (data->hmid);
+    CHK_FREE (data->vis);
+    CHK_FREE (data->dewp);
+
+    if (data->uv)
+        xml_uv_free(data->uv);
+
+    if (data->wind)
+        xml_wind_free(data->wind);
+
+    if (data->bar)
+        xml_bar_free(data->bar);
+
+    panel_slice_free (xml_cc, data);
+}
+
+static void
+xml_loc_free (xml_loc *data)
+{
+    CHK_FREE (data->dnam);
+    CHK_FREE (data->sunr);
+    CHK_FREE (data->suns);
+
+    panel_slice_free (xml_loc, data);
+}
+
+static void
+xml_part_free (xml_part *data)
+{
+    if (!data)
+        return;
+
+    CHK_FREE (data->icon);
+    CHK_FREE (data->t);
+    CHK_FREE (data->ppcp);
+    CHK_FREE (data->hmid);
+
+    if (data->wind)
+        xml_wind_free(data->wind);
+
+    panel_slice_free (xml_part, data);
+}
+
+static void
+xml_dayf_free (xml_dayf *data)
+{
+    if (!data)
+        return;
+
+    CHK_FREE (data->day);
+    CHK_FREE (data->date);
+    CHK_FREE (data->hi);
+    CHK_FREE (data->low);
+
+    if (data->part[0])
+        xml_part_free(data->part[0]);
+
+    if (data->part[1])
+        xml_part_free(data->part[1]);
+
+    panel_slice_free (xml_dayf, data);
+}
+
+void
+xml_weather_free (xml_weather *data)
+{
+    if (data->cc)
+        xml_cc_free(data->cc);
+
+    if (data->loc)
+        xml_loc_free(data->loc);
+
+    if (data->dayf)
+    {
+        guint i;
+        for (i = 0; i < XML_WEATHER_DAYF_N; i++)
+        {
+            if (!data->dayf[i])
+                break;
+
+            xml_dayf_free(data->dayf[i]);
+        }
+
+    }
+
+    panel_slice_free (xml_weather, data);
+}

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/parsers.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,132 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PARSERS_H
+#define PARSERS_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libxml/parser.h>
+
+G_BEGIN_DECLS
+
+#define DATA(node) (gchar *) xmlNodeListGetString(node->doc, node->children, 1)
+#define NODE_IS_TYPE(node, type) xmlStrEqual (node->name, (const xmlChar *) type)
+
+#define XML_WEATHER_DAYF_N 5
+
+typedef struct
+{
+        gchar *dnam;
+        gchar *sunr;
+        gchar *suns;
+}
+xml_loc;
+
+typedef struct
+{
+        gchar *i;
+        gchar *t;
+}
+xml_uv;
+
+typedef struct
+{
+        gchar *s;
+        gchar *gust;
+        gchar *d;
+        gchar *t;
+}
+xml_wind;
+
+typedef struct
+{
+        gchar *r;
+        gchar *d;
+}
+xml_bar;
+
+typedef struct
+{
+        gchar    *lsup;
+        gchar    *obst;
+        gchar    *flik;
+        gchar    *t;
+        gchar    *icon;
+        gchar    *tmp;
+
+        gchar    *hmid;
+        gchar    *vis;
+
+        xml_uv   *uv;
+        xml_wind *wind;
+        xml_bar  *bar;
+
+        gchar    *dewp;
+}
+xml_cc;
+
+typedef struct
+{
+        gchar    *icon;
+        gchar    *t;
+        gchar    *ppcp;
+        gchar    *hmid;
+
+        xml_wind *wind;
+}
+xml_part;
+
+typedef struct
+{
+        gchar    *day;
+        gchar    *date;
+
+        gchar    *hi;
+        gchar    *low;
+
+        xml_part *part[2];
+}
+xml_dayf;
+
+typedef struct
+{
+        xml_loc  *loc;
+        xml_cc   *cc;
+        xml_dayf *dayf[XML_WEATHER_DAYF_N];
+}
+xml_weather;
+
+
+xml_weather *
+parse_weather    (xmlNode *cur_node);
+
+xml_loc *
+parse_loc        (xmlNode *cur_node);
+
+xml_cc *
+parse_cc         (xmlNode *cur_node);
+
+xml_dayf *
+parse_dayf       (xmlNode *cur_node);
+
+void
+xml_weather_free (xml_weather *data);
+
+G_END_DECLS
+
+#endif

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/scrollbox.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,500 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libxfce4panel/xfce-panel-macros.h>
+
+#include "weather-scrollbox.h"
+#define LABEL_REFRESH 3000
+#define LABEL_SPEED 25
+
+typedef struct _Label Label;
+
+struct _Label {
+    gchar *msg;
+    GdkPixmap *pixmap;
+};
+
+enum {
+    GTK_SCROLLBOX_ENABLECB = 1
+};
+
+static GObjectClass *parent_class;
+
+static gboolean
+start_draw_down (GtkScrollbox *self);
+
+static void
+start_draw_up   (GtkScrollbox *self);
+
+static void
+stop_callback   (GtkScrollbox *self);
+
+static GdkPixmap *
+make_pixmap     (GtkScrollbox *, gchar *);
+
+static void
+free_label (Label *lbl)
+{
+    if (lbl->pixmap)
+        g_object_unref (G_OBJECT (lbl->pixmap));
+    if (lbl->msg)
+        g_free (lbl->msg);
+
+    panel_slice_free (Label, lbl);
+}
+
+static gboolean
+draw_up (GtkScrollbox *self)
+{
+    GdkRectangle update_rect = {0,0, GTK_WIDGET(self)->allocation.width,
+        GTK_WIDGET(self)->allocation.height};
+
+    if (self->draw_offset == 0)
+    {
+        self->draw_timeout = g_timeout_add(LABEL_REFRESH,
+                (GSourceFunc)start_draw_down, self);
+
+        return FALSE;
+    }
+    else
+        self->draw_offset++;
+
+    gtk_widget_draw(GTK_WIDGET(self), &update_rect);
+
+    return TRUE;
+}
+
+static gboolean
+draw_down (GtkScrollbox *self)
+{
+    GdkRectangle update_rect = {0, 0, GTK_WIDGET(self)->allocation.width,
+        GTK_WIDGET(self)->allocation.height};
+
+    if (self->draw_offset == self->draw_maxoffset)
+    {
+        self->draw_timeout = 0;
+        start_draw_up(self);
+
+        return FALSE;
+    }
+    else
+        self->draw_offset--;
+
+    gtk_widget_draw(GTK_WIDGET(self), &update_rect);
+
+    return TRUE;
+}
+
+static void
+start_draw_up (GtkScrollbox *self)
+{
+    gint          width, height;
+    Label *lbl;
+    static size_t i = 0;
+
+    if (self->labels->len == 0)
+        return;
+
+    if (i >= self->labels->len)
+        i = 0;
+
+    lbl = (Label *)g_ptr_array_index(self->labels, i);
+    self->pixmap = lbl->pixmap;
+
+	/* If we failed to create a proper pixmap, try again now */
+	if (!lbl->pixmap)
+	{
+        lbl->pixmap = make_pixmap(self, lbl->msg);
+		if (!lbl->pixmap)
+		{
+			/* Still no pixmap. We need to restart the timer */
+			if (self->draw_timeout)
+				stop_callback(self);
+    		self->draw_timeout = g_timeout_add(LABEL_SPEED, (GSourceFunc)start_draw_up, self);
+			return;
+		}
+	}
+
+    if (self->labels->len == 1)
+    {
+        GdkRectangle update_rect = {0, 0, GTK_WIDGET(self)->allocation.width,
+            GTK_WIDGET(self)->allocation.height};
+
+        self->pixmap = lbl->pixmap;
+        self->draw_offset = 0;
+
+        gtk_widget_draw(GTK_WIDGET(self), &update_rect);
+        return;
+    }
+
+    gdk_drawable_get_size(GDK_DRAWABLE(self->pixmap), &width, &height);
+    self->draw_middle = self->draw_maxmiddle - width / 2;
+
+    self->draw_timeout = g_timeout_add(LABEL_SPEED, (GSourceFunc)draw_up, self);
+
+    i++;
+}
+
+static gboolean
+start_draw_down (GtkScrollbox *self)
+{
+    self->draw_timeout = g_timeout_add(LABEL_SPEED, (GSourceFunc)draw_down, self);
+
+    return FALSE;
+}
+
+static void
+stop_callback (GtkScrollbox *self)
+{
+    if (self->draw_timeout == 0)
+        return;
+
+    g_source_remove(self->draw_timeout);
+    self->draw_timeout = 0;
+}
+
+
+static void
+start_callback (GtkScrollbox *self)
+{
+    if (self->draw_timeout)
+        stop_callback(self);
+
+    start_draw_up(self);
+}
+
+static GdkPixmap *
+make_pixmap (GtkScrollbox *self,
+             gchar        *value)
+{
+    GdkWindow      *rootwin;
+    PangoLayout    *pl;
+    gint            width, height, middle;
+    GdkPixmap      *pixmap;
+    GtkRequisition  widgsize = {0, };
+    GtkWidget      *widget = (GtkWidget *)self;
+
+
+    /* If we can't draw yet, don't do anything to avoid screwing things */
+    if (!GDK_IS_GC(widget->style->bg_gc[0]))
+        return NULL;
+
+    rootwin = gtk_widget_get_root_window(widget);
+
+    pl = gtk_widget_create_pango_layout(widget, NULL);
+    pango_layout_set_markup(pl, value, -1);
+
+    pango_layout_get_pixel_size(pl, &width, &height);
+
+    pixmap = gdk_pixmap_new(GDK_DRAWABLE(rootwin), width, height, -1);
+
+    gdk_draw_rectangle(GDK_DRAWABLE(pixmap),
+            widget->style->bg_gc[0],
+            TRUE, 0, 0, width, height);
+
+    gdk_draw_layout(GDK_DRAWABLE(pixmap), widget->style->fg_gc[0], 0, 0, pl);
+
+    g_object_unref(G_OBJECT (pl));
+
+    gtk_widget_size_request(widget, &widgsize);
+
+    if (width <= widgsize.width)
+        width = widgsize.width;
+
+    if (height <= widgsize.height)
+        height = widgsize.height;
+    else
+        self->draw_maxoffset = -height;
+
+    if (width != widgsize.width || height != widgsize.height)
+        gtk_widget_set_size_request(widget, width, height);
+
+    middle = width / 2;
+    if (self->draw_maxmiddle < middle)
+        self->draw_maxmiddle = middle;
+
+    return pixmap;
+}
+
+
+
+void
+gtk_scrollbox_set_label (GtkScrollbox *self,
+                         gint          n,
+                         gchar        *value)
+{
+    gboolean   append = TRUE;
+    GdkPixmap *newpixmap;
+    Label     *newlbl;
+
+    if (n != -1)
+        append = FALSE;
+
+    if (!append)
+    {
+        Label *lbl = (Label *)g_ptr_array_index(self->labels, n);
+
+        if (lbl)
+            free_label(lbl);
+
+        newlbl = lbl;
+    }
+    else
+    {
+        newlbl = panel_slice_new0 (Label);
+        g_ptr_array_add(self->labels, newlbl);
+    }
+
+    newpixmap = make_pixmap(self, value);
+
+    newlbl->pixmap = newpixmap;
+    newlbl->msg = g_strdup(value);
+}
+
+static void
+gtk_scrollbox_set_property (GObject      *object,
+                            guint         property_id,
+                            const GValue *value,
+                            GParamSpec   *pspec)
+{
+    GtkScrollbox *self = (GtkScrollbox *)object;
+
+    switch (property_id)
+    {
+        case GTK_SCROLLBOX_ENABLECB:
+        {
+            gboolean realvalue = g_value_get_boolean(value);
+
+            if (!realvalue && self->draw_timeout)
+                stop_callback(self);
+            else if (realvalue && !self->draw_timeout)
+                start_callback(self);
+
+            break;
+        }
+        default:
+            /* We don't have any other property... */
+            g_assert (FALSE);
+
+            break;
+    }
+}
+
+static void
+gtk_scrollbox_get_property (GObject      *object,
+                            guint         property_id,
+                            GValue       *value,
+                            GParamSpec   *pspec)
+{
+    return;
+}
+
+static void
+gtk_scrollbox_finalize (GObject *gobject)
+{
+    GtkScrollbox *self = (GtkScrollbox *)gobject;
+    guint i;
+
+    if (self->draw_timeout) {
+        g_source_remove(self->draw_timeout);
+        self->draw_timeout = 0;
+    }
+
+    if (self->labels->len > 0)
+    {
+        for (i = 0; i < self->labels->len; i++)
+        {
+            Label *lbl = (Label*)g_ptr_array_index(self->labels, i);
+
+            g_object_unref (G_OBJECT (lbl->pixmap));
+            g_free(lbl->msg);
+        }
+        g_ptr_array_free(self->labels, TRUE);
+    }
+
+    G_OBJECT_CLASS (parent_class)->finalize (gobject);
+}
+
+static void
+redraw_labels (GtkWidget *widget,
+               GtkStyle  *previous_style)
+{
+    GtkScrollbox *self = GTK_SCROLLBOX(widget);
+    guint i;
+
+    if (self->labels->len < 1)
+        return;
+
+    stop_callback(self);
+
+    gtk_widget_set_size_request(GTK_WIDGET(self), 0, 0);
+    self->draw_middle = 0;
+    self->draw_maxmiddle = 0;
+
+    for (i = 0; i < self->labels->len; i++)
+    {
+        GdkPixmap *newpixmap;
+        Label *lbl = (Label *)g_ptr_array_index(self->labels, i);
+
+        if (!lbl->msg)
+            continue;
+
+        newpixmap = make_pixmap(self, lbl->msg);
+
+        if (lbl->pixmap)
+            g_object_unref (G_OBJECT (lbl->pixmap));
+
+        lbl->pixmap = newpixmap;
+    }
+
+    start_callback(self);
+
+}
+
+
+static void
+gtk_scrollbox_instance_init (GTypeInstance *instance,
+                             gpointer       g_class)
+{
+      GtkScrollbox *self = (GtkScrollbox *)instance;
+
+/*      GTK_WIDGET_SET_FLAGS (GTK_WIDGET(self), GTK_NO_WINDOW);*/
+
+      self->draw_timeout = 0;
+      self->labels = g_ptr_array_new();
+      self->pixmap = NULL;
+
+      g_signal_connect(self, "style-set", G_CALLBACK(redraw_labels), NULL);
+}
+
+static gboolean
+gtk_scrollbox_expose (GtkWidget      *widget,
+                      GdkEventExpose *event)
+{
+    GtkScrollbox *self = (GtkScrollbox *)widget;
+
+    if (self->pixmap)
+        gdk_draw_drawable(widget->window,
+            widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
+            self->pixmap,
+            0, self->draw_offset,
+            self->draw_middle, 0,
+            widget->allocation.width,widget->allocation.height);
+
+    return FALSE;
+}
+
+void
+gtk_scrollbox_enablecb (GtkScrollbox *self,
+                        gboolean      enable)
+{
+    GValue val = {0, };
+
+    g_value_init (&val, G_TYPE_BOOLEAN);
+    g_value_set_boolean (&val, enable);
+
+    g_object_set_property(G_OBJECT(self), "enablecb", &val);
+}
+
+GtkWidget *
+gtk_scrollbox_new (void)
+{
+    return GTK_WIDGET(g_object_new (GTK_TYPE_SCROLLBOX, NULL));
+}
+
+static void
+gtk_scrollbox_class_init (gpointer g_class,
+                          gpointer g_class_data)
+{
+
+  GObjectClass *gobject_class = G_OBJECT_CLASS(g_class);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(g_class);
+
+  parent_class = g_type_class_peek_parent (g_class);
+
+  GParamSpec *scrollbox_param_spec;
+
+  gobject_class->set_property = gtk_scrollbox_set_property;
+  gobject_class->get_property = gtk_scrollbox_get_property;
+
+  scrollbox_param_spec = g_param_spec_boolean("enablecb",
+          "Enable callback",
+          "Enable or disable the callback",
+          FALSE,
+          G_PARAM_READWRITE);
+  g_object_class_install_property (gobject_class,
+       GTK_SCROLLBOX_ENABLECB,
+       scrollbox_param_spec);
+
+  widget_class->expose_event = gtk_scrollbox_expose;
+  gobject_class->finalize = gtk_scrollbox_finalize;
+}
+
+
+GType
+gtk_scrollbox_get_type (void)
+{
+    static GType type = 0;
+
+    if (type == 0) {
+
+	static const GTypeInfo info = {
+            sizeof (GtkScrollboxClass),
+            NULL,                          /* base_init      */
+            NULL,                          /* base_finalize  */
+            gtk_scrollbox_class_init,      /* class_init     */
+            NULL,                          /* class_finalize */
+            NULL,                          /* class_data     */
+            sizeof (GtkScrollbox),
+            0,                             /* n_preallocs    */
+            gtk_scrollbox_instance_init,   /* instance_init  */
+	    NULL
+        };
+
+        type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
+                "GtkScrollbox", &info, 0);
+    }
+
+    return type;
+}
+
+void
+gtk_scrollbox_clear (GtkScrollbox *self)
+{
+    stop_callback(self);
+
+    while(self->labels->len > 0)
+    {
+        Label *lbl = (Label *) g_ptr_array_index(self->labels, 0);
+        free_label(lbl);
+
+        g_ptr_array_remove_index (self->labels, 0);
+    }
+
+    self->pixmap = NULL;
+    gtk_widget_set_size_request(GTK_WIDGET(self), 0, 0);
+    self->draw_middle = 0;
+    self->draw_maxmiddle = 0;
+}

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/scrollbox.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,67 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef SCROLLBOX_H
+#define SCROLLBOX_H
+
+G_BEGIN_DECLS
+
+GType gtk_scrollbox_get_type (void);
+
+#define GTK_TYPE_SCROLLBOX             (gtk_scrollbox_get_type())
+#define GTK_SCROLLBOX(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_SCROLLBOX, GtkScrollbox))
+#define GTK_SCROLLBOX_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_SCROLLBOX, GtkScrollboxClass))
+#define GTK_IS_SCROLLBOX(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_SCROLLBOX))
+#define GTK_IS_SCROLLBOX_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_SCROLLBOX))
+#define GTK_SCROLLBOX_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_SCROLLBOX, GtkScrollboxClass))
+
+typedef struct _GtkScrollbox GtkScrollbox;
+typedef struct _GtkScrollboxClass GtkScrollboxClass;
+
+struct _GtkScrollbox {
+        GtkDrawingArea parent;
+
+        GPtrArray *labels;
+
+        gint draw_offset;
+        gint draw_maxoffset;
+        gint draw_middle;
+        gint draw_maxmiddle;
+        gint draw_timeout;
+
+        GdkPixmap *pixmap;
+};
+
+struct _GtkScrollboxClass {
+        GtkDrawingAreaClass parent;
+};
+
+void
+gtk_scrollbox_set_label (GtkScrollbox *self, gint n, gchar *value);
+
+GtkWidget *
+gtk_scrollbox_new       (void);
+
+void
+gtk_scrollbox_enablecb  (GtkScrollbox *self, gboolean enable);
+
+void
+gtk_scrollbox_clear     (GtkScrollbox *self);
+
+G_END_DECLS
+
+#endif

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-search.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/search_dialog.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-search.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-search.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,257 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "weather-search.h"
+
+#include <string.h>
+
+#include "weather-parsers.h"
+#include "weather-data.h"
+#include "weather.h"
+
+#include "weather-http.h"
+
+#define BORDER 8
+
+static void
+append_result (GtkListStore *mdl,
+               gchar        *id,
+               gchar        *city)
+{
+     GtkTreeIter iter;
+
+     gtk_list_store_append(mdl, &iter);
+     gtk_list_store_set(mdl, &iter, 0, city, 1, id, -1);
+}
+
+static gchar *
+sanitize_str (const gchar *str)
+{
+    GString *retstr = g_string_sized_new(strlen(str));
+    gchar *realstr, c = '\0';
+
+    while((c = *str++))
+    {
+        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);
+    }
+
+    realstr = retstr->str;
+
+    g_string_free(retstr, FALSE);
+
+
+
+    return realstr;
+}
+
+static void
+cb_searchdone (gboolean result,
+               gpointer user_data)
+{
+    search_dialog *dialog = (search_dialog *) user_data;
+    xmlDoc *doc;
+    xmlNode *cur_node;
+
+    if (!result || dialog->recv_buffer == NULL)
+        return;
+
+    doc = xmlParseMemory(dialog->recv_buffer, strlen(dialog->recv_buffer));
+    g_free(dialog->recv_buffer);
+    dialog->recv_buffer = NULL;
+
+    if (!doc)
+        return;
+
+    cur_node = xmlDocGetRootElement(doc);
+
+    if (cur_node)
+    {
+        for (cur_node = cur_node->children;
+                cur_node;
+                cur_node = cur_node->next)
+        {
+            if (NODE_IS_TYPE(cur_node, "loc"))
+            {
+                gchar *id = (gchar *) xmlGetProp(cur_node, (const xmlChar *) "id");
+                gchar *city;
+
+                if (!id)
+                    continue;
+
+                city = DATA(cur_node);
+
+                if (!city)
+                {
+                    g_free(id);
+                    continue;
+                }
+                append_result(dialog->result_mdl, id, city);
+                g_free(id);
+                g_free(city);
+            }
+        }
+    }
+
+    xmlFreeDoc(doc);
+
+    return;
+}
+
+
+static gboolean
+search_cb (GtkButton *button,
+           gpointer   user_data)
+{
+    search_dialog *dialog = (search_dialog *)user_data;
+    gchar *sane_str, *url;
+    const gchar *str;
+    gboolean result;
+
+    str = gtk_entry_get_text(GTK_ENTRY(dialog->search_entry));
+
+    if (strlen(str) == 0)
+        return FALSE;
+
+    gtk_list_store_clear(GTK_LIST_STORE(dialog->result_mdl));
+
+    if ((sane_str = sanitize_str(str)) == NULL)
+        return FALSE;
+
+    url = g_strdup_printf("/search/search?where=%s", sane_str);
+    g_free(sane_str);
+
+    result = http_get_buffer(url, "xoap.weather.com", dialog->proxy_host, dialog->proxy_port,
+            &dialog->recv_buffer, cb_searchdone, (gpointer)dialog);
+    g_free(url);
+
+    return result;
+}
+
+
+search_dialog *
+create_search_dialog (GtkWindow *parent,
+                      gchar     *proxy_host,
+                      gint       proxy_port)
+{
+    GtkWidget *vbox, *label, *button, *hbox, *scroll, *frame;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
+    search_dialog *dialog;
+
+    dialog = panel_slice_new0 (search_dialog);
+
+    dialog->proxy_host = proxy_host;
+    dialog->proxy_port = proxy_port;
+
+    if (!dialog)
+        return NULL;
+
+    dialog->dialog = gtk_dialog_new_with_buttons (_("Search weather location code"),
+            parent,
+            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+            GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+            GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+            NULL);
+
+    vbox = gtk_vbox_new(FALSE, BORDER);
+    gtk_window_set_icon_name  (GTK_WINDOW (dialog->dialog), GTK_STOCK_FIND);
+
+    label = gtk_label_new(_("Enter a city name or zip code:"));
+    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+
+    dialog->search_entry = gtk_entry_new();
+    button = gtk_button_new_from_stock(GTK_STOCK_FIND);
+    hbox = gtk_hbox_new(FALSE, BORDER);
+    gtk_box_pack_start(GTK_BOX(hbox), dialog->search_entry, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+    /* list */
+    dialog->result_mdl = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+    dialog->result_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->result_mdl));
+
+    column = gtk_tree_view_column_new_with_attributes(_("Results"), renderer,
+            "text", 0, NULL);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(dialog->result_list), column);
+
+    scroll = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
+            GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+    gtk_container_add(GTK_CONTAINER(scroll), dialog->result_list);
+
+    frame = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(frame), scroll);
+
+    gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox), vbox, TRUE, TRUE, 0);
+
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
+
+    g_signal_connect(button, "clicked", G_CALLBACK(search_cb), dialog);
+
+    gtk_widget_set_size_request(dialog->dialog, 350, 250);
+
+    return dialog;
+}
+
+gboolean
+run_search_dialog (search_dialog *dialog)
+{
+    gtk_widget_show_all(dialog->dialog);
+    if (gtk_dialog_run(GTK_DIALOG(dialog->dialog)) == GTK_RESPONSE_ACCEPT)
+    {
+        GtkTreeIter iter;
+        GtkTreeSelection *selection =
+            gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->result_list));
+
+        if (gtk_tree_selection_get_selected(selection, NULL, &iter))
+        {
+            GValue value = {0, };
+
+            gtk_tree_model_get_value(GTK_TREE_MODEL(dialog->result_mdl),
+                    &iter, 1, &value);
+            dialog->result = g_strdup(g_value_get_string(&value));
+
+            g_value_unset(&value);
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+void
+free_search_dialog (search_dialog *dialog)
+{
+    g_free(dialog->result);
+    gtk_widget_destroy(dialog->dialog);
+
+    panel_slice_free (search_dialog, dialog);
+}

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-search.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/search_dialog.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-search.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-search.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,54 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+#include <gmodule.h>
+#include <gtk/gtk.h>
+
+#ifndef SEARCH_DIALOG_H
+#define SEARCH_DIALOG_H
+
+G_BEGIN_DECLS
+
+typedef struct
+{
+        GtkWidget *dialog;
+        GtkWidget *search_entry;
+        GtkWidget *result_list;
+        GtkListStore *result_mdl;
+
+        gchar *result;
+
+        gchar *proxy_host;
+        gint proxy_port;
+
+        gchar *recv_buffer;
+}
+search_dialog;
+
+search_dialog *
+create_search_dialog (GtkWindow *, gchar *, gint);
+
+gboolean
+run_search_dialog    (search_dialog *dialog);
+
+void
+free_search_dialog   (search_dialog *dialog);
+
+G_END_DECLS
+
+#endif

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-summary.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/summary_window.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-summary.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-summary.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,394 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <libxfcegui4/libxfcegui4.h>
+
+#include "weather-parsers.h"
+#include "weather-data.h"
+#include "weather.h"
+
+#include "weather-summary.h"
+#include "weather-translate.h"
+#include "weather-icon.h"
+
+#define BORDER 8
+
+#define APPEND_BTEXT(text) gtk_text_buffer_insert_with_tags(GTK_TEXT_BUFFER(buffer),\
+        &iter, text, -1, btag, NULL);
+
+#define APPEND_TEXT_ITEM_REAL(text) gtk_text_buffer_insert(GTK_TEXT_BUFFER(buffer), &iter, text, -1);
+
+#define APPEND_TEXT_ITEM(text, item) value = g_strdup_printf("\t%s: %s %s\n",\
+        text, get_data(data, item), get_unit(unit, item));\
+        APPEND_TEXT_ITEM_REAL(value); g_free(value);
+
+static GtkTooltips *tooltips = NULL;
+
+static GtkWidget *
+create_summary_tab (xml_weather *data,
+                    units        unit)
+{
+    GtkTextBuffer *buffer;
+    GtkTextIter iter;
+    GtkTextTag *btag;
+    gchar *value, *date, *wind, *sun_val, *vis;
+    GtkWidget *view, *frame, *scrolled;
+
+    view = gtk_text_view_new();
+    gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE);
+    frame = gtk_frame_new(NULL);
+    scrolled = gtk_scrolled_window_new(NULL, NULL);
+
+    gtk_container_add(GTK_CONTAINER(scrolled), view);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+            GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+    gtk_container_set_border_width(GTK_CONTAINER(frame), BORDER);
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(frame), scrolled);
+
+    buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(view));
+    gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(buffer),
+            &iter,
+            0);
+    btag = gtk_text_buffer_create_tag(buffer, NULL, "weight", PANGO_WEIGHT_BOLD, NULL);
+
+
+    value = g_strdup_printf(_("Weather report for: %s.\n\n"), get_data(data, DNAM));
+    APPEND_BTEXT (value);
+    g_free(value);
+
+    date = translate_lsup(get_data(data, LSUP));
+    value = g_strdup_printf(_("Observation station located in %s\nLast update: %s.\n"),
+            get_data(data, OBST), date ? date : get_data(data, LSUP));
+    APPEND_TEXT_ITEM_REAL(value);
+
+    if (date)
+        g_free(date);
+
+    g_free(value);
+
+    APPEND_BTEXT (_("\nTemperature\n"));
+    APPEND_TEXT_ITEM (_("Temperature"), TEMP);
+    APPEND_TEXT_ITEM (_("Windchill"), FLIK);
+
+    /* special case for TRANS because of translate_desc */
+    value = g_strdup_printf("\t%s: %s\n",
+        _("Description"), translate_desc(get_data(data, TRANS)));
+    APPEND_TEXT_ITEM_REAL(value);
+    g_free(value);
+
+    APPEND_TEXT_ITEM (_("Dew point"), DEWP);
+
+    APPEND_BTEXT (_("\nWind\n"));
+    wind = translate_wind_speed(get_data(data, WIND_SPEED), unit);
+	value = g_strdup_printf("\t%s: %s\n", _("Speed"), wind);
+    APPEND_TEXT_ITEM_REAL(value);
+    g_free(wind);
+    g_free(value);
+
+    wind = translate_wind_direction(get_data(data, WIND_DIRECTION));
+    value = g_strdup_printf("\t%s: %s\n",
+            _("Direction"), wind ? wind : get_data(data, WIND_DIRECTION));
+    if (wind)
+        g_free(wind);
+    APPEND_TEXT_ITEM_REAL(value);
+    g_free(value);
+
+    wind = translate_wind_speed(get_data(data, WIND_GUST), unit);
+	value = g_strdup_printf("\t%s: %s\n", _("Gusts"), wind);
+    APPEND_TEXT_ITEM_REAL(value);
+    g_free(wind);
+    g_free(value);
+
+    APPEND_BTEXT (_("\nUV\n"));
+    APPEND_TEXT_ITEM (_("Index"), UV_INDEX);
+    value = g_strdup_printf("\t%s: %s\n",
+        _("Risk"), translate_risk(get_data(data, UV_TRANS)));
+    APPEND_TEXT_ITEM_REAL(value);
+	g_free(value);
+
+    APPEND_BTEXT (_("\nAtmospheric pressure\n"));
+    APPEND_TEXT_ITEM (_("Pressure"), BAR_R);
+
+    value = g_strdup_printf("\t%s: %s\n",
+            _("State"), translate_bard(get_data(data, BAR_D)));
+    APPEND_TEXT_ITEM_REAL(value);
+    g_free(value);
+
+    APPEND_BTEXT (_("\nSun\n"));
+
+    sun_val = translate_time(get_data(data, SUNR));
+    value = g_strdup_printf("\t%s: %s\n",
+            _("Rise"), sun_val ? sun_val : get_data(data, SUNR));
+    if (sun_val)
+        g_free(sun_val);
+    APPEND_TEXT_ITEM_REAL(value);
+    g_free(value);
+
+    sun_val = translate_time(get_data(data, SUNS));
+    value = g_strdup_printf("\t%s: %s\n",
+            _("Set"), sun_val ? sun_val : get_data(data, SUNS));
+    if (sun_val)
+        g_free(sun_val);
+    APPEND_TEXT_ITEM_REAL(value);
+    g_free(value);
+
+    APPEND_BTEXT (_("\nOther\n"));
+    APPEND_TEXT_ITEM (_("Humidity"), HMID);
+	vis = translate_visibility(get_data(data, VIS), unit);
+	value = g_strdup_printf("\t%s: %s\n", _("Visibility"), vis);
+    APPEND_TEXT_ITEM_REAL(value);
+	g_free(vis);
+    g_free(value);
+
+    return frame;
+}
+
+static GtkWidget *
+make_forecast (xml_dayf *weatherdata,
+               units     unit)
+{
+    GtkWidget *item_vbox, *temp_hbox, *icon_hbox, *label, *icon_d, *icon_n, *box_d, *box_n;
+    GdkPixbuf *icon;
+    gchar *str, *day, *wind;
+
+    DBG ("this day %s", weatherdata->day);
+
+    item_vbox = gtk_vbox_new(FALSE, 0);
+    gtk_container_set_border_width(GTK_CONTAINER(item_vbox), 6);
+
+
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+
+    day = translate_day(get_data_f(weatherdata, WDAY));
+
+    str = g_strdup_printf("<b>%s</b>", day ? day : get_data_f(weatherdata, WDAY));
+    if (day)
+        g_free(day);
+    gtk_label_set_markup(GTK_LABEL(label), str);
+    g_free(str);
+    gtk_box_pack_start(GTK_BOX(item_vbox), label, FALSE, FALSE, 0);
+
+    icon_hbox = gtk_hbox_new(FALSE, 0);
+
+    icon = get_icon(get_data_f(weatherdata, ICON_D), GTK_ICON_SIZE_DIALOG);
+    icon_d = gtk_image_new_from_pixbuf(icon);
+    g_object_unref (G_OBJECT (icon));
+    box_d = gtk_event_box_new();
+    gtk_container_add(GTK_CONTAINER(box_d), icon_d);
+
+    icon = get_icon(get_data_f(weatherdata, ICON_N), GTK_ICON_SIZE_DIALOG);
+    icon_n = gtk_image_new_from_pixbuf(icon);
+    g_object_unref (G_OBJECT (icon));
+    box_n = gtk_event_box_new();
+    gtk_container_add(GTK_CONTAINER(box_n), icon_n);
+
+    if (G_UNLIKELY (!tooltips))
+        tooltips = gtk_tooltips_new ();
+
+    str = g_strdup_printf(_("Day: %s"), translate_desc(get_data_f(weatherdata, TRANS_D)));
+    gtk_tooltips_set_tip(tooltips, box_d, str, NULL);
+    g_free(str);
+    str = g_strdup_printf(_("Night: %s"), translate_desc(get_data_f(weatherdata, TRANS_N)));
+    gtk_tooltips_set_tip(tooltips, box_n, str, NULL);
+    g_free(str);
+
+    gtk_box_pack_start(GTK_BOX(icon_hbox), box_d, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(icon_hbox), box_n, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(item_vbox), icon_hbox, FALSE, FALSE, 0);
+
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    gtk_label_set_markup(GTK_LABEL(label), _("<b>Precipitation</b>"));
+    gtk_box_pack_start(GTK_BOX(item_vbox), label, FALSE, FALSE, 0);
+
+    temp_hbox = gtk_hbox_new(FALSE, 0);
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    str = g_strdup_printf("%s %%", get_data_f(weatherdata, PPCP_D));
+    gtk_label_set_markup(GTK_LABEL(label), str);
+    g_free(str);
+    gtk_box_pack_start(GTK_BOX(temp_hbox), label, TRUE, TRUE, 0);
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    str = g_strdup_printf("%s %%", get_data_f(weatherdata, PPCP_N));
+    gtk_label_set_markup(GTK_LABEL(label), str);
+    g_free(str);
+    gtk_box_pack_start(GTK_BOX(temp_hbox), label, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(item_vbox), temp_hbox, FALSE, FALSE, 0);
+
+
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    gtk_label_set_markup(GTK_LABEL(label), _("<b>Temperature</b>"));
+    gtk_box_pack_start(GTK_BOX(item_vbox), label, FALSE, FALSE, 0);
+
+
+    temp_hbox = gtk_hbox_new(FALSE, 0);
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    str = g_strdup_printf("<span foreground=\"red\">%s</span> %s",
+            get_data_f(weatherdata, TEMP_MAX), get_unit(unit, TEMP));
+    gtk_label_set_markup(GTK_LABEL(label), str);
+    g_free(str);
+    gtk_box_pack_start(GTK_BOX(temp_hbox), label, TRUE, TRUE, 0);
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    str = g_strdup_printf("<span foreground=\"blue\">%s</span> %s",
+            get_data_f(weatherdata, TEMP_MIN), get_unit(unit, TEMP));
+    gtk_label_set_markup(GTK_LABEL(label), str);
+    g_free(str);
+    gtk_box_pack_start(GTK_BOX(temp_hbox), label, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(item_vbox), temp_hbox, FALSE, FALSE, 0);
+
+
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    gtk_label_set_markup(GTK_LABEL(label), _("<b>Wind</b>"));
+    gtk_box_pack_start(GTK_BOX(item_vbox), label, FALSE, FALSE, 0);
+
+    temp_hbox = gtk_hbox_new(FALSE, 0);
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+
+    wind = translate_wind_direction(get_data_f(weatherdata, W_DIRECTION_D));
+    gtk_label_set_markup(GTK_LABEL(label), wind ? wind : get_data_f(weatherdata, W_DIRECTION_D));
+    if (wind)
+        g_free(wind);
+
+    gtk_box_pack_start(GTK_BOX(temp_hbox), label, TRUE, TRUE, 0);
+
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+
+    wind = translate_wind_direction(get_data_f(weatherdata, W_DIRECTION_N));
+    gtk_label_set_markup(GTK_LABEL(label), wind ? wind : get_data_f(weatherdata, W_DIRECTION_N));
+    if (wind)
+        g_free(wind);
+    gtk_box_pack_start(GTK_BOX(temp_hbox), label, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(item_vbox), temp_hbox, FALSE, FALSE, 0);
+
+    /* speed */
+
+    temp_hbox = gtk_hbox_new(FALSE, 2);
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    str = g_strdup_printf("%s %s", get_data_f(weatherdata, W_SPEED_D),
+            get_unit(unit, WIND_SPEED));
+    gtk_label_set_markup(GTK_LABEL(label), str);
+    g_free(str);
+    gtk_box_pack_start(GTK_BOX(temp_hbox), label, TRUE, TRUE, 0);
+
+    label = gtk_label_new(NULL);
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    str = g_strdup_printf("%s %s", get_data_f(weatherdata, W_SPEED_N),
+            get_unit(unit, WIND_SPEED));
+    gtk_label_set_markup(GTK_LABEL(label), str);
+    g_free(str);
+    gtk_box_pack_start(GTK_BOX(temp_hbox), label, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(item_vbox), temp_hbox, FALSE, FALSE, 0);
+
+    DBG ("Done");
+
+    return item_vbox;
+}
+
+static GtkWidget *
+create_forecast_tab (xml_weather *data,
+                     units        unit)
+{
+    GtkWidget *widg = gtk_hbox_new(FALSE, 0);
+    guint i;
+
+    gtk_container_set_border_width(GTK_CONTAINER(widg), 6);
+
+    if (data && data->dayf)
+    {
+        for (i = 0; i < XML_WEATHER_DAYF_N - 1; i++)
+        {
+            if (!data->dayf[i])
+                break;
+
+            DBG ("%s", data->dayf[i]->day);
+
+            gtk_box_pack_start(GTK_BOX(widg),
+                    make_forecast(data->dayf[i], unit), FALSE, FALSE, 0);
+            gtk_box_pack_start(GTK_BOX(widg),
+                    gtk_vseparator_new(), TRUE, TRUE, 0);
+        }
+
+        if (data->dayf[i])
+            gtk_box_pack_start(GTK_BOX(widg),
+                    make_forecast(data->dayf[i], unit), FALSE, FALSE, 0);
+    }
+
+    return widg;
+}
+
+GtkWidget *
+create_summary_window (xml_weather *data,
+                       units        unit)
+{
+    GtkWidget *window, *notebook, *vbox;
+    gchar *title;
+    GdkPixbuf *icon;
+
+    window = xfce_titled_dialog_new_with_buttons (_("Weather Update"),
+                          NULL,
+                          GTK_DIALOG_NO_SEPARATOR,
+                          GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+                          NULL);
+
+    title = g_strdup_printf(_("Weather report for: %s"), get_data(data, DNAM));
+
+    xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (window),
+                     title);
+    g_free (title);
+
+    vbox = gtk_vbox_new(FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), vbox, TRUE, TRUE, 0);
+
+    icon = get_icon (get_data(data, WICON), GTK_ICON_SIZE_DIALOG);
+
+    if (!icon)
+	icon = get_icon ("25", GTK_ICON_SIZE_DIALOG);
+
+    gtk_window_set_icon (GTK_WINDOW (window), icon);
+    g_object_unref (G_OBJECT (icon));
+
+    notebook = gtk_notebook_new();
+    gtk_container_set_border_width(GTK_CONTAINER(notebook), BORDER);
+    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
+            create_summary_tab(data, unit), gtk_label_new(_("Summary")));
+    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
+            create_forecast_tab(data, unit), gtk_label_new(_("Forecast")));
+
+    gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
+
+    g_signal_connect(window, "response",
+            G_CALLBACK (gtk_widget_destroy), window);
+
+    gtk_window_set_default_size(GTK_WINDOW(window), 500, 400);
+
+    return window;
+}

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-summary.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/summary_window.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-summary.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-summary.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,28 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef SUMMARY_WINDOW_H
+#define SUMMARY_WINDOW_H
+
+G_BEGIN_DECLS
+
+GtkWidget *
+create_summary_window (xml_weather *data, units unit);
+
+G_END_DECLS
+
+#endif

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-translate.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/translate.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-translate.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-translate.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,418 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <time.h>
+
+#include "weather-parsers.h"
+#include "weather-data.h"
+#include "weather.h"
+#include "weather-translate.h"
+
+
+static const gchar *desc_strings[] = {
+    N_("Snow to Rain"),
+    N_("Becoming Cloudy"),
+    N_("Blizzard"),
+    N_("Blizzard Conditions"),
+    N_("Blowing Snow"),
+    N_("Chance of Rain"),
+    N_("Chance of Rain/Snow"),
+    N_("Chance of Showers"),
+    N_("Chance of Snow"),
+    N_("Chance of Snow/Rain"),
+    N_("Chance of T-Storm"),
+    N_("Clear"),
+    N_("Clearing"),
+    N_("Clouds"),
+    N_("Cloudy"),
+    N_("Cloudy Periods"),
+    N_("Continued Hot"),
+    N_("Cumulonimbus Clouds Observed"),
+    N_("Drifting Snow"),
+    N_("Drizzle"),
+    N_("Dry"),
+    N_("Fair"),
+    N_("Flurries"),
+    N_("Fog"),
+    N_("Freezing Drizzle"),
+    N_("Freezing Rain"),
+    N_("Freezing Rain/Snow"),
+    N_("Frozen Precip"),
+    N_("Hazy"),
+    N_("Heavy Rain"),
+    N_("Heavy Snow"),
+    N_("Hot And Humid"),
+    N_("Ice Crystals"),
+    N_("Ice/Snow Mixture"),
+    N_("Increasing Clouds"),
+    N_("Isolated Showers"),
+    N_("Light Rain"),
+    N_("Light Snow"),
+    N_("Lightning Observed"),
+    N_("mild and breezy"),
+    N_("Mist"),
+    N_("Mostly Clear"),
+    N_("Mostly Cloudy"),
+    N_("Mostly Sunny"),
+    N_("N/A"),
+    N_("Occasional Sunshine"),
+    N_("Overcast"),
+    N_("Partial Clearing"),
+    N_("Partial Sunshine"),
+    N_("Partly Cloudy"),
+    N_("Partly Sunny"),
+    N_("Rain"),
+    N_("Rain and Snow"),
+    N_("Rain or Snow"),
+    N_("Rain Showers"),
+    N_("Rain to Snow"),
+    N_("Rain / Snow Showers"),
+    N_("Showers"),
+    N_("Sleet"),
+    N_("Sleet and Snow"),
+    N_("Smoke"),
+    N_("Snow"),
+    N_("Snow and Rain"),
+    N_("Snow or Rain"),
+    N_("Snow Showers"),
+    N_("Sunny"),
+    N_("Thunder"),
+    N_("Thunder storms"),
+    N_("Variable Cloudiness"),
+    N_("Variable Clouds"),
+    N_("Windy"),
+    N_("Wintry Mix"),
+    N_("Showers in the Vicinity"),
+    N_("Light Rain Shower"),
+    N_("Showers Late"),
+    N_("PM Showers"),
+    N_("Light Rain / Wind"),
+    N_("Scattered Showers"),
+    N_("PM Light Rain"),
+    N_("AM Showers"),
+    N_("AM Light Rain"),
+    N_("Partly Cloudy and Windy"),
+    N_("Few Showers"),
+    N_("Light Drizzle"),
+    N_("Clouds Early / Clearing Late"),
+    N_("Mostly Cloudy and Windy"),
+    N_("Rain / Snow"),
+    N_("Rain and Sleet"),
+    N_("Snow Showers Late"),
+    N_("Light Drizzle and Windy"),
+    N_("Snow Shower"),
+    N_("Snow Showers Early"),
+    N_("Few Snow Showers"),
+    NULL
+};
+
+static const gchar *bard_strings[] = {
+    N_("rising"),
+    N_("steady"),
+    N_("falling"),
+    NULL
+};
+
+static const gchar *risk_strings[] = {
+    N_("Low"),
+    N_("Moderate"),
+    N_("High"),
+    N_("Very High"),
+    N_("Extreme"),
+    NULL
+};
+
+static const gchar *wdirs[] = {
+    N_("S"),
+    N_("SSW"),
+    N_("SW"),
+    N_("WSW"),
+    N_("W"),
+    N_("WNW"),
+    N_("NW"),
+    N_("NNW"),
+    N_("N"),
+    N_("NNE"),
+    N_("NE"),
+    N_("ENE"),
+    N_("E"),
+    N_("ESE"),
+    N_("SE"),
+    N_("SSE"),
+    NULL
+};
+
+static const gchar *
+translate_str(const gchar **loc_strings,
+              const gchar  *str)
+{
+    gint loc_string_len, str_len;
+    guint i;
+
+    if (str == NULL)
+        return "?";
+
+    str_len = strlen(str);
+
+    if (str_len < 1)
+        return "?";
+
+    for (i = 0; loc_strings[i] != NULL; i++)
+    {
+        loc_string_len = strlen(loc_strings[i]);
+
+        if (str_len != loc_string_len)
+            continue;
+
+        if (str[0] != loc_strings[i][0])
+            continue;
+
+        if (!g_ascii_strncasecmp(loc_strings[i], str, str_len))
+            return _(loc_strings[i]);
+    }
+
+    return str;
+}
+
+const gchar *
+translate_bard (const gchar *bard)
+{
+    return translate_str(bard_strings, bard);
+}
+
+const gchar *
+translate_risk (const gchar *risk)
+{
+    return translate_str(risk_strings, risk);
+}
+
+const gchar *
+translate_desc (const gchar *desc)
+{
+    return translate_str(desc_strings, desc);
+}
+
+/* used by translate_lsup and translate_time */
+static void
+_fill_time(struct tm   *time,
+           const gchar *hour,
+           const gchar *minute,
+           const gchar *am)
+{
+    time->tm_hour = atoi(hour);
+
+    if (am[0] == 'P' && time->tm_hour != 12) /* PM or AM */
+        time->tm_hour += 12;
+
+    time->tm_min = atoi(minute);
+    time->tm_sec = 0;
+    time->tm_isdst = -1;
+}
+
+
+
+#define HDATE_N sizeof(gchar) * 100
+gchar *
+translate_lsup (const gchar *lsup)
+{
+    gchar *hdate;
+    struct tm time;
+    gint size = 0, i = 0;
+
+
+    gchar **lsup_split;
+
+    if (lsup == NULL || strlen(lsup) == 0)
+        return NULL;
+
+    /* 10/17/04 5:55 PM Local Time */
+    if ((lsup_split = g_strsplit_set(lsup, " /:", 8)) == NULL)
+        return NULL;
+
+    while(lsup_split[i++])
+        size++;
+
+    if (size != 8)
+    {
+        g_strfreev(lsup_split);
+        return NULL;
+    }
+
+    time.tm_mon = atoi(lsup_split[0]) - 1;
+    time.tm_mday = atoi(lsup_split[1]);
+    time.tm_year = atoi(lsup_split[2]) + 100;
+
+    _fill_time(&time, lsup_split[3], lsup_split[4], lsup_split[5]);
+
+    g_strfreev(lsup_split);
+
+    if (mktime(&time) != -1)
+    {
+        hdate = g_malloc(HDATE_N);
+
+        strftime(hdate, HDATE_N, _("%x at %X Local Time"), &time);
+
+        return hdate;
+    }
+    else
+        return NULL;
+}
+
+#define DAY_LOC_N sizeof(gchar) * 20
+gchar *
+translate_day (const gchar *day)
+{
+    gint wday = -1;
+    guint i;
+    const gchar *days[] = {
+      "su", "mo", "tu", "we", "th", "fr", "sa", NULL
+    };
+    gchar *day_loc;
+
+    if (day == NULL || strlen(day) < 2)
+        return NULL;
+
+    for (i = 0; days[i] != NULL; i++)
+        if (!g_ascii_strncasecmp(day, days[i], 2))
+            wday = i;
+
+    if (wday == -1)
+        return NULL;
+    else
+    {
+        struct tm time;
+
+        time.tm_wday = wday;
+
+        day_loc = g_malloc(DAY_LOC_N);
+
+        strftime(day_loc, DAY_LOC_N, "%A", &time);
+
+        return day_loc;
+    }
+}
+
+/* NNW  VAR */
+gchar *
+translate_wind_direction (const gchar *wdir)
+{
+    gint wdir_len;
+    guint i;
+    gchar *wdir_loc;
+
+    if (wdir == NULL || (wdir_len = strlen(wdir)) < 1)
+        return NULL;
+
+    if (strchr(wdir, '/')) /* N/A */
+        return NULL;
+
+    /*
+     * If the direction code can be translated, then translated the
+     * whole code so that it can be correctly translated in CJK (and
+     * possibly Finnish).  If not, use the old behaviour where
+     * individual direction codes are successively translated.
+     */
+    if (g_ascii_strcasecmp(wdir, _(wdir)) != 0)
+        wdir_loc = g_strdup(_(wdir));
+    else
+    {
+        wdir_loc = g_strdup("");
+        for (i = 0; i < strlen(wdir); i++)
+            {
+                gchar wdir_i[2];
+                gchar *tmp;
+
+                wdir_i[0] = wdir[i];
+                wdir_i[1] = '\0';
+
+                tmp = g_strdup_printf("%s%s", wdir_loc,
+                        translate_str(wdirs, wdir_i));
+                g_free(wdir_loc);
+                wdir_loc = tmp;
+            }
+
+    }
+
+    return wdir_loc;
+}
+
+/* calm or a number */
+gchar *
+translate_wind_speed (const gchar *wspeed,
+                      units        unit)
+{
+    gchar *wspeed_loc;
+
+    if (g_ascii_strcasecmp(wspeed, "calm") == 0)
+        wspeed_loc = g_strdup(_("calm"));
+    else if (g_ascii_strcasecmp(wspeed, "N/A") == 0)
+        wspeed_loc = g_strdup(_("N/A"));
+    else
+        wspeed_loc = g_strdup_printf("%s %s", wspeed, get_unit(unit, WIND_SPEED));
+
+    return wspeed_loc;
+}
+
+/* 8:13 AM */
+#define TIME_LOC_N sizeof(gchar) * 20
+gchar *
+translate_time (const gchar *time)
+{
+    gchar **time_split, *time_loc;
+    int i = 0, size = 0;
+    struct tm time_tm;
+
+    if (strlen(time) == 0)
+        return NULL;
+
+    time_split = g_strsplit_set(time, ": ", 3);
+
+    while(time_split[i++])
+        size++;
+
+    if (size != 3)
+        return NULL;
+
+    time_loc = g_malloc(TIME_LOC_N);
+
+    _fill_time(&time_tm, time_split[0], time_split[1], time_split[2]);
+    g_strfreev(time_split);
+
+    strftime(time_loc, TIME_LOC_N, "%X", &time_tm);
+
+    return time_loc;
+}
+
+/* Unlimited or a number */
+gchar *
+translate_visibility (const gchar *vis,
+                      units        unit)
+{
+    gchar *vis_loc;
+
+    if (g_ascii_strcasecmp(vis, "Unlimited") == 0)
+        vis_loc = g_strdup(_("Unlimited"));
+    else
+        vis_loc = g_strdup_printf("%s %s", vis, get_unit(unit, VIS));
+
+    return vis_loc;
+}

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather-translate.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/translate.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-translate.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-translate.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,57 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef TRANSLATE_H
+#define TRANSLATE_H
+
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+const gchar *
+translate_desc          (const gchar *);
+
+const gchar *
+translate_bard          (const gchar *);
+
+const gchar *
+translate_risk          (const gchar *);
+
+/* these return a newly alocted string, that should be freed */
+gchar *
+translate_lsup           (const gchar *);
+
+gchar *
+translate_day            (const gchar *);
+
+gchar *
+translate_wind_direction (const gchar *);
+
+gchar *
+translate_wind_speed     (const gchar *, units);
+
+gchar *
+translate_time           (const gchar *);
+
+gchar *
+translate_visibility     (const gchar *, units);
+
+G_END_DECLS
+
+#endif

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather.c (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/plugin.c)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather.c	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather.c	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,779 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <sys/stat.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+#include "weather-parsers.h"
+#include "weather-data.h"
+#include "weather.h"
+
+#include "weather-translate.h"
+#include "weather-http.h"
+#include "weather-summary.h"
+#include "weather-config.h"
+#include "weather-icon.h"
+#include "weather-scrollbox.h"
+
+#define XFCEWEATHER_ROOT "weather"
+#define UPDATE_TIME 1600
+#define BORDER 8
+
+gboolean
+check_envproxy (gchar **proxy_host,
+                gint   *proxy_port)
+{
+
+    gchar *env_proxy = getenv ("HTTP_PROXY"), *tmp, **split;
+
+    if (!env_proxy)
+        return FALSE;
+
+    tmp = strstr (env_proxy, "://");
+
+    if (!tmp || strlen (tmp) < 3)
+        return FALSE;
+
+    env_proxy = tmp + 3;
+
+    /* we don't support username:password so return */
+    tmp = strchr (env_proxy, '@');
+    if (tmp)
+        return FALSE;
+
+    split = g_strsplit (env_proxy, ":", 2);
+
+    if (!split[0])
+        return FALSE;
+    else if (!split[1])
+    {
+        g_strfreev (split);
+        return FALSE;
+    }
+
+    *proxy_host = g_strdup (split[0]);
+    *proxy_port = (int)strtol (split[1], NULL, 0);
+
+    g_strfreev (split);
+
+    return TRUE;
+}
+
+static gint
+GTK_ICON_SIZE_SMALL = 0;
+
+static gchar *
+make_label (xml_weather *weatherdata,
+            datas        opt,
+            units        unit,
+            gint         size)
+{
+
+    gchar *str, *value;
+    const gchar *rawvalue, *lbl, *txtsize;
+
+    switch (opt)
+    {
+        case VIS:       lbl = _("V"); break;
+        case UV_INDEX:  lbl = _("U"); break;
+        case WIND_DIRECTION: lbl = _("WD"); break;
+        case BAR_D:     lbl = _("P"); break;
+        case BAR_R:     lbl = _("P"); break;
+        case FLIK:      lbl = _("F"); break;
+        case TEMP:      lbl = _("T"); break;
+        case DEWP:      lbl = _("D"); break;
+        case HMID:      lbl = _("H"); break;
+        case WIND_SPEED:lbl = _("WS"); break;
+        case WIND_GUST: lbl = _("WG"); break;
+        default:        lbl = "?"; break;
+    }
+
+    /* arbitrary, choose something that works */
+    if (size > 36)
+        txtsize = "medium";
+    else if (size > 30)
+        txtsize = "small";
+    else if (size > 24)
+        txtsize = "x-small";
+    else
+        txtsize = "xx-small";
+
+    rawvalue = get_data(weatherdata, opt);
+
+    switch (opt)
+    {
+        case VIS:
+            value = translate_visibility (rawvalue, unit);
+            break;
+        case WIND_DIRECTION:
+            value = translate_wind_direction (rawvalue);
+            break;
+        case WIND_SPEED:
+        case WIND_GUST:
+            value = translate_wind_speed (rawvalue, unit);
+            break;
+        default:
+            value = NULL;
+            break;
+    }
+
+
+
+    if (value != NULL)
+    {
+        str = g_strdup_printf ("<span size=\"%s\">%s: %s</span>",
+                txtsize, lbl, value);
+
+        g_free (value);
+    }
+    else
+    {
+        str = g_strdup_printf ("<span size=\"%s\">%s: %s %s</span>",
+                txtsize, lbl, rawvalue, get_unit (unit, opt));
+    }
+
+    return str;
+}
+
+static gchar *
+get_filename (const xfceweather_data *data)
+{
+
+    gchar *filename =
+        g_strdup_printf ("xfce4/weather-plugin/weather_%s_%c.xml",
+            data->location_code, data->unit == METRIC ? 'm' : 'i');
+
+    gchar *fullfilename =
+        xfce_resource_save_location (XFCE_RESOURCE_CACHE, filename,
+                        TRUE);
+    g_free (filename);
+
+    return fullfilename;
+}
+
+static void
+set_icon_error (xfceweather_data *data)
+{
+    GdkPixbuf *icon = get_icon ("25", data->iconsize);
+    gtk_image_set_from_pixbuf (GTK_IMAGE(data->iconimage), icon);
+    g_object_unref (G_OBJECT (icon));
+
+    if (data->weatherdata)
+    {
+        xml_weather_free (data->weatherdata);
+        data->weatherdata = NULL;
+    }
+
+    gtk_tooltips_set_tip (data->tooltips, data->tooltipbox,
+                 _("Cannot update weather data"), NULL);
+
+    return;
+}
+
+static void
+set_icon_current (xfceweather_data *data)
+{
+    guint      i;
+    GdkPixbuf *icon = NULL;
+
+    for (i = 0; i < data->labels->len; i++)
+    {
+        datas opt;
+        gchar *str;
+
+        opt = g_array_index(data->labels, datas, i);
+
+        str = make_label (data->weatherdata, opt, data->unit,
+                data->size);
+
+        gtk_scrollbox_set_label (GTK_SCROLLBOX(data->scrollbox), -1,
+                str);
+
+        g_free (str);
+    }
+
+    gtk_scrollbox_enablecb(GTK_SCROLLBOX(data->scrollbox), TRUE);
+
+    icon = get_icon (get_data(data->weatherdata, WICON), data->iconsize);
+    gtk_image_set_from_pixbuf (GTK_IMAGE(data->iconimage), icon);
+    g_object_unref (G_OBJECT (icon));
+
+    gtk_tooltips_set_tip (data->tooltips, data->tooltipbox,
+        translate_desc(get_data(data->weatherdata, TRANS)), NULL);
+}
+
+static void
+cb_update (gboolean status,
+           gpointer user_data)
+{
+
+
+    xfceweather_data *data = (xfceweather_data *)user_data;
+    gchar            *fullfilename = get_filename (data);
+    xmlDoc           *doc;
+    xmlNode          *cur_node;
+    xml_weather      *weather = NULL;
+
+    if (!fullfilename)
+        return;
+
+    doc = xmlParseFile (fullfilename);
+    g_free (fullfilename);
+
+    if (!doc)
+        return;
+
+    cur_node = xmlDocGetRootElement (doc);
+
+    if (cur_node)
+        weather = parse_weather (cur_node);
+
+    xmlFreeDoc (doc);
+
+    gtk_scrollbox_clear (GTK_SCROLLBOX(data->scrollbox));
+
+    if (weather)
+    {
+
+        if (data->weatherdata)
+            xml_weather_free (data->weatherdata);
+
+        data->weatherdata = weather;
+        set_icon_current (data);
+    }
+    else
+    {
+        set_icon_error (data);
+        return;
+    }
+}
+
+/* -1 error 0 no update needed 1 updating */
+static gint
+update_weatherdata (xfceweather_data *data,
+                    gboolean          force)
+{
+
+    struct stat attrs;
+    gchar *fullfilename;
+    gchar *url;
+
+    if (!data->location_code)
+        return -1;
+
+    fullfilename = get_filename (data);
+
+    if (!fullfilename)
+    {
+        DBG ("can't get savedir?");
+        return -1;
+    }
+
+    if (force || (stat (fullfilename, &attrs) == -1) ||
+            ((time (NULL) - attrs.st_mtime) > (UPDATE_TIME)))
+    {
+        url = g_strdup_printf ("/weather/local/%s?cc=*&dayf=%d&unit=%c",
+                data->location_code, XML_WEATHER_DAYF_N,
+                data->unit == METRIC ? 'm' : 'i');
+
+        gboolean status = http_get_file (url, "xoap.weather.com", fullfilename,
+                data->proxy_host, data->proxy_port, cb_update,
+                (gpointer) data);
+
+        g_free (url);
+        g_free (fullfilename);
+
+        return status ? 1 : -1;
+    }
+    else if (data->weatherdata)
+    {
+	return 0;
+    }
+    else
+    {
+        cb_update (TRUE, data);
+        return 1;
+    }
+}
+
+static void
+update_plugin (xfceweather_data *data,
+               gboolean          force)
+{
+
+    if (update_weatherdata(data, force) == -1)
+    {
+        gtk_scrollbox_clear (GTK_SCROLLBOX(data->scrollbox));
+        set_icon_error (data);
+    }
+    /* else update will be called through the callback in http_get_file () */
+}
+
+static GArray *
+labels_clear (GArray *array)
+{
+
+    if (!array || array->len > 0)
+    {
+        if (array)
+            g_array_free (array, TRUE);
+
+        array = g_array_new (FALSE, TRUE, sizeof (datas));
+    }
+
+    return array;
+}
+
+static void
+xfceweather_read_config (XfcePanelPlugin  *plugin,
+                         xfceweather_data *data)
+{
+
+    gchar label[10];
+    guint i;
+    const gchar *value;
+    gchar *file;
+    XfceRc *rc;
+    gint val;
+
+    if (!(file = xfce_panel_plugin_lookup_rc_file (plugin)))
+        return;
+
+    rc = xfce_rc_simple_open (file, TRUE);
+    g_free (file);
+
+    if (!rc)
+        return;
+
+    value = xfce_rc_read_entry (rc, "loc_code", NULL);
+
+    if (value)
+    {
+        if (data->location_code)
+            g_free (data->location_code);
+
+        data->location_code = g_strdup (value);
+    }
+
+    if (xfce_rc_read_bool_entry (rc, "celcius", TRUE))
+        data->unit = METRIC;
+    else
+        data->unit = IMPERIAL;
+
+    if (data->proxy_host)
+    {
+        g_free (data->proxy_host);
+        data->proxy_host = NULL;
+    }
+
+    if (data->saved_proxy_host)
+    {
+        g_free (data->saved_proxy_host);
+        data->saved_proxy_host = NULL;
+    }
+
+    value = xfce_rc_read_entry (rc, "proxy_host", NULL);
+
+    if (value && *value)
+    {
+        data->saved_proxy_host = g_strdup (value);
+    }
+
+    data->saved_proxy_port = xfce_rc_read_int_entry (rc, "proxy_port", 0);
+
+    data->proxy_fromenv = xfce_rc_read_bool_entry (rc, "proxy_fromenv", FALSE);
+
+    if (data->proxy_fromenv)
+    {
+        check_envproxy (&data->proxy_host, &data->proxy_port);
+    }
+    else
+    {
+        data->proxy_host = g_strdup (data->saved_proxy_host);
+        data->proxy_port = data->saved_proxy_port;
+    }
+
+    data->labels = labels_clear (data->labels);
+
+    for (i = 0; i < 100 /* arbitrary */; ++i)
+    {
+        g_snprintf (label, 10, "label%d", i);
+
+        val = xfce_rc_read_int_entry (rc, label, -1);
+
+        if (val >= 0)
+            g_array_append_val (data->labels, val);
+        else
+            break;
+    }
+
+    xfce_rc_close (rc);
+}
+
+static void
+xfceweather_write_config (XfcePanelPlugin  *plugin,
+                          xfceweather_data *data)
+{
+
+    gchar   label[10];
+    guint   i;
+    XfceRc *rc;
+    gchar  *file;
+
+    if (!(file = xfce_panel_plugin_save_location (plugin, TRUE)))
+        return;
+
+    /* get rid of old values */
+    unlink (file);
+
+    rc = xfce_rc_simple_open (file, FALSE);
+    g_free (file);
+
+    if (!rc)
+        return;
+
+    xfce_rc_write_bool_entry (rc, "celcius", (data->unit == METRIC));
+
+    if (data->location_code)
+        xfce_rc_write_entry (rc, "loc_code", data->location_code);
+
+    xfce_rc_write_bool_entry (rc, "proxy_fromenv", data->proxy_fromenv);
+
+    if (data->proxy_host)
+    {
+        xfce_rc_write_entry (rc, "proxy_host", data->proxy_host);
+
+        xfce_rc_write_int_entry (rc, "proxy_port", data->proxy_port);
+    }
+
+    for (i = 0; i < data->labels->len; i++)
+    {
+        g_snprintf (label, 10, "label%d", i);
+
+        xfce_rc_write_int_entry (rc, label, (gint)g_array_index (data->labels, datas, i));
+    }
+
+    xfce_rc_close (rc);
+}
+
+static gboolean
+update_cb (xfceweather_data *data)
+{
+
+    DBG ("update_cb(): callback called");
+
+    update_plugin (data, FALSE);
+
+    DBG ("update_cb(): request added, returning");
+
+    return TRUE;
+}
+
+static void
+update_plugin_with_reset (xfceweather_data *data,
+                          gboolean          force)
+{
+
+    if (data->updatetimeout)
+        g_source_remove (data->updatetimeout);
+
+    update_plugin (data, force);
+
+    data->updatetimeout = gtk_timeout_add (UPDATE_TIME * 1000, (GSourceFunc)update_cb, data);
+}
+
+
+static void
+update_config (xfceweather_data *data)
+{
+
+    update_plugin_with_reset (data, TRUE); /* force because units could have changed */
+}
+
+static void
+close_summary (GtkWidget *widget,
+               gpointer  *user_data)
+{
+
+    xfceweather_data *data = (xfceweather_data *) user_data;
+
+    data->summary_window = NULL;
+}
+
+static gboolean
+cb_click (GtkWidget      *widget,
+          GdkEventButton *event,
+          gpointer        user_data)
+{
+
+    xfceweather_data *data = (xfceweather_data *) user_data;
+
+    if (event->button == 1)
+    {
+
+        if (data->summary_window != NULL)
+        {
+
+            gtk_window_present (GTK_WINDOW(data->summary_window));
+        }
+        else
+        {
+            data->summary_window = create_summary_window (data->weatherdata,
+                    data->unit);
+            g_signal_connect (data->summary_window, "destroy",
+                    G_CALLBACK (close_summary), (gpointer)data);
+
+            gtk_widget_show_all (data->summary_window);
+        }
+    }
+    else if (event->button == 2)
+        update_plugin_with_reset (data, TRUE);
+
+    return FALSE;
+}
+
+static void
+mi_click (GtkWidget *widget,
+          gpointer   user_data)
+{
+    xfceweather_data *data = (xfceweather_data *) user_data;
+
+    update_plugin_with_reset (data, TRUE);
+}
+
+static void
+xfceweather_dialog_response (GtkWidget          *dlg,
+                             gint                response,
+                             xfceweather_dialog *dialog)
+{
+
+    xfceweather_data *data = (xfceweather_data *) dialog->wd;
+
+    apply_options (dialog);
+
+    gtk_widget_destroy (dlg);
+    gtk_list_store_clear (dialog->mdl_xmloption);
+    panel_slice_free (xfceweather_dialog, dialog);
+
+    xfce_panel_plugin_unblock_menu (data->plugin);
+    xfceweather_write_config (data->plugin, data);
+}
+
+static void
+xfceweather_create_options (XfcePanelPlugin  *plugin,
+                            xfceweather_data *data)
+{
+
+    GtkWidget          *dlg, *vbox;
+    xfceweather_dialog *dialog;
+
+    xfce_panel_plugin_block_menu (plugin);
+
+    dlg = xfce_titled_dialog_new_with_buttons (_("Weather Update"),
+                          GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
+                          GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
+                          GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
+                          NULL);
+
+    gtk_container_set_border_width (GTK_CONTAINER (dlg), 2);
+    gtk_window_set_icon_name  (GTK_WINDOW (dlg), "xfce4-settings");
+
+    vbox = gtk_vbox_new (FALSE, BORDER);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER - 2);
+    gtk_widget_show (vbox);
+    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), vbox,
+                TRUE, TRUE, 0);
+
+    dialog = create_config_dialog (data, vbox);
+
+    g_signal_connect (dlg, "response", G_CALLBACK (xfceweather_dialog_response),
+              dialog);
+
+    set_callback_config_dialog (dialog, update_config);
+
+    gtk_widget_show (dlg);
+}
+
+
+static xfceweather_data *
+xfceweather_create_control (XfcePanelPlugin *plugin)
+{
+
+    xfceweather_data *data = panel_slice_new0 (xfceweather_data);
+    GtkWidget    *vbox, *refresh;
+    datas         lbl;
+    GdkPixbuf    *icon = NULL;
+
+    if (!GTK_ICON_SIZE_SMALL)
+        GTK_ICON_SIZE_SMALL = gtk_icon_size_register ("iconsize_small", 16, 16);
+
+    data->plugin = plugin;
+
+    data->tooltips = gtk_tooltips_new ();
+    g_object_ref (data->tooltips);
+    gtk_object_sink (GTK_OBJECT (data->tooltips));
+
+    data->scrollbox = gtk_scrollbox_new ();
+
+    icon = get_icon ("25", GTK_ICON_SIZE_SMALL);
+    data->iconimage = gtk_image_new_from_pixbuf (icon);
+    gtk_misc_set_alignment (GTK_MISC(data->iconimage), 0.5, 1);
+    g_object_unref (G_OBJECT (icon));
+
+    data->labels = g_array_new (FALSE, TRUE, sizeof (datas));
+
+    vbox = gtk_vbox_new (FALSE, 0);
+
+    gtk_box_pack_start (GTK_BOX(vbox), data->iconimage, TRUE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX(vbox), data->scrollbox, TRUE, TRUE, 0);
+
+    data->tooltipbox = gtk_event_box_new ();
+    gtk_container_add (GTK_CONTAINER(data->tooltipbox), vbox);
+    gtk_widget_show_all (data->tooltipbox);
+
+    xfce_panel_plugin_add_action_widget (plugin, data->tooltipbox);
+
+    g_signal_connect (data->tooltipbox, "button-press-event",
+            G_CALLBACK (cb_click), (gpointer)data);
+
+    /* add refresh button to right click menu, for people who missed the middle mouse click feature */
+    refresh = gtk_image_menu_item_new_from_stock ("gtk-refresh", NULL);
+    gtk_widget_show (refresh);
+
+    g_signal_connect (refresh, "activate",
+            G_CALLBACK (mi_click), (gpointer) data);
+
+    xfce_panel_plugin_menu_insert_item (plugin, GTK_MENU_ITEM (refresh));
+
+    /* assign to tempval because g_array_append_val () is using & operator */
+    lbl = TEMP;
+    g_array_append_val (data->labels, lbl);
+    lbl = WIND_DIRECTION;
+    g_array_append_val (data->labels, lbl);
+    lbl = WIND_SPEED;
+    g_array_append_val (data->labels, lbl);
+
+    /* FIXME Without this the first label looks odd, because
+     * the gc isn't created yet */
+    gtk_scrollbox_set_label (GTK_SCROLLBOX(data->scrollbox), -1, "1");
+    gtk_scrollbox_clear (GTK_SCROLLBOX(data->scrollbox));
+
+    data->updatetimeout =
+        gtk_timeout_add (UPDATE_TIME * 1000, (GSourceFunc)update_cb, data);
+
+    return data;
+}
+
+static void
+xfceweather_free (XfcePanelPlugin  *plugin,
+                  xfceweather_data *data)
+{
+
+    if (data->weatherdata)
+        xml_weather_free (data->weatherdata);
+
+    if (data->updatetimeout)
+    {
+        g_source_remove (data->updatetimeout);
+        data->updatetimeout = 0;
+    }
+
+    free_get_data_buffer ();
+    xmlCleanupParser ();
+
+    /* Free Tooltip */
+    gtk_tooltips_set_tip (data->tooltips, data->tooltipbox, NULL, NULL);
+    g_object_unref (G_OBJECT (data->tooltips));
+
+    /* Free chars */
+    g_free (data->location_code);
+    g_free (data->proxy_host);
+
+    /* Free Array */
+    g_array_free (data->labels, TRUE);
+
+    panel_slice_free (xfceweather_data, data);
+}
+
+static gboolean
+xfceweather_set_size (XfcePanelPlugin  *panel,
+                     int               size,
+                     xfceweather_data *data)
+{
+
+    data->size = size;
+
+    /* arbitrary, choose something that works */
+    if (size <= 30)
+        data->iconsize = GTK_ICON_SIZE_SMALL;
+    else if (size <= 36)
+        data->iconsize = GTK_ICON_SIZE_BUTTON;
+    else if (size <= 48)
+        data->iconsize = GTK_ICON_SIZE_LARGE_TOOLBAR;
+    else
+        data->iconsize = GTK_ICON_SIZE_DND;
+
+    gtk_scrollbox_clear (GTK_SCROLLBOX(data->scrollbox));
+
+    if (data->weatherdata)
+        set_icon_current (data);
+    else
+	set_icon_error (data);
+
+    return TRUE;
+}
+
+static void
+weather_construct (XfcePanelPlugin *plugin)
+{
+    xfceweather_data *data;
+
+    xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+
+    data = xfceweather_create_control (plugin);
+
+    xfceweather_read_config (plugin, data);
+
+    xfceweather_set_size (plugin, xfce_panel_plugin_get_size (plugin),
+                  data);
+
+    gtk_container_add (GTK_CONTAINER (plugin), data->tooltipbox);
+
+    g_signal_connect (plugin, "free-data", G_CALLBACK (xfceweather_free),
+              data);
+
+    g_signal_connect (plugin, "save",
+              G_CALLBACK (xfceweather_write_config), data);
+
+    g_signal_connect (plugin, "size-changed",
+              G_CALLBACK (xfceweather_set_size), data);
+
+    xfce_panel_plugin_menu_show_configure (plugin);
+    g_signal_connect (plugin, "configure-plugin",
+              G_CALLBACK (xfceweather_create_options), data);
+
+    update_plugin (data, TRUE);
+}
+
+XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (weather_construct);

Copied: xfce4-weather-plugin/trunk/panel-plugin/weather.h (from rev 2235, xfce4-weather-plugin/trunk/panel-plugin/plugin.h)
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather.h	                        (rev 0)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather.h	2006-12-16 13:02:07 UTC (rev 2236)
@@ -0,0 +1,67 @@
+/*  $Id$
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PLUGIN_H
+#define PLUGIN_H
+
+#include <libxfce4panel/xfce-panel-plugin.h>
+#include <libxfce4util/libxfce4util.h>
+
+G_BEGIN_DECLS
+
+typedef struct
+{
+        XfcePanelPlugin *plugin;
+
+	GtkTooltips     *tooltips;
+
+        GtkWidget       *scrollbox;
+        GtkWidget       *iconimage;
+        GtkWidget       *tooltipbox;
+
+        GtkWidget       *summary_window;
+
+        GArray          *labels;
+
+        GtkIconSize      iconsize;
+
+        gint             size;
+        gint             updatetimeout;
+
+        gchar           *location_code;
+
+        units            unit;
+
+        xml_weather     *weatherdata;
+
+        gchar           *proxy_host;
+        gint             proxy_port;
+
+        gboolean         proxy_fromenv;
+        /* used for storing the configured
+         * but not active proxy setttings */
+        gchar           *saved_proxy_host;
+        gint             saved_proxy_port;
+}
+xfceweather_data;
+
+gboolean
+check_envproxy (gchar **proxy_host, gint *proxy_port);
+
+G_END_DECLS
+
+#endif




More information about the Goodies-commits mailing list