new clock plugin

Foxy foxy at on-the-hill.me.uk
Sun Oct 23 12:11:26 CEST 2005


Brian J. Tarricone wrote:

>Hey Jasper & all,
>
>I spent a few hours and rewrote the clock plugin from scratch.  It's
>basically datetime with a bunch of pre-selected time/date formats and
>the ability to enter custom format strings.  I probably should have just
>modified datetime, but I wanted to write a plugin from scratch with the
>new panel interface (was damned easy).
>
>Anyway, patch attached.  If you like the direction I'm taking with it,
>feel free to commit and I'll finish it later.
>
>Stuff that's missing:
>* LED view (do we care?)
>  
>
personally I do not...

>* analog view (do we care?)
>  
>
I love analogue clock

>* ability to set different fonts (do we care?)
>  
>
would be nice

>* tooltip (yes, we care)
>
>We can also debate what the pre-selected date/time formats should be
>later ^_~.
>
>Note that the patch needs a one-line change to configure.ac, so be sure
>to rerun autogen.
>
>	-brian
>
>  
>
>------------------------------------------------------------------------
>
>Index: plugins/clock/clock.c
>===================================================================
>--- plugins/clock/clock.c	(revision 18423)
>+++ plugins/clock/clock.c	(working copy)
>@@ -1,486 +1,797 @@
>-/* vim: set expandtab ts=8 sw=4: */
>-
>-/*  $Id$
>+/*
>+ * clock plugin for the xfce4 panel
>  *
>- *  Copyright © 2005 The Xfce Development Team
>+ * Copyright (c) 2005 Brian Tarricone <bjt23 at cornell.edu>
>  *
>- *  This program is free software; you can redistribute it and/or modify
>- *  it under the terms of the GNU Library 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 Library 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.
>- *
>- *  Authors:
>- *      Jasper Huijsmans <jasper at xfce.org>
>- *      Jannis Pohlmann <info at sten-net.de>
>+ * 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; version 2 of the License ONLY.
>+ * 
>+ * 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
> 
>-#ifdef HAVE_SYS_STAT_H
>-#include <sys/stat.h>
>+#ifdef HAVE_TIME_H
>+#include <time.h>
> #endif
> 
>-#ifdef HAVE_MEMORY_H
>-#include <memory.h>
>-#endif
>-#include <stdio.h>
> #ifdef HAVE_STRING_H
> #include <string.h>
> #endif
>-#ifdef HAVE_TIME_H
>-#include <time.h>
>-#endif
>-#ifdef HAVE_UNISTD_H
>-#include <unistd.h>
>-#endif
> 
>-#include <gtk/gtk.h>
>-#include <gdk/gdkevents.h>
>-
> #include <libxfce4util/libxfce4util.h>
> #include <libxfcegui4/libxfcegui4.h>
> #include <libxfce4panel/xfce-panel-plugin.h>
> 
>+typedef enum
>+{
>+    CLOCK_LAYOUT_DATE_ONLY = 0,
>+    CLOCK_LAYOUT_TIME_ONLY,
>+    CLOCK_LAYOUT_DATE_TIME,
>+    CLOCK_LAYOUT_TIME_DATE,
>+    CLOCK_LAYOUT_DATE_ABOVE_TIME,
>+    CLOCK_LAYOUT_TIME_ABOVE_DATE,
>+    N_CLOCK_LAYOUTS,
>+} XfceClockLayout;
>+
>+static const gchar *clock_layout_strs[] = {
>+    N_("Date only"),
>+    N_("Time only"),
>+    N_("Date, then time"),
>+    N_("Time, then date"),
>+    N_("Date above time"),
>+    N_("Time above date"),
>+};
>+
> typedef struct
> {
>     XfcePanelPlugin *plugin;
>-
>+    
>     GtkWidget *frame;
>-    GtkWidget *clock;
>-    GtkTooltips *tips;
>-
>-    int timeout_id;
>-
>-    /* Settings */
>-    int mode;
>-    gboolean military;
>-    gboolean ampm;
>-    gboolean secs;
>-
>+    GtkWidget *label;
>+    
>+    guint clock_timeout;
>+    gchar *overall_format;
>+    gint max_width;
>+    
>     gboolean show_frame;
>-}
>-Clock;
>+    
>+    guint builtin_time_format;
>+    gboolean use_custom_time_format;
>+    gchar *custom_time_format;
>+    PangoFontDescription *time_font;
>+    
>+    guint builtin_date_format;
>+    gboolean use_custom_date_format;
>+    gchar *custom_date_format;
>+    PangoFontDescription *date_font;
>+    
>+    XfceClockLayout layout;
>+} XfceClockPlugin;
> 
>-static void clock_properties_dialog (XfcePanelPlugin *plugin, 
>-                                     Clock *clock);
>+typedef struct
>+{
>+    XfceClockPlugin *clock_plugin;
>+    
>+    GtkWidget *dlg;
>+    
>+    GtkWidget *date_frame;
>+    GtkWidget *date_custom_box;
>+    GtkWidget *date_font;
>+    
>+    GtkWidget *time_frame;
>+    GtkWidget *time_custom_box;
>+    GtkWidget *time_font;
>+} XfceClockConfig;
> 
>-static void clock_construct (XfcePanelPlugin *plugin);
>+static const gchar *builtin_time_formats[] = {
>+    "%H:%M",
>+    "%H:%M:%S",
>+    "%I:%M %P",
>+    "%I:%M:%S %P",
>+};
>+#define N_TIME_FORMATS       4
>+#define DEFAULT_TIME_FORMAT  1
> 
>+static const gchar *builtin_date_formats[] = {
>+    "%Y/%m/%d",
>+    "%m/%d/%Y",
>+    "%B %d, %Y",
>+    "%b %d, %Y",
>+    "%A, %B %d, %Y",
>+    "%a, %b %d, %Y",
>+    "%d/%m/%Y",
>+    "%d %B %Y",
>+    "%d %b %Y",
>+    "%A, %d %B %Y",
>+    "%a, %d %b %Y",
>+};
>+#define N_DATE_FORMATS       11
>+#define DEFAULT_DATE_FORMAT  0
> 
>-/* -------------------------------------------------------------------- *
>- *                               Clock                                  *
>- * -------------------------------------------------------------------- */
>+#define BORDER 8
> 
>-static gboolean 
>-clock_date_tooltip (Clock *clock)
>+static gchar *
>+xfclock_get_overall_format(XfceClockPlugin *clock_plugin)
> {
>-    time_t ticks;
>-    struct tm *tm;
>-    static gint mday = -1;
>-    char date_s[255];
>-    char *utf8date = NULL;
>+    gchar *overall_format = NULL;
>+    const gchar *date_str, *time_str;
>+    
>+    /* TODO: handle fonts */
>+    
>+    if(clock_plugin->use_custom_date_format)
>+        date_str = clock_plugin->custom_date_format;
>+    else
>+        date_str = builtin_date_formats[clock_plugin->builtin_date_format];
>+    if(!date_str)
>+        date_str = " ";
>+    
>+    if(clock_plugin->use_custom_time_format)
>+        time_str = clock_plugin->custom_time_format;
>+    else
>+        time_str = builtin_time_formats[clock_plugin->builtin_time_format];
>+    if(!time_str)
>+        time_str = " ";
>+    
>+    switch(clock_plugin->layout) {
>+        case CLOCK_LAYOUT_DATE_ONLY:
>+            overall_format = g_strdup(date_str);
>+            break;
>+        
>+        case CLOCK_LAYOUT_TIME_ONLY:
>+            overall_format = g_strdup(time_str);
>+            break;
>+        
>+        case CLOCK_LAYOUT_DATE_TIME:
>+            overall_format = g_strconcat(date_str, " ", time_str, NULL);
>+            break;
>+        
>+        case CLOCK_LAYOUT_TIME_DATE:
>+            overall_format = g_strconcat(time_str, " ", date_str, NULL);
>+            break;
>+        
>+        case CLOCK_LAYOUT_DATE_ABOVE_TIME:
>+            overall_format = g_strconcat(date_str, "\n", time_str, NULL);
>+            break;
>+        
>+        case CLOCK_LAYOUT_TIME_ABOVE_DATE:
>+            overall_format = g_strconcat(time_str, "\n", date_str, NULL);
>+            break;
>+        
>+        default:
>+            g_critical("Invalid XfceClockLayout: %d", clock_plugin->layout);
>+            overall_format = g_strdup(builtin_time_formats[DEFAULT_TIME_FORMAT]);
>+            break;
>+    }
>+    
>+    return overall_format;
>+}
> 
>-    ticks = time (0);
>-    tm = localtime (&ticks);
>-
>-    if (mday != tm->tm_mday)
>-    {
>-        mday = tm->tm_mday;
>-
>-        /* Use format characters from strftime(3)
>-	 * to get the proper string for your locale.
>-	 * I used these:
>-	 * %A  : full weekday name
>-	 * %d  : day of the month
>-	 * %B  : full month name
>-	 * %Y  : four digit year
>-	 */
>-        strftime(date_s, 255, _("%A %d %B %Y"), tm);
>-
>-        /* Conversion to utf8
>-         * Patch by Oliver M. Bolzer <oliver at fakeroot.net>
>-         */
>-        if (!g_utf8_validate(date_s, -1, NULL)) 
>-        {
>-            utf8date = g_locale_to_utf8(date_s, -1, NULL, NULL, NULL);
>+static gboolean
>+xfclock_timeout(XfceClockPlugin *clock_plugin)
>+{
>+    time_t now = time(NULL);
>+    char buf[2048];
>+    gchar *timestr_utf8 = NULL;
>+    GtkRequisition req;
>+    gint w, h;
>+#ifdef HAVE_LOCALTIME_R
>+    struct tm real_tm;
>+    struct tm *tm_now = &real_tm;
>+    
>+    localtime_r(&now, tm_now);
>+#else
>+    struct *tm tm_now = localtime(&now);
>+#endif
>+    
>+    if(strftime(buf, 2048, clock_plugin->overall_format, tm_now) == 0)
>+        return TRUE;
>+    
>+    if(!g_utf8_validate(buf, -1, NULL)) {
>+        gsize read, written;
>+        GError *err = NULL;
>+        
>+        timestr_utf8 = g_locale_to_utf8(buf, -1, &read, &written, &err);
>+        if(!timestr_utf8) {
>+            g_critical("System strftime() returned string in strange locale (%d): %s",
>+                       err->code, err->message);
>+            g_error_free(err);
>+            timestr_utf8 = g_strconcat("<small>",  /* help out translators... */
>+                                       _("(UTF-8 conversion failed)"),
>+                                       "</small>", NULL);
>         }
>-
>-        if (utf8date)
>-        {
>-            gtk_tooltips_set_tip (clock->tips, GTK_WIDGET (clock->plugin), 
>-                                  utf8date, NULL);
>-            g_free (utf8date);
>-        }
>-        else
>-        {
>-            gtk_tooltips_set_tip (clock->tips, GTK_WIDGET (clock->plugin), 
>-                                  date_s, NULL);
>-        }
>-    } 
>-
>+    }
>+    
>+    gtk_label_set_markup(GTK_LABEL(clock_plugin->label),
>+                         timestr_utf8 ? timestr_utf8 : buf);
>+    
>+    g_free(timestr_utf8);
>+    
>+    /* the idea here is to force the plugin to allocate as much width as it
>+     * will ever need, and always keep that width.  that way, we will never
>+     * resize second-to-second if the text takes up more or less space due to
>+     * a changing value */
>+    gtk_widget_get_size_request(clock_plugin->label, &w, &h);
>+    gtk_widget_set_size_request(clock_plugin->label, -1, -1);
>+    gtk_widget_size_request(clock_plugin->label, &req);
>+    if(req.width > clock_plugin->max_width)
>+        clock_plugin->max_width = req.width;
>+    else {
>+        gtk_widget_set_size_request(clock_plugin->label,
>+                                    clock_plugin->max_width, h);
>+    }
>+    
>     return TRUE;
> }
> 
> static void
>-clock_update_size (Clock *clock, int size)
>+xfclock_config_changed(XfceClockPlugin *clock_plugin)
> {
>-    XfceClock *clk = XFCE_CLOCK (clock->clock);
>+    g_free(clock_plugin->overall_format);
>+    clock_plugin->overall_format = xfclock_get_overall_format(clock_plugin);
>+    
>+    clock_plugin->max_width = -1;
>+    
>+    xfclock_timeout(clock_plugin);
>+}
> 
>-    g_return_if_fail (clk != NULL);
>-    g_return_if_fail (GTK_IS_WIDGET (clk));
>-
>-    /* keep in sync with systray */
>-    if (size > 26)
>-    {
>-        gtk_container_set_border_width (GTK_CONTAINER (clock->frame), 2);
>-        size -= 3;
>+static gboolean
>+xfclock_read_config(XfceClockPlugin *clock_plugin)
>+{
>+    XfceRc *rcfile;
>+    char *filename;
>+    const gchar *str;
>+    
>+    filename = xfce_panel_plugin_save_location(clock_plugin->plugin, FALSE);
>+    if(!filename)
>+        return FALSE;
>+    
>+    rcfile = xfce_rc_simple_open(filename, TRUE);
>+    if(!rcfile) {
>+        g_free(filename);
>+        return FALSE;
>     }
>-    else
>-    {
>-        gtk_container_set_border_width (GTK_CONTAINER (clock->frame), 0);
>-        size -= 1;
>-    }
>     
>-    /* Replaced old 4-stage switch; Perhaps DIGIT_*_HEIGHT 
>-     * should be moved from xfce_clock.c to xfce_clock.h so we
>-     * can use them here (e.g. 10*2 => DIGIT_SMALL_HEIGHT*2)
>-     * */
>+    xfce_rc_set_group(rcfile, "plugin");
>+    clock_plugin->show_frame = xfce_rc_read_bool_entry(rcfile, "show_frame",
>+                                                       TRUE);
>+    clock_plugin->layout = xfce_rc_read_int_entry(rcfile, "layout",
>+                                                  CLOCK_LAYOUT_TIME_ONLY);
>+    if(clock_plugin->layout >= N_CLOCK_LAYOUTS)
>+        clock_plugin->layout = CLOCK_LAYOUT_TIME_ONLY;
>+    
>+    xfce_rc_set_group(rcfile, "date");
>+    clock_plugin->builtin_date_format = xfce_rc_read_int_entry(rcfile,
>+                                                               "builtin_format",
>+                                                               DEFAULT_DATE_FORMAT);
>+    if(clock_plugin->builtin_date_format >= N_DATE_FORMATS)
>+        clock_plugin->builtin_date_format = DEFAULT_DATE_FORMAT;
>+    clock_plugin->use_custom_date_format = xfce_rc_read_bool_entry(rcfile,
>+                                                                   "use_custom_format",
>+                                                                   FALSE);
>+    str = xfce_rc_read_entry(rcfile, "custom_format", NULL);
>+    if(str)
>+        clock_plugin->custom_date_format = g_strdup(str);
>+    str = xfce_rc_read_entry(rcfile, "font", NULL);
>+    if(str)
>+        clock_plugin->date_font = pango_font_description_from_string(str);
>+    
>+    xfce_rc_set_group(rcfile, "time");
>+    clock_plugin->builtin_time_format = xfce_rc_read_int_entry(rcfile,
>+                                                               "builtin_format",
>+                                                               DEFAULT_TIME_FORMAT);
>+    if(clock_plugin->builtin_time_format >= N_TIME_FORMATS)
>+        clock_plugin->builtin_time_format = DEFAULT_TIME_FORMAT;
>+    clock_plugin->use_custom_time_format = xfce_rc_read_bool_entry(rcfile,
>+                                                                   "use_custom_format",
>+                                                                   FALSE);
>+    str = xfce_rc_read_entry(rcfile, "custom_format", NULL);
>+    if(str)
>+        clock_plugin->custom_time_format = g_strdup(str);
>+    str = xfce_rc_read_entry(rcfile, "font", NULL);
>+    if(str)
>+        clock_plugin->time_font = pango_font_description_from_string(str);
>+    
>+    xfce_rc_close(rcfile);
>+    g_free(filename);
>+    
>+    clock_plugin->overall_format = xfclock_get_overall_format(clock_plugin);
>+    
>+    return TRUE;
>+}
> 
>-    if (size <= 10*2)
>-    {
>-        xfce_clock_set_led_size (clk, DIGIT_SMALL);
>+static XfceClockPlugin *
>+xfclock_plugin_new(XfcePanelPlugin *plugin)
>+{
>+    XfceClockPlugin *clock_plugin = g_new0(XfceClockPlugin, 1);
>+    
>+    clock_plugin->plugin = plugin;
>+    
>+    if(!xfclock_read_config(clock_plugin)) {
>+        clock_plugin->show_frame = TRUE;
>+        clock_plugin->layout = CLOCK_LAYOUT_TIME_ONLY;
>+        clock_plugin->builtin_date_format = DEFAULT_DATE_FORMAT;
>+        clock_plugin->builtin_time_format = DEFAULT_TIME_FORMAT;
>+        clock_plugin->overall_format = g_strdup(builtin_time_formats[DEFAULT_TIME_FORMAT]);
>     }
>-    else if (size <= 14*2) 
>-    {
>-        xfce_clock_set_led_size (clk, DIGIT_MEDIUM);
>-    } 
>-    else if (size <= 20*2) 
>-    {
>-        xfce_clock_set_led_size (clk, DIGIT_LARGE);
>-    }
>-    else 
>-    {
>-        xfce_clock_set_led_size (clk, DIGIT_HUGE);
>-    }
>-
>-    if ((xfce_clock_get_mode (clk) == XFCE_CLOCK_LEDS) ||
>-        (xfce_clock_get_mode (clk) == XFCE_CLOCK_DIGITAL))
>-    {
>-        gtk_widget_set_size_request (GTK_WIDGET (clk), -1, -1);
>-    }
>-    else
>-    {
>-        gtk_widget_set_size_request (GTK_WIDGET (clk), size, size);
>-    }
>-
>-    gtk_widget_queue_resize (GTK_WIDGET (clk));
>+    
>+    clock_plugin->frame = gtk_frame_new(NULL);
>+    gtk_container_set_border_width(GTK_CONTAINER(clock_plugin->frame), BORDER/2);
>+    gtk_frame_set_shadow_type(GTK_FRAME(clock_plugin->frame),
>+                              clock_plugin->show_frame
>+                                  ? GTK_SHADOW_IN : GTK_SHADOW_NONE);
>+    gtk_widget_show(clock_plugin->frame);
>+    
>+    clock_plugin->label = gtk_label_new("");
>+    gtk_label_set_justify(GTK_LABEL(clock_plugin->label), GTK_JUSTIFY_CENTER);
>+    gtk_misc_set_alignment(GTK_MISC(clock_plugin->label), 0.5, 0.5);
>+    gtk_widget_show(clock_plugin->label);
>+    gtk_container_add(GTK_CONTAINER(clock_plugin->frame), clock_plugin->label);
>+    
>+    return clock_plugin;
> }
> 
>-
>-/* -------------------------------------------------------------------- *
>- *                     Panel Plugin Interface                           *
>- * -------------------------------------------------------------------- */
>-
>-/* Register with the panel */
>-
>-XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (clock_construct);
>-
>-
>-/* Interface Implementation */
>-
>-static gboolean 
>-clock_set_size (XfcePanelPlugin *plugin, int size, Clock *clock)
>+static void
>+xfclock_config_layout_changed_cb(GtkComboBox *combo,
>+                                 XfceClockConfig *clock_config)
> {
>-    clock_update_size(clock, size);
>-
>-    return TRUE;
>+    clock_config->clock_plugin->layout = gtk_combo_box_get_active(combo);
>+    
>+    if(clock_config->clock_plugin->layout == CLOCK_LAYOUT_DATE_ONLY) {
>+        gtk_widget_set_sensitive(clock_config->date_frame, TRUE);
>+        gtk_widget_set_sensitive(clock_config->time_frame, FALSE);
>+        if(!clock_config->clock_plugin->use_custom_date_format)
>+            gtk_widget_set_sensitive(clock_config->date_custom_box, FALSE);
>+    } else if(clock_config->clock_plugin->layout == CLOCK_LAYOUT_TIME_ONLY) {
>+        gtk_widget_set_sensitive(clock_config->date_frame, FALSE);
>+        gtk_widget_set_sensitive(clock_config->time_frame, TRUE);
>+        if(!clock_config->clock_plugin->use_custom_time_format)
>+            gtk_widget_set_sensitive(clock_config->time_custom_box, FALSE);
>+    } else {
>+        gtk_widget_set_sensitive(clock_config->date_frame, TRUE);
>+        gtk_widget_set_sensitive(clock_config->time_frame, TRUE);
>+        if(!clock_config->clock_plugin->use_custom_date_format)
>+            gtk_widget_set_sensitive(clock_config->date_custom_box, FALSE);
>+        if(!clock_config->clock_plugin->use_custom_time_format)
>+            gtk_widget_set_sensitive(clock_config->time_custom_box, FALSE);
>+    }
>+    
>+    xfclock_config_changed(clock_config->clock_plugin);
> }
> 
> static void
>-clock_free_data (XfcePanelPlugin *plugin, Clock *clock)
>+xfclock_config_frame_toggled_cb(GtkToggleButton *tb,
>+                                XfceClockConfig *clock_config)
> {
>-    g_source_remove (clock->timeout_id);
>-    g_object_unref (clock->tips);
>-    g_free (clock);
>+    clock_config->clock_plugin->show_frame = gtk_toggle_button_get_active(tb);
>+    gtk_frame_set_shadow_type(GTK_FRAME(clock_config->clock_plugin->frame),
>+                              clock_config->clock_plugin->show_frame
>+                                  ? GTK_SHADOW_IN : GTK_SHADOW_NONE);
> }
> 
> static void
>-clock_read_rc_file (XfcePanelPlugin *plugin, Clock* clock)
>+xfclock_config_time_fmt_changed_cb(GtkComboBox *combo,
>+                                   XfceClockConfig *clock_config)
> {
>-    char *file;
>-    XfceRc *rc;
>-    int mode;
>-    gboolean military, ampm, secs, show_frame;
>-
>-    mode = XFCE_CLOCK_DIGITAL;
>-    military = TRUE;
>-    ampm = FALSE;
>-    secs = FALSE;
>-    show_frame = TRUE;
>+    gint setting = gtk_combo_box_get_active(combo);
>     
>-    if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL)
>-    {
>-        rc = xfce_rc_simple_open (file, TRUE);
>-        g_free (file);
>-
>-        if (rc != NULL)
>-        {
>-            mode = xfce_rc_read_int_entry (rc, "mode", XFCE_CLOCK_DIGITAL);
>-            military = xfce_rc_read_bool_entry (rc, "military", TRUE);
>-            ampm = xfce_rc_read_bool_entry (rc, "ampm", FALSE);
>-            secs = xfce_rc_read_bool_entry (rc, "secs", FALSE);
>-            show_frame = xfce_rc_read_bool_entry (rc, "show_frame", TRUE);
>-            xfce_rc_close (rc);
>-        }
>+    if(setting == N_TIME_FORMATS) {
>+        clock_config->clock_plugin->use_custom_time_format = TRUE;
>+        gtk_widget_set_sensitive(clock_config->time_custom_box, TRUE);
>+    } else {
>+        clock_config->clock_plugin->builtin_time_format = setting;
>+        clock_config->clock_plugin->use_custom_time_format = FALSE;
>+        gtk_widget_set_sensitive(clock_config->time_custom_box, FALSE);
>     }
>-
>-    clock->mode = mode;
>-    clock->military = military;
>-    clock->ampm = ampm;
>-    clock->secs = secs;
>-
>-    xfce_clock_set_mode (XFCE_CLOCK (clock->clock), mode);
>-    xfce_clock_show_military (XFCE_CLOCK (clock->clock), military);
>-    xfce_clock_show_ampm (XFCE_CLOCK (clock->clock), ampm);
>-    xfce_clock_show_secs (XFCE_CLOCK (clock->clock), secs);
>     
>-    clock->show_frame = show_frame;
>-    gtk_frame_set_shadow_type (GTK_FRAME (clock->frame), 
>-                               show_frame ? GTK_SHADOW_IN : GTK_SHADOW_NONE);
>-    
>-    clock_update_size (clock, 
>-            xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
>+    xfclock_config_changed(clock_config->clock_plugin);
> }
> 
> static void
>-clock_write_rc_file (XfcePanelPlugin *plugin, Clock *clock)
>+xfclock_config_date_fmt_changed_cb(GtkComboBox *combo,
>+                                   XfceClockConfig *clock_config)
> {
>-    char *file;
>-    XfceRc *rc;
>+    gint setting = gtk_combo_box_get_active(combo);
>     
>-    if (!(file = xfce_panel_plugin_save_location (plugin, TRUE)))
>-        return;
>-
>-    rc = xfce_rc_simple_open (file, FALSE);
>-    g_free (file);
>-
>-    if (!rc)
>-        return;
>-
>-    xfce_rc_write_int_entry (rc, "mode", clock->mode);
>-    xfce_rc_write_bool_entry (rc, "military", clock->military);
>-    xfce_rc_write_bool_entry (rc, "ampm", clock->ampm);
>-    xfce_rc_write_bool_entry (rc, "secs", clock->secs);
>-    xfce_rc_write_bool_entry (rc, "show_frame", clock->show_frame);
>+    if(setting == N_DATE_FORMATS) {
>+        clock_config->clock_plugin->use_custom_date_format = TRUE;
>+        gtk_widget_set_sensitive(clock_config->date_custom_box, TRUE);
>+    } else {
>+        clock_config->clock_plugin->builtin_date_format = setting;
>+        clock_config->clock_plugin->use_custom_date_format = FALSE;
>+        gtk_widget_set_sensitive(clock_config->date_custom_box, FALSE);
>+    }
>     
>-    xfce_rc_close (rc);
>+    xfclock_config_changed(clock_config->clock_plugin);
> }
> 
>-/* Create widgets and connect to signals */
>-
>-static void 
>-clock_construct (XfcePanelPlugin *plugin)
>+static gboolean
>+xfclock_config_custom_time_focus_out_cb(GtkWidget *w,
>+                                        GdkEventFocus *evt,
>+                                        XfceClockConfig *clock_config)
> {
>-    Clock *clock = g_new0 (Clock, 1);
>-
>-    clock->plugin = plugin;
>-
>-    g_signal_connect (plugin, "size-changed", 
>-                      G_CALLBACK (clock_set_size), clock);
>+    gchar *str = gtk_editable_get_chars(GTK_EDITABLE(w), 0, -1);
>     
>-    g_signal_connect (plugin, "free-data", 
>-                      G_CALLBACK (clock_free_data), clock);
>+    if(str && clock_config->clock_plugin->custom_time_format
>+                && strcmp(str, clock_config->clock_plugin->custom_time_format))
>+    {
>+        /* hasn't changed */
>+        g_free(str);
>+        return FALSE;
>+    }
>     
>-    g_signal_connect (plugin, "save", 
>-                      G_CALLBACK (clock_write_rc_file), clock);
>+    g_free(clock_config->clock_plugin->custom_time_format);
>+    clock_config->clock_plugin->custom_time_format = str;
>     
>-    xfce_panel_plugin_menu_show_configure (plugin);
>-    g_signal_connect (plugin, "configure-plugin", 
>-                      G_CALLBACK (clock_properties_dialog), clock);
>-
>-    clock->frame = gtk_frame_new (NULL);
>-    gtk_widget_show (clock->frame);
>-    gtk_container_add (GTK_CONTAINER (plugin), clock->frame);
>-
>-    clock->clock = xfce_clock_new ();
>-    gtk_widget_show (clock->clock);
>-    gtk_container_add (GTK_CONTAINER (clock->frame), clock->clock);
>-
>-    clock_read_rc_file (plugin, clock);
>+    xfclock_config_changed(clock_config->clock_plugin);
>     
>-    clock->tips = gtk_tooltips_new ();
>-    g_object_ref (clock->tips);
>-    gtk_object_sink (GTK_OBJECT (clock->tips));
>-        
>-    clock_date_tooltip (clock);
>-
>-    clock->timeout_id = 
>-        g_timeout_add (60000, (GSourceFunc) clock_date_tooltip, clock);
>+    return FALSE;
> }
> 
>-/* -------------------------------------------------------------------- *
>- *                        Configuration Dialog                          *
>- * -------------------------------------------------------------------- */
>-
>-static void
>-clock_show_frame_toggled (GtkToggleButton *cb, Clock *clock)
>+static gboolean
>+xfclock_config_custom_date_focus_out_cb(GtkWidget *w,
>+                                        GdkEventFocus *evt,
>+                                        XfceClockConfig *clock_config)
> {
>-    clock->show_frame = gtk_toggle_button_get_active (cb);
>-
>-    gtk_frame_set_shadow_type (GTK_FRAME (clock->frame), clock->show_frame ?
>-                               GTK_SHADOW_IN : GTK_SHADOW_NONE);
>+    gchar *str = gtk_editable_get_chars(GTK_EDITABLE(w), 0, -1);
>+    
>+    if(str && clock_config->clock_plugin->custom_date_format
>+                && strcmp(str, clock_config->clock_plugin->custom_date_format))
>+    {
>+        /* hasn't changed */
>+        g_free(str);
>+        return FALSE;
>+    }
>+    
>+    g_free(clock_config->clock_plugin->custom_date_format);
>+    clock_config->clock_plugin->custom_date_format = str;
>+    
>+    xfclock_config_changed(clock_config->clock_plugin);
>+    
>+    return FALSE;
> }
> 
> static void
>-clock_military_toggled (GtkToggleButton *cb, Clock *clock)
>+xfclock_configure_plugin_cb(XfcePanelPlugin *plugin,
>+                            XfceClockPlugin *clock_plugin)
> {
>-    clock->military = gtk_toggle_button_get_active (cb);
>-    xfce_clock_show_military (XFCE_CLOCK (clock->clock), clock->military);
>+    XfceClockConfig *clock_config = g_new0(XfceClockConfig, 1);
>+    GtkWidget *header, *frame, *frame_bin, *topvbox, *vbox, *hbox, *lbl, *chk,
>+              *combo, *entry;
>+    gint i;
>+    char buf[2048];
>+    gchar *timestr_utf8;
>+    time_t now = time(NULL);
>+#ifdef HAVE_LOCALTIME_R
>+    struct tm real_tm;
>+    struct tm *tm_now = &real_tm;
>     
>-    clock_update_size (clock, 
>-            xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (clock->plugin)));
>+    localtime_r(&now, tm_now);
>+#else
>+    struct *tm tm_now = localtime(&now);
>+#endif
>+    
>+    clock_config->clock_plugin = clock_plugin;
>+    
>+    clock_config->dlg = gtk_dialog_new_with_buttons(_("Clock Properties"),
>+                                                    GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(plugin))),
>+                                                    GTK_DIALOG_DESTROY_WITH_PARENT
>+                                                    | GTK_DIALOG_NO_SEPARATOR,
>+                                                    GTK_STOCK_CLOSE,
>+                                                    GTK_RESPONSE_ACCEPT, NULL);
>+    g_signal_connect(G_OBJECT(clock_config->dlg), "response",
>+                     G_CALLBACK(gtk_widget_destroy), NULL);
>+    g_signal_connect_swapped(G_OBJECT(clock_config->dlg), "destroy",
>+                             G_CALLBACK(g_free), clock_config);
>+    topvbox = GTK_DIALOG(clock_config->dlg)->vbox;
>+    
>+    header = xfce_create_header(NULL, _("Clock"));
>+    gtk_widget_set_size_request(GTK_BIN(header)->child, 200, 32);
>+    gtk_container_set_border_width(GTK_CONTAINER(header), BORDER/2);
>+    gtk_widget_show(header);
>+    gtk_box_pack_start(GTK_BOX(topvbox), header, FALSE, TRUE, 0);
>+    
>+    frame = xfce_create_framebox(_("Appearance"), &frame_bin);
>+    gtk_widget_show(frame);
>+    gtk_box_pack_start(GTK_BOX(topvbox), frame, FALSE, FALSE, 0);
>+    
>+    vbox = gtk_vbox_new(FALSE, BORDER/2);
>+    gtk_widget_show(vbox);
>+    gtk_container_add(GTK_CONTAINER(frame_bin), vbox);
>+    
>+    chk = gtk_check_button_new_with_mnemonic(_("Show _Frame"));
>+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk),
>+                                 clock_plugin->show_frame);
>+    gtk_widget_show(chk);
>+    gtk_box_pack_start(GTK_BOX(vbox), chk, FALSE, FALSE, 0);
>+    g_signal_connect(G_OBJECT(chk), "toggled",
>+                     G_CALLBACK(xfclock_config_frame_toggled_cb), clock_config);
>+    
>+    hbox = gtk_hbox_new(FALSE, BORDER/2);
>+    gtk_widget_show(hbox);
>+    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
>+    
>+    lbl = gtk_label_new(_("Display Layout:"));
>+    gtk_widget_show(lbl);
>+    gtk_box_pack_start(GTK_BOX(hbox), lbl, FALSE, FALSE, 0);
>+    
>+    combo = gtk_combo_box_new_text();
>+    for(i = 0; i < N_CLOCK_LAYOUTS; i++)
>+        gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _(clock_layout_strs[i]));
>+    gtk_combo_box_set_active(GTK_COMBO_BOX(combo), clock_plugin->layout);
>+    gtk_widget_show(combo);
>+    gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0);
>+    g_signal_connect(G_OBJECT(combo), "changed",
>+                     G_CALLBACK(xfclock_config_layout_changed_cb), clock_config);
>+    
>+    clock_config->time_frame = frame = xfce_create_framebox(_("Time Format"),
>+                                                            &frame_bin);
>+    gtk_widget_show(frame);
>+    gtk_box_pack_start(GTK_BOX(topvbox), frame, FALSE, FALSE, 0);
>+    
>+    vbox = gtk_vbox_new(FALSE, BORDER/2);
>+    gtk_widget_show(vbox);
>+    gtk_container_add(GTK_CONTAINER(frame_bin), vbox);
>+    
>+    combo = gtk_combo_box_new_text();
>+    for(i = 0; i < N_TIME_FORMATS; i++) {
>+        timestr_utf8 = NULL;
>+        
>+        if(strftime(buf, 2048, builtin_time_formats[i], tm_now) == 0) {
>+            gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
>+                                      _("(Unable to show format)"));
>+            continue;
>+        }
>+        
>+        if(!g_utf8_validate(buf, -1, NULL)) {
>+            gsize read, written;
>+            GError *err = NULL;
>+            
>+            timestr_utf8 = g_locale_to_utf8(buf, -1, &read, &written, &err);
>+            if(!timestr_utf8) {
>+                g_critical("System strftime() returned string in strange locale (%d): %s",
>+                           err->code, err->message);
>+                g_error_free(err);
>+                timestr_utf8 = g_strdup(_("(UTF-8 conversion failed)"));
>+            }
>+        }
>+        
>+        gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
>+                                  timestr_utf8 ? timestr_utf8 : buf);
>+        g_free(timestr_utf8);
>+    }
>+    gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Custom..."));
>+    if(clock_plugin->use_custom_time_format)
>+        gtk_combo_box_set_active(GTK_COMBO_BOX(combo), N_TIME_FORMATS);
>+    else {
>+        gtk_combo_box_set_active(GTK_COMBO_BOX(combo),
>+                                 clock_plugin->builtin_time_format);
>+    }
>+    gtk_widget_show(combo);
>+    gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
>+    g_signal_connect(G_OBJECT(combo), "changed",
>+                     G_CALLBACK(xfclock_config_time_fmt_changed_cb), clock_config);
>+    
>+    clock_config->time_custom_box = hbox = gtk_hbox_new(FALSE, BORDER/2);
>+    gtk_widget_show(hbox);
>+    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
>+    
>+    lbl = gtk_label_new_with_mnemonic(_("Custom _time format:"));
>+    gtk_widget_show(lbl);
>+    gtk_box_pack_start(GTK_BOX(hbox), lbl, FALSE, FALSE, 0);
>+    
>+    entry = gtk_entry_new();
>+    if(clock_plugin->custom_time_format)
>+        gtk_entry_set_text(GTK_ENTRY(entry), clock_plugin->custom_time_format);
>+    gtk_widget_show(entry);
>+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
>+    g_signal_connect(G_OBJECT(entry), "focus-out-event",
>+                     G_CALLBACK(xfclock_config_custom_time_focus_out_cb),
>+                     clock_config);
>+    gtk_label_set_mnemonic_widget(GTK_LABEL(lbl), entry);
>+    
>+    if(clock_plugin->layout == CLOCK_LAYOUT_DATE_ONLY)
>+        gtk_widget_set_sensitive(frame, FALSE);
>+    else if(!clock_plugin->use_custom_time_format)
>+        gtk_widget_set_sensitive(hbox, FALSE);
>+    
>+    clock_config->date_frame = frame = xfce_create_framebox(_("Date Format"),
>+                                                            &frame_bin);
>+    gtk_widget_show(frame);
>+    gtk_box_pack_start(GTK_BOX(topvbox), frame, FALSE, FALSE, 0);
>+    
>+    vbox = gtk_vbox_new(FALSE, BORDER/2);
>+    gtk_widget_show(vbox);
>+    gtk_container_add(GTK_CONTAINER(frame_bin), vbox);
>+    
>+    combo = gtk_combo_box_new_text();
>+    for(i = 0; i < N_DATE_FORMATS; i++) {
>+        timestr_utf8 = NULL;
>+        
>+        if(strftime(buf, 2048, builtin_date_formats[i], tm_now) == 0) {
>+            gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
>+                                      _("(Unable to show format)"));
>+            continue;
>+        }
>+        
>+        if(!g_utf8_validate(buf, -1, NULL)) {
>+            gsize read, written;
>+            GError *err = NULL;
>+            
>+            timestr_utf8 = g_locale_to_utf8(buf, -1, &read, &written, &err);
>+            if(!timestr_utf8) {
>+                g_critical("System strftime() returned string in strange locale (%d): %s",
>+                           err->code, err->message);
>+                g_error_free(err);
>+                timestr_utf8 = g_strdup(_("(UTF-8 conversion failed)"));
>+            }
>+        }
>+        
>+        gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
>+                                  timestr_utf8 ? timestr_utf8 : buf);
>+        g_free(timestr_utf8);
>+    }
>+    gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Custom..."));
>+    if(clock_plugin->use_custom_date_format)
>+        gtk_combo_box_set_active(GTK_COMBO_BOX(combo), N_DATE_FORMATS);
>+    else {
>+        gtk_combo_box_set_active(GTK_COMBO_BOX(combo),
>+                                 clock_plugin->builtin_date_format);
>+    }
>+    gtk_widget_show(combo);
>+    gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
>+    g_signal_connect(G_OBJECT(combo), "changed",
>+                     G_CALLBACK(xfclock_config_date_fmt_changed_cb), clock_config);
>+    
>+    clock_config->date_custom_box = hbox = gtk_hbox_new(FALSE, BORDER/2);
>+    gtk_widget_show(hbox);
>+    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
>+    
>+    lbl = gtk_label_new_with_mnemonic(_("Custom _date format:"));
>+    gtk_widget_show(lbl);
>+    gtk_box_pack_start(GTK_BOX(hbox), lbl, FALSE, FALSE, 0);
>+    
>+    entry = gtk_entry_new();
>+    if(clock_plugin->custom_date_format)
>+        gtk_entry_set_text(GTK_ENTRY(entry), clock_plugin->custom_date_format);
>+    gtk_widget_show(entry);
>+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
>+    g_signal_connect(G_OBJECT(entry), "focus-out-event",
>+                     G_CALLBACK(xfclock_config_custom_date_focus_out_cb),
>+                     clock_config);
>+    gtk_label_set_mnemonic_widget(GTK_LABEL(lbl), entry);
>+    
>+    if(clock_plugin->layout == CLOCK_LAYOUT_TIME_ONLY)
>+        gtk_widget_set_sensitive(frame, FALSE);
>+    else if(!clock_plugin->use_custom_date_format)
>+        gtk_widget_set_sensitive(hbox, FALSE);
>+    
>+    gtk_widget_show(clock_config->dlg);
> }
> 
> static void
>-clock_ampm_toggled (GtkToggleButton *cb, Clock *clock)
>+xfclock_free_data_cb(XfcePanelPlugin *plugin,
>+                     XfceClockPlugin *clock_plugin)
> {
>-    clock->ampm = gtk_toggle_button_get_active(cb);
>-    xfce_clock_show_ampm (XFCE_CLOCK (clock->clock), clock->ampm);
>+    if(clock_plugin->clock_timeout)
>+        g_source_remove(clock_plugin->clock_timeout);
>     
>-    clock_update_size (clock, 
>-            xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (clock->plugin)));
>+    g_free(clock_plugin->overall_format);
>+    g_free(clock_plugin->custom_time_format);
>+    g_free(clock_plugin->custom_date_format);
>+    if(clock_plugin->time_font)
>+        pango_font_description_free(clock_plugin->time_font);
>+    if(clock_plugin->date_font)
>+        pango_font_description_free(clock_plugin->date_font);
>+    
>+    g_free(clock_plugin);
> }
> 
> static void
>-clock_secs_toggled (GtkToggleButton *cb, Clock *clock)
>+xfclock_save_cb(XfcePanelPlugin *plugin,
>+                XfceClockPlugin *clock_plugin)
> {
>-    clock->secs = gtk_toggle_button_get_active(cb);
>-    xfce_clock_show_secs (XFCE_CLOCK (clock->clock), clock->secs);
>+    XfceRc *rcfile;
>+    char *filename;
>     
>-    clock_update_size (clock, 
>-            xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (clock->plugin)));
>+    filename = xfce_panel_plugin_save_location(plugin, TRUE);
>+    if(!filename)
>+        return;
>+    
>+    rcfile = xfce_rc_simple_open(filename, FALSE);
>+    if(!rcfile) {
>+        g_free(filename);
>+        return;
>+    }
>+    
>+    xfce_rc_set_group(rcfile, "plugin");
>+    xfce_rc_write_bool_entry(rcfile, "show_frame", clock_plugin->show_frame);
>+    xfce_rc_write_int_entry(rcfile, "layout", clock_plugin->layout);
>+    
>+    xfce_rc_set_group(rcfile, "date");
>+    xfce_rc_write_int_entry(rcfile, "builtin_format",
>+                            clock_plugin->builtin_date_format);
>+    xfce_rc_write_bool_entry(rcfile, "use_custom_format",
>+                             clock_plugin->use_custom_date_format);
>+    if(clock_plugin->custom_date_format) {
>+        xfce_rc_write_entry(rcfile, "custom_format",
>+                            clock_plugin->custom_date_format);
>+    }
>+    if(clock_plugin->date_font) {
>+        gchar *str = pango_font_description_to_string(clock_plugin->date_font);
>+        xfce_rc_write_entry(rcfile, "font", str);
>+        g_free(str);
>+    }
>+    
>+    xfce_rc_set_group(rcfile, "time");
>+    xfce_rc_write_int_entry(rcfile, "builtin_format",
>+                            clock_plugin->builtin_time_format);
>+    xfce_rc_write_bool_entry(rcfile, "use_custom_format",
>+                             clock_plugin->use_custom_time_format);
>+    if(clock_plugin->custom_time_format) {
>+        xfce_rc_write_entry(rcfile, "custom_format",
>+                            clock_plugin->custom_time_format);
>+    }
>+    if(clock_plugin->time_font) {
>+        gchar *str = pango_font_description_to_string(clock_plugin->time_font);
>+        xfce_rc_write_entry(rcfile, "font", str);
>+        g_free(str);
>+    }
>+    
>+    xfce_rc_close(rcfile);
>+    g_free(filename);
> }
> 
>-static void
>-clock_mode_changed (GtkComboBox *cb, Clock *clock)
>+static gboolean
>+xfclock_size_changed_cb(XfcePanelPlugin *plugin,
>+                        gint size,
>+                        XfceClockPlugin *clock_plugin)
> {
>-    clock->mode = gtk_combo_box_get_active(cb);
>-    xfce_clock_set_mode (XFCE_CLOCK (clock->clock), clock->mode);
>+    if(GTK_ORIENTATION_HORIZONTAL == xfce_panel_plugin_get_orientation(plugin)) {
>+        /* ensure the clock doesn't force the panel larger */
>+        gtk_widget_set_size_request(clock_plugin->frame, -1, size);
>+        return TRUE;
>+    }
>     
>-    clock_update_size (clock, 
>-            xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (clock->plugin)));
>+    return FALSE;
> }
> 
> static void
>-clock_dialog_response (GtkWidget *dlg, int reponse, 
>-                       Clock *clock)
>+xfclock_construct(XfcePanelPlugin *plugin)
> {
>-    gtk_widget_destroy (dlg);
>-    xfce_panel_plugin_unblock_menu (clock->plugin);
>-    clock_write_rc_file (clock->plugin, clock);
>-}
>-
>-static void
>-clock_properties_dialog (XfcePanelPlugin *plugin, Clock *clock)
>-{
>-    GtkWidget *dlg, *header, *frame, *bin, *vbox, *cb;
>-
>-    xfce_panel_plugin_block_menu (plugin);
>+    XfceClockPlugin *clock_plugin;
>     
>-    dlg = gtk_dialog_new_with_buttons (_("Properties"), 
>-                GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
>-                GTK_DIALOG_DESTROY_WITH_PARENT |
>-                GTK_DIALOG_NO_SEPARATOR,
>-                GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
>-                NULL);
>+    xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
>     
>-    g_signal_connect (dlg, "response", G_CALLBACK (clock_dialog_response),
>-                      clock);
>-
>-    gtk_container_set_border_width (GTK_CONTAINER (dlg), 2);
>+    clock_plugin = xfclock_plugin_new(plugin);
>+    gtk_container_add(GTK_CONTAINER(plugin), clock_plugin->frame);
>     
>-    header = xfce_create_header (NULL, _("Clock"));
>-    gtk_widget_set_size_request (GTK_BIN (header)->child, 200, 32);
>-    gtk_container_set_border_width (GTK_CONTAINER (header), 6);
>-    gtk_widget_show (header);
>-    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), header,
>-                        FALSE, TRUE, 0);
>+    xfce_panel_plugin_add_action_widget(plugin, clock_plugin->frame);
>+    xfce_panel_plugin_menu_show_configure(plugin);
>     
>-    frame = xfce_create_framebox (_("Appearance"), &bin);
>-    gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
>-    gtk_widget_show (frame);
>-    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame,
>-                        FALSE, FALSE, 0);
>+    g_signal_connect(G_OBJECT(plugin), "configure-plugin",
>+                     G_CALLBACK(xfclock_configure_plugin_cb), clock_plugin);
>+    g_signal_connect(G_OBJECT(plugin), "free-data",
>+                     G_CALLBACK(xfclock_free_data_cb), clock_plugin);
>+    g_signal_connect(G_OBJECT(plugin), "save",
>+                     G_CALLBACK(xfclock_save_cb), clock_plugin);
>+    g_signal_connect(G_OBJECT(plugin), "size-changed",
>+                     G_CALLBACK(xfclock_size_changed_cb), clock_plugin);
>     
>-    vbox = gtk_vbox_new (FALSE, 8);
>-    gtk_widget_show (vbox);
>-    gtk_container_add (GTK_CONTAINER (bin), vbox);
>-
>-    cb = gtk_combo_box_new_text ();
>-    gtk_widget_show (cb);
>-    gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0);
>-
>-    /* Keep order in sync with XfceClockMode */
>-    gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("Analog"));
>-    gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("Digital"));
>-    gtk_combo_box_append_text (GTK_COMBO_BOX (cb), _("LED"));
>-    gtk_combo_box_set_active (GTK_COMBO_BOX (cb), clock->mode);
>-    g_signal_connect (cb, "changed", 
>-            G_CALLBACK (clock_mode_changed), clock);
>-
>-    cb = gtk_check_button_new_with_mnemonic (_("Show _frame"));
>-    gtk_widget_show (cb);
>-    gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0);
>-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb),
>-            clock->show_frame);
>-    g_signal_connect (cb, "toggled", G_CALLBACK (clock_show_frame_toggled), 
>-                      clock);
>+    clock_plugin->clock_timeout = g_timeout_add(1000,
>+                                                (GSourceFunc)xfclock_timeout,
>+                                                clock_plugin);
>     
>-    frame = xfce_create_framebox (_("Clock Options"), &bin);
>-    gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
>-    gtk_widget_show (frame);
>-    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame,
>-                        FALSE, FALSE, 0);
>-    
>-    vbox = gtk_vbox_new (FALSE, 8);
>-    gtk_widget_show (vbox);
>-    gtk_container_add (GTK_CONTAINER (bin), vbox);
>-
>-    cb = gtk_check_button_new_with_mnemonic (_("Use 24-_hour clock"));
>-    gtk_widget_show (cb);
>-    gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0);
>-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb),
>-            clock->military);
>-    g_signal_connect (cb, "toggled", G_CALLBACK (clock_military_toggled), 
>-            clock);
>-
>-    cb = gtk_check_button_new_with_mnemonic (_("Show AM/PM"));
>-    gtk_widget_show (cb);
>-    gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0);
>-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb),
>-            clock->ampm);
>-    g_signal_connect (cb, "toggled", G_CALLBACK (clock_ampm_toggled), 
>-            clock);
>-
>-    cb = gtk_check_button_new_with_mnemonic (_("Display seconds"));
>-    gtk_widget_show (cb);
>-    gtk_box_pack_start (GTK_BOX (vbox), cb, FALSE, FALSE, 0);
>-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb),
>-            clock->secs);
>-    g_signal_connect (cb, "toggled", G_CALLBACK (clock_secs_toggled), 
>-            clock);
>-
>-    gtk_widget_show (dlg);
> }
> 
>+XFCE_PANEL_PLUGIN_REGISTER_INTERNAL(xfclock_construct)
>Index: configure.ac
>===================================================================
>--- configure.ac	(revision 18423)
>+++ configure.ac	(working copy)
>@@ -44,7 +44,7 @@
> dnl Check for standard header files
> AC_HEADER_STDC
> AC_CHECK_HEADERS([signal.h stddef.h sys/wait.h time.h])
>-AC_CHECK_FUNCS([sigaction])
>+AC_CHECK_FUNCS([localtime_r sigaction])
> 
> dnl Check for i18n support
> XDT_I18N([ar az be bg bn_IN ca cs de el en_GB eo es_MX es et eu fa fi fr
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Xfce4-dev mailing list
>Xfce4-dev at xfce.org
>http://foo-projects.org/mailman/listinfo/xfce4-dev
>




More information about the Xfce4-dev mailing list