[Goodies-commits] r2237 - xfce4-weather-plugin/trunk/panel-plugin
Nick Schermer
nick at xfce.org
Sat Dec 16 14:20:22 CET 2006
Author: nick
Date: 2006-12-16 13:20:22 +0000 (Sat, 16 Dec 2006)
New Revision: 2237
Modified:
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
Log:
Change code layout, to be continued
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-config.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-config.c 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-config.c 2006-12-16 13:20:22 UTC (rev 2237)
@@ -33,218 +33,247 @@
#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},
+ {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 *);
+typedef void (*cb_function) (xfceweather_data *);
static cb_function cb = NULL;
static void
add_mdl_option (GtkListStore *mdl,
- int opt)
+ gint opt)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
- gtk_list_store_append (mdl, &iter);
- gtk_list_store_set (mdl, &iter,
- 0, _(labeloptions[opt].name),
- 1, labeloptions[opt].number,
- -1);
+ 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));
+ xfceweather_dialog *dialog;
+ gint history;
- add_mdl_option (dialog->mdl_xmloption, history);
+ dialog = (xfceweather_dialog *) data;
+ history = gtk_option_menu_get_history (GTK_OPTION_MENU (dialog->opt_xmloption));
- return FALSE;
+ 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));
+ xfceweather_dialog *dialog = (xfceweather_dialog *) data;
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
- if (gtk_tree_selection_get_selected (selection, NULL, &iter))
- gtk_list_store_remove (GTK_LIST_STORE (dialog->mdl_xmloption), &iter);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->lst_xmloption));
- return FALSE;
+ 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;
+ GtkWidget *target = (GtkWidget *) data;
- gtk_widget_set_sensitive (target,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
+ gtk_widget_set_sensitive (target,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (widget)));
- return FALSE;
+ return FALSE;
}
+
+
static gboolean
cb_not_toggle (GtkWidget *widget,
gpointer data)
{
- GtkWidget *target = (GtkWidget *)data;
+ GtkWidget *target = (GtkWidget *) data;
- gtk_widget_set_sensitive (target,
- !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
+ gtk_widget_set_sensitive (target,
+ !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+ (widget)));
- return FALSE;
+ return FALSE;
}
-static
-GtkWidget *make_label (void)
+
+
+static GtkWidget *
+make_label (void)
{
- guint i;
- GtkWidget *widget, *menu;
+ guint i;
+ GtkWidget *widget, *menu;
- menu = gtk_menu_new ();
- widget = gtk_option_menu_new ();
+ menu = gtk_menu_new ();
+ widget = gtk_option_menu_new ();
- for (i = 0; i < 11; i++)
+ for (i = 0; i < 11; i++)
{
- labeloption opt = labeloptions[i];
+ labeloption opt = labeloptions[i];
- gtk_menu_shell_append (GTK_MENU_SHELL (menu),
- gtk_menu_item_new_with_label (_(opt.name)));
+ 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);
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);
- return widget;
+ return widget;
}
+
+
void
apply_options (xfceweather_dialog *dialog)
{
- gint history = 0;
- gboolean hasiter = FALSE;
- GtkTreeIter iter;
- gchar *text;
+ gint history = 0;
+ gboolean hasiter = FALSE;
+ GtkTreeIter iter;
+ gchar *text;
+ gint option;
+ GValue value = { 0, };
- xfceweather_data *data = (xfceweather_data *) dialog->wd;
+ xfceweather_data *data = (xfceweather_data *) dialog->wd;
- history = gtk_option_menu_get_history (GTK_OPTION_MENU (dialog->opt_unit));
+ history = gtk_option_menu_get_history (GTK_OPTION_MENU (dialog->opt_unit));
- if (history == 0)
- data->unit = IMPERIAL;
- else
- data->unit = METRIC;
+ if (history == 0)
+ data->unit = IMPERIAL;
+ else
+ data->unit = METRIC;
- if (data->location_code)
- g_free (data->location_code);
+ if (data->location_code)
+ g_free (data->location_code);
- data->location_code = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->txt_loc_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);
+ /* 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));
+ 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))
+ 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);
+ 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)
+ if (data->proxy_host)
{
- g_free (data->proxy_host);
- data->proxy_host = NULL;
+ 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)))
+ 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);
+ data->proxy_fromenv = TRUE;
+ check_envproxy (&data->proxy_host, &data->proxy_port);
}
- else /* use provided proxy settings */
+ else /* use provided proxy settings */
{
- data->proxy_fromenv = FALSE;
- text = g_strdup (gtk_entry_get_text (GTK_ENTRY(dialog->txt_proxy_host)));
+ data->proxy_fromenv = FALSE;
+ text =
+ g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->txt_proxy_host)));
- if (strlen (text) == 0)
+ if (strlen (text) == 0)
{
- xfce_err(_("Please enter proxy settings"));
- gtk_widget_grab_focus (dialog->txt_proxy_host);
- return;
+ 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));
+ 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);
+ 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;
+ data->saved_proxy_host = g_strdup (text);
+ data->saved_proxy_port = data->proxy_port;
- g_free (text);
+ g_free (text);
}
- if (cb)
- cb(data);
+ if (cb)
+ cb (data);
}
static int
option_i (datas opt)
{
- guint i;
+ guint i;
- for (i = 0; i < OPTIONS_N; i++)
+ for (i = 0; i < OPTIONS_N; i++)
{
- if (labeloptions[i].number == opt)
- return i;
+ if (labeloptions[i].number == opt)
+ return i;
}
- return -1;
+ 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);
+ xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
+ search_dialog *sdialog;
- if (run_search_dialog(sdialog))
- gtk_entry_set_text (GTK_ENTRY(dialog->txt_loc_code), sdialog->result);
+ sdialog = create_search_dialog (NULL,
+ dialog->wd->proxy_host,
+ dialog->wd->proxy_port);
- free_search_dialog(sdialog);
+ if (run_search_dialog (sdialog))
+ gtk_entry_set_text (GTK_ENTRY (dialog->txt_loc_code), sdialog->result);
- return FALSE;
+ free_search_dialog (sdialog);
+
+ return FALSE;
}
@@ -252,191 +281,202 @@
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;
+ xfceweather_dialog *dialog;
+ GtkWidget *vbox2, *vbox3, *hbox, *hbox2, *label,
+ *menu, *button_add, *button_del, *image, *button, *scroll;
+ GtkSizeGroup *sg, *sg_buttons;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ datas opt;
+ guint i;
+ gint n;
- dialog = panel_slice_new0 (xfceweather_dialog);
+ sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ sg_buttons = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- dialog->wd = (xfceweather_data *)data;
- dialog->dialog = gtk_widget_get_toplevel (vbox);
+ dialog = panel_slice_new0 (xfceweather_dialog);
- 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 ();
+ dialog->wd = (xfceweather_data *) data;
+ dialog->dialog = gtk_widget_get_toplevel (vbox);
- 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);
+ 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 ();
- 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);
+ 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);
- 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);
+ 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);
+ label = gtk_label_new (_("Location code:"));
+ dialog->txt_loc_code = gtk_entry_new ();
- 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);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- 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);
+ 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);
- 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);
+ 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);
- /* 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);
+ 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);
- gtk_misc_set_alignment (GTK_MISC(label), 0, 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_size_group_add_widget (sg, label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
- 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);
+ gtk_size_group_add_widget (sg, label);
- 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);
+ 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);
+ 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);
- 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);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
- 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);
+ 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);
- if (dialog->wd->saved_proxy_host != NULL)
+ 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_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);
+ 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)
+ if (dialog->wd->proxy_host || dialog->wd->proxy_fromenv)
{
- 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),
+ TRUE);
- if (dialog->wd->proxy_fromenv)
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (dialog->chk_proxy_fromenv), TRUE);
+ if (dialog->wd->proxy_fromenv)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+ (dialog->chk_proxy_fromenv), TRUE);
}
- else
+ 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);
+ 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 */
+ /* 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));
+ 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);
+ 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_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);
+ 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);
+ 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)
+ if (data->labels->len > 0)
{
- datas opt;
- guint i;
- gint n;
-
- for (i = 0; i < data->labels->len; i++)
+ for (i = 0; i < data->labels->len; i++)
{
- opt = g_array_index (data->labels, datas, i);
+ opt = g_array_index (data->labels, datas, i);
- if ((n = option_i(opt)) != -1)
- add_mdl_option (dialog->mdl_xmloption, n);
+ 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);
+ g_object_unref (G_OBJECT (sg));
+ g_object_unref (G_OBJECT (sg_buttons));
- gtk_widget_show_all (vbox);
+ g_signal_connect (button_add, "clicked", G_CALLBACK (cb_addoption), dialog);
+ g_signal_connect (button_del, "clicked", G_CALLBACK (cb_deloption), dialog);
- return dialog;
+ gtk_widget_show_all (vbox);
+
+ return dialog;
}
void
set_callback_config_dialog (xfceweather_dialog *dialog,
cb_function cb_new)
{
- cb = cb_new;
+ cb = cb_new;
}
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-config.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-config.h 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-config.h 2006-12-16 13:20:22 UTC (rev 2237)
@@ -18,43 +18,42 @@
#ifndef CONFIG_DIALOG_H
#define CONFIG_DIALOG_H
-G_BEGIN_DECLS
-
-typedef struct {
- gchar *name;
- datas number;
+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;
+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 *tooltip_yes;
+ GtkWidget *tooltip_no;
- GtkWidget *opt_xmloption;
- GtkWidget *lst_xmloption;
- GtkListStore *mdl_xmloption;
+ GtkWidget *opt_xmloption;
+ GtkWidget *lst_xmloption;
+ GtkListStore *mdl_xmloption;
- xfceweather_data *wd;
+ xfceweather_data *wd;
}
xfceweather_dialog;
-xfceweather_dialog *
-create_config_dialog (xfceweather_data *data, GtkWidget *vbox);
+xfceweather_dialog *create_config_dialog (xfceweather_data * data,
+ GtkWidget * vbox);
void
-set_callback_config_dialog (xfceweather_dialog *dialog, void(cb)(xfceweather_data *));
+set_callback_config_dialog (xfceweather_dialog * dialog,
+ void (cb) (xfceweather_data *));
-void
-apply_options (xfceweather_dialog *dialog);
+void apply_options (xfceweather_dialog * dialog);
G_END_DECLS
-
#endif
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-data.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-data.c 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-data.c 2006-12-16 13:20:22 UTC (rev 2237)
@@ -32,43 +32,43 @@
#define EMPTY_STRING g_strdup("-")
#define CHK_NULL(str) str ? g_strdup(str) : EMPTY_STRING;
-gchar *kill_ring[KILL_RING_S] = {NULL, };
+gchar *kill_ring[KILL_RING_S] = { NULL, };
#define debug_print printf
static gchar *
copy_buffer (gchar *str)
{
- static gint p = 0;
- gchar *s;
+ static gint p = 0;
+ gchar *s;
- if (!str)
+ if (!str)
{
- DBG ("copy_buffer: received NULL pointer");
- return EMPTY_STRING;
+ DBG ("copy_buffer: received NULL pointer");
+ return EMPTY_STRING;
}
- if (p >= KILL_RING_S)
- p = 0;
+ if (p >= KILL_RING_S)
+ p = 0;
- if (kill_ring[p])
- g_free(kill_ring[p]);
+ if (kill_ring[p])
+ g_free (kill_ring[p]);
- s = g_strdup(str);
+ s = g_strdup (str);
- kill_ring[p++] = s;
+ kill_ring[p++] = s;
- return s;
+ return s;
}
void
free_get_data_buffer (void)
{
- guint i;
+ guint i;
- for (i = 0; i < KILL_RING_S; i++)
+ for (i = 0; i < KILL_RING_S; i++)
{
- if (kill_ring[i])
- g_free(kill_ring[i]);
+ if (kill_ring[i])
+ g_free (kill_ring[i]);
}
}
@@ -76,21 +76,25 @@
get_data_uv (xml_uv *data,
datas_uv type)
{
- gchar *str = NULL;
+ gchar *str = NULL;
- if (!data)
+ if (!data)
{
- DBG ("get_data_bar: xml-uv not present");
- return EMPTY_STRING;
+ DBG ("get_data_bar: xml-uv not present");
+ return EMPTY_STRING;
}
- switch(type)
+ switch (type)
{
- case _UV_INDEX: str = data->i; break;
- case _UV_TRANS: str = data->t; break;
+ case _UV_INDEX:
+ str = data->i;
+ break;
+ case _UV_TRANS:
+ str = data->t;
+ break;
}
- return CHK_NULL(str);
+ return CHK_NULL (str);
}
@@ -98,50 +102,62 @@
get_data_bar (xml_bar *data,
datas_bar type)
{
- gchar *str = NULL;
+ gchar *str = NULL;
- if (!data)
+ if (!data)
{
- DBG ("get_data_bar: xml-wind not present");
- return EMPTY_STRING;
+ DBG ("get_data_bar: xml-wind not present");
+ return EMPTY_STRING;
}
- switch(type)
+ switch (type)
{
- case _BAR_R: str = data->r; break;
- case _BAR_D: str = data->d; break;
+ case _BAR_R:
+ str = data->r;
+ break;
+ case _BAR_D:
+ str = data->d;
+ break;
}
- return CHK_NULL(str);
+ return CHK_NULL (str);
}
static gchar *
get_data_wind (xml_wind *data,
- datas_wind type)
+ datas_wind type)
{
- gchar *str = NULL;
+ gchar *str = NULL;
- if (!data)
+ if (!data)
{
- DBG ("get_data_wind: xml-wind not present");
- return EMPTY_STRING;
+ DBG ("get_data_wind: xml-wind not present");
+ return EMPTY_STRING;
}
- DBG ("starting");
+ DBG ("starting");
- switch(type)
+ 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;
+ 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 ("print %p", data->d);
- DBG ("%s", str);
+ DBG ("%s", str);
- return CHK_NULL(str);
+ return CHK_NULL (str);
}
/* -- This is not the same as the previous functions */
@@ -149,175 +165,229 @@
get_data_cc (xml_cc *data,
datas type)
{
- gchar *str = NULL;
+ gchar *str = NULL;
- if (!data)
+ if (!data)
{
- DBG ("get_data_cc: xml-cc not present");
- return EMPTY_STRING;
+ DBG ("get_data_cc: xml-cc not present");
+ return EMPTY_STRING;
}
- switch(type)
+ 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;
+ 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);
+ return CHK_NULL (str);
}
static gchar *
get_data_loc (xml_loc *data,
datas_loc type)
{
- gchar *str = NULL;
+ gchar *str = NULL;
- if (!data)
+ if (!data)
{
- DBG ("get_data_loc: xml-loc not present");
- return EMPTY_STRING;
+ DBG ("get_data_loc: xml-loc not present");
+ return EMPTY_STRING;
}
- switch(type)
+ switch (type)
{
- case DNAM: str = data->dnam; break;
- case SUNR: str = data->sunr; break;
- case SUNS: str = data->suns; break;
+ case DNAM:
+ str = data->dnam;
+ break;
+ case SUNR:
+ str = data->sunr;
+ break;
+ case SUNS:
+ str = data->suns;
+ break;
}
- return CHK_NULL(str);
+ return CHK_NULL (str);
}
const gchar *
get_data (xml_weather *data,
- datas type)
+ datas type)
{
- gchar *str = NULL;
- gchar *p;
+ gchar *str = NULL;
+ gchar *p;
- if (!data)
- str = EMPTY_STRING;
- else
+ if (!data)
+ str = EMPTY_STRING;
+ else
{
- switch (type & 0xFF00)
+ 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;
+ 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);
+ p = copy_buffer (str);
+ g_free (str);
- return p;
+ return p;
}
static gchar *
get_data_part (xml_part *data,
forecast type)
{
- gchar *str = NULL;
+ gchar *str = NULL;
- DBG ("now here %s", data->ppcp);
+ DBG ("now here %s", data->ppcp);
- if (!data)
- return EMPTY_STRING;
+ if (!data)
+ return EMPTY_STRING;
- switch (type & 0x000F)
+ 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;
+ 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;
+ return str;
}
const gchar *
get_data_f (xml_dayf *data,
forecast type)
{
- gchar *p, *str = NULL;
+ gchar *p, *str = NULL;
- if (data)
+ if (data)
{
- switch (type & 0x0F00)
+ 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;
+ 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 = "-";
+ if (!str)
+ str = "-";
- p = copy_buffer(str);
- DBG ("value: %s", p);
+ p = copy_buffer (str);
+ DBG ("value: %s", p);
- return p;
+ return p;
}
const gchar *
get_unit (units unit,
datas type)
{
- gchar *str;
+ gchar *str;
- switch (type & 0x00F0)
+ 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 = "";
+ 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);
+ return copy_buffer (str);
}
-
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-data.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-data.h 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-data.h 2006-12-16 13:20:22 UTC (rev 2237)
@@ -18,109 +18,109 @@
#ifndef GET_DATA_H
#define GET_DATA_H
-G_BEGIN_DECLS
-
-typedef enum {
- _WIND_SPEED,
- _WIND_GUST,
- _WIND_DIRECTION,
- _WIND_TRANS
+G_BEGIN_DECLS typedef enum
+{
+ _WIND_SPEED,
+ _WIND_GUST,
+ _WIND_DIRECTION,
+ _WIND_TRANS
}
datas_wind;
-typedef enum {
- _BAR_R,
- _BAR_D
+typedef enum
+{
+ _BAR_R,
+ _BAR_D
}
datas_bar;
-typedef enum {
- _UV_INDEX,
- _UV_TRANS
+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,
+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,
+ FLIK = 0x0120,
+ TEMP = 0x0121,
+ DEWP = 0x0122,
- HMID = 0x0130,
+ HMID = 0x0130,
- WIND_SPEED = 0x0140,
- WIND_GUST = 0x0141,
+ WIND_SPEED = 0x0140,
+ WIND_GUST = 0x0141,
- BAR_R = 0x0150,
+ BAR_R = 0x0150,
- VIS = 0x0160
+ VIS = 0x0160
}
datas;
-typedef enum {
- DNAM = 0x0201,
- SUNR = 0x0202,
- SUNS = 0x0203
+typedef enum
+{
+ DNAM = 0x0201,
+ SUNR = 0x0202,
+ SUNS = 0x0203
}
datas_loc;
-typedef enum {
- ITEMS = 0x0100,
- WDAY = 0x0101,
- TEMP_MIN = 0x0102,
- TEMP_MAX = 0x0103,
+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,
+ 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,
+ 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
+ DPART = 0x0300,
+ ICON_D = 0x0301,
+ PPCP_D = 0x0302,
+ W_DIRECTION_D = 0x0303,
+ W_SPEED_D = 0x0304,
+ TRANS_D = 0x0305
}
forecast;
-typedef enum {
- METRIC,
- IMPERIAL
+typedef enum
+{
+ METRIC,
+ IMPERIAL
}
units;
-const gchar *
-get_data (xml_weather *data, datas type);
+const gchar *get_data (xml_weather * data, datas type);
-const gchar *
-get_data_f (xml_dayf * , forecast type);
+const gchar *get_data_f (xml_dayf *, forecast type);
-const gchar *
-get_unit (units unit, datas type);
+const gchar *get_unit (units unit, datas type);
-void
-free_get_data_buffer (void);
+void free_get_data_buffer (void);
G_END_DECLS
-
#endif
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-http.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-http.c 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-http.c 2006-12-16 13:20:22 UTC (rev 2237)
@@ -37,314 +37,303 @@
struct request_data
{
- int fd;
+ int fd;
- FILE *save_fp;
- gchar *save_filename;
- gchar **save_buffer;
+ FILE *save_fp;
+ gchar *save_filename;
+ gchar **save_buffer;
- gboolean has_header;
- gchar last_chars[4];
+ gboolean has_header;
+ gchar last_chars[4];
- gchar *request_buffer;
- gint offset;
- gint size;
+ gchar *request_buffer;
+ gint offset;
+ gint size;
- CB_TYPE cb_function;
- gpointer cb_data;
+ CB_TYPE cb_function;
+ gpointer cb_data;
};
-static gboolean
-keep_receiving (gpointer data);
+static gboolean keep_receiving (gpointer data);
static int
-http_connect (gchar *hostname,
- gint port)
+http_connect (gchar * hostname, gint port)
{
- struct sockaddr_in dest_host;
- struct hostent *host_address;
- gint fd;
+ struct sockaddr_in dest_host;
+ struct hostent *host_address;
+ gint fd;
- if ((host_address = gethostbyname(hostname)) == NULL)
- return -1;
+ if ((host_address = gethostbyname (hostname)) == NULL)
+ return -1;
- if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
- 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);
+ 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)
+ if ((connect (fd, (struct sockaddr *) &dest_host, sizeof (struct sockaddr))
+ == -1) && errno != EINPROGRESS)
{
- perror("http_connect()");
- return -1;
+ perror ("http_connect()");
+ return -1;
}
- else
- return fd;
+ else
+ return fd;
}
static void
request_free (struct request_data *request)
{
- if (request->request_buffer)
- g_free(request->request_buffer);
+ if (request->request_buffer)
+ g_free (request->request_buffer);
- if (request->save_filename)
- g_free(request->save_filename);
+ if (request->save_filename)
+ g_free (request->save_filename);
- if (request->save_fp)
- fclose(request->save_fp);
+ if (request->save_fp)
+ fclose (request->save_fp);
- if (request->fd)
- close(request->fd);
+ if (request->fd)
+ close (request->fd);
- panel_slice_free (struct request_data, request);
+ panel_slice_free (struct request_data, request);
}
static void
-request_save (struct request_data *request,
- const gchar *buffer)
+request_save (struct request_data *request, const gchar * buffer)
{
- DBG ("Request Save");
+ DBG ("Request Save");
- if (request->save_filename)
+ 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);
+ 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
+ else
{
- if (*request->save_buffer)
+ if (*request->save_buffer)
{
- gchar *newbuff = g_strconcat(*request->save_buffer, buffer, NULL);
- g_free(*request->save_buffer);
- *request->save_buffer = newbuff;
+ 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);
+ else
+ *request->save_buffer = g_strdup (buffer);
}
}
static gboolean
keep_sending (gpointer data)
{
- struct request_data *request = (struct request_data *)data;
- gint n;
+ struct request_data *request = (struct request_data *) data;
+ gint n;
- if (!request)
+ if (!request)
{
- DBG ("keep_sending(): empty request data");
- return FALSE;
+ DBG ("keep_sending(): empty request data");
+ return FALSE;
}
- if ((n = send(request->fd, request->request_buffer + request->offset,
- request->size - request->offset,
- 0)) != -1)
+ if ((n = send (request->fd, request->request_buffer + request->offset,
+ request->size - request->offset, 0)) != -1)
{
- request->offset += n;
+ request->offset += n;
- DBG ("now at offset: %d", request->offset);
- DBG ("now at byte: %d", n);
+ DBG ("now at offset: %d", request->offset);
+ DBG ("now at byte: %d", n);
- if (request->offset == request->size)
+ if (request->offset == request->size)
{
- DBG ("keep_sending(): ok data sent");
- g_idle_add(keep_receiving, (gpointer) request);
- return FALSE;
+ DBG ("keep_sending(): ok data sent");
+ g_idle_add (keep_receiving, (gpointer) request);
+ return FALSE;
}
}
- else if (errno != EAGAIN) /* some other error happened */
+ else if (errno != EAGAIN) /* some other error happened */
{
#if DEBUG
- perror("keep_sending()");
+ perror ("keep_sending()");
#endif
- DBG ("file desc: %d", request->fd);
+ DBG ("file desc: %d", request->fd);
- request_free(request);
- return FALSE;
+ request_free (request);
+ return FALSE;
}
- return TRUE;
+ 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;
+ struct request_data *request = (struct request_data *) data;
+ gchar recvbuffer[1024];
+ gint n;
+ gchar *p;
+ gchar *str = NULL;
- if (!request)
+ if (!request)
{
- DBG ("keep_receiving(): empty request data ");
- return FALSE;
+ DBG ("keep_receiving(): empty request data ");
+ return FALSE;
}
- if ((n = recv(request->fd, recvbuffer, sizeof(recvbuffer) -
- sizeof(char), 0)) > 0)
+ if ((n = recv (request->fd, recvbuffer, sizeof (recvbuffer) -
+ sizeof (char), 0)) > 0)
{
- recvbuffer[n] = '\0';
+ recvbuffer[n] = '\0';
- DBG ("keep_receiving(): bytes recv: %d", n);
+ DBG ("keep_receiving(): bytes recv: %d", n);
- if (!request->has_header)
+ if (!request->has_header)
{
- if (request->last_chars != '\0')
- str = g_strconcat(request->last_chars,
- recvbuffer, NULL);
+ if (request->last_chars != '\0')
+ str = g_strconcat (request->last_chars, recvbuffer, NULL);
- if ((p = strstr(str, "\r\n\r\n")))
+ if ((p = strstr (str, "\r\n\r\n")))
{
- request_save(request, p + 4);
- request->has_header = TRUE;
- DBG ("keep_receiving(): got header");
+ request_save (request, p + 4);
+ request->has_header = TRUE;
+ DBG ("keep_receiving(): got header");
}
- else
+ else
{
- DBG ("keep_receiving(): no header yet\n\n%s\n..\n",
- recvbuffer);
- memcpy(request->last_chars, recvbuffer + (n - 4),
- sizeof(char) * 3);
+ 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);
+ g_free (str);
}
- else
- request_save(request, recvbuffer);
+ else
+ request_save (request, recvbuffer);
}
- else if (n == 0)
+ else if (n == 0)
{
- CB_TYPE callback = request->cb_function;
- gpointer data = request->cb_data;
- DBG ("keep_receiving(): ending with succes");
- request_free(request);
+ 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;
+ callback (TRUE, data);
+ return FALSE;
}
- else if (errno != EAGAIN)
+ else if (errno != EAGAIN)
{
- perror("keep_receiving()");
- request->cb_function(FALSE, request->cb_data);
- request_free(request);
- return FALSE;
+ perror ("keep_receiving()");
+ request->cb_function (FALSE, request->cb_data);
+ request_free (request);
+ return FALSE;
}
- return TRUE;
+ 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)
+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);
+ struct request_data *request = panel_slice_new0 (struct request_data);
- if (!request)
+ if (!request)
{
#if DEBUG
- perror("http_get(): empty request");
+ perror ("http_get(): empty request");
#endif
- return FALSE;
+ return FALSE;
}
- request->has_header = FALSE;
- request->cb_function = callback;
- request->cb_data = data;
+ request->has_header = FALSE;
+ request->cb_function = callback;
+ request->cb_data = data;
- if (proxy_host)
+ if (proxy_host)
{
- DBG ("using proxy %s", proxy_host);
- request->fd = http_connect(proxy_host, proxy_port);
+ DBG ("using proxy %s", proxy_host);
+ request->fd = http_connect (proxy_host, proxy_port);
}
- else
+ else
{
- DBG ("Not USING PROXY");
- request->fd = http_connect(hostname, 80);
+ DBG ("Not USING PROXY");
+ request->fd = http_connect (hostname, 80);
}
- if (request->fd == -1)
+ if (request->fd == -1)
{
- DBG ("http_get(): fd = -1 returned");
- request_free(request);
- return FALSE;
+ 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 (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 (request->request_buffer == NULL)
{
#if DEBUG
- perror("http_get(): empty request buffer\n");
+ perror ("http_get(): empty request buffer\n");
#endif
- close(request->fd);
- panel_slice_free(struct request_data, request);
- return FALSE;
+ close (request->fd);
+ panel_slice_free (struct request_data, request);
+ return FALSE;
}
- request->size = strlen (request->request_buffer);
+ request->size = strlen (request->request_buffer);
- if (savefile)
- request->save_filename = g_strdup (*fname_buff);
- else
- request->save_buffer = fname_buff;
+ if (savefile)
+ request->save_filename = g_strdup (*fname_buff);
+ else
+ request->save_buffer = fname_buff;
- DBG ("http_get(): adding idle function");
+ DBG ("http_get(): adding idle function");
- (void)g_idle_add ((GSourceFunc)keep_sending, (gpointer)request);
+ (void) g_idle_add ((GSourceFunc) keep_sending, (gpointer) request);
- DBG ("http_get(): request added");
+ DBG ("http_get(): request added");
- return TRUE;
+ return TRUE;
}
gboolean
-http_get_file (gchar *url,
- gchar *hostname,
- gchar *filename,
- gchar *proxy_host,
- gint proxy_port,
- CB_TYPE callback,
- gpointer data)
+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);
+ 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)
+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);
+ return http_get (url, hostname, FALSE, buffer, proxy_host, proxy_port,
+ callback, data);
}
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-http.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-http.h 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-http.h 2006-12-16 13:20:22 UTC (rev 2237)
@@ -18,20 +18,17 @@
#ifndef HTTP_CLIENT_H
#define HTTP_CLIENT_H
-G_BEGIN_DECLS
+G_BEGIN_DECLS typedef void (*CB_TYPE) (gboolean, gpointer);
-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);
+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,
+http_get_buffer (gchar * url, gchar * hostname,
+ gchar * proxy_host, gint proxy_port, gchar ** buffer,
CB_TYPE callback, gpointer data);
G_END_DECLS
-
#endif
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-icon.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-icon.c 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-icon.c 2006-12-16 13:20:22 UTC (rev 2237)
@@ -27,28 +27,25 @@
#define DEFAULT_W_THEME "liquid"
GdkPixbuf *
-get_icon (const gchar *number,
- GtkIconSize size)
+get_icon (const gchar * number, GtkIconSize size)
{
- GdkPixbuf *image = NULL;
- gchar *filename;
- gint width, height;
+ GdkPixbuf *image = NULL;
+ gchar *filename;
+ gint width, height;
- gtk_icon_size_lookup (size, &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);
+ 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);
+ image = gdk_pixbuf_new_from_file_at_scale (filename,
+ width, height, TRUE, NULL);
- g_free (filename);
+ g_free (filename);
- if (!image)
- g_warning ("Weather Plugin: No image found");
+ if (!image)
+ g_warning ("Weather Plugin: No image found");
- return image;
+ return image;
}
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-icon.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-icon.h 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-icon.h 2006-12-16 13:20:22 UTC (rev 2237)
@@ -18,11 +18,7 @@
#ifndef ICON_H
#define ICON_H
-G_BEGIN_DECLS
+G_BEGIN_DECLS GdkPixbuf *get_icon (const gchar * icon, GtkIconSize size);
-GdkPixbuf *
-get_icon (const gchar *icon, GtkIconSize size);
-
G_END_DECLS
-
#endif
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.c 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.c 2006-12-16 13:20:22 UTC (rev 2237)
@@ -23,383 +23,386 @@
#include <libxfce4panel/xfce-panel-macros.h>
xml_weather *
-parse_weather (xmlNode *cur_node)
+parse_weather (xmlNode * cur_node)
{
- xml_weather *ret;
+ xml_weather *ret;
- if (!NODE_IS_TYPE (cur_node, "weather")) {
- return NULL;
+ if (!NODE_IS_TYPE (cur_node, "weather"))
+ {
+ return NULL;
}
- if ((ret = panel_slice_new0 (xml_weather)) == NULL)
- 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)
+ for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
- if (cur_node->type != XML_ELEMENT_NODE)
- continue;
+ 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"))
+ 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;
+ xmlNode *child_node;
+ guint i = 0;
- for (child_node = cur_node->children; child_node; child_node = child_node->next)
+ for (child_node = cur_node->children; child_node;
+ child_node = child_node->next)
{
- if (NODE_IS_TYPE (child_node, "day"))
+ if (NODE_IS_TYPE (child_node, "day"))
{
- if (i >= XML_WEATHER_DAYF_N)
- break;
+ if (i >= XML_WEATHER_DAYF_N)
+ break;
- ret->dayf[i] = parse_dayf(child_node);
+ ret->dayf[i] = parse_dayf (child_node);
- i++;
+ i++;
}
}
}
}
- return ret;
+ return ret;
}
xml_loc *
-parse_loc (xmlNode *cur_node)
+parse_loc (xmlNode * cur_node)
{
- xml_loc *ret;
+ xml_loc *ret;
- if ((ret = panel_slice_new0 (xml_loc)) == NULL)
- return NULL;
+ if ((ret = panel_slice_new0 (xml_loc)) == NULL)
+ return NULL;
- for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+ for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
- if (cur_node->type != XML_ELEMENT_NODE)
- continue;
+ 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);
+ 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;
+ return ret;
}
static xml_uv *
-parse_uv (xmlNode *cur_node)
+parse_uv (xmlNode * cur_node)
{
- xml_uv *ret;
+ xml_uv *ret;
- if ((ret = panel_slice_new0 (xml_uv)) == NULL)
- return NULL;
+ if ((ret = panel_slice_new0 (xml_uv)) == NULL)
+ return NULL;
- for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+ for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
- if (cur_node->type != XML_ELEMENT_NODE)
- continue;
+ 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);
+ 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;
+ return ret;
}
static xml_bar *
-parse_bar (xmlNode *cur_node)
+parse_bar (xmlNode * cur_node)
{
- xml_bar *ret;
+ xml_bar *ret;
- if ((ret = panel_slice_new0 (xml_bar)) == NULL)
- return NULL;
+ if ((ret = panel_slice_new0 (xml_bar)) == NULL)
+ return NULL;
- for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+ for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
- if (cur_node->type != XML_ELEMENT_NODE)
- continue;
+ 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);
+ 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;
+ return ret;
}
static xml_wind *
-parse_wind (xmlNode *cur_node)
+parse_wind (xmlNode * cur_node)
{
- xml_wind *ret;
+ xml_wind *ret;
- if ((ret = panel_slice_new0 (xml_wind)) == NULL)
- return NULL;
+ if ((ret = panel_slice_new0 (xml_wind)) == NULL)
+ return NULL;
- for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+ for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
- if (cur_node->type != XML_ELEMENT_NODE)
- continue;
+ 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);
+ 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;
+ return ret;
}
xml_cc *
-parse_cc (xmlNode *cur_node)
+parse_cc (xmlNode * cur_node)
{
- xml_cc *ret;
+ xml_cc *ret;
- if ((ret = panel_slice_new0 (xml_cc)) == NULL)
- return NULL;
+ if ((ret = panel_slice_new0 (xml_cc)) == NULL)
+ return NULL;
- for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+ for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
- if (cur_node->type != XML_ELEMENT_NODE)
- continue;
+ 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);
+ 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;
+ return ret;
}
static xml_part *
-parse_part (xmlNode *cur_node)
+parse_part (xmlNode * cur_node)
{
- xml_part *ret;
+ xml_part *ret;
- if ((ret = panel_slice_new0 (xml_part)) == NULL)
- return NULL;
+ if ((ret = panel_slice_new0 (xml_part)) == NULL)
+ return NULL;
- for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
+ for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
- if (cur_node->type != XML_ELEMENT_NODE)
- continue;
+ 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);
+ 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;
+ return ret;
}
xml_dayf *
-parse_dayf (xmlNode *cur_node)
+parse_dayf (xmlNode * cur_node)
{
- xml_dayf *ret;
- gchar *value;
+ xml_dayf *ret;
+ gchar *value;
- if ((ret = panel_slice_new0 (xml_dayf)) == NULL)
- return NULL;
+ 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");
+ 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)
+ for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
- if (cur_node->type != XML_ELEMENT_NODE)
- continue;
+ if (cur_node->type != XML_ELEMENT_NODE)
+ continue;
- if (NODE_IS_TYPE (cur_node, "hi"))
+ if (NODE_IS_TYPE (cur_node, "hi"))
{
- ret->hi = DATA(cur_node);
- g_assert(ret->hi != NULL);
+ ret->hi = DATA (cur_node);
+ g_assert (ret->hi != NULL);
}
- else if (NODE_IS_TYPE (cur_node, "low"))
+ else if (NODE_IS_TYPE (cur_node, "low"))
{
- ret->low = DATA(cur_node);
+ ret->low = DATA (cur_node);
}
- else if (NODE_IS_TYPE (cur_node, "part"))
+ else if (NODE_IS_TYPE (cur_node, "part"))
{
- value = (gchar *) xmlGetProp (cur_node, (const xmlChar *) "p");
+ 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);
+ 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);
+ g_free (value);
}
}
- return ret;
+ return ret;
}
#define CHK_FREE(this) if (this)\
g_free(this);
static void
-xml_uv_free (xml_uv *data)
+xml_uv_free (xml_uv * data)
{
- CHK_FREE (data->i);
- CHK_FREE (data->t);
+ CHK_FREE (data->i);
+ CHK_FREE (data->t);
- panel_slice_free (xml_uv, data);
+ panel_slice_free (xml_uv, data);
}
static void
-xml_wind_free (xml_wind *data)
+xml_wind_free (xml_wind * data)
{
- CHK_FREE (data->s);
- CHK_FREE (data->gust);
- CHK_FREE (data->d);
- CHK_FREE (data->t);
+ CHK_FREE (data->s);
+ CHK_FREE (data->gust);
+ CHK_FREE (data->d);
+ CHK_FREE (data->t);
- panel_slice_free (xml_wind, data);
+ panel_slice_free (xml_wind, data);
}
static void
-xml_bar_free (xml_bar *data)
+xml_bar_free (xml_bar * data)
{
- CHK_FREE (data->r);
- CHK_FREE (data->d);
+ CHK_FREE (data->r);
+ CHK_FREE (data->d);
- panel_slice_free (xml_bar, data);
+ panel_slice_free (xml_bar, data);
}
static void
-xml_cc_free (xml_cc *data)
+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);
+ 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->uv)
+ xml_uv_free (data->uv);
- if (data->wind)
- xml_wind_free(data->wind);
+ if (data->wind)
+ xml_wind_free (data->wind);
- if (data->bar)
- xml_bar_free(data->bar);
+ if (data->bar)
+ xml_bar_free (data->bar);
- panel_slice_free (xml_cc, data);
+ panel_slice_free (xml_cc, data);
}
static void
-xml_loc_free (xml_loc *data)
+xml_loc_free (xml_loc * data)
{
- CHK_FREE (data->dnam);
- CHK_FREE (data->sunr);
- CHK_FREE (data->suns);
+ CHK_FREE (data->dnam);
+ CHK_FREE (data->sunr);
+ CHK_FREE (data->suns);
- panel_slice_free (xml_loc, data);
+ panel_slice_free (xml_loc, data);
}
static void
-xml_part_free (xml_part *data)
+xml_part_free (xml_part * data)
{
- if (!data)
- return;
+ if (!data)
+ return;
- CHK_FREE (data->icon);
- CHK_FREE (data->t);
- CHK_FREE (data->ppcp);
- CHK_FREE (data->hmid);
+ CHK_FREE (data->icon);
+ CHK_FREE (data->t);
+ CHK_FREE (data->ppcp);
+ CHK_FREE (data->hmid);
- if (data->wind)
- xml_wind_free(data->wind);
+ if (data->wind)
+ xml_wind_free (data->wind);
- panel_slice_free (xml_part, data);
+ panel_slice_free (xml_part, data);
}
static void
-xml_dayf_free (xml_dayf *data)
+xml_dayf_free (xml_dayf * data)
{
- if (!data)
- return;
+ if (!data)
+ return;
- CHK_FREE (data->day);
- CHK_FREE (data->date);
- CHK_FREE (data->hi);
- CHK_FREE (data->low);
+ 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[0])
+ xml_part_free (data->part[0]);
- if (data->part[1])
- xml_part_free(data->part[1]);
+ if (data->part[1])
+ xml_part_free (data->part[1]);
- panel_slice_free (xml_dayf, data);
+ panel_slice_free (xml_dayf, data);
}
void
-xml_weather_free (xml_weather *data)
+xml_weather_free (xml_weather * data)
{
- if (data->cc)
- xml_cc_free(data->cc);
+ if (data->cc)
+ xml_cc_free (data->cc);
- if (data->loc)
- xml_loc_free(data->loc);
+ if (data->loc)
+ xml_loc_free (data->loc);
- if (data->dayf)
+ if (data->dayf)
{
- guint i;
- for (i = 0; i < XML_WEATHER_DAYF_N; i++)
+ guint i;
+ for (i = 0; i < XML_WEATHER_DAYF_N; i++)
{
- if (!data->dayf[i])
- break;
+ if (!data->dayf[i])
+ break;
- xml_dayf_free(data->dayf[i]);
+ xml_dayf_free (data->dayf[i]);
}
}
- panel_slice_free (xml_weather, data);
+ panel_slice_free (xml_weather, data);
}
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.h 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-parsers.h 2006-12-16 13:20:22 UTC (rev 2237)
@@ -23,110 +23,101 @@
#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
+ typedef struct
{
- gchar *dnam;
- gchar *sunr;
- gchar *suns;
+ gchar *dnam;
+ gchar *sunr;
+ gchar *suns;
}
xml_loc;
typedef struct
{
- gchar *i;
- gchar *t;
+ gchar *i;
+ gchar *t;
}
xml_uv;
typedef struct
{
- gchar *s;
- gchar *gust;
- gchar *d;
- gchar *t;
+ gchar *s;
+ gchar *gust;
+ gchar *d;
+ gchar *t;
}
xml_wind;
typedef struct
{
- gchar *r;
- gchar *d;
+ gchar *r;
+ gchar *d;
}
xml_bar;
typedef struct
{
- gchar *lsup;
- gchar *obst;
- gchar *flik;
- gchar *t;
- gchar *icon;
- gchar *tmp;
+ gchar *lsup;
+ gchar *obst;
+ gchar *flik;
+ gchar *t;
+ gchar *icon;
+ gchar *tmp;
- gchar *hmid;
- gchar *vis;
+ gchar *hmid;
+ gchar *vis;
- xml_uv *uv;
- xml_wind *wind;
- xml_bar *bar;
+ xml_uv *uv;
+ xml_wind *wind;
+ xml_bar *bar;
- gchar *dewp;
+ gchar *dewp;
}
xml_cc;
typedef struct
{
- gchar *icon;
- gchar *t;
- gchar *ppcp;
- gchar *hmid;
+ gchar *icon;
+ gchar *t;
+ gchar *ppcp;
+ gchar *hmid;
- xml_wind *wind;
+ xml_wind *wind;
}
xml_part;
typedef struct
{
- gchar *day;
- gchar *date;
+ gchar *day;
+ gchar *date;
- gchar *hi;
- gchar *low;
+ gchar *hi;
+ gchar *low;
- xml_part *part[2];
+ xml_part *part[2];
}
xml_dayf;
typedef struct
{
- xml_loc *loc;
- xml_cc *cc;
- xml_dayf *dayf[XML_WEATHER_DAYF_N];
+ xml_loc *loc;
+ xml_cc *cc;
+ xml_dayf *dayf[XML_WEATHER_DAYF_N];
}
xml_weather;
-xml_weather *
-parse_weather (xmlNode *cur_node);
+xml_weather *parse_weather (xmlNode * cur_node);
-xml_loc *
-parse_loc (xmlNode *cur_node);
+xml_loc *parse_loc (xmlNode * cur_node);
-xml_cc *
-parse_cc (xmlNode *cur_node);
+xml_cc *parse_cc (xmlNode * cur_node);
-xml_dayf *
-parse_dayf (xmlNode *cur_node);
+xml_dayf *parse_dayf (xmlNode * cur_node);
-void
-xml_weather_free (xml_weather *data);
+void xml_weather_free (xml_weather * data);
G_END_DECLS
-
#endif
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.c 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.c 2006-12-16 13:20:22 UTC (rev 2237)
@@ -31,406 +31,401 @@
typedef struct _Label Label;
-struct _Label {
- gchar *msg;
- GdkPixmap *pixmap;
+struct _Label
+{
+ gchar *msg;
+ GdkPixmap *pixmap;
};
-enum {
- GTK_SCROLLBOX_ENABLECB = 1
+enum
+{
+ GTK_SCROLLBOX_ENABLECB = 1
};
static GObjectClass *parent_class;
-static gboolean
-start_draw_down (GtkScrollbox *self);
+static gboolean start_draw_down (GtkScrollbox * self);
-static void
-start_draw_up (GtkScrollbox *self);
+static void start_draw_up (GtkScrollbox * self);
-static void
-stop_callback (GtkScrollbox *self);
+static void stop_callback (GtkScrollbox * self);
-static GdkPixmap *
-make_pixmap (GtkScrollbox *, gchar *);
+static GdkPixmap *make_pixmap (GtkScrollbox *, gchar *);
static void
-free_label (Label *lbl)
+free_label (Label * lbl)
{
- if (lbl->pixmap)
- g_object_unref (G_OBJECT (lbl->pixmap));
- if (lbl->msg)
- g_free (lbl->msg);
+ if (lbl->pixmap)
+ g_object_unref (G_OBJECT (lbl->pixmap));
+ if (lbl->msg)
+ g_free (lbl->msg);
- panel_slice_free (Label, lbl);
+ panel_slice_free (Label, lbl);
}
static gboolean
-draw_up (GtkScrollbox *self)
+draw_up (GtkScrollbox * self)
{
- GdkRectangle update_rect = {0,0, GTK_WIDGET(self)->allocation.width,
- GTK_WIDGET(self)->allocation.height};
+ GdkRectangle update_rect = { 0, 0, GTK_WIDGET (self)->allocation.width,
+ GTK_WIDGET (self)->allocation.height
+ };
- if (self->draw_offset == 0)
+ if (self->draw_offset == 0)
{
- self->draw_timeout = g_timeout_add(LABEL_REFRESH,
- (GSourceFunc)start_draw_down, self);
+ self->draw_timeout = g_timeout_add (LABEL_REFRESH,
+ (GSourceFunc) start_draw_down,
+ self);
- return FALSE;
+ return FALSE;
}
- else
- self->draw_offset++;
+ else
+ self->draw_offset++;
- gtk_widget_draw(GTK_WIDGET(self), &update_rect);
+ gtk_widget_draw (GTK_WIDGET (self), &update_rect);
- return TRUE;
+ return TRUE;
}
static gboolean
-draw_down (GtkScrollbox *self)
+draw_down (GtkScrollbox * self)
{
- GdkRectangle update_rect = {0, 0, GTK_WIDGET(self)->allocation.width,
- GTK_WIDGET(self)->allocation.height};
+ GdkRectangle update_rect = { 0, 0, GTK_WIDGET (self)->allocation.width,
+ GTK_WIDGET (self)->allocation.height
+ };
- if (self->draw_offset == self->draw_maxoffset)
+ if (self->draw_offset == self->draw_maxoffset)
{
- self->draw_timeout = 0;
- start_draw_up(self);
+ self->draw_timeout = 0;
+ start_draw_up (self);
- return FALSE;
+ return FALSE;
}
- else
- self->draw_offset--;
+ else
+ self->draw_offset--;
- gtk_widget_draw(GTK_WIDGET(self), &update_rect);
+ gtk_widget_draw (GTK_WIDGET (self), &update_rect);
- return TRUE;
+ return TRUE;
}
static void
-start_draw_up (GtkScrollbox *self)
+start_draw_up (GtkScrollbox * self)
{
- gint width, height;
- Label *lbl;
- static size_t i = 0;
+ gint width, height;
+ Label *lbl;
+ static size_t i = 0;
- if (self->labels->len == 0)
- return;
+ if (self->labels->len == 0)
+ return;
- if (i >= self->labels->len)
- i = 0;
+ if (i >= self->labels->len)
+ i = 0;
- lbl = (Label *)g_ptr_array_index(self->labels, i);
- self->pixmap = lbl->pixmap;
+ 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 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)
+ if (self->labels->len == 1)
{
- GdkRectangle update_rect = {0, 0, GTK_WIDGET(self)->allocation.width,
- GTK_WIDGET(self)->allocation.height};
+ GdkRectangle update_rect = { 0, 0, GTK_WIDGET (self)->allocation.width,
+ GTK_WIDGET (self)->allocation.height
+ };
- self->pixmap = lbl->pixmap;
- self->draw_offset = 0;
+ self->pixmap = lbl->pixmap;
+ self->draw_offset = 0;
- gtk_widget_draw(GTK_WIDGET(self), &update_rect);
- return;
+ 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;
+ 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);
+ self->draw_timeout =
+ g_timeout_add (LABEL_SPEED, (GSourceFunc) draw_up, self);
- i++;
+ i++;
}
static gboolean
-start_draw_down (GtkScrollbox *self)
+start_draw_down (GtkScrollbox * self)
{
- self->draw_timeout = g_timeout_add(LABEL_SPEED, (GSourceFunc)draw_down, self);
+ self->draw_timeout =
+ g_timeout_add (LABEL_SPEED, (GSourceFunc) draw_down, self);
- return FALSE;
+ return FALSE;
}
static void
-stop_callback (GtkScrollbox *self)
+stop_callback (GtkScrollbox * self)
{
- if (self->draw_timeout == 0)
- return;
+ if (self->draw_timeout == 0)
+ return;
- g_source_remove(self->draw_timeout);
- self->draw_timeout = 0;
+ g_source_remove (self->draw_timeout);
+ self->draw_timeout = 0;
}
static void
-start_callback (GtkScrollbox *self)
+start_callback (GtkScrollbox * self)
{
- if (self->draw_timeout)
- stop_callback(self);
+ if (self->draw_timeout)
+ stop_callback (self);
- start_draw_up(self);
+ start_draw_up (self);
}
static GdkPixmap *
-make_pixmap (GtkScrollbox *self,
- gchar *value)
+make_pixmap (GtkScrollbox * self, gchar * value)
{
- GdkWindow *rootwin;
- PangoLayout *pl;
- gint width, height, middle;
- GdkPixmap *pixmap;
- GtkRequisition widgsize = {0, };
- GtkWidget *widget = (GtkWidget *)self;
+ 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;
+ /* 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);
+ rootwin = gtk_widget_get_root_window (widget);
- pl = gtk_widget_create_pango_layout(widget, NULL);
- pango_layout_set_markup(pl, value, -1);
+ pl = gtk_widget_create_pango_layout (widget, NULL);
+ pango_layout_set_markup (pl, value, -1);
- pango_layout_get_pixel_size(pl, &width, &height);
+ pango_layout_get_pixel_size (pl, &width, &height);
- pixmap = gdk_pixmap_new(GDK_DRAWABLE(rootwin), width, height, -1);
+ 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_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);
+ gdk_draw_layout (GDK_DRAWABLE (pixmap), widget->style->fg_gc[0], 0, 0, pl);
- g_object_unref(G_OBJECT (pl));
+ g_object_unref (G_OBJECT (pl));
- gtk_widget_size_request(widget, &widgsize);
+ gtk_widget_size_request (widget, &widgsize);
- if (width <= widgsize.width)
- width = widgsize.width;
+ if (width <= widgsize.width)
+ width = widgsize.width;
- if (height <= widgsize.height)
- height = widgsize.height;
- else
- self->draw_maxoffset = -height;
+ 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);
+ 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;
+ middle = width / 2;
+ if (self->draw_maxmiddle < middle)
+ self->draw_maxmiddle = middle;
- return pixmap;
+ return pixmap;
}
void
-gtk_scrollbox_set_label (GtkScrollbox *self,
- gint n,
- gchar *value)
+gtk_scrollbox_set_label (GtkScrollbox * self, gint n, gchar * value)
{
- gboolean append = TRUE;
- GdkPixmap *newpixmap;
- Label *newlbl;
+ gboolean append = TRUE;
+ GdkPixmap *newpixmap;
+ Label *newlbl;
- if (n != -1)
- append = FALSE;
+ if (n != -1)
+ append = FALSE;
- if (!append)
+ if (!append)
{
- Label *lbl = (Label *)g_ptr_array_index(self->labels, n);
+ Label *lbl = (Label *) g_ptr_array_index (self->labels, n);
- if (lbl)
- free_label(lbl);
+ if (lbl)
+ free_label (lbl);
- newlbl = lbl;
+ newlbl = lbl;
}
- else
+ else
{
- newlbl = panel_slice_new0 (Label);
- g_ptr_array_add(self->labels, newlbl);
+ newlbl = panel_slice_new0 (Label);
+ g_ptr_array_add (self->labels, newlbl);
}
- newpixmap = make_pixmap(self, value);
+ newpixmap = make_pixmap (self, value);
- newlbl->pixmap = newpixmap;
- newlbl->msg = g_strdup(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)
+gtk_scrollbox_set_property (GObject * object,
+ guint property_id,
+ const GValue * value, GParamSpec * pspec)
{
- GtkScrollbox *self = (GtkScrollbox *)object;
+ GtkScrollbox *self = (GtkScrollbox *) object;
- switch (property_id)
+ switch (property_id)
{
- case GTK_SCROLLBOX_ENABLECB:
- {
- gboolean realvalue = g_value_get_boolean(value);
+ 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);
+ 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;
+ }
+ default:
+ /* We don't have any other property... */
+ g_assert (FALSE);
- break;
+ break;
}
}
static void
-gtk_scrollbox_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+gtk_scrollbox_get_property (GObject * object,
+ guint property_id,
+ GValue * value, GParamSpec * pspec)
{
- return;
+ return;
}
static void
-gtk_scrollbox_finalize (GObject *gobject)
+gtk_scrollbox_finalize (GObject * gobject)
{
- GtkScrollbox *self = (GtkScrollbox *)gobject;
- guint i;
+ GtkScrollbox *self = (GtkScrollbox *) gobject;
+ guint i;
- if (self->draw_timeout) {
- g_source_remove(self->draw_timeout);
- self->draw_timeout = 0;
+ if (self->draw_timeout)
+ {
+ g_source_remove (self->draw_timeout);
+ self->draw_timeout = 0;
}
- if (self->labels->len > 0)
+ if (self->labels->len > 0)
{
- for (i = 0; i < self->labels->len; i++)
+ for (i = 0; i < self->labels->len; i++)
{
- Label *lbl = (Label*)g_ptr_array_index(self->labels, i);
+ Label *lbl = (Label *) g_ptr_array_index (self->labels, i);
- g_object_unref (G_OBJECT (lbl->pixmap));
- g_free(lbl->msg);
+ g_object_unref (G_OBJECT (lbl->pixmap));
+ g_free (lbl->msg);
}
- g_ptr_array_free(self->labels, TRUE);
+ g_ptr_array_free (self->labels, TRUE);
}
- G_OBJECT_CLASS (parent_class)->finalize (gobject);
+ G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
static void
-redraw_labels (GtkWidget *widget,
- GtkStyle *previous_style)
+redraw_labels (GtkWidget * widget, GtkStyle * previous_style)
{
- GtkScrollbox *self = GTK_SCROLLBOX(widget);
- guint i;
+ GtkScrollbox *self = GTK_SCROLLBOX (widget);
+ guint i;
- if (self->labels->len < 1)
- return;
+ if (self->labels->len < 1)
+ return;
- stop_callback(self);
+ stop_callback (self);
- gtk_widget_set_size_request(GTK_WIDGET(self), 0, 0);
- self->draw_middle = 0;
- self->draw_maxmiddle = 0;
+ 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++)
+ for (i = 0; i < self->labels->len; i++)
{
- GdkPixmap *newpixmap;
- Label *lbl = (Label *)g_ptr_array_index(self->labels, i);
+ GdkPixmap *newpixmap;
+ Label *lbl = (Label *) g_ptr_array_index (self->labels, i);
- if (!lbl->msg)
- continue;
+ if (!lbl->msg)
+ continue;
- newpixmap = make_pixmap(self, lbl->msg);
+ newpixmap = make_pixmap (self, lbl->msg);
- if (lbl->pixmap)
- g_object_unref (G_OBJECT (lbl->pixmap));
+ if (lbl->pixmap)
+ g_object_unref (G_OBJECT (lbl->pixmap));
- lbl->pixmap = newpixmap;
+ lbl->pixmap = newpixmap;
}
- start_callback(self);
+ start_callback (self);
}
static void
-gtk_scrollbox_instance_init (GTypeInstance *instance,
- gpointer g_class)
+gtk_scrollbox_instance_init (GTypeInstance * instance, gpointer g_class)
{
- GtkScrollbox *self = (GtkScrollbox *)instance;
+ 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;
+ self->draw_timeout = 0;
+ self->labels = g_ptr_array_new ();
+ self->pixmap = NULL;
- g_signal_connect(self, "style-set", G_CALLBACK(redraw_labels), NULL);
+ g_signal_connect (self, "style-set", G_CALLBACK (redraw_labels), NULL);
}
static gboolean
-gtk_scrollbox_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_scrollbox_expose (GtkWidget * widget, GdkEventExpose * event)
{
- GtkScrollbox *self = (GtkScrollbox *)widget;
+ 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);
+ 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;
+ return FALSE;
}
void
-gtk_scrollbox_enablecb (GtkScrollbox *self,
- gboolean enable)
+gtk_scrollbox_enablecb (GtkScrollbox * self, gboolean enable)
{
- GValue val = {0, };
+ GValue val = { 0, };
- g_value_init (&val, G_TYPE_BOOLEAN);
- g_value_set_boolean (&val, enable);
+ g_value_init (&val, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&val, enable);
- g_object_set_property(G_OBJECT(self), "enablecb", &val);
+ g_object_set_property (G_OBJECT (self), "enablecb", &val);
}
GtkWidget *
gtk_scrollbox_new (void)
{
- return GTK_WIDGET(g_object_new (GTK_TYPE_SCROLLBOX, NULL));
+ return GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLBOX, NULL));
}
static void
-gtk_scrollbox_class_init (gpointer g_class,
- gpointer g_class_data)
+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);
+ 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);
@@ -439,14 +434,13 @@
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);
+ 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);
+ GTK_SCROLLBOX_ENABLECB,
+ scrollbox_param_spec);
widget_class->expose_event = gtk_scrollbox_expose;
gobject_class->finalize = gtk_scrollbox_finalize;
@@ -456,45 +450,46 @@
GType
gtk_scrollbox_get_type (void)
{
- static GType type = 0;
+ static GType type = 0;
- if (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
- };
+ 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);
+ type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
+ "GtkScrollbox", &info, 0);
}
- return type;
+ return type;
}
void
-gtk_scrollbox_clear (GtkScrollbox *self)
+gtk_scrollbox_clear (GtkScrollbox * self)
{
- stop_callback(self);
+ stop_callback (self);
- while(self->labels->len > 0)
+ while (self->labels->len > 0)
{
- Label *lbl = (Label *) g_ptr_array_index(self->labels, 0);
- free_label(lbl);
+ Label *lbl = (Label *) g_ptr_array_index (self->labels, 0);
+ free_label (lbl);
- g_ptr_array_remove_index (self->labels, 0);
+ 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;
+ self->pixmap = NULL;
+ gtk_widget_set_size_request (GTK_WIDGET (self), 0, 0);
+ self->draw_middle = 0;
+ self->draw_maxmiddle = 0;
}
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.h 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-scrollbox.h 2006-12-16 13:20:22 UTC (rev 2237)
@@ -18,10 +18,8 @@
#ifndef SCROLLBOX_H
#define SCROLLBOX_H
-G_BEGIN_DECLS
+G_BEGIN_DECLS GType gtk_scrollbox_get_type (void);
-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))
@@ -32,36 +30,33 @@
typedef struct _GtkScrollbox GtkScrollbox;
typedef struct _GtkScrollboxClass GtkScrollboxClass;
-struct _GtkScrollbox {
- GtkDrawingArea parent;
+struct _GtkScrollbox
+{
+ GtkDrawingArea parent;
- GPtrArray *labels;
+ GPtrArray *labels;
- gint draw_offset;
- gint draw_maxoffset;
- gint draw_middle;
- gint draw_maxmiddle;
- gint draw_timeout;
+ gint draw_offset;
+ gint draw_maxoffset;
+ gint draw_middle;
+ gint draw_maxmiddle;
+ gint draw_timeout;
- GdkPixmap *pixmap;
+ GdkPixmap *pixmap;
};
-struct _GtkScrollboxClass {
- GtkDrawingAreaClass parent;
+struct _GtkScrollboxClass
+{
+ GtkDrawingAreaClass parent;
};
-void
-gtk_scrollbox_set_label (GtkScrollbox *self, gint n, gchar *value);
+void gtk_scrollbox_set_label (GtkScrollbox * self, gint n, gchar * value);
-GtkWidget *
-gtk_scrollbox_new (void);
+GtkWidget *gtk_scrollbox_new (void);
-void
-gtk_scrollbox_enablecb (GtkScrollbox *self, gboolean enable);
+void gtk_scrollbox_enablecb (GtkScrollbox * self, gboolean enable);
-void
-gtk_scrollbox_clear (GtkScrollbox *self);
+void gtk_scrollbox_clear (GtkScrollbox * self);
G_END_DECLS
-
#endif
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-search.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-search.c 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-search.c 2006-12-16 13:20:22 UTC (rev 2237)
@@ -31,227 +31,224 @@
#define BORDER 8
static void
-append_result (GtkListStore *mdl,
- gchar *id,
- gchar *city)
+append_result (GtkListStore * mdl, gchar * id, gchar * city)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
- gtk_list_store_append(mdl, &iter);
- gtk_list_store_set(mdl, &iter, 0, city, 1, id, -1);
+ gtk_list_store_append (mdl, &iter);
+ gtk_list_store_set (mdl, &iter, 0, city, 1, id, -1);
}
static gchar *
-sanitize_str (const gchar *str)
+sanitize_str (const gchar * str)
{
- GString *retstr = g_string_sized_new(strlen(str));
- gchar *realstr, c = '\0';
+ GString *retstr = g_string_sized_new (strlen (str));
+ gchar *realstr, c = '\0';
- while((c = *str++))
+ while ((c = *str++))
{
- if (g_ascii_isspace(c))
- g_string_append(retstr, "%20");
- else if (g_ascii_isalnum(c) == FALSE)
+ if (g_ascii_isspace (c))
+ g_string_append (retstr, "%20");
+ else if (g_ascii_isalnum (c) == FALSE)
{
- g_string_free(retstr, TRUE);
- return NULL;
+ g_string_free (retstr, TRUE);
+ return NULL;
}
- else
- g_string_append_c(retstr, c);
+ else
+ g_string_append_c (retstr, c);
}
- realstr = retstr->str;
+ realstr = retstr->str;
- g_string_free(retstr, FALSE);
+ g_string_free (retstr, FALSE);
- return realstr;
+ return realstr;
}
static void
-cb_searchdone (gboolean result,
- gpointer user_data)
+cb_searchdone (gboolean result, gpointer user_data)
{
- search_dialog *dialog = (search_dialog *) user_data;
- xmlDoc *doc;
- xmlNode *cur_node;
+ search_dialog *dialog = (search_dialog *) user_data;
+ xmlDoc *doc;
+ xmlNode *cur_node;
- if (!result || dialog->recv_buffer == NULL)
- return;
+ 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;
+ doc = xmlParseMemory (dialog->recv_buffer, strlen (dialog->recv_buffer));
+ g_free (dialog->recv_buffer);
+ dialog->recv_buffer = NULL;
- if (!doc)
- return;
+ if (!doc)
+ return;
- cur_node = xmlDocGetRootElement(doc);
+ cur_node = xmlDocGetRootElement (doc);
- if (cur_node)
+ if (cur_node)
{
- for (cur_node = cur_node->children;
- cur_node;
- cur_node = cur_node->next)
+ for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
- if (NODE_IS_TYPE(cur_node, "loc"))
+ if (NODE_IS_TYPE (cur_node, "loc"))
{
- gchar *id = (gchar *) xmlGetProp(cur_node, (const xmlChar *) "id");
- gchar *city;
+ gchar *id =
+ (gchar *) xmlGetProp (cur_node, (const xmlChar *) "id");
+ gchar *city;
- if (!id)
- continue;
+ if (!id)
+ continue;
- city = DATA(cur_node);
+ city = DATA (cur_node);
- if (!city)
+ if (!city)
{
- g_free(id);
- continue;
+ g_free (id);
+ continue;
}
- append_result(dialog->result_mdl, id, city);
- g_free(id);
- g_free(city);
+ append_result (dialog->result_mdl, id, city);
+ g_free (id);
+ g_free (city);
}
}
}
- xmlFreeDoc(doc);
+ xmlFreeDoc (doc);
- return;
+ return;
}
static gboolean
-search_cb (GtkButton *button,
- gpointer user_data)
+search_cb (GtkButton * button, gpointer user_data)
{
- search_dialog *dialog = (search_dialog *)user_data;
- gchar *sane_str, *url;
- const gchar *str;
- gboolean result;
+ 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));
+ str = gtk_entry_get_text (GTK_ENTRY (dialog->search_entry));
- if (strlen(str) == 0)
- return FALSE;
+ if (strlen (str) == 0)
+ return FALSE;
- gtk_list_store_clear(GTK_LIST_STORE(dialog->result_mdl));
+ gtk_list_store_clear (GTK_LIST_STORE (dialog->result_mdl));
- if ((sane_str = sanitize_str(str)) == NULL)
- return FALSE;
+ if ((sane_str = sanitize_str (str)) == NULL)
+ return FALSE;
- url = g_strdup_printf("/search/search?where=%s", sane_str);
- g_free(sane_str);
+ 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);
+ 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;
+ return result;
}
search_dialog *
-create_search_dialog (GtkWindow *parent,
- gchar *proxy_host,
- gint proxy_port)
+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;
+ 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 = panel_slice_new0 (search_dialog);
- dialog->proxy_host = proxy_host;
- dialog->proxy_port = proxy_port;
+ dialog->proxy_host = proxy_host;
+ dialog->proxy_port = proxy_port;
- if (!dialog)
- return NULL;
+ 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);
+ 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);
+ 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);
+ 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);
+ 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));
+ /* 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);
+ 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);
+ 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);
+ 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_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);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
- g_signal_connect(button, "clicked", G_CALLBACK(search_cb), dialog);
+ g_signal_connect (button, "clicked", G_CALLBACK (search_cb), dialog);
- gtk_widget_set_size_request(dialog->dialog, 350, 250);
+ gtk_widget_set_size_request (dialog->dialog, 350, 250);
- return dialog;
+ return dialog;
}
gboolean
-run_search_dialog (search_dialog *dialog)
+run_search_dialog (search_dialog * dialog)
{
- gtk_widget_show_all(dialog->dialog);
- if (gtk_dialog_run(GTK_DIALOG(dialog->dialog)) == GTK_RESPONSE_ACCEPT)
+ 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));
+ GtkTreeIter iter;
+ GtkTreeSelection *selection =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->result_list));
- if (gtk_tree_selection_get_selected(selection, NULL, &iter))
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
{
- GValue value = {0, };
+ 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));
+ 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;
+ g_value_unset (&value);
+ return TRUE;
}
}
- return FALSE;
+ return FALSE;
}
void
-free_search_dialog (search_dialog *dialog)
+free_search_dialog (search_dialog * dialog)
{
- g_free(dialog->result);
- gtk_widget_destroy(dialog->dialog);
+ g_free (dialog->result);
+ gtk_widget_destroy (dialog->dialog);
- panel_slice_free (search_dialog, dialog);
+ panel_slice_free (search_dialog, dialog);
}
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-search.h
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-search.h 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-search.h 2006-12-16 13:20:22 UTC (rev 2237)
@@ -22,33 +22,27 @@
#ifndef SEARCH_DIALOG_H
#define SEARCH_DIALOG_H
-G_BEGIN_DECLS
-
-typedef struct
+G_BEGIN_DECLS typedef struct
{
- GtkWidget *dialog;
- GtkWidget *search_entry;
- GtkWidget *result_list;
- GtkListStore *result_mdl;
+ GtkWidget *dialog;
+ GtkWidget *search_entry;
+ GtkWidget *result_list;
+ GtkListStore *result_mdl;
- gchar *result;
+ gchar *result;
- gchar *proxy_host;
- gint proxy_port;
+ gchar *proxy_host;
+ gint proxy_port;
- gchar *recv_buffer;
+ gchar *recv_buffer;
}
search_dialog;
-search_dialog *
-create_search_dialog (GtkWindow *, gchar *, gint);
+search_dialog *create_search_dialog (GtkWindow *, gchar *, gint);
-gboolean
-run_search_dialog (search_dialog *dialog);
+gboolean run_search_dialog (search_dialog * dialog);
-void
-free_search_dialog (search_dialog *dialog);
+void free_search_dialog (search_dialog * dialog);
G_END_DECLS
-
#endif
Modified: xfce4-weather-plugin/trunk/panel-plugin/weather-summary.c
===================================================================
--- xfce4-weather-plugin/trunk/panel-plugin/weather-summary.c 2006-12-16 13:02:07 UTC (rev 2236)
+++ xfce4-weather-plugin/trunk/panel-plugin/weather-summary.c 2006-12-16 13:20:22 UTC (rev 2237)
@@ -43,352 +43,375 @@
static GtkTooltips *tooltips = NULL;
static GtkWidget *
-create_summary_tab (xml_weather *data,
- units unit)
+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;
+ 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);
+ 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_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), BORDE