Commit 21630eca authored by Nick Schermer's avatar Nick Schermer

* A lot if changed in the code to reduce exec. size

* Fix build
* Added new xfce dialog (if available)


(Old svn revision: 1416)
parent d91a5fe0
dnl configure.ac
dnl
dnl xfce4-fsguard-plugin - <Plugin for xfce4-panel>
dnl xfce4-weather-plugin - <Plugin for xfce4-panel>
dnl
dnl 2003 Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de>
dnl
......@@ -33,7 +33,12 @@ dnl check for xml
XDT_CHECK_PACKAGE([LIBXML], [libxml-2.0], [2.4.0])
dnl configure the panel plugin
XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.22])
XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.90])
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.90])
dnl check for gtk
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
dnl check for i18n support
XDT_I18N([de fr lt nl sk zh_TW])
......@@ -41,6 +46,23 @@ XDT_I18N([de fr lt nl sk zh_TW])
dnl Check for debugging support
XDT_FEATURE_DEBUG()
dnl Compilation fails with --as-needed in the LDFLAGS
AC_MSG_CHECKING([Check if --as-needed is in the LDFLAGS])
if echo ${LDFLAGS} | grep as-needed >/dev/null 2>&1; then
LDFLAGS=""
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_MSG_CHECKING([whether to use new header dialog])
if $PKG_CONFIG --atleast-version 4.3.90.2 libxfcegui4-1.0 >/dev/null 2>&1; then
AC_DEFINE([USE_NEW_DIALOG], [1], [Define to use new header dialog])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_OUTPUT([
Makefile
panel-plugin/Makefile
......
......@@ -5,10 +5,12 @@ xfce4_weather_plugin_CFLAGS = \
-DTHEMESDIR=\"$(datadir)/xfce4/weather/icons\" \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
@LIBXFCE4PANEL_CFLAGS@ \
@LIBXFCE4UTIL_CFLAGS@ \
@LIBXML_CFLAGS@
xfce4_weather_plugin_LDFLAGS = \
@LIBXFCE4PANEL_LIBS@ \
@LIBXFCE4UTIL_LIBS@ \
@LIBXML_LIBS@
xfce4_weather_plugin_SOURCES = \
......
/* vim: set expandtab ts=8 sw=4: */
/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <gtk/gtk.h>
#include <libxfcegui4/libxfcegui4.h>
#include <libxfce4panel/xfce-panel-plugin.h>
#include <libxml/parser.h>
#include "config_dialog.h"
#include "parsers.h"
#include "get_data.h"
#include "plugin.h"
#include <libxfce4util/libxfce4util.h>
#include "config_dialog.h"
#include "search_dialog.h"
struct labeloption labeloptions[OPTIONS_N] = {
#define OPTIONS_N 11
#define BORDER 8
static labeloption labeloptions[OPTIONS_N] = {
{N_("Windchill (F)"), FLIK},
{N_("Temperature (T)"), TEMP},
{N_("Atmosphere pressure (P)"), BAR_R},
......@@ -20,10 +49,10 @@ struct labeloption labeloptions[OPTIONS_N] = {
{N_("Dewpoint (DP)"), DEWP}
};
typedef void(*cb_function)(struct xfceweather_data *);
typedef void(*cb_function)(xfceweather_data *);
static cb_function cb = NULL;
void
static void
add_mdl_option (GtkListStore *mdl,
int opt)
{
......@@ -36,11 +65,11 @@ add_mdl_option (GtkListStore *mdl,
-1);
}
gboolean
static gboolean
cb_addoption (GtkWidget *widget,
gpointer data)
{
struct xfceweather_dialog *dialog = (struct xfceweather_dialog *)data;
xfceweather_dialog *dialog = (xfceweather_dialog *) data;
gint history = gtk_option_menu_get_history(GTK_OPTION_MENU(dialog->opt_xmloption));
add_mdl_option(dialog->mdl_xmloption, history);
......@@ -48,11 +77,11 @@ cb_addoption (GtkWidget *widget,
return FALSE;
}
gboolean
static gboolean
cb_deloption (GtkWidget *widget,
gpointer data)
{
struct xfceweather_dialog *dialog = (struct xfceweather_dialog *)data;
xfceweather_dialog *dialog = (xfceweather_dialog *)data;
GtkTreeIter iter;
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->lst_xmloption));
......@@ -62,7 +91,7 @@ cb_deloption (GtkWidget *widget,
return FALSE;
}
gboolean
static gboolean
cb_toggle (GtkWidget *widget,
gpointer data)
{
......@@ -74,7 +103,7 @@ cb_toggle (GtkWidget *widget,
return FALSE;
}
gboolean
static gboolean
cb_not_toggle (GtkWidget *widget,
gpointer data)
{
......@@ -97,7 +126,7 @@ GtkWidget *make_label (void)
for (i = 0; i < 11; i++)
{
struct labeloption opt = labeloptions[i];
labeloption opt = labeloptions[i];
gtk_menu_shell_append(GTK_MENU_SHELL(menu),
gtk_menu_item_new_with_label(_(opt.name)));
......@@ -109,14 +138,14 @@ GtkWidget *make_label (void)
}
void
apply_options (struct xfceweather_dialog *dialog)
apply_options (xfceweather_dialog *dialog)
{
int history = 0;
gboolean hasiter = FALSE;
GtkTreeIter iter;
gchar *value;
struct xfceweather_data *data = (struct xfceweather_data *)dialog->wd;
xfceweather_data *data = (xfceweather_data *) dialog->wd;
history = gtk_option_menu_get_history(GTK_OPTION_MENU(dialog->opt_unit));
......@@ -134,7 +163,7 @@ apply_options (struct xfceweather_dialog *dialog)
if (data->labels && data->labels->len > 0)
g_array_free(data->labels, TRUE);
data->labels = g_array_new(FALSE, TRUE, sizeof(enum 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(
......@@ -189,8 +218,8 @@ apply_options (struct xfceweather_dialog *dialog)
cb(data);
}
int
option_i (enum datas opt)
static int
option_i (datas opt)
{
int i;
......@@ -203,12 +232,12 @@ option_i (enum datas opt)
return -1;
}
gboolean
static gboolean
cb_findlocation (GtkButton *button,
gpointer user_data)
{
struct xfceweather_dialog *dialog = (struct xfceweather_dialog *)user_data;
struct search_dialog *sdialog = create_search_dialog(NULL,
xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
search_dialog *sdialog = create_search_dialog(NULL,
dialog->wd->proxy_host, dialog->wd->proxy_port);
if (run_search_dialog(sdialog))
......@@ -220,11 +249,11 @@ cb_findlocation (GtkButton *button,
}
struct xfceweather_dialog *
create_config_dialog (struct xfceweather_data *data,
GtkWidget *vbox)
xfceweather_dialog *
create_config_dialog (xfceweather_data *data,
GtkWidget *vbox)
{
struct xfceweather_dialog *dialog;
xfceweather_dialog *dialog;
GtkWidget *vbox2, *vbox3, *hbox, *hbox2, *label,
*menu, *button_add,
*button_del, *image, *button, *scroll;
......@@ -233,9 +262,9 @@ create_config_dialog (struct xfceweather_data *data,
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
dialog = g_new0(struct xfceweather_dialog, 1);
dialog = g_new0(xfceweather_dialog, 1);
dialog->wd = (struct xfceweather_data *)data;
dialog->wd = (xfceweather_data *)data;
dialog->dialog = gtk_widget_get_toplevel(vbox);
label = gtk_label_new(_("Measurement unit:"));
......@@ -385,12 +414,12 @@ create_config_dialog (struct xfceweather_data *data,
if (data->labels->len > 0)
{
enum datas opt;
datas opt;
gint i, n;
for (i = 0; i < data->labels->len; i++)
{
opt = g_array_index (data->labels, enum datas, i);
opt = g_array_index (data->labels, datas, i);
if ((n = option_i(opt)) != -1)
add_mdl_option(dialog->mdl_xmloption, n);
......@@ -406,8 +435,8 @@ create_config_dialog (struct xfceweather_data *data,
}
void
set_callback_config_dialog (struct xfceweather_dialog *dialog,
cb_function cb_new)
set_callback_config_dialog (xfceweather_dialog *dialog,
cb_function cb_new)
{
cb = cb_new;
}
/* vim: set expandtab ts=8 sw=4: */
/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef CONFIG_DIALOG_H
#define CONFIG_DIALOG_H
typedef struct {
gchar *name;
datas number;
}
labeloption;
#include <gtk/gtk.h>
#include "search_dialog.h"
#include "plugin.h"
#define OPTIONS_N 11
struct labeloption {
gchar *name;
enum datas number;
};
struct xfceweather_dialog {
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;
struct xfceweather_data *wd;
};
xfceweather_data *wd;
}
xfceweather_dialog;
struct xfceweather_dialog *create_config_dialog(struct xfceweather_data *data,
GtkWidget *vbox);
xfceweather_dialog *
create_config_dialog (xfceweather_data *data, GtkWidget *vbox);
void set_callback_config_dialog(struct xfceweather_dialog *dialog,
void(cb)(struct xfceweather_data *));
void
set_callback_config_dialog (xfceweather_dialog *dialog, void(cb)(xfceweather_data *));
void apply_options (struct xfceweather_dialog *dialog);
void
apply_options (xfceweather_dialog *dialog);
#endif
/* vim: set expandtab ts=8 sw=4: */
/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <libxfce4util/libxfce4util.h>
#include <gtk/gtk.h>
#include <libxfce4panel/xfce-panel-plugin.h>
#include <libxml/parser.h>
#include "parsers.h"
#include "get_data.h"
#include "plugin.h"
#define DATAS_CC 0x0100
#define DATAS_LOC 0x0200
#define DATAS_DAYF 0x0300
#define KILL_RING_S 5
#define EMPTY_STRING g_strdup("-")
......@@ -18,7 +45,7 @@ copy_buffer (gchar *str)
if (!str)
{
DBG ("copy_buffer: received NULL pointer");
//DBG ("copy_buffer: received NULL pointer");
return EMPTY_STRING;
}
......@@ -47,15 +74,15 @@ free_get_data_buffer (void)
}
}
gchar *
get_data_uv (struct xml_uv *data,
enum datas_uv type)
static gchar *
get_data_uv (xml_uv *data,
datas_uv type)
{
gchar *str = NULL;
if (!data)
{
DBG ("get_data_bar: xml-uv not present");
//DBG ("get_data_bar: xml-uv not present");
return EMPTY_STRING;
}
......@@ -69,15 +96,15 @@ get_data_uv (struct xml_uv *data,
}
gchar *
get_data_bar (struct xml_bar *data,
enum datas_bar type)
static gchar *
get_data_bar (xml_bar *data,
datas_bar type)
{
gchar *str = NULL;
if (!data)
{
DBG ("get_data_bar: xml-wind not present");
//DBG ("get_data_bar: xml-wind not present");
return EMPTY_STRING;
}
......@@ -90,19 +117,19 @@ get_data_bar (struct xml_bar *data,
return CHK_NULL(str);
}
gchar *
get_data_wind (struct xml_wind *data,
enum datas_wind type)
static gchar *
get_data_wind (xml_wind *data,
datas_wind type)
{
gchar *str = NULL;
if (!data)
{
DBG ("get_data_wind: xml-wind not present");
//DBG ("get_data_wind: xml-wind not present");
return EMPTY_STRING;
}
DBG ("starting");
//DBG ("starting");
switch(type)
{
......@@ -112,23 +139,23 @@ get_data_wind (struct xml_wind *data,
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);
}
/* -- This is not the same as the previous functions */
gchar *
get_data_cc (struct xml_cc *data,
enum datas type)
static gchar *
get_data_cc (xml_cc *data,
datas type)
{
gchar *str = NULL;
if (!data)
{
DBG ("get_data_cc: xml-cc not present");
//DBG ("get_data_cc: xml-cc not present");
return EMPTY_STRING;
}
......@@ -156,15 +183,15 @@ get_data_cc (struct xml_cc *data,
return CHK_NULL(str);
}
gchar *
get_data_loc (struct xml_loc *data,
enum datas_loc type)
static gchar *
get_data_loc (xml_loc *data,
datas_loc type)
{
gchar *str = NULL;
if (!data)
{
DBG ("get_data_loc: xml-loc not present");
//DBG ("get_data_loc: xml-loc not present");
return EMPTY_STRING;
}
......@@ -180,8 +207,8 @@ get_data_loc (struct xml_loc *data,
const gchar *
get_data (struct xml_weather *data,
enum datas type)
get_data (xml_weather *data,
datas type)
{
gchar *str = NULL;
gchar *p;
......@@ -205,13 +232,13 @@ get_data (struct xml_weather *data,
return p;
}
gchar *
get_data_part (struct xml_part *data,
enum forecast type)
static gchar *
get_data_part (xml_part *data,
forecast type)
{
gchar *str = NULL;
DBG ("now here %s", data->ppcp);
//DBG ("now here %s", data->ppcp);
if (!data)
return EMPTY_STRING;
......@@ -229,8 +256,8 @@ get_data_part (struct xml_part *data,
}
const gchar *
get_data_f (struct xml_dayf *data,
enum forecast type)
get_data_f (xml_dayf *data,
forecast type)
{
gchar *p, *str = NULL;
......@@ -261,26 +288,37 @@ get_data_f (struct xml_dayf *data,
p = copy_buffer(str);
DBG ("value: %s", p);
//DBG ("value: %s", p);
return p;
}
const gchar *
get_unit (enum units unit,
enum datas type)
get_unit (units unit,
datas type)
{
gchar *str = NULL;
gchar *str;
switch (type & 0x00F0)
{
case 0x0020: str = (unit == METRIC ? "\302\260C" : "\302\260F"); break;
case 0x0030: str = "%"; break;
case 0x0040: str = (unit == METRIC ? _("km/h") : _("mph")); break;
case 0x0050: str = (unit == METRIC ? _("hPa") : _("in")); break;
case 0x0060: str = (unit == METRIC ? _("km") : _("mi")); break;
default: str = "";
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);
}
/* vim: set expandtab ts=8 sw=4: */
/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef GET_DATA_H
#define GET_DATA_H
#include <glib.h>
#include "parsers.h"
#define DATAS_CC 0x0100
#define DATAS_LOC 0x0200
#define DATAS_DAYF 0x0300
enum datas_wind {
typedef enum {
_WIND_SPEED,
_WIND_GUST,
_WIND_DIRECTION,
_WIND_TRANS
};
}
datas_wind;
enum datas_bar {
typedef enum {
_BAR_R,
_BAR_D
};
}
datas_bar;
enum datas_uv {
typedef enum {
_UV_INDEX,
_UV_TRANS