rendered paste bodydiff --git a/configure.in.in b/configure.in.in
index c21d47d..8b4e7ff 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -58,11 +58,11 @@ XDT_I18N([@LINGUAS@])
dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.12.0])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.90.2])
-XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.3.90.2])
-XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.99.1])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfcegui4-1.0], [4.7.0])
+XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.7.0])
XDT_CHECK_PACKAGE([LIBXML], [libxml-2.0], [2.4.0])
AC_CHECK_LIB(resolv, res_query, [LIBRESOLV=-lresolv])
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index 79a406e..47e0439 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -4,14 +4,13 @@ INCLUDES = \
-I$(top_srcdir) \
-DTHEMESDIR=\"$(datadir)/xfce4/weather/icons\" \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
- -DG_LOG_DOMAIN=\"weather\"
+ -DG_LOG_DOMAIN=\"libweather\"
-plugindir = $(libexecdir)/xfce4/panel-plugins
+plugindir = $(libdir)/xfce4/panel-plugins
-plugin_PROGRAMS = \
- xfce4-weather-plugin
+plugin_LTLIBRARIES = libweather.la
-xfce4_weather_plugin_SOURCES = \
+libweather_la_SOURCES = \
weather.c \
weather.h \
weather-config.c \
@@ -33,17 +32,17 @@ xfce4_weather_plugin_SOURCES = \
weather-translate.c \
weather-translate.h
-xfce4_weather_plugin_CFLAGS = \
+libweather_la_CFLAGS = \
$(LIBXFCE4PANEL_CFLAGS) \
- $(LIBXFCEGUI4_CFLAGS) \
+ $(LIBXFCE4UI_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
$(GTK_CFLAGS) \
$(LIBXML_CFLAGS)
-xfce4_weather_plugin_LDADD = \
+libweather_la_LDADD = \
$(LIBXFCE4PANEL_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
- $(LIBXFCEGUI4_LIBS) \
+ $(LIBXFCE4UI_LIBS) \
$(GTK_LIBS) \
$(LIBXML_LIBS) \
$(LIBRESOLV)
@@ -52,7 +51,7 @@ desktopdir = $(datadir)/xfce4/panel-plugins
desktop_in_in_files = weather.desktop.in.in
desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
%.desktop.in: %.desktop.in.in
- sed -e "s,\@libexecdir\@,$(libexecdir),g" < $< > $@
+ sed -e "s,\@libdir\@,$(libdir),g" < $< > $@
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index c472619..a7da4a6 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -342,7 +342,7 @@ create_config_dialog (xfceweather_data *data,
sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
sg_buttons = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- dialog = panel_slice_new0 (xfceweather_dialog);
+ dialog = g_slice_new0 (xfceweather_dialog);
dialog->wd = (xfceweather_data *) data;
dialog->dialog = gtk_widget_get_toplevel (vbox);
@@ -369,7 +369,6 @@ create_config_dialog (xfceweather_data *data,
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:"));
dialog->txt_loc_code = gtk_entry_new ();
dialog->txt_loc_name = gtk_label_new ("");
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index bce8f6e..73c2ae9 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -402,7 +402,6 @@ get_data_f (xml_dayf *data,
str = data->hi;
break;
default:
- str = g_strdup ("-");
break;
}
break;
@@ -416,7 +415,7 @@ get_data_f (xml_dayf *data,
}
if (!str)
- str = "-";
+ str = "99";
p = copy_buffer (str);
diff --git a/panel-plugin/weather-http.c b/panel-plugin/weather-http.c
index 923a6a6..a3043bc 100644
--- a/panel-plugin/weather-http.c
+++ b/panel-plugin/weather-http.c
@@ -40,7 +40,7 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <libxfce4util/libxfce4util.h>
-#include <libxfce4panel/xfce-panel-macros.h>
+#include <libxfce4panel/libxfce4panel.h>
#include "weather-http.h"
@@ -478,7 +478,7 @@ weather_http_receive_data_destroyed (gpointer user_data)
g_free (connection->proxy_host);
/* cleanup */
- panel_slice_free (WeatherConnection, connection);
+ g_slice_free (WeatherConnection, connection);
}
@@ -494,7 +494,7 @@ weather_http_receive_data (const gchar *hostname,
WeatherConnection *connection;
/* create slice */
- connection = panel_slice_new0 (WeatherConnection);
+ connection = g_slice_new0 (WeatherConnection);
/* set connection properties */
connection->hostname = g_strdup (hostname);
diff --git a/panel-plugin/weather-icon.c b/panel-plugin/weather-icon.c
index ea389d6..9306699 100644
--- a/panel-plugin/weather-icon.c
+++ b/panel-plugin/weather-icon.c
@@ -21,6 +21,7 @@
#include <config.h>
#endif
+#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
@@ -38,11 +39,17 @@ get_icon (const gchar *number,
{
GdkPixbuf *image = NULL;
gchar *filename;
+
+ if (number == NULL || strcmp (number, "-") == 0)
+ number = "99";
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S "%s.png",
THEMESDIR, DEFAULT_W_THEME, number);
- image = gdk_pixbuf_new_from_file_at_scale (filename, size, size, TRUE, NULL);
+ if (size == -1)
+ image = gdk_pixbuf_new_from_file (filename, NULL);
+ else
+ image = gdk_pixbuf_new_from_file_at_scale (filename, size, size, TRUE, NULL);
if (G_UNLIKELY (!image)) {
g_warning ("Unable to open image: %s", filename);
diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
index 6ab4870..f095784 100644
--- a/panel-plugin/weather-parsers.c
+++ b/panel-plugin/weather-parsers.c
@@ -22,7 +22,7 @@
#endif
#include "weather-parsers.h"
-#include <libxfce4panel/xfce-panel-macros.h>
+#include <libxfce4panel/libxfce4panel.h>
@@ -38,7 +38,7 @@ parse_weather (xmlNode *cur_node)
return NULL;
}
- if ((ret = panel_slice_new0 (xml_weather)) == NULL)
+ if ((ret = g_slice_new0 (xml_weather)) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
@@ -80,7 +80,7 @@ parse_loc (xmlNode *cur_node)
{
xml_loc *ret;
- if ((ret = panel_slice_new0 (xml_loc)) == NULL)
+ if ((ret = g_slice_new0 (xml_loc)) == NULL)
return NULL;
@@ -105,7 +105,7 @@ parse_lnk (xmlNode *cur_node)
{
xml_lnk *ret;
int i = 0;
- if ((ret = panel_slice_new0 (xml_lnk)) == NULL)
+ if ((ret = g_slice_new0 (xml_lnk)) == NULL)
return NULL;
@@ -138,7 +138,7 @@ parse_uv (xmlNode *cur_node)
{
xml_uv *ret;
- if ((ret = panel_slice_new0 (xml_uv)) == NULL)
+ if ((ret = g_slice_new0 (xml_uv)) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
@@ -162,7 +162,7 @@ parse_bar (xmlNode *cur_node)
{
xml_bar *ret;
- if ((ret = panel_slice_new0 (xml_bar)) == NULL)
+ if ((ret = g_slice_new0 (xml_bar)) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
@@ -186,7 +186,7 @@ parse_wind (xmlNode *cur_node)
{
xml_wind *ret;
- if ((ret = panel_slice_new0 (xml_wind)) == NULL)
+ if ((ret = g_slice_new0 (xml_wind)) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
@@ -214,7 +214,7 @@ parse_cc (xmlNode *cur_node)
{
xml_cc *ret;
- if ((ret = panel_slice_new0 (xml_cc)) == NULL)
+ if ((ret = g_slice_new0 (xml_cc)) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
@@ -258,7 +258,7 @@ parse_part (xmlNode *cur_node)
{
xml_part *ret;
- if ((ret = panel_slice_new0 (xml_part)) == NULL)
+ if ((ret = g_slice_new0 (xml_part)) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
@@ -289,7 +289,7 @@ parse_dayf (xmlNode *cur_node)
xml_dayf *ret;
gchar *value;
- if ((ret = panel_slice_new0 (xml_dayf)) == NULL)
+ if ((ret = g_slice_new0 (xml_dayf)) == NULL)
return NULL;
ret->day = (gchar *) xmlGetProp (cur_node, (const xmlChar *) "t");
@@ -334,7 +334,7 @@ xml_uv_free (xml_uv * data)
g_free (data->i);
g_free (data->t);
- panel_slice_free (xml_uv, data);
+ g_slice_free (xml_uv, data);
}
@@ -347,7 +347,7 @@ xml_wind_free (xml_wind * data)
g_free (data->d);
g_free (data->t);
- panel_slice_free (xml_wind, data);
+ g_slice_free (xml_wind, data);
}
@@ -358,7 +358,7 @@ xml_bar_free (xml_bar * data)
g_free (data->r);
g_free (data->d);
- panel_slice_free (xml_bar, data);
+ g_slice_free (xml_bar, data);
}
@@ -385,7 +385,7 @@ xml_cc_free (xml_cc * data)
if (data->bar)
xml_bar_free (data->bar);
- panel_slice_free (xml_cc, data);
+ g_slice_free (xml_cc, data);
}
@@ -397,7 +397,7 @@ xml_loc_free (xml_loc *data)
g_free (data->sunr);
g_free (data->suns);
- panel_slice_free (xml_loc, data);
+ g_slice_free (xml_loc, data);
}
static void
@@ -408,7 +408,7 @@ xml_lnk_free (xml_lnk *data)
g_free (data->lnk[i]);
g_free (data->lnk_txt[i]);
}
- panel_slice_free (xml_lnk, data);
+ g_slice_free (xml_lnk, data);
}
static void
@@ -425,7 +425,7 @@ xml_part_free (xml_part *data)
if (data->wind)
xml_wind_free (data->wind);
- panel_slice_free (xml_part, data);
+ g_slice_free (xml_part, data);
}
@@ -447,7 +447,7 @@ xml_dayf_free (xml_dayf *data)
if (data->part[1])
xml_part_free (data->part[1]);
- panel_slice_free (xml_dayf, data);
+ g_slice_free (xml_dayf, data);
}
@@ -477,5 +477,5 @@ xml_weather_free (xml_weather *data)
}
}
- panel_slice_free (xml_weather, data);
+ g_slice_free (xml_weather, data);
}
diff --git a/panel-plugin/weather-scrollbox.c b/panel-plugin/weather-scrollbox.c
index 752ccf5..0b217dd 100644
--- a/panel-plugin/weather-scrollbox.c
+++ b/panel-plugin/weather-scrollbox.c
@@ -25,426 +25,228 @@
#include <glib.h>
#include <gtk/gtk.h>
-#include <libxfce4panel/xfce-panel-macros.h>
+#include <libxfce4panel/libxfce4panel.h>
#include "weather-scrollbox.h"
#define LABEL_REFRESH 3000
#define LABEL_SPEED 25
+static void gtk_scrollbox_finalize (GObject *object);
+static void gtk_scrollbox_size_request (GtkWidget *widget, GtkRequisition *requisition);
+static gboolean gtk_scrollbox_expose_event (GtkWidget *widget, GdkEventExpose *event);
+static gboolean gtk_scrollbox_fade_out (gpointer user_data);
-typedef struct
-{
- gchar *msg;
- GdkPixmap *pixmap;
-}
-Label;
-
-enum
-{
- GTK_SCROLLBOX_ENABLECB = 1
-};
-
-
-
-static GObjectClass *parent_class;
-static gboolean start_draw_down (GtkScrollbox * self);
-static void start_draw_up (GtkScrollbox * self);
-static void stop_callback (GtkScrollbox * self);
-static GdkPixmap *make_pixmap (GtkScrollbox *, gchar *);
+G_DEFINE_TYPE (GtkScrollbox, gtk_scrollbox, GTK_TYPE_DRAWING_AREA)
static void
-free_label (Label *lbl)
+gtk_scrollbox_class_init (GtkScrollboxClass *klass)
{
- if (lbl->pixmap)
- g_object_unref (G_OBJECT (lbl->pixmap));
- if (lbl->msg)
- g_free (lbl->msg);
+ GObjectClass *gobject_class;
+ GtkWidgetClass *widget_class;
- panel_slice_free (Label, lbl);
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = gtk_scrollbox_finalize;
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->size_request = gtk_scrollbox_size_request;
+ widget_class->expose_event = gtk_scrollbox_expose_event;
+ //widget_class->style_changed = gtk_scrollbox_style_changed;
}
-static gboolean
-draw_up (GtkScrollbox *self)
+static void
+gtk_scrollbox_init (GtkScrollbox *self)
{
- GdkRectangle update_rect = { 0, 0,
- GTK_WIDGET (self)->allocation.width,
- GTK_WIDGET (self)->allocation.height
- };
-
- if (self->draw_offset == 0)
- {
- self->draw_timeout = g_timeout_add (LABEL_REFRESH,
- (GSourceFunc) start_draw_down,
- self);
+ GTK_WIDGET_SET_FLAGS (self, GTK_NO_WINDOW);
- return FALSE;
- }
- else
- self->draw_offset++;
-
- gtk_widget_draw (GTK_WIDGET (self), &update_rect);
-
- return TRUE;
+ self->labels = NULL;
+ self->timeout_id = 0;
+ self->offset = 0;
+ self->active = NULL;
}
-static gboolean
-draw_down (GtkScrollbox *self)
+static void
+gtk_scrollbox_finalize (GObject *object)
{
- GdkRectangle update_rect = { 0, 0,
- GTK_WIDGET (self)->allocation.width,
- GTK_WIDGET (self)->allocation.height
- };
+ GtkScrollbox *self = GTK_SCROLLBOX (object);
- if (self->draw_offset == self->draw_maxoffset)
- {
- self->draw_timeout = 0;
- start_draw_up (self);
-
- return FALSE;
- }
- else
- self->draw_offset--;
-
- gtk_widget_draw (GTK_WIDGET (self), &update_rect);
+ /* stop running timeout */
+ if (self->timeout_id != 0)
+ g_source_remove (self->timeout_id);
- return TRUE;
+ /* free all the labels */
+ g_slist_foreach (self->labels, (GFunc) g_object_unref, NULL);
+ g_slist_free (self->labels);
+
+ G_OBJECT_CLASS (gtk_scrollbox_parent_class)->finalize (object);
}
static void
-start_draw_up (GtkScrollbox *self)
+gtk_scrollbox_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
{
- gint width, height;
- Label *lbl;
- static size_t i = 0;
- GdkRectangle update_rect = { 0, 0,
- GTK_WIDGET (self)->allocation.width,
- GTK_WIDGET (self)->allocation.height
- };
+ GtkScrollbox *self = GTK_SCROLLBOX (widget);
+ GSList *li;
+ PangoLayout *layout;
+ PangoRectangle logical_rect;
+ gint width, height;
- if (self->labels->len == 0)
- return;
-
- if (i >= self->labels->len)
- i = 0;
-
- lbl = (Label *) g_ptr_array_index (self->labels, i);
- self->pixmap = lbl->pixmap;
-
- /* If we failed to create a proper pixmap, try again now */
- if (!lbl->pixmap)
- {
- lbl->pixmap = make_pixmap (self, lbl->msg);
- if (!lbl->pixmap)
- {
- /* Still no pixmap. We need to restart the timer */
- if (self->draw_timeout)
- stop_callback (self);
- self->draw_timeout =
- g_timeout_add (LABEL_SPEED, (GSourceFunc) start_draw_up, self);
- return;
- }
- }
+ requisition->width = 0;
+ requisition->height = 0;
- if (self->labels->len == 1)
+ for (li = self->labels; li != NULL; li = li->next)
{
- self->pixmap = lbl->pixmap;
- self->draw_offset = 0;
+ layout = PANGO_LAYOUT (li->data);
+ pango_layout_get_extents (layout, NULL, &logical_rect);
+ width = PANGO_PIXELS (logical_rect.width);
+ height = PANGO_PIXELS (logical_rect.height);
- gtk_widget_draw (GTK_WIDGET (self), &update_rect);
- return;
+ requisition->width = MAX (width, requisition->width);
+ requisition->height = MAX (height, requisition->height);
}
-
- gdk_drawable_get_size (GDK_DRAWABLE (self->pixmap), &width, &height);
- self->draw_middle = self->draw_maxmiddle - width / 2;
-
- self->draw_timeout =
- g_timeout_add (LABEL_SPEED, (GSourceFunc) draw_up, self);
-
- i++;
}
static gboolean
-start_draw_down (GtkScrollbox *self)
+gtk_scrollbox_expose_event (GtkWidget *widget,
+ GdkEventExpose *event)
{
- self->draw_timeout =
- g_timeout_add (LABEL_SPEED, (GSourceFunc) draw_down, self);
+ GtkScrollbox *self = GTK_SCROLLBOX (widget);
+ PangoLayout *layout;
+ gint width, height;
+ PangoRectangle logical_rect;
+ if (self->active != NULL)
+ {
+ layout = PANGO_LAYOUT (self->active->data);
+ pango_layout_get_extents (layout, NULL, &logical_rect);
+ width = PANGO_PIXELS (logical_rect.width);
+ height = PANGO_PIXELS (logical_rect.height);
+
+ gtk_paint_layout (widget->style,
+ widget->window,
+ GTK_WIDGET_STATE (widget),
+ TRUE, &event->area,
+ widget, "GtkScrollbox",
+ widget->allocation.x + (widget->allocation.width - width) / 2,
+ widget->allocation.y + (widget->allocation.height - height) / 2 + self->offset,
+ layout);
+ }
return FALSE;
}
-
-static void
-stop_callback (GtkScrollbox *self)
-{
- if (self->draw_timeout == 0)
- return;
-
- g_source_remove (self->draw_timeout);
- self->draw_timeout = 0;
-}
-
-
-
-static void
-start_callback (GtkScrollbox *self)
+
+static gboolean
+gtk_scrollbox_sleep (gpointer user_data)
{
- if (self->draw_timeout)
- stop_callback (self);
-
- start_draw_up (self);
+ GtkScrollbox *self = GTK_SCROLLBOX (user_data);
+ self->timeout_id = g_timeout_add (LABEL_SPEED, gtk_scrollbox_fade_out, self);
+ return FALSE;
}
-static GdkPixmap *
-make_pixmap (GtkScrollbox *self,
- gchar *value)
+static gboolean
+gtk_scrollbox_fade_in (gpointer user_data)
{
- GdkWindow *rootwin;
- PangoLayout *pl;
- gint width, height, middle;
- GdkPixmap *pixmap;
- GtkRequisition widgsize = { 0, };
- GtkWidget *widget = (GtkWidget *) self;
-
-
- /* If we can't draw yet, don't do anything to avoid screwing things */
- if (!GDK_IS_GC (widget->style->bg_gc[0]))
- return NULL;
-
- rootwin = gtk_widget_get_root_window (widget);
-
- pl = gtk_widget_create_pango_layout (widget, NULL);
- pango_layout_set_markup (pl, value, -1);
-
- pango_layout_get_pixel_size (pl, &width, &height);
-
- pixmap = gdk_pixmap_new (GDK_DRAWABLE (rootwin), width, height, -1);
-
- gdk_draw_rectangle (GDK_DRAWABLE (pixmap),
- widget->style->bg_gc[0], TRUE, 0, 0, width, height);
-
- gdk_draw_layout (GDK_DRAWABLE (pixmap), widget->style->fg_gc[0], 0, 0, pl);
-
- g_object_unref (G_OBJECT (pl));
-
- gtk_widget_size_request (widget, &widgsize);
+ GtkScrollbox *self = GTK_SCROLLBOX (user_data);
+
+ /* decrease counter */
+ self->offset--;
- if (width <= widgsize.width)
- width = widgsize.width;
+ gtk_widget_queue_draw (GTK_WIDGET (self));
- 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 (self->offset > 0)
+ return TRUE;
- middle = width / 2;
- if (self->draw_maxmiddle < middle)
- self->draw_maxmiddle = middle;
+ self->timeout_id = g_timeout_add (LABEL_REFRESH, gtk_scrollbox_sleep, self);
- return pixmap;
+ return FALSE;
}
-void
-gtk_scrollbox_set_label (GtkScrollbox *self,
- gint n,
- gchar *value)
+static gboolean
+gtk_scrollbox_fade_out (gpointer user_data)
{
- gboolean append = TRUE;
- GdkPixmap *newpixmap;
- Label *newlbl, *lbl;
+ GtkScrollbox *self = GTK_SCROLLBOX (user_data);
- if (n != -1)
- append = FALSE;
+ /* decrease counter */
+ self->offset++;
- if (!append)
- {
- lbl = (Label *) g_ptr_array_index (self->labels, n);
+ gtk_widget_queue_draw (GTK_WIDGET (self));
- if (lbl)
- free_label (lbl);
+ if (self->offset < GTK_WIDGET (self)->allocation.height)
+ return TRUE;
- newlbl = lbl;
- }
- else
+ if (self->active != NULL)
{
- newlbl = panel_slice_new0 (Label);
- g_ptr_array_add (self->labels, newlbl);
- }
+ if (self->active->next != NULL)
+ self->active = self->active->next;
+ else
+ self->active = self->labels;
- newpixmap = make_pixmap (self, value);
-
- newlbl->pixmap = newpixmap;
- newlbl->msg = g_strdup (value);
-}
-
-
-
-static void
-gtk_scrollbox_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkScrollbox *self = (GtkScrollbox *) object;
- gboolean realvalue;
-
- switch (property_id)
- {
- case GTK_SCROLLBOX_ENABLECB:
- {
- realvalue = g_value_get_boolean (value);
-
- if (!realvalue && self->draw_timeout)
- stop_callback (self);
- else if (realvalue && !self->draw_timeout)
- start_callback (self);
-
- break;
- }
- default:
- /* We don't have any other property... */
- g_assert (FALSE);
-
- break;
+ self->timeout_id = g_timeout_add (LABEL_SPEED, gtk_scrollbox_fade_in, self);
}
-}
-
-
-static void
-gtk_scrollbox_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- return;
+ return FALSE;
}
static void
-gtk_scrollbox_finalize (GObject *gobject)
+gtk_scrollbox_start_fade (GtkScrollbox *self)
{
- GtkScrollbox *self = (GtkScrollbox *) gobject;
- guint i;
- Label *lbl;
-
- if (self->draw_timeout)
+ if (self->timeout_id != 0)
{
- g_source_remove (self->draw_timeout);
- self->draw_timeout = 0;
+ g_source_remove (self->timeout_id);
+ self->timeout_id = 0;
}
- if (self->labels->len > 0)
- {
- for (i = 0; i < self->labels->len; i++)
- {
- lbl = (Label *) g_ptr_array_index (self->labels, i);
+ self->active = self->labels;
- if (lbl->pixmap)
- g_object_unref (G_OBJECT (lbl->pixmap));
-
- g_free (lbl->msg);
- }
- g_ptr_array_free (self->labels, TRUE);
+ if (g_slist_length (self->labels) > 1)
+ {
+ self->offset = GTK_WIDGET (self)->allocation.height;
+ self->timeout_id = g_timeout_add (25, gtk_scrollbox_fade_in, self);
}
-
- G_OBJECT_CLASS (parent_class)->finalize (gobject);
-}
-
-
-
-static void
-redraw_labels (GtkWidget *widget,
- GtkStyle *previous_style)
-{
- GtkScrollbox *self = GTK_SCROLLBOX (widget);
- guint i;
- GdkPixmap *newpixmap;
- Label *lbl;
-
- if (self->labels->len < 1)
- return;
-
- stop_callback (self);
-
- gtk_widget_set_size_request (GTK_WIDGET (self), 0, 0);
- self->draw_middle = 0;
- self->draw_maxmiddle = 0;
-
- for (i = 0; i < self->labels->len; i++)
+ else
{
- lbl = (Label *) g_ptr_array_index (self->labels, i);
-
- if (!lbl->msg)
- continue;
-
- newpixmap = make_pixmap (self, lbl->msg);
-
- if (lbl->pixmap)
- g_object_unref (G_OBJECT (lbl->pixmap));
-
- lbl->pixmap = newpixmap;
+ self->offset = 0;
}
-
- start_callback (self);
-
}
-static void
-gtk_scrollbox_instance_init (GTypeInstance *instance,
- gpointer g_class)
-{
- GtkScrollbox *self = (GtkScrollbox *) instance;
-
- self->draw_timeout = 0;
- self->labels = g_ptr_array_new ();
- self->pixmap = NULL;
-
- g_signal_connect (G_OBJECT (self), "style-set",
- G_CALLBACK (redraw_labels), NULL);
-}
-
-
-
-static gboolean
-gtk_scrollbox_expose (GtkWidget *widget,
- GdkEventExpose *event)
+void
+gtk_scrollbox_set_label (GtkScrollbox *self,
+ gint position,
+ gchar *markup)
{
- GtkScrollbox *self = (GtkScrollbox *) widget;
+ PangoLayout *layout;
- if (self->pixmap)
- gdk_draw_drawable (widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
- self->pixmap,
- 0, (self->animate ? self->draw_offset : 0),
- self->draw_middle, 0,
- widget->allocation.width, widget->allocation.height);
+ g_return_if_fail (GTK_IS_SCROLLBOX (self));
+
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), NULL);
+ pango_layout_set_markup (layout, markup, -1);
+ self->labels = g_slist_insert (self->labels, layout, position);
+ gtk_widget_queue_resize (GTK_WIDGET (self));
- return FALSE;
+ gtk_scrollbox_start_fade (self);
}
+/* TODO - Not sure about this... */
void
gtk_scrollbox_next_label(GtkScrollbox *self)
{
@@ -452,105 +254,24 @@ gtk_scrollbox_next_label(GtkScrollbox *self)
start_draw_down (self);
}
-void
-gtk_scrollbox_enablecb (GtkScrollbox *self,
- gboolean enable)
-{
- GValue val = { 0, };
-
- g_value_init (&val, G_TYPE_BOOLEAN);
- g_value_set_boolean (&val, enable);
-
- g_object_set_property (G_OBJECT (self), "enablecb", &val);
-}
-
GtkWidget *
gtk_scrollbox_new (void)
{
- return GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLBOX, NULL));
-}
-
-
-
-static void
-gtk_scrollbox_class_init (gpointer g_class,
- gpointer g_class_data)
-{
-
- GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (g_class);
- GParamSpec *scrollbox_param_spec;
-
- parent_class = g_type_class_peek_parent (g_class);
-
- gobject_class->set_property = gtk_scrollbox_set_property;
- gobject_class->get_property = gtk_scrollbox_get_property;
-
- scrollbox_param_spec = g_param_spec_boolean ("enablecb",
- "Enable callback",
- "Enable or disable the callback",
- FALSE, G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class,
- GTK_SCROLLBOX_ENABLECB,
- scrollbox_param_spec);
-
- widget_class->expose_event = gtk_scrollbox_expose;
- gobject_class->finalize = gtk_scrollbox_finalize;
-}
-
-
-
-GType
-gtk_scrollbox_get_type (void)
-{
- static GType type = 0;
-
- if (type == 0)
- {
-
- static const GTypeInfo info = {
- sizeof (GtkScrollboxClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- gtk_scrollbox_class_init, /* class_init */
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtkScrollbox),
- 0, /* n_preallocs */
- gtk_scrollbox_instance_init, /* instance_init */
- NULL
- };
-
- type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
- "GtkScrollbox", &info, 0);
- }
-
- return type;
+ return g_object_new (GTK_TYPE_SCROLLBOX, NULL);
}
-
void
gtk_scrollbox_clear (GtkScrollbox *self)
{
- Label *lbl;
-
- stop_callback (self);
-
- while (self->labels->len > 0)
- {
- lbl = (Label *) g_ptr_array_index (self->labels, 0);
- free_label (lbl);
-
- g_ptr_array_remove_index (self->labels, 0);
- }
+ g_return_if_fail (GTK_IS_SCROLLBOX (self));
+ g_slist_foreach (self->labels, (GFunc) g_object_unref, NULL);
+ g_slist_free (self->labels);
+ self->labels = NULL;
- self->pixmap = NULL;
- gtk_widget_set_size_request (GTK_WIDGET (self), 0, 0);
- self->draw_middle = 0;
- self->draw_maxmiddle = 0;
+ gtk_widget_queue_resize (GTK_WIDGET (self));
}
void gtk_scrollbox_set_animate(GtkScrollbox *self, gboolean animate)
diff --git a/panel-plugin/weather-scrollbox.h b/panel-plugin/weather-scrollbox.h
index c4a1197..7f8793b 100644
--- a/panel-plugin/weather-scrollbox.h
+++ b/panel-plugin/weather-scrollbox.h
@@ -36,30 +36,23 @@ typedef struct _GtkScrollboxClass GtkScrollboxClass;
struct _GtkScrollbox
{
- GtkDrawingArea parent;
+ GtkDrawingArea __parent__;
- GPtrArray *labels;
-
- gint draw_offset;
- gint draw_maxoffset;
- gint draw_middle;
- gint draw_maxmiddle;
- gint draw_timeout;
- gboolean animate;
- GdkPixmap *pixmap;
+ GSList *labels;
+ guint timeout_id;
+ gint offset;
+ GSList *active;
};
struct _GtkScrollboxClass
{
- GtkDrawingAreaClass parent;
+ GtkDrawingAreaClass __parent__;
};
-void gtk_scrollbox_set_label (GtkScrollbox * self, gint n, gchar * value);
+void gtk_scrollbox_set_label (GtkScrollbox * self, gint position, gchar *markup);
GtkWidget *gtk_scrollbox_new (void);
-void gtk_scrollbox_enablecb (GtkScrollbox * self, gboolean enable);
-
void gtk_scrollbox_clear (GtkScrollbox * self);
void gtk_scrollbox_set_animate(GtkScrollbox *self, gboolean animate);
diff --git a/panel-plugin/weather-search.c b/panel-plugin/weather-search.c
index ea6b8e8..ced881c 100644
--- a/panel-plugin/weather-search.c
+++ b/panel-plugin/weather-search.c
@@ -213,7 +213,7 @@ create_search_dialog (GtkWindow *parent,
search_dialog *dialog;
GtkWidget *dialog_vbox, *dialog_action;
- dialog = panel_slice_new0 (search_dialog);
+ dialog = g_slice_new0 (search_dialog);
dialog->proxy_host = proxy_host;
dialog->proxy_port = proxy_port;
@@ -329,7 +329,7 @@ free_search_dialog (search_dialog * dialog)
gtk_widget_destroy (dialog->dialog);
- panel_slice_free (search_dialog, dialog);
+ g_slice_free (search_dialog, dialog);
}
typedef struct {
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 764f641..0a45e61 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -215,7 +215,6 @@ static void
set_icon_error (xfceweather_data *data)
{
GdkPixbuf *icon;
- gint height;
gint size;
gchar *str;
const gchar *txtsize;
@@ -245,16 +244,8 @@ set_icon_error (xfceweather_data *data)
gtk_scrollbox_set_label (GTK_SCROLLBOX (data->scrollbox), -1, str);
g_free (str);
- gtk_scrollbox_enablecb (GTK_SCROLLBOX (data->scrollbox), TRUE);
-
- gtk_widget_get_size_request (data->scrollbox, NULL, &height);
-
- if (data->orientation == GTK_ORIENTATION_VERTICAL)
- icon = get_icon ("99", data->size - height - 2);
- else
- icon = get_icon ("99", data->size);
-
- gtk_image_set_from_pixbuf (GTK_IMAGE (data->iconimage), icon);
+ icon = get_icon ("99", -1);
+ xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (data->iconimage), icon);
if (G_LIKELY (icon))
g_object_unref (G_OBJECT (icon));
@@ -274,7 +265,6 @@ set_icon_current (xfceweather_data *data)
GdkPixbuf *icon = NULL;
datas opt;
gchar *str;
- gint size, height;
for (i = 0; i < data->labels->len; i++)
{
@@ -287,24 +277,8 @@ set_icon_current (xfceweather_data *data)
g_free (str);
}
- gtk_scrollbox_enablecb (GTK_SCROLLBOX (data->scrollbox), TRUE);
-
- if (i == 0)
- {
- size = data->size;
- }
- else
- {
- gtk_widget_get_size_request (data->scrollbox, NULL, &height);
- if (data->orientation == GTK_ORIENTATION_VERTICAL)
- size = data->size - height - 2;
- else
- size = data->size;
- }
-
- icon = get_icon (get_data (data->weatherdata, WICON), size);
-
- gtk_image_set_from_pixbuf (GTK_IMAGE (data->iconimage), icon);
+ icon = get_icon (get_data (data->weatherdata, WICON), -1);
+ xfce_scaled_image_set_from_pixbuf (XFCE_SCALED_IMAGE (data->iconimage), icon);
if (G_LIKELY (icon))
g_object_unref (G_OBJECT (icon));
@@ -704,7 +678,7 @@ xfceweather_dialog_response (GtkWidget *dlg,
gtk_widget_destroy (dlg);
gtk_list_store_clear (dialog->mdl_xmloption);
- panel_slice_free (xfceweather_dialog, dialog);
+ g_slice_free (xfceweather_dialog, dialog);
xfce_panel_plugin_unblock_menu (data->plugin);
xfceweather_write_config (data->plugin, data);
@@ -785,7 +759,7 @@ static gboolean weather_get_tooltip_cb (GtkWidget *widget,
static xfceweather_data *
xfceweather_create_control (XfcePanelPlugin *plugin)
{
- xfceweather_data *data = panel_slice_new0 (xfceweather_data);
+ xfceweather_data *data = g_slice_new0 (xfceweather_data);
GtkWidget *refresh, *forecast;
datas lbl;
GdkPixbuf *icon = NULL;
@@ -799,8 +773,8 @@ xfceweather_create_control (XfcePanelPlugin *plugin)
#endif
data->scrollbox = gtk_scrollbox_new ();
- icon = get_icon ("99", 16);
- data->iconimage = gtk_image_new_from_pixbuf (icon);
+ icon = get_icon ("99", -1);
+ data->iconimage = xfce_scaled_image_new_from_pixbuf (icon);
if (G_LIKELY (icon))
g_object_unref (G_OBJECT (icon));
@@ -810,9 +784,9 @@ xfceweather_create_control (XfcePanelPlugin *plugin)
data->vbox_center_scrollbox = gtk_vbox_new(FALSE, 0);
data->top_hbox = gtk_hbox_new (FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (data->iconimage), 1, 0.5);
- gtk_box_pack_start (GTK_BOX (data->top_hbox), data->iconimage, TRUE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (data->top_hbox), data->iconimage, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (data->vbox_center_scrollbox), data->scrollbox, TRUE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (data->top_hbox), data->vbox_center_scrollbox, TRUE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (data->top_hbox), data->vbox_center_scrollbox, FALSE, TRUE, 0);
data->top_vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (data->top_vbox), data->top_hbox, TRUE, FALSE, 0);
@@ -912,7 +886,7 @@ xfceweather_free (XfcePanelPlugin *plugin,
/* Free Array */
g_array_free (data->labels, TRUE);
- panel_slice_free (xfceweather_data, data);
+ g_slice_free (xfceweather_data, data);
}
@@ -1004,4 +978,4 @@ weather_construct (XfcePanelPlugin *plugin)
update_weatherdata (data);
}
-XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (weather_construct);
+XFCE_PANEL_PLUGIN_REGISTER (weather_construct);
diff --git a/panel-plugin/weather.desktop.in.in b/panel-plugin/weather.desktop.in.in
index c4c7b23..e1ed111 100644
--- a/panel-plugin/weather.desktop.in.in
+++ b/panel-plugin/weather.desktop.in.in
@@ -1,8 +1,9 @@
[Xfce Panel]
Type=X-XFCE-PanelPlugin
-Encoding=UTF-8
_Name=Weather Update
_Comment=Show current weather conditions
Icon=xfce4-weather
-X-XFCE-Exec=@libexecdir@/xfce4/panel-plugins/xfce4-weather-plugin
+X-XFCE-Module=weather
+X-XFCE-Module-Path=@libdir@/xfce4/panel-plugins
+X-XFCE-Internal=FALSE
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
index a553b10..35b9e8d 100644
--- a/panel-plugin/weather.h
+++ b/panel-plugin/weather.h
@@ -20,8 +20,9 @@
#ifndef __WEATHER_H__
#define __WEATHER_H__
-#include <libxfce4panel/xfce-panel-plugin.h>
+#include <libxfce4panel/libxfce4panel.h>
#include <libxfce4util/libxfce4util.h>
+
#define PLUGIN_WEBSITE "http://goodies.xfce.org/projects/panel-plugins/xfce4-weather-plugin"
#define PARTNER_ID "1121946239"
#define LICENSE_KEY "3c4cd39ee5dec84f"