[Xfce4-commits] [apps/xfdashboard] 01/05: Move settings of clock view into a seperate object class to share it, e.g. with configure function of clock-view plugin
noreply at xfce.org
noreply at xfce.org
Tue Feb 23 22:35:12 CET 2016
This is an automated email from the git hooks/post-receive script.
nomad pushed a commit to branch master
in repository apps/xfdashboard.
commit 3cca65c529168c69154d4370fb405b189e006f3f
Author: Stephan Haller <nomad at froevel.de>
Date: Tue Feb 23 21:26:11 2016 +0100
Move settings of clock view into a seperate object class to share it, e.g. with configure function of clock-view plugin
---
plugins/clock-view/Makefile.am | 2 +
plugins/clock-view/clock-view-settings.c | 444 +++++++++++++++++++++++++++++++
plugins/clock-view/clock-view-settings.h | 81 ++++++
plugins/clock-view/clock-view.c | 362 ++-----------------------
plugins/clock-view/clock-view.h | 18 +-
plugins/clock-view/plugin.c | 2 +
6 files changed, 556 insertions(+), 353 deletions(-)
diff --git a/plugins/clock-view/Makefile.am b/plugins/clock-view/Makefile.am
index 4b4a45f..9eb6c74 100644
--- a/plugins/clock-view/Makefile.am
+++ b/plugins/clock-view/Makefile.am
@@ -15,6 +15,8 @@ plugin_LTLIBRARIES = \
clock_view_la_SOURCES = \
clock-view.c \
clock-view.h \
+ clock-view-settings.c \
+ clock-view-settings.h \
plugin.c
clock_view_la_CFLAGS = \
diff --git a/plugins/clock-view/clock-view-settings.c b/plugins/clock-view/clock-view-settings.c
new file mode 100644
index 0000000..8b4da12
--- /dev/null
+++ b/plugins/clock-view/clock-view-settings.c
@@ -0,0 +1,444 @@
+/*
+ * clock-view-settings: Shared object instance holding settings for plugin
+ *
+ * Copyright 2012-2016 Stephan Haller <nomad at froevel.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; 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 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "clock-view-settings.h"
+
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <math.h>
+
+#include <libxfdashboard/utils.h>
+#include <libxfdashboard/view.h>
+#include <libxfdashboard/fill-box-layout.h>
+#include <libxfdashboard/application.h>
+
+
+/* Define this class in GObject system */
+G_DEFINE_DYNAMIC_TYPE(XfdashboardClockViewSettings,
+ xfdashboard_clock_view_settings,
+ G_TYPE_OBJECT)
+
+/* Define this class in this plugin */
+XFDASHBOARD_DEFINE_PLUGIN_TYPE(xfdashboard_clock_view_settings);
+
+/* Private structure - access only by public API if needed */
+#define XFDASHBOARD_CLOCK_VIEW_SETTINGS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), XFDASHBOARD_TYPE_CLOCK_VIEW_SETTINGS, XfdashboardClockViewSettingsPrivate))
+
+struct _XfdashboardClockViewSettingsPrivate
+{
+ /* Properties related */
+ ClutterColor *hourColor;
+ ClutterColor *minuteColor;
+ ClutterColor *secondColor;
+ ClutterColor *backgroundColor;
+
+ /* Instance related */
+ XfconfChannel *xfconfChannel;
+ guint xfconfHourColorBindingID;
+ guint xfconfMinuteColorBindingID;
+ guint xfconfSecondColorBindingID;
+ guint xfconfBackgroundColorBindingID;
+};
+
+/* Properties */
+enum
+{
+ PROP_0,
+
+ PROP_HOUR_COLOR,
+ PROP_MINUTE_COLOR,
+ PROP_SECOND_COLOR,
+ PROP_BACKGROUOND_COLOR,
+
+ PROP_LAST
+};
+
+static GParamSpec* XfdashboardClockViewSettingsProperties[PROP_LAST]={ 0, };
+
+
+/* IMPLEMENTATION: Private variables and methods */
+
+#define XFDASHBOARD_XFCONF_CHANNEL "xfdashboard"
+
+#define COLOR_HOUR_XFCONF_PROP "/plugins/"PLUGIN_ID"/hour-color"
+#define COLOR_MINUTE_XFCONF_PROP "/plugins/"PLUGIN_ID"/minute-color"
+#define COLOR_SECOND_XFCONF_PROP "/plugins/"PLUGIN_ID"/second-color"
+#define COLOR_BACKGROUND_XFCONF_PROP "/plugins/"PLUGIN_ID"/background-color"
+
+
+/* IMPLEMENTATION: GObject */
+
+/* Dispose this object */
+static void _xfdashboard_clock_view_settings_dispose(GObject *inObject)
+{
+ XfdashboardClockViewSettings *self=XFDASHBOARD_CLOCK_VIEW_SETTINGS(inObject);
+ XfdashboardClockViewSettingsPrivate *priv=self->priv;
+
+ /* Release allocated resources */
+ if(priv->xfconfHourColorBindingID)
+ {
+ xfconf_g_property_unbind(priv->xfconfHourColorBindingID);
+ priv->xfconfHourColorBindingID=0;
+ }
+
+ if(priv->xfconfMinuteColorBindingID)
+ {
+ xfconf_g_property_unbind(priv->xfconfMinuteColorBindingID);
+ priv->xfconfMinuteColorBindingID=0;
+ }
+
+ if(priv->xfconfSecondColorBindingID)
+ {
+ xfconf_g_property_unbind(priv->xfconfSecondColorBindingID);
+ priv->xfconfSecondColorBindingID=0;
+ }
+
+ if(priv->xfconfBackgroundColorBindingID)
+ {
+ xfconf_g_property_unbind(priv->xfconfBackgroundColorBindingID);
+ priv->xfconfBackgroundColorBindingID=0;
+ }
+
+ if(priv->xfconfChannel)
+ {
+ priv->xfconfChannel=NULL;
+ }
+
+ if(priv->hourColor)
+ {
+ clutter_color_free(priv->hourColor);
+ priv->hourColor=NULL;
+ }
+
+ if(priv->minuteColor)
+ {
+ clutter_color_free(priv->minuteColor);
+ priv->minuteColor=NULL;
+ }
+
+ if(priv->secondColor)
+ {
+ clutter_color_free(priv->secondColor);
+ priv->secondColor=NULL;
+ }
+
+ /* Call parent's class dispose method */
+ G_OBJECT_CLASS(xfdashboard_clock_view_settings_parent_class)->dispose(inObject);
+}
+
+/* Set/get properties */
+static void _xfdashboard_clock_view_settings_set_property(GObject *inObject,
+ guint inPropID,
+ const GValue *inValue,
+ GParamSpec *inSpec)
+{
+ XfdashboardClockViewSettings *self=XFDASHBOARD_CLOCK_VIEW_SETTINGS(inObject);
+
+ switch(inPropID)
+ {
+ case PROP_HOUR_COLOR:
+ xfdashboard_clock_view_settings_set_hour_color(self, clutter_value_get_color(inValue));
+ break;
+
+ case PROP_MINUTE_COLOR:
+ xfdashboard_clock_view_settings_set_minute_color(self, clutter_value_get_color(inValue));
+ break;
+
+ case PROP_SECOND_COLOR:
+ xfdashboard_clock_view_settings_set_second_color(self, clutter_value_get_color(inValue));
+ break;
+
+ case PROP_BACKGROUOND_COLOR:
+ xfdashboard_clock_view_settings_set_background_color(self, clutter_value_get_color(inValue));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
+ break;
+ }
+}
+
+static void _xfdashboard_clock_view_settings_get_property(GObject *inObject,
+ guint inPropID,
+ GValue *outValue,
+ GParamSpec *inSpec)
+{
+ XfdashboardClockViewSettings *self=XFDASHBOARD_CLOCK_VIEW_SETTINGS(inObject);
+ XfdashboardClockViewSettingsPrivate *priv=self->priv;
+
+ switch(inPropID)
+ {
+ case PROP_HOUR_COLOR:
+ clutter_value_set_color(outValue, priv->hourColor);
+ break;
+
+ case PROP_MINUTE_COLOR:
+ clutter_value_set_color(outValue, priv->minuteColor);
+ break;
+
+ case PROP_SECOND_COLOR:
+ clutter_value_set_color(outValue, priv->secondColor);
+ break;
+
+ case PROP_BACKGROUOND_COLOR:
+ clutter_value_set_color(outValue, priv->backgroundColor);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
+ break;
+ }
+}
+
+/* Class initialization
+ * Override functions in parent classes and define properties
+ * and signals
+ */
+void xfdashboard_clock_view_settings_class_init(XfdashboardClockViewSettingsClass *klass)
+{
+ GObjectClass *gobjectClass=G_OBJECT_CLASS(klass);
+
+ /* Override functions */
+ gobjectClass->dispose=_xfdashboard_clock_view_settings_dispose;
+ gobjectClass->set_property=_xfdashboard_clock_view_settings_set_property;
+ gobjectClass->get_property=_xfdashboard_clock_view_settings_get_property;
+
+ /* Set up private structure */
+ g_type_class_add_private(klass, sizeof(XfdashboardClockViewSettingsPrivate));
+
+ /* Define properties */
+ XfdashboardClockViewSettingsProperties[PROP_HOUR_COLOR]=
+ clutter_param_spec_color("hour-color",
+ _("Hour color"),
+ _("Color to draw the hour hand with"),
+ CLUTTER_COLOR_LightChameleon,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ XfdashboardClockViewSettingsProperties[PROP_MINUTE_COLOR]=
+ clutter_param_spec_color("minute-color",
+ _("Minute color"),
+ _("Color to draw the minute hand with"),
+ CLUTTER_COLOR_LightChameleon,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ XfdashboardClockViewSettingsProperties[PROP_SECOND_COLOR]=
+ clutter_param_spec_color("second-color",
+ _("Sedond color"),
+ _("Color to draw the second hand with"),
+ CLUTTER_COLOR_White,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ XfdashboardClockViewSettingsProperties[PROP_BACKGROUOND_COLOR]=
+ clutter_param_spec_color("background-color",
+ _("Background color"),
+ _("Color to draw the circle with that holds the second hand"),
+ CLUTTER_COLOR_Blue,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardClockViewSettingsProperties);
+}
+
+/* Class finalization */
+void xfdashboard_clock_view_settings_class_finalize(XfdashboardClockViewSettingsClass *klass)
+{
+}
+
+/* Object initialization
+ * Create private structure and set up default values
+ */
+void xfdashboard_clock_view_settings_init(XfdashboardClockViewSettings *self)
+{
+ XfdashboardClockViewSettingsPrivate *priv;
+
+ self->priv=priv=XFDASHBOARD_CLOCK_VIEW_SETTINGS_GET_PRIVATE(self);
+
+ /* Set up default values */
+ priv->hourColor=clutter_color_copy(CLUTTER_COLOR_LightChameleon);
+ priv->minuteColor=clutter_color_copy(CLUTTER_COLOR_LightChameleon);
+ priv->secondColor=clutter_color_copy(CLUTTER_COLOR_White);
+ priv->backgroundColor=clutter_color_copy(CLUTTER_COLOR_Blue);
+ priv->xfconfChannel=xfconf_channel_get(XFDASHBOARD_XFCONF_CHANNEL);
+
+ /* Bind to xfconf to react on changes */
+ priv->xfconfHourColorBindingID=
+ xfconf_g_property_bind(priv->xfconfChannel,
+ COLOR_HOUR_XFCONF_PROP,
+ G_TYPE_STRING,
+ self,
+ "hour-color");
+
+ priv->xfconfMinuteColorBindingID=
+ xfconf_g_property_bind(priv->xfconfChannel,
+ COLOR_MINUTE_XFCONF_PROP,
+ G_TYPE_STRING,
+ self,
+ "minute-color");
+
+ priv->xfconfSecondColorBindingID=
+ xfconf_g_property_bind(priv->xfconfChannel,
+ COLOR_SECOND_XFCONF_PROP,
+ G_TYPE_STRING,
+ self,
+ "second-color");
+
+ priv->xfconfBackgroundColorBindingID=
+ xfconf_g_property_bind(priv->xfconfChannel,
+ COLOR_BACKGROUND_XFCONF_PROP,
+ G_TYPE_STRING,
+ self,
+ "background-color");
+}
+
+
+/* IMPLEMENTATION: Public API */
+
+/* Create new instance */
+XfdashboardClockViewSettings* xfdashboard_clock_view_settings_new(void)
+{
+ return(XFDASHBOARD_CLOCK_VIEW_SETTINGS(g_object_new(XFDASHBOARD_TYPE_CLOCK_VIEW_SETTINGS, NULL)));
+}
+
+/* Get/set color to draw hour hand with */
+const ClutterColor* xfdashboard_clock_view_settings_get_hour_color(XfdashboardClockViewSettings *self)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(self), NULL);
+
+ return(self->priv->hourColor);
+}
+
+void xfdashboard_clock_view_settings_set_hour_color(XfdashboardClockViewSettings *self, const ClutterColor *inColor)
+{
+ XfdashboardClockViewSettingsPrivate *priv;
+
+ g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(self));
+ g_return_if_fail(inColor);
+
+ priv=self->priv;
+
+ /* Set value if changed */
+ if(priv->hourColor==NULL ||
+ !clutter_color_equal(inColor, priv->hourColor))
+ {
+ /* Set value */
+ if(priv->hourColor) clutter_color_free(priv->hourColor);
+ priv->hourColor=clutter_color_copy(inColor);
+
+ /* Notify about property change */
+ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardClockViewSettingsProperties[PROP_HOUR_COLOR]);
+ }
+}
+
+/* Get/set color to draw minute hand with */
+const ClutterColor* xfdashboard_clock_view_settings_get_minute_color(XfdashboardClockViewSettings *self)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(self), NULL);
+
+ return(self->priv->minuteColor);
+}
+
+void xfdashboard_clock_view_settings_set_minute_color(XfdashboardClockViewSettings *self, const ClutterColor *inColor)
+{
+ XfdashboardClockViewSettingsPrivate *priv;
+
+ g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(self));
+ g_return_if_fail(inColor);
+
+ priv=self->priv;
+
+ /* Set value if changed */
+ if(priv->minuteColor==NULL ||
+ !clutter_color_equal(inColor, priv->minuteColor))
+ {
+ /* Set value */
+ if(priv->minuteColor) clutter_color_free(priv->minuteColor);
+ priv->minuteColor=clutter_color_copy(inColor);
+
+ /* Notify about property change */
+ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardClockViewSettingsProperties[PROP_MINUTE_COLOR]);
+ }
+}
+
+/* Get/set color to draw second hand with */
+const ClutterColor* xfdashboard_clock_view_settings_get_second_color(XfdashboardClockViewSettings *self)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(self), NULL);
+
+ return(self->priv->secondColor);
+}
+
+void xfdashboard_clock_view_settings_set_second_color(XfdashboardClockViewSettings *self, const ClutterColor *inColor)
+{
+ XfdashboardClockViewSettingsPrivate *priv;
+
+ g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(self));
+ g_return_if_fail(inColor);
+
+ priv=self->priv;
+
+ /* Set value if changed */
+ if(priv->secondColor==NULL ||
+ !clutter_color_equal(inColor, priv->secondColor))
+ {
+ /* Set value */
+ if(priv->secondColor) clutter_color_free(priv->secondColor);
+ priv->secondColor=clutter_color_copy(inColor);
+
+ /* Notify about property change */
+ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardClockViewSettingsProperties[PROP_SECOND_COLOR]);
+ }
+}
+
+/* Get/set color to draw background with that holds second hand */
+const ClutterColor* xfdashboard_clock_view_settings_get_background_color(XfdashboardClockViewSettings *self)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(self), NULL);
+
+ return(self->priv->backgroundColor);
+}
+
+void xfdashboard_clock_view_settings_set_background_color(XfdashboardClockViewSettings *self, const ClutterColor *inColor)
+{
+ XfdashboardClockViewSettingsPrivate *priv;
+
+ g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(self));
+ g_return_if_fail(inColor);
+
+ priv=self->priv;
+
+ /* Set value if changed */
+ if(priv->backgroundColor==NULL ||
+ !clutter_color_equal(inColor, priv->backgroundColor))
+ {
+ /* Set value */
+ if(priv->backgroundColor) clutter_color_free(priv->backgroundColor);
+ priv->backgroundColor=clutter_color_copy(inColor);
+
+ /* Notify about property change */
+ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardClockViewSettingsProperties[PROP_BACKGROUOND_COLOR]);
+ }
+}
diff --git a/plugins/clock-view/clock-view-settings.h b/plugins/clock-view/clock-view-settings.h
new file mode 100644
index 0000000..72889f4
--- /dev/null
+++ b/plugins/clock-view/clock-view-settings.h
@@ -0,0 +1,81 @@
+/*
+ * clock-view-settings: Shared object instance holding settings for plugin
+ *
+ * Copyright 2012-2016 Stephan Haller <nomad at froevel.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; 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 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ */
+
+#ifndef __XFDASHBOARD_CLOCK_VIEW_SETTINGS__
+#define __XFDASHBOARD_CLOCK_VIEW_SETTINGS__
+
+#include <libxfdashboard/plugin.h>
+#include <glib-object.h>
+#include <clutter/clutter.h>
+
+G_BEGIN_DECLS
+
+#define XFDASHBOARD_TYPE_CLOCK_VIEW_SETTINGS (xfdashboard_clock_view_settings_get_type())
+#define XFDASHBOARD_CLOCK_VIEW_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFDASHBOARD_TYPE_CLOCK_VIEW_SETTINGS, XfdashboardClockViewSettings))
+#define XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFDASHBOARD_TYPE_CLOCK_VIEW_SETTINGS))
+#define XFDASHBOARD_CLOCK_VIEW_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XFDASHBOARD_TYPE_CLOCK_VIEW_SETTINGS, XfdashboardClockViewSettingsClass))
+#define XFDASHBOARD_IS_CLOCK_VIEW_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), XFDASHBOARD_TYPE_CLOCK_VIEW_SETTINGS))
+#define XFDASHBOARD_CLOCK_VIEW_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XFDASHBOARD_TYPE_CLOCK_VIEW_SETTINGS, XfdashboardClockViewSettingsClass))
+
+typedef struct _XfdashboardClockViewSettings XfdashboardClockViewSettings;
+typedef struct _XfdashboardClockViewSettingsPrivate XfdashboardClockViewSettingsPrivate;
+typedef struct _XfdashboardClockViewSettingsClass XfdashboardClockViewSettingsClass;
+
+struct _XfdashboardClockViewSettings
+{
+ /* Parent instance */
+ GObject parent_instance;
+
+ /* Private structure */
+ XfdashboardClockViewSettingsPrivate *priv;
+};
+
+struct _XfdashboardClockViewSettingsClass
+{
+ /*< private >*/
+ /* Parent class */
+ GObjectClass parent_class;
+};
+
+/* Public API */
+GType xfdashboard_clock_view_settings_get_type(void) G_GNUC_CONST;
+
+XfdashboardClockViewSettings* xfdashboard_clock_view_settings_new(void);
+
+const ClutterColor* xfdashboard_clock_view_settings_get_hour_color(XfdashboardClockViewSettings *self);
+void xfdashboard_clock_view_settings_set_hour_color(XfdashboardClockViewSettings *self, const ClutterColor *inColor);
+
+const ClutterColor* xfdashboard_clock_view_settings_get_minute_color(XfdashboardClockViewSettings *self);
+void xfdashboard_clock_view_settings_set_minute_color(XfdashboardClockViewSettings *self, const ClutterColor *inColor);
+
+const ClutterColor* xfdashboard_clock_view_settings_get_second_color(XfdashboardClockViewSettings *self);
+void xfdashboard_clock_view_settings_set_second_color(XfdashboardClockViewSettings *self, const ClutterColor *inColor);
+
+const ClutterColor* xfdashboard_clock_view_settings_get_background_color(XfdashboardClockViewSettings *self);
+void xfdashboard_clock_view_settings_set_background_color(XfdashboardClockViewSettings *self, const ClutterColor *inColor);
+
+XFDASHBOARD_DECLARE_PLUGIN_TYPE(xfdashboard_clock_view_settings);
+
+G_END_DECLS
+
+#endif
diff --git a/plugins/clock-view/clock-view.c b/plugins/clock-view/clock-view.c
index 552734b..3752cc0 100644
--- a/plugins/clock-view/clock-view.c
+++ b/plugins/clock-view/clock-view.c
@@ -31,10 +31,12 @@
#include <gtk/gtk.h>
#include <math.h>
-#include "libxfdashboard/utils.h"
-#include "libxfdashboard/view.h"
-#include "libxfdashboard/fill-box-layout.h"
-#include "libxfdashboard/application.h"
+#include <libxfdashboard/utils.h>
+#include <libxfdashboard/view.h>
+#include <libxfdashboard/fill-box-layout.h>
+#include <libxfdashboard/application.h>
+
+#include "clock-view-settings.h"
/* Define this class in GObject system */
@@ -51,48 +53,17 @@ XFDASHBOARD_DEFINE_PLUGIN_TYPE(xfdashboard_clock_view);
struct _XfdashboardClockViewPrivate
{
- /* Properties related */
- ClutterColor *hourColor;
- ClutterColor *minuteColor;
- ClutterColor *secondColor;
- ClutterColor *backgroundColor;
-
/* Instance related */
- ClutterActor *clockActor;
- ClutterContent *clockCanvas;
- guint timeoutID;
-
- XfconfChannel *xfconfChannel;
- guint xfconfHourColorBindingID;
- guint xfconfMinuteColorBindingID;
- guint xfconfSecondColorBindingID;
- guint xfconfBackgroundColorBindingID;
-};
-
-/* Properties */
-enum
-{
- PROP_0,
-
- PROP_HOUR_COLOR,
- PROP_MINUTE_COLOR,
- PROP_SECOND_COLOR,
- PROP_BACKGROUOND_COLOR,
+ ClutterActor *clockActor;
+ ClutterContent *clockCanvas;
+ guint timeoutID;
- PROP_LAST
+ XfdashboardClockViewSettings *settings;
};
-static GParamSpec* XfdashboardClockViewProperties[PROP_LAST]={ 0, };
-
/* IMPLEMENTATION: Private variables and methods */
-#define COLOR_HOUR_XFCONF_PROP "/plugins/"PLUGIN_ID"/hour-color"
-#define COLOR_MINUTE_XFCONF_PROP "/plugins/"PLUGIN_ID"/minute-color"
-#define COLOR_SECOND_XFCONF_PROP "/plugins/"PLUGIN_ID"/second-color"
-#define COLOR_BACKGROUND_XFCONF_PROP "/plugins/"PLUGIN_ID"/background-color"
-
-
/* Rectangle canvas should be redrawn */
static gboolean _xfdashboard_clock_view_on_draw_canvas(XfdashboardClockView *self,
cairo_t *inContext,
@@ -146,24 +117,28 @@ static gboolean _xfdashboard_clock_view_on_draw_canvas(XfdashboardClockView *sel
cairo_set_line_width(inContext, 0.1f);
/* The blue circle that holds the seconds indicator */
- clutter_cairo_set_source_color(inContext, priv->backgroundColor);
+ clutter_cairo_set_source_color(inContext,
+ xfdashboard_clock_view_settings_get_background_color(priv->settings));
cairo_arc(inContext, 0.0f, 0.0f, 0.4f, 0.0f, G_PI*2.0f);
cairo_stroke(inContext);
/* The seconds indicator */
- clutter_cairo_set_source_color(inContext, priv->secondColor);
+ clutter_cairo_set_source_color(inContext,
+ xfdashboard_clock_view_settings_get_second_color(priv->settings));
cairo_move_to(inContext, 0.0f, 0.0f);
cairo_arc(inContext, sinf(seconds)*0.4f, -cosf(seconds)*0.4f, 0.05f, 0.0f, G_PI*2);
cairo_fill(inContext);
/* The minutes indicator */
- clutter_cairo_set_source_color(inContext, priv->minuteColor);
+ clutter_cairo_set_source_color(inContext,
+ xfdashboard_clock_view_settings_get_minute_color(priv->settings));
cairo_move_to(inContext, 0.0f, 0.0f);
cairo_line_to(inContext, sinf(minutes)*0.4f, -cosf(minutes)*0.4f);
cairo_stroke(inContext);
/* The hours indicator */
- clutter_cairo_set_source_color(inContext, priv->hourColor);
+ clutter_cairo_set_source_color(inContext,
+ xfdashboard_clock_view_settings_get_hour_color(priv->settings));
cairo_move_to(inContext, 0.0f, 0.0f);
cairo_line_to(inContext, sinf(hours)*0.2f, -cosf(hours)*0.2f);
cairo_stroke(inContext);
@@ -255,35 +230,6 @@ static void _xfdashboard_clock_view_dispose(GObject *inObject)
XfdashboardClockViewPrivate *priv=self->priv;
/* Release allocated resources */
- if(priv->xfconfHourColorBindingID)
- {
- xfconf_g_property_unbind(priv->xfconfHourColorBindingID);
- priv->xfconfHourColorBindingID=0;
- }
-
- if(priv->xfconfMinuteColorBindingID)
- {
- xfconf_g_property_unbind(priv->xfconfMinuteColorBindingID);
- priv->xfconfMinuteColorBindingID=0;
- }
-
- if(priv->xfconfSecondColorBindingID)
- {
- xfconf_g_property_unbind(priv->xfconfSecondColorBindingID);
- priv->xfconfSecondColorBindingID=0;
- }
-
- if(priv->xfconfBackgroundColorBindingID)
- {
- xfconf_g_property_unbind(priv->xfconfBackgroundColorBindingID);
- priv->xfconfBackgroundColorBindingID=0;
- }
-
- if(priv->xfconfChannel)
- {
- priv->xfconfChannel=NULL;
- }
-
if(priv->timeoutID)
{
g_source_remove(priv->timeoutID);
@@ -302,92 +248,16 @@ static void _xfdashboard_clock_view_dispose(GObject *inObject)
priv->clockCanvas=NULL;
}
- if(priv->hourColor)
- {
- clutter_color_free(priv->hourColor);
- priv->hourColor=NULL;
- }
-
- if(priv->minuteColor)
- {
- clutter_color_free(priv->minuteColor);
- priv->minuteColor=NULL;
- }
-
- if(priv->secondColor)
+ if(priv->settings)
{
- clutter_color_free(priv->secondColor);
- priv->secondColor=NULL;
+ g_object_unref(priv->settings);
+ priv->settings=NULL;
}
/* Call parent's class dispose method */
G_OBJECT_CLASS(xfdashboard_clock_view_parent_class)->dispose(inObject);
}
-/* Set/get properties */
-static void _xfdashboard_clock_view_set_property(GObject *inObject,
- guint inPropID,
- const GValue *inValue,
- GParamSpec *inSpec)
-{
- XfdashboardClockView *self=XFDASHBOARD_CLOCK_VIEW(inObject);
-
- switch(inPropID)
- {
- case PROP_HOUR_COLOR:
- xfdashboard_clock_view_set_hour_color(self, clutter_value_get_color(inValue));
- break;
-
- case PROP_MINUTE_COLOR:
- xfdashboard_clock_view_set_minute_color(self, clutter_value_get_color(inValue));
- break;
-
- case PROP_SECOND_COLOR:
- xfdashboard_clock_view_set_second_color(self, clutter_value_get_color(inValue));
- break;
-
- case PROP_BACKGROUOND_COLOR:
- xfdashboard_clock_view_set_background_color(self, clutter_value_get_color(inValue));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
-static void _xfdashboard_clock_view_get_property(GObject *inObject,
- guint inPropID,
- GValue *outValue,
- GParamSpec *inSpec)
-{
- XfdashboardClockView *self=XFDASHBOARD_CLOCK_VIEW(inObject);
- XfdashboardClockViewPrivate *priv=self->priv;
-
- switch(inPropID)
- {
- case PROP_HOUR_COLOR:
- clutter_value_set_color(outValue, priv->hourColor);
- break;
-
- case PROP_MINUTE_COLOR:
- clutter_value_set_color(outValue, priv->minuteColor);
- break;
-
- case PROP_SECOND_COLOR:
- clutter_value_set_color(outValue, priv->secondColor);
- break;
-
- case PROP_BACKGROUOND_COLOR:
- clutter_value_set_color(outValue, priv->backgroundColor);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
-}
-
/* Class initialization
* Override functions in parent classes and define properties
* and signals
@@ -400,8 +270,6 @@ void xfdashboard_clock_view_class_init(XfdashboardClockViewClass *klass)
/* Override functions */
gobjectClass->dispose=_xfdashboard_clock_view_dispose;
- gobjectClass->set_property=_xfdashboard_clock_view_set_property;
- gobjectClass->get_property=_xfdashboard_clock_view_get_property;
actorClass->allocate=_xfdashboard_clock_view_allocate;
@@ -410,37 +278,6 @@ void xfdashboard_clock_view_class_init(XfdashboardClockViewClass *klass)
/* Set up private structure */
g_type_class_add_private(klass, sizeof(XfdashboardClockViewPrivate));
-
- /* Define properties */
- XfdashboardClockViewProperties[PROP_HOUR_COLOR]=
- clutter_param_spec_color("hour-color",
- _("Hour color"),
- _("Color to draw the hour hand with"),
- CLUTTER_COLOR_LightChameleon,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- XfdashboardClockViewProperties[PROP_MINUTE_COLOR]=
- clutter_param_spec_color("minute-color",
- _("Minute color"),
- _("Color to draw the minute hand with"),
- CLUTTER_COLOR_LightChameleon,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- XfdashboardClockViewProperties[PROP_SECOND_COLOR]=
- clutter_param_spec_color("second-color",
- _("Sedond color"),
- _("Color to draw the second hand with"),
- CLUTTER_COLOR_White,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- XfdashboardClockViewProperties[PROP_BACKGROUOND_COLOR]=
- clutter_param_spec_color("background-color",
- _("Background color"),
- _("Color to draw the circle with that holds the second hand"),
- CLUTTER_COLOR_Blue,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardClockViewProperties);
}
/* Class finalization */
@@ -458,13 +295,11 @@ void xfdashboard_clock_view_init(XfdashboardClockView *self)
self->priv=priv=XFDASHBOARD_CLOCK_VIEW_GET_PRIVATE(self);
/* Set up default values */
- priv->hourColor=clutter_color_copy(CLUTTER_COLOR_LightChameleon);
- priv->minuteColor=clutter_color_copy(CLUTTER_COLOR_LightChameleon);
- priv->secondColor=clutter_color_copy(CLUTTER_COLOR_White);
- priv->backgroundColor=clutter_color_copy(CLUTTER_COLOR_Blue);
- priv->xfconfChannel=xfdashboard_application_get_xfconf_channel(NULL);
priv->timeoutID=0;
+ /* Set up settings */
+ priv->settings=xfdashboard_clock_view_settings_new();
+
/* Set up this actor */
xfdashboard_view_set_view_fit_mode(XFDASHBOARD_VIEW(self), XFDASHBOARD_VIEW_FIT_MODE_BOTH);
@@ -481,153 +316,4 @@ void xfdashboard_clock_view_init(XfdashboardClockView *self)
/* Set up view */
xfdashboard_view_set_name(XFDASHBOARD_VIEW(self), _("Clock"));
xfdashboard_view_set_icon(XFDASHBOARD_VIEW(self), "appointment-soon");
-
- /* Bind to xfconf to react on changes */
- priv->xfconfHourColorBindingID=
- xfconf_g_property_bind(priv->xfconfChannel,
- COLOR_HOUR_XFCONF_PROP,
- G_TYPE_STRING,
- self,
- "hour-color");
-
- priv->xfconfMinuteColorBindingID=
- xfconf_g_property_bind(priv->xfconfChannel,
- COLOR_MINUTE_XFCONF_PROP,
- G_TYPE_STRING,
- self,
- "minute-color");
-
- priv->xfconfSecondColorBindingID=
- xfconf_g_property_bind(priv->xfconfChannel,
- COLOR_SECOND_XFCONF_PROP,
- G_TYPE_STRING,
- self,
- "second-color");
-
- priv->xfconfBackgroundColorBindingID=
- xfconf_g_property_bind(priv->xfconfChannel,
- COLOR_BACKGROUND_XFCONF_PROP,
- G_TYPE_STRING,
- self,
- "background-color");
-}
-
-/* Get/set color to draw hour hand with */
-const ClutterColor* xfdashboard_clock_view_get_hour_color(XfdashboardClockView *self)
-{
- g_return_val_if_fail(XFDASHBOARD_IS_CLOCK_VIEW(self), NULL);
-
- return(self->priv->hourColor);
-}
-
-void xfdashboard_clock_view_set_hour_color(XfdashboardClockView *self, const ClutterColor *inColor)
-{
- XfdashboardClockViewPrivate *priv;
-
- g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW(self));
- g_return_if_fail(inColor);
-
- priv=self->priv;
-
- /* Set value if changed */
- if(priv->hourColor==NULL ||
- !clutter_color_equal(inColor, priv->hourColor))
- {
- /* Set value */
- if(priv->hourColor) clutter_color_free(priv->hourColor);
- priv->hourColor=clutter_color_copy(inColor);
-
- /* Notify about property change */
- g_object_notify_by_pspec(G_OBJECT(self), XfdashboardClockViewProperties[PROP_HOUR_COLOR]);
- }
-}
-
-/* Get/set color to draw minute hand with */
-const ClutterColor* xfdashboard_clock_view_get_minute_color(XfdashboardClockView *self)
-{
- g_return_val_if_fail(XFDASHBOARD_IS_CLOCK_VIEW(self), NULL);
-
- return(self->priv->minuteColor);
-}
-
-void xfdashboard_clock_view_set_minute_color(XfdashboardClockView *self, const ClutterColor *inColor)
-{
- XfdashboardClockViewPrivate *priv;
-
- g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW(self));
- g_return_if_fail(inColor);
-
- priv=self->priv;
-
- /* Set value if changed */
- if(priv->minuteColor==NULL ||
- !clutter_color_equal(inColor, priv->minuteColor))
- {
- /* Set value */
- if(priv->minuteColor) clutter_color_free(priv->minuteColor);
- priv->minuteColor=clutter_color_copy(inColor);
-
- /* Notify about property change */
- g_object_notify_by_pspec(G_OBJECT(self), XfdashboardClockViewProperties[PROP_MINUTE_COLOR]);
- }
-}
-
-/* Get/set color to draw second hand with */
-const ClutterColor* xfdashboard_clock_view_get_second_color(XfdashboardClockView *self)
-{
- g_return_val_if_fail(XFDASHBOARD_IS_CLOCK_VIEW(self), NULL);
-
- return(self->priv->secondColor);
-}
-
-void xfdashboard_clock_view_set_second_color(XfdashboardClockView *self, const ClutterColor *inColor)
-{
- XfdashboardClockViewPrivate *priv;
-
- g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW(self));
- g_return_if_fail(inColor);
-
- priv=self->priv;
-
- /* Set value if changed */
- if(priv->secondColor==NULL ||
- !clutter_color_equal(inColor, priv->secondColor))
- {
- /* Set value */
- if(priv->secondColor) clutter_color_free(priv->secondColor);
- priv->secondColor=clutter_color_copy(inColor);
-
- /* Notify about property change */
- g_object_notify_by_pspec(G_OBJECT(self), XfdashboardClockViewProperties[PROP_SECOND_COLOR]);
- }
-}
-
-/* Get/set color to draw background with that holds second hand */
-const ClutterColor* xfdashboard_clock_view_get_background_color(XfdashboardClockView *self)
-{
- g_return_val_if_fail(XFDASHBOARD_IS_CLOCK_VIEW(self), NULL);
-
- return(self->priv->secondColor);
-}
-
-void xfdashboard_clock_view_set_background_color(XfdashboardClockView *self, const ClutterColor *inColor)
-{
- XfdashboardClockViewPrivate *priv;
-
- g_return_if_fail(XFDASHBOARD_IS_CLOCK_VIEW(self));
- g_return_if_fail(inColor);
-
- priv=self->priv;
-
- /* Set value if changed */
- if(priv->backgroundColor==NULL ||
- !clutter_color_equal(inColor, priv->backgroundColor))
- {
- /* Set value */
- if(priv->backgroundColor) clutter_color_free(priv->backgroundColor);
- priv->backgroundColor=clutter_color_copy(inColor);
-
- /* Notify about property change */
- g_object_notify_by_pspec(G_OBJECT(self), XfdashboardClockViewProperties[PROP_BACKGROUOND_COLOR]);
- }
}
diff --git a/plugins/clock-view/clock-view.h b/plugins/clock-view/clock-view.h
index bec5392..b74cd95 100644
--- a/plugins/clock-view/clock-view.h
+++ b/plugins/clock-view/clock-view.h
@@ -24,8 +24,8 @@
#ifndef __XFDASHBOARD_CLOCK_VIEW__
#define __XFDASHBOARD_CLOCK_VIEW__
-#include "libxfdashboard/plugin.h"
-#include "libxfdashboard/view.h"
+#include <libxfdashboard/plugin.h>
+#include <libxfdashboard/view.h>
G_BEGIN_DECLS
@@ -46,7 +46,7 @@ struct _XfdashboardClockView
XfdashboardView parent_instance;
/* Private structure */
- XfdashboardClockViewPrivate *priv;
+ XfdashboardClockViewPrivate *priv;
};
struct _XfdashboardClockViewClass
@@ -59,18 +59,6 @@ struct _XfdashboardClockViewClass
/* Public API */
GType xfdashboard_clock_view_get_type(void) G_GNUC_CONST;
-const ClutterColor* xfdashboard_clock_view_get_hour_color(XfdashboardClockView *self);
-void xfdashboard_clock_view_set_hour_color(XfdashboardClockView *self, const ClutterColor *inColor);
-
-const ClutterColor* xfdashboard_clock_view_get_minute_color(XfdashboardClockView *self);
-void xfdashboard_clock_view_set_minute_color(XfdashboardClockView *self, const ClutterColor *inColor);
-
-const ClutterColor* xfdashboard_clock_view_get_second_color(XfdashboardClockView *self);
-void xfdashboard_clock_view_set_second_color(XfdashboardClockView *self, const ClutterColor *inColor);
-
-const ClutterColor* xfdashboard_clock_view_get_background_color(XfdashboardClockView *self);
-void xfdashboard_clock_view_set_background_color(XfdashboardClockView *self, const ClutterColor *inColor);
-
XFDASHBOARD_DECLARE_PLUGIN_TYPE(xfdashboard_clock_view);
G_END_DECLS
diff --git a/plugins/clock-view/plugin.c b/plugins/clock-view/plugin.c
index 049e7b5..221c565 100644
--- a/plugins/clock-view/plugin.c
+++ b/plugins/clock-view/plugin.c
@@ -26,6 +26,7 @@
#endif
#include "clock-view.h"
+#include "clock-view-settings.h"
#include <libxfce4util/libxfce4util.h>
@@ -91,6 +92,7 @@ G_MODULE_EXPORT void plugin_init(XfdashboardPlugin *self)
/* Register GObject types of this plugin */
XFDASHBOARD_REGISTER_PLUGIN_TYPE(self, xfdashboard_clock_view);
+ XFDASHBOARD_REGISTER_PLUGIN_TYPE(self, xfdashboard_clock_view_settings);
/* Connect plugin action handlers */
g_signal_connect(self, "enable", G_CALLBACK(plugin_enable), NULL);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list