[Xfce4-commits] [apps/xfdashboard] 01/01: Move settings of hot corner plugin into a seperate object class to share it, e.g. with configure function of hot corner plugin which is not implemented yet
noreply at xfce.org
noreply at xfce.org
Thu Feb 25 12:13:20 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 8fa7f400b26e184c5eca12ca5beb400fdc1c7d2f
Author: Stephan Haller <nomad at froevel.de>
Date: Thu Feb 25 12:12:49 2016 +0100
Move settings of hot corner plugin into a seperate object class to share it, e.g. with configure function of hot corner plugin which is not implemented yet
---
plugins/hot-corner/Makefile.am | 2 +
plugins/hot-corner/hot-corner-settings.c | 400 +++++++++++++++++++++++++++++++
plugins/hot-corner/hot-corner-settings.h | 90 +++++++
plugins/hot-corner/hot-corner.c | 301 +++--------------------
plugins/hot-corner/hot-corner.h | 9 -
5 files changed, 531 insertions(+), 271 deletions(-)
diff --git a/plugins/hot-corner/Makefile.am b/plugins/hot-corner/Makefile.am
index 91782f4..6a4bba4 100644
--- a/plugins/hot-corner/Makefile.am
+++ b/plugins/hot-corner/Makefile.am
@@ -15,6 +15,8 @@ plugin_LTLIBRARIES = \
hot_corner_la_SOURCES = \
hot-corner.c \
hot-corner.h \
+ hot-corner-settings.c \
+ hot-corner-settings.h \
plugin.c
hot_corner_la_CFLAGS = \
diff --git a/plugins/hot-corner/hot-corner-settings.c b/plugins/hot-corner/hot-corner-settings.c
new file mode 100644
index 0000000..07b3dcc
--- /dev/null
+++ b/plugins/hot-corner/hot-corner-settings.c
@@ -0,0 +1,400 @@
+/*
+ * hot-corner-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 "hot-corner-settings.h"
+
+#include <libxfdashboard/libxfdashboard.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <math.h>
+
+
+/* Define this class in GObject system */
+G_DEFINE_DYNAMIC_TYPE(XfdashboardHotCornerSettings,
+ xfdashboard_hot_corner_settings,
+ G_TYPE_OBJECT)
+
+/* Define this class in this plugin */
+XFDASHBOARD_DEFINE_PLUGIN_TYPE(xfdashboard_hot_corner_settings);
+
+/* Private structure - access only by public API if needed */
+#define XFDASHBOARD_HOT_CORNER_SETTINGS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS, XfdashboardHotCornerSettingsPrivate))
+
+struct _XfdashboardHotCornerSettingsPrivate
+{
+ /* Properties related */
+ XfdashboardHotCornerSettingsActivationCorner activationCorner;
+ gint activationRadius;
+ gint64 activationDuration;
+
+ /* Instance related */
+ XfconfChannel *xfconfChannel;
+ guint xfconfActivationCornerBindingID;
+ guint xfconfActivationRadiusBindingID;
+ guint xfconfActivationDurationBindingID;
+};
+
+/* Properties */
+enum
+{
+ PROP_0,
+
+ PROP_ACTIVATION_CORNER,
+ PROP_ACTIVATION_RADIUS,
+ PROP_ACTIVATION_DURATION,
+
+ PROP_LAST
+};
+
+static GParamSpec* XfdashboardHotCornerSettingsProperties[PROP_LAST]={ 0, };
+
+
+/* IMPLEMENTATION: Enum XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS_ACTIVATION_CORNER */
+
+GType xfdashboard_hot_corner_settings_activation_corner_get_type(void)
+{
+ static volatile gsize g_define_type_id__volatile=0;
+
+ if(g_once_init_enter(&g_define_type_id__volatile))
+ {
+ static const GEnumValue values[]=
+ {
+ { XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_TOP_LEFT, "XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_TOP_LEFT", "top-left" },
+ { XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_TOP_RIGHT, "XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_TOP_RIGHT", "top-right" },
+ { XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_BOTTOM_LEFT, "XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_BOTTOM_LEFT", "bottom-left" },
+ { XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_BOTTOM_RIGHT, "XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_BOTTOM_RIGHT", "bottom-right" },
+ { 0, NULL, NULL }
+ };
+
+ GType g_define_type_id=g_enum_register_static(g_intern_static_string("XfdashboardHotCornerSettingsActivationCorner"), values);
+ g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
+ }
+
+ return(g_define_type_id__volatile);
+}
+
+
+/* IMPLEMENTATION: Private variables and methods */
+#define POLL_POINTER_POSITION_INTERVAL 100
+
+#define XFDASHBOARD_XFCONF_CHANNEL "xfdashboard"
+
+#define ACTIVATION_CORNER_XFCONF_PROP "/plugins/"PLUGIN_ID"/activation-corner"
+#define DEFAULT_ACTIVATION_CORNER XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_TOP_LEFT
+
+#define ACTIVATION_RADIUS_XFCONF_PROP "/plugins/"PLUGIN_ID"/activation-radius"
+#define DEFAULT_ACTIVATION_RADIUS 4
+
+#define ACTIVATION_DURATION_XFCONF_PROP "/plugins/"PLUGIN_ID"/activation-duration"
+#define DEFAULT_ACTIVATION_DURATION 300
+
+
+typedef struct _XfdashboardHotCornerSettingsBox XfdashboardHotCornerSettingsBox;
+struct _XfdashboardHotCornerSettingsBox
+{
+ gint x1, y1;
+ gint x2, y2;
+};
+
+
+/* IMPLEMENTATION: GObject */
+
+/* Dispose this object */
+static void _xfdashboard_hot_corner_settings_dispose(GObject *inObject)
+{
+ XfdashboardHotCornerSettings *self=XFDASHBOARD_HOT_CORNER_SETTINGS(inObject);
+ XfdashboardHotCornerSettingsPrivate *priv=self->priv;
+
+ /* Release allocated resources */
+ if(priv->xfconfActivationCornerBindingID)
+ {
+ xfconf_g_property_unbind(priv->xfconfActivationCornerBindingID);
+ priv->xfconfActivationCornerBindingID=0;
+ }
+
+ if(priv->xfconfActivationRadiusBindingID)
+ {
+ xfconf_g_property_unbind(priv->xfconfActivationRadiusBindingID);
+ priv->xfconfActivationRadiusBindingID=0;
+ }
+
+ if(priv->xfconfActivationDurationBindingID)
+ {
+ xfconf_g_property_unbind(priv->xfconfActivationDurationBindingID);
+ priv->xfconfActivationDurationBindingID=0;
+ }
+
+ if(priv->xfconfChannel)
+ {
+ priv->xfconfChannel=NULL;
+ }
+
+ /* Call parent's class dispose method */
+ G_OBJECT_CLASS(xfdashboard_hot_corner_settings_parent_class)->dispose(inObject);
+}
+
+/* Set/get properties */
+static void _xfdashboard_hot_corner_settings_set_property(GObject *inObject,
+ guint inPropID,
+ const GValue *inValue,
+ GParamSpec *inSpec)
+{
+ XfdashboardHotCornerSettings *self=XFDASHBOARD_HOT_CORNER_SETTINGS(inObject);
+
+ switch(inPropID)
+ {
+ case PROP_ACTIVATION_CORNER:
+ xfdashboard_hot_corner_settings_set_activation_corner(self, g_value_get_enum(inValue));
+ break;
+
+ case PROP_ACTIVATION_RADIUS:
+ xfdashboard_hot_corner_settings_set_activation_radius(self, g_value_get_int(inValue));
+ break;
+
+ case PROP_ACTIVATION_DURATION:
+ xfdashboard_hot_corner_settings_set_activation_duration(self, g_value_get_uint64(inValue));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
+ break;
+ }
+}
+
+static void _xfdashboard_hot_corner_settings_get_property(GObject *inObject,
+ guint inPropID,
+ GValue *outValue,
+ GParamSpec *inSpec)
+{
+ XfdashboardHotCornerSettings *self=XFDASHBOARD_HOT_CORNER_SETTINGS(inObject);
+ XfdashboardHotCornerSettingsPrivate *priv=self->priv;
+
+ switch(inPropID)
+ {
+ case PROP_ACTIVATION_CORNER:
+ g_value_set_enum(outValue, priv->activationCorner);
+ break;
+
+ case PROP_ACTIVATION_RADIUS:
+ g_value_set_int(outValue, priv->activationRadius);
+ break;
+
+ case PROP_ACTIVATION_DURATION:
+ g_value_set_uint64(outValue, priv->activationDuration);
+ 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_hot_corner_settings_class_init(XfdashboardHotCornerSettingsClass *klass)
+{
+ GObjectClass *gobjectClass=G_OBJECT_CLASS(klass);
+
+ /* Override functions */
+ gobjectClass->dispose=_xfdashboard_hot_corner_settings_dispose;
+ gobjectClass->set_property=_xfdashboard_hot_corner_settings_set_property;
+ gobjectClass->get_property=_xfdashboard_hot_corner_settings_get_property;
+
+ /* Set up private structure */
+ g_type_class_add_private(klass, sizeof(XfdashboardHotCornerSettingsPrivate));
+
+ /* Define properties */
+ XfdashboardHotCornerSettingsProperties[PROP_ACTIVATION_CORNER]=
+ g_param_spec_enum("activation-corner",
+ _("Activation corner"),
+ _("The hot corner where to trigger the application to suspend or to resume"),
+ XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS_ACTIVATION_CORNER,
+ DEFAULT_ACTIVATION_CORNER,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ XfdashboardHotCornerSettingsProperties[PROP_ACTIVATION_RADIUS]=
+ g_param_spec_int("activation-radius",
+ _("Activation radius"),
+ _("The radius around hot corner where the pointer must be inside"),
+ 0, G_MAXINT,
+ DEFAULT_ACTIVATION_RADIUS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ XfdashboardHotCornerSettingsProperties[PROP_ACTIVATION_DURATION]=
+ g_param_spec_uint64("activation-duration",
+ _("Activation duration"),
+ _("The time in milliseconds the pointer must stay inside the radius at hot corner to trigger"),
+ 0, G_MAXUINT64,
+ DEFAULT_ACTIVATION_DURATION,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardHotCornerSettingsProperties);
+}
+
+/* Class finalization */
+void xfdashboard_hot_corner_settings_class_finalize(XfdashboardHotCornerSettingsClass *klass)
+{
+}
+
+/* Object initialization
+ * Create private structure and set up default values
+ */
+void xfdashboard_hot_corner_settings_init(XfdashboardHotCornerSettings *self)
+{
+ XfdashboardHotCornerSettingsPrivate *priv;
+
+ self->priv=priv=XFDASHBOARD_HOT_CORNER_SETTINGS_GET_PRIVATE(self);
+
+ /* Set up default values */
+ priv->activationCorner=DEFAULT_ACTIVATION_CORNER;
+ priv->activationRadius=DEFAULT_ACTIVATION_RADIUS;
+ priv->activationDuration=DEFAULT_ACTIVATION_DURATION;
+ priv->xfconfChannel=xfconf_channel_get(XFDASHBOARD_XFCONF_CHANNEL);
+
+ /* Bind to xfconf to react on changes */
+ priv->xfconfActivationCornerBindingID=
+ xfconf_g_property_bind(priv->xfconfChannel,
+ ACTIVATION_CORNER_XFCONF_PROP,
+ G_TYPE_STRING,
+ self,
+ "activation-corner");
+
+ priv->xfconfActivationRadiusBindingID=
+ xfconf_g_property_bind(priv->xfconfChannel,
+ ACTIVATION_RADIUS_XFCONF_PROP,
+ G_TYPE_INT,
+ self,
+ "activation-radius");
+
+ priv->xfconfActivationDurationBindingID=
+ xfconf_g_property_bind(priv->xfconfChannel,
+ ACTIVATION_DURATION_XFCONF_PROP,
+ G_TYPE_INT64,
+ self,
+ "activation-duration");
+}
+
+
+/* IMPLEMENTATION: Public API */
+
+/* Create new instance */
+XfdashboardHotCornerSettings* xfdashboard_hot_corner_settings_new(void)
+{
+ GObject *hotCorner;
+
+ hotCorner=g_object_new(XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS, NULL);
+ if(!hotCorner) return(NULL);
+
+ return(XFDASHBOARD_HOT_CORNER_SETTINGS(hotCorner));
+}
+
+/* Get/set hot corner */
+XfdashboardHotCornerSettingsActivationCorner xfdashboard_hot_corner_settings_get_activation_corner(XfdashboardHotCornerSettings *self)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_HOT_CORNER_SETTINGS(self), XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_TOP_LEFT);
+
+ return(self->priv->activationCorner);
+}
+
+void xfdashboard_hot_corner_settings_set_activation_corner(XfdashboardHotCornerSettings *self, XfdashboardHotCornerSettingsActivationCorner inCorner)
+{
+ XfdashboardHotCornerSettingsPrivate *priv;
+
+ g_return_if_fail(XFDASHBOARD_IS_HOT_CORNER_SETTINGS(self));
+ g_return_if_fail(inCorner<=XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_BOTTOM_RIGHT);
+
+ priv=self->priv;
+
+ /* Set value if changed */
+ if(priv->activationCorner!=inCorner)
+ {
+ /* Set value */
+ priv->activationCorner=inCorner;
+
+ /* Notify about property change */
+ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardHotCornerSettingsProperties[PROP_ACTIVATION_CORNER]);
+ }
+}
+
+/* Get/set radius around hot corner */
+gint xfdashboard_hot_corner_settings_get_activation_radius(XfdashboardHotCornerSettings *self)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_HOT_CORNER_SETTINGS(self), 0);
+
+ return(self->priv->activationRadius);
+}
+
+void xfdashboard_hot_corner_settings_set_activation_radius(XfdashboardHotCornerSettings *self, gint inRadius)
+{
+ XfdashboardHotCornerSettingsPrivate *priv;
+
+ g_return_if_fail(XFDASHBOARD_IS_HOT_CORNER_SETTINGS(self));
+ g_return_if_fail(inRadius>0);
+
+ priv=self->priv;
+
+ /* Set value if changed */
+ if(priv->activationRadius!=inRadius)
+ {
+ /* Set value */
+ priv->activationRadius=inRadius;
+
+ /* Notify about property change */
+ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardHotCornerSettingsProperties[PROP_ACTIVATION_RADIUS]);
+ }
+}
+
+/* Get/set duration when to trigger hot corner */
+gint64 xfdashboard_hot_corner_settings_get_activation_duration(XfdashboardHotCornerSettings *self)
+{
+ g_return_val_if_fail(XFDASHBOARD_IS_HOT_CORNER_SETTINGS(self), 0);
+
+ return(self->priv->activationDuration);
+}
+
+void xfdashboard_hot_corner_settings_set_activation_duration(XfdashboardHotCornerSettings *self, gint64 inDuration)
+{
+ XfdashboardHotCornerSettingsPrivate *priv;
+
+ g_return_if_fail(XFDASHBOARD_IS_HOT_CORNER_SETTINGS(self));
+ g_return_if_fail(inDuration>0);
+
+ priv=self->priv;
+
+ /* Set value if changed */
+ if(priv->activationDuration!=inDuration)
+ {
+ /* Set value */
+ priv->activationDuration=inDuration;
+
+ /* Notify about property change */
+ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardHotCornerSettingsProperties[PROP_ACTIVATION_DURATION]);
+ }
+}
diff --git a/plugins/hot-corner/hot-corner-settings.h b/plugins/hot-corner/hot-corner-settings.h
new file mode 100644
index 0000000..57ca282
--- /dev/null
+++ b/plugins/hot-corner/hot-corner-settings.h
@@ -0,0 +1,90 @@
+/*
+ * hot-corner-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_HOT_CORNER_SETTINGS__
+#define __XFDASHBOARD_HOT_CORNER_SETTINGS__
+
+#include <libxfdashboard/libxfdashboard.h>
+
+G_BEGIN_DECLS
+
+/* Public definitions */
+typedef enum /*< prefix=XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER >*/
+{
+ XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_TOP_LEFT=0,
+ XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_TOP_RIGHT,
+ XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_BOTTOM_LEFT,
+ XFDASHBOARD_HOT_CORNER_SETTINGS_ACTIVATION_CORNER_BOTTOM_RIGHT,
+} XfdashboardHotCornerSettingsActivationCorner;
+
+GType xfdashboard_hot_corner_settings_activation_corner_get_type(void) G_GNUC_CONST;
+#define XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS_ACTIVATION_CORNER (xfdashboard_hot_corner_settings_activation_corner_get_type())
+
+
+/* Object declaration */
+#define XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS (xfdashboard_hot_corner_settings_get_type())
+#define XFDASHBOARD_HOT_CORNER_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS, XfdashboardHotCornerSettings))
+#define XFDASHBOARD_IS_HOT_CORNER_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS))
+#define XFDASHBOARD_HOT_CORNER_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS, XfdashboardHotCornerSettingsClass))
+#define XFDASHBOARD_IS_HOT_CORNER_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS))
+#define XFDASHBOARD_HOT_CORNER_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XFDASHBOARD_TYPE_HOT_CORNER_SETTINGS, XfdashboardHotCornerSettingsClass))
+
+typedef struct _XfdashboardHotCornerSettings XfdashboardHotCornerSettings;
+typedef struct _XfdashboardHotCornerSettingsPrivate XfdashboardHotCornerSettingsPrivate;
+typedef struct _XfdashboardHotCornerSettingsClass XfdashboardHotCornerSettingsClass;
+
+struct _XfdashboardHotCornerSettings
+{
+ /* Parent instance */
+ GObject parent_instance;
+
+ /* Private structure */
+ XfdashboardHotCornerSettingsPrivate *priv;
+};
+
+struct _XfdashboardHotCornerSettingsClass
+{
+ /*< private >*/
+ /* Parent class */
+ GObjectClass parent_class;
+};
+
+/* Public API */
+GType xfdashboard_hot_corner_settings_get_type(void) G_GNUC_CONST;
+
+XFDASHBOARD_DECLARE_PLUGIN_TYPE(xfdashboard_hot_corner_settings);
+
+XfdashboardHotCornerSettings* xfdashboard_hot_corner_settings_new(void);
+
+XfdashboardHotCornerSettingsActivationCorner xfdashboard_hot_corner_settings_get_activation_corner(XfdashboardHotCornerSettings *self);
+void xfdashboard_hot_corner_settings_set_activation_corner(XfdashboardHotCornerSettings *self, const XfdashboardHotCornerSettingsActivationCorner inCorner);
+
+gint xfdashboard_hot_corner_settings_get_activation_radius(XfdashboardHotCornerSettings *self);
+void xfdashboard_hot_corner_settings_set_activation_radius(XfdashboardHotCornerSettings *self, gint inRadius);
+
+gint64 xfdashboard_hot_corner_settings_get_activation_duration(XfdashboardHotCornerSettings *self);
+void xfdashboard_hot_corner_settings_set_activation_duration(XfdashboardHotCornerSettings *self, gint64 inDuration);
+
+G_END_DECLS
+
+#endif
diff --git a/plugins/hot-corner/hot-corner.c b/plugins/hot-corner/hot-corner.c
index 895fcd6..a6c1572 100644
--- a/plugins/hot-corner/hot-corner.c
+++ b/plugins/hot-corner/hot-corner.c
@@ -32,6 +32,8 @@
#include <gtk/gtk.h>
#include <math.h>
+#include "hot-corner-settings.h"
+
/* Define this class in GObject system */
G_DEFINE_DYNAMIC_TYPE(XfdashboardHotCorner,
@@ -47,11 +49,6 @@ XFDASHBOARD_DEFINE_PLUGIN_TYPE(xfdashboard_hot_corner);
struct _XfdashboardHotCornerPrivate
{
- /* Properties related */
- XfdashboardHotCornerActivationCorner activationCorner;
- gint activationRadius;
- gint64 activationDuration;
-
/* Instance related */
XfdashboardApplication *application;
XfdashboardWindowTracker *windowTracker;
@@ -62,26 +59,9 @@ struct _XfdashboardHotCornerPrivate
GDateTime *enteredTime;
gboolean wasHandledRecently;
- XfconfChannel *xfconfChannel;
- guint xfconfActivationCornerBindingID;
- guint xfconfActivationRadiusBindingID;
- guint xfconfActivationDurationBindingID;
-};
-
-/* Properties */
-enum
-{
- PROP_0,
-
- PROP_ACTIVATION_CORNER,
- PROP_ACTIVATION_RADIUS,
- PROP_ACTIVATION_DURATION,
-
- PROP_LAST
+ XfdashboardHotCornerSettings *settings;
};
-static GParamSpec* XfdashboardHotCornerProperties[PROP_LAST]={ 0, };
-
/* IMPLEMENTATION: Enum XFDASHBOARD_TYPE_HOT_CORNER_ACTIVATION_CORNER */
@@ -131,22 +111,30 @@ struct _XfdashboardHotCornerBox
/* Timeout callback to check for activation or suspend via hot corner */
static gboolean _xfdashboard_hot_corner_check_hot_corner(gpointer inUserData)
{
- XfdashboardHotCorner *self;
- XfdashboardHotCornerPrivate *priv;
- XfdashboardWindowTrackerWindow *activeWindow;
- GdkDevice *pointerDevice;
- gint pointerX, pointerY;
- XfdashboardWindowTrackerMonitor *primaryMonitor;
- XfdashboardHotCornerBox monitorRect;
- XfdashboardHotCornerBox hotCornerRect;
- GDateTime *currentTime;
- GTimeSpan timeDiff;
+ XfdashboardHotCorner *self;
+ XfdashboardHotCornerPrivate *priv;
+ XfdashboardWindowTrackerWindow *activeWindow;
+ GdkDevice *pointerDevice;
+ gint pointerX, pointerY;
+ XfdashboardWindowTrackerMonitor *primaryMonitor;
+ XfdashboardHotCornerBox monitorRect;
+ XfdashboardHotCornerBox hotCornerRect;
+ GDateTime *currentTime;
+ GTimeSpan timeDiff;
+ XfdashboardHotCornerSettingsActivationCorner activationCorner;
+ gint activationRadius;
+ gint64 activationDuration;
g_return_val_if_fail(XFDASHBOARD_IS_HOT_CORNER(inUserData), G_SOURCE_CONTINUE);
self=XFDASHBOARD_HOT_CORNER(inUserData);
priv=self->priv;
+ /* Get all settings now which are used within this function */
+ activationCorner=xfdashboard_hot_corner_settings_get_activation_corner(priv->settings);
+ activationRadius=xfdashboard_hot_corner_settings_get_activation_radius(priv->settings);
+ activationDuration=xfdashboard_hot_corner_settings_get_activation_duration(priv->settings);
+
/* Do nothing if current window is fullscreen but not this application */
activeWindow=xfdashboard_window_tracker_get_active_window(priv->windowTracker);
if(activeWindow &&
@@ -189,35 +177,35 @@ static gboolean _xfdashboard_hot_corner_check_hot_corner(gpointer inUserData)
}
/* Get rectangle where pointer must be inside to activate hot corner */
- switch(priv->activationCorner)
+ switch(activationCorner)
{
case XFDASHBOARD_HOT_CORNER_ACTIVATION_CORNER_TOP_RIGHT:
hotCornerRect.x2=monitorRect.x2;
- hotCornerRect.x1=MAX(monitorRect.x2-priv->activationRadius, monitorRect.x1);
+ hotCornerRect.x1=MAX(monitorRect.x2-activationRadius, monitorRect.x1);
hotCornerRect.y1=monitorRect.y1;
- hotCornerRect.y2=MIN(monitorRect.y1+priv->activationRadius, monitorRect.y2);
+ hotCornerRect.y2=MIN(monitorRect.y1+activationRadius, monitorRect.y2);
break;
case XFDASHBOARD_HOT_CORNER_ACTIVATION_CORNER_BOTTOM_LEFT:
hotCornerRect.x1=monitorRect.x1;
- hotCornerRect.x2=MIN(monitorRect.x1+priv->activationRadius, monitorRect.x2);
+ hotCornerRect.x2=MIN(monitorRect.x1+activationRadius, monitorRect.x2);
hotCornerRect.y2=monitorRect.y2;
- hotCornerRect.y1=MAX(monitorRect.y2-priv->activationRadius, monitorRect.y1);
+ hotCornerRect.y1=MAX(monitorRect.y2-activationRadius, monitorRect.y1);
break;
case XFDASHBOARD_HOT_CORNER_ACTIVATION_CORNER_BOTTOM_RIGHT:
hotCornerRect.x2=monitorRect.x2;
- hotCornerRect.x1=MAX(monitorRect.x2-priv->activationRadius, monitorRect.x1);
+ hotCornerRect.x1=MAX(monitorRect.x2-activationRadius, monitorRect.x1);
hotCornerRect.y2=monitorRect.y2;
- hotCornerRect.y1=MAX(monitorRect.y2-priv->activationRadius, monitorRect.y1);
+ hotCornerRect.y1=MAX(monitorRect.y2-activationRadius, monitorRect.y1);
break;
case XFDASHBOARD_HOT_CORNER_ACTIVATION_CORNER_TOP_LEFT:
default:
hotCornerRect.x1=monitorRect.x1;
- hotCornerRect.x2=MIN(monitorRect.x1+priv->activationRadius, monitorRect.x2);
+ hotCornerRect.x2=MIN(monitorRect.x1+activationRadius, monitorRect.x2);
hotCornerRect.y1=monitorRect.y1;
- hotCornerRect.y2=MIN(monitorRect.y1+priv->activationRadius, monitorRect.y2);
+ hotCornerRect.y2=MIN(monitorRect.y1+activationRadius, monitorRect.y2);
break;
}
@@ -266,7 +254,7 @@ static gboolean _xfdashboard_hot_corner_check_hot_corner(gpointer inUserData)
timeDiff=g_date_time_difference(currentTime, priv->enteredTime);
g_date_time_unref(currentTime);
- if(timeDiff<(priv->activationDuration*G_TIME_SPAN_MILLISECOND)) return(G_SOURCE_CONTINUE);
+ if(timeDiff<(activationDuration*G_TIME_SPAN_MILLISECOND)) return(G_SOURCE_CONTINUE);
/* Activation duration reached so activate application if suspended or suspend it
* if active currently.
@@ -295,29 +283,6 @@ static void _xfdashboard_hot_corner_dispose(GObject *inObject)
XfdashboardHotCornerPrivate *priv=self->priv;
/* Release allocated resources */
- if(priv->xfconfActivationCornerBindingID)
- {
- xfconf_g_property_unbind(priv->xfconfActivationCornerBindingID);
- priv->xfconfActivationCornerBindingID=0;
- }
-
- if(priv->xfconfActivationRadiusBindingID)
- {
- xfconf_g_property_unbind(priv->xfconfActivationRadiusBindingID);
- priv->xfconfActivationRadiusBindingID=0;
- }
-
- if(priv->xfconfActivationDurationBindingID)
- {
- xfconf_g_property_unbind(priv->xfconfActivationDurationBindingID);
- priv->xfconfActivationDurationBindingID=0;
- }
-
- if(priv->xfconfChannel)
- {
- priv->xfconfChannel=NULL;
- }
-
if(priv->enteredTime)
{
g_date_time_unref(priv->enteredTime);
@@ -336,64 +301,14 @@ static void _xfdashboard_hot_corner_dispose(GObject *inObject)
priv->timeoutID=0;
}
- /* Call parent's class dispose method */
- G_OBJECT_CLASS(xfdashboard_hot_corner_parent_class)->dispose(inObject);
-}
-
-/* Set/get properties */
-static void _xfdashboard_hot_corner_set_property(GObject *inObject,
- guint inPropID,
- const GValue *inValue,
- GParamSpec *inSpec)
-{
- XfdashboardHotCorner *self=XFDASHBOARD_HOT_CORNER(inObject);
-
- switch(inPropID)
+ if(priv->settings)
{
- case PROP_ACTIVATION_CORNER:
- xfdashboard_hot_corner_set_activation_corner(self, g_value_get_enum(inValue));
- break;
-
- case PROP_ACTIVATION_RADIUS:
- xfdashboard_hot_corner_set_activation_radius(self, g_value_get_int(inValue));
- break;
-
- case PROP_ACTIVATION_DURATION:
- xfdashboard_hot_corner_set_activation_duration(self, g_value_get_uint64(inValue));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
+ g_object_unref(priv->settings);
+ priv->settings=NULL;
}
-}
-static void _xfdashboard_hot_corner_get_property(GObject *inObject,
- guint inPropID,
- GValue *outValue,
- GParamSpec *inSpec)
-{
- XfdashboardHotCorner *self=XFDASHBOARD_HOT_CORNER(inObject);
- XfdashboardHotCornerPrivate *priv=self->priv;
-
- switch(inPropID)
- {
- case PROP_ACTIVATION_CORNER:
- g_value_set_enum(outValue, priv->activationCorner);
- break;
-
- case PROP_ACTIVATION_RADIUS:
- g_value_set_int(outValue, priv->activationRadius);
- break;
-
- case PROP_ACTIVATION_DURATION:
- g_value_set_uint64(outValue, priv->activationDuration);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
- break;
- }
+ /* Call parent's class dispose method */
+ G_OBJECT_CLASS(xfdashboard_hot_corner_parent_class)->dispose(inObject);
}
/* Class initialization
@@ -406,38 +321,9 @@ void xfdashboard_hot_corner_class_init(XfdashboardHotCornerClass *klass)
/* Override functions */
gobjectClass->dispose=_xfdashboard_hot_corner_dispose;
- gobjectClass->set_property=_xfdashboard_hot_corner_set_property;
- gobjectClass->get_property=_xfdashboard_hot_corner_get_property;
/* Set up private structure */
g_type_class_add_private(klass, sizeof(XfdashboardHotCornerPrivate));
-
- /* Define properties */
- XfdashboardHotCornerProperties[PROP_ACTIVATION_CORNER]=
- g_param_spec_enum("activation-corner",
- _("Activation corner"),
- _("The hot corner where to trigger the application to suspend or to resume"),
- XFDASHBOARD_TYPE_HOT_CORNER_ACTIVATION_CORNER,
- DEFAULT_ACTIVATION_CORNER,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- XfdashboardHotCornerProperties[PROP_ACTIVATION_RADIUS]=
- g_param_spec_int("activation-radius",
- _("Activation radius"),
- _("The radius around hot corner where the pointer must be inside"),
- 0, G_MAXINT,
- DEFAULT_ACTIVATION_RADIUS,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- XfdashboardHotCornerProperties[PROP_ACTIVATION_DURATION]=
- g_param_spec_uint64("activation-duration",
- _("Activation duration"),
- _("The time in milliseconds the pointer must stay inside the radius at hot corner to trigger"),
- 0, G_MAXUINT64,
- DEFAULT_ACTIVATION_DURATION,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardHotCornerProperties);
}
/* Class finalization */
@@ -457,10 +343,6 @@ void xfdashboard_hot_corner_init(XfdashboardHotCorner *self)
self->priv=priv=XFDASHBOARD_HOT_CORNER_GET_PRIVATE(self);
/* Set up default values */
- priv->activationCorner=DEFAULT_ACTIVATION_CORNER;
- priv->activationRadius=DEFAULT_ACTIVATION_RADIUS;
- priv->activationDuration=DEFAULT_ACTIVATION_DURATION;
-
priv->windowTracker=xfdashboard_window_tracker_get_default();
priv->rootWindow=NULL;
priv->deviceManager=NULL;
@@ -468,8 +350,9 @@ void xfdashboard_hot_corner_init(XfdashboardHotCorner *self)
priv->timeoutID=0;
priv->enteredTime=NULL;
priv->wasHandledRecently=FALSE;
- priv->application=xfdashboard_application_get_default();
- priv->xfconfChannel=xfdashboard_application_get_xfconf_channel(priv->application);
+
+ /* Set up settings */
+ priv->settings=xfdashboard_hot_corner_settings_new();
/* Get device manager for polling pointer position */
if(xfdashboard_application_is_daemonized(priv->application))
@@ -502,28 +385,6 @@ void xfdashboard_hot_corner_init(XfdashboardHotCorner *self)
{
g_warning(_("Disabling hot-corner plugin because application is not running as daemon."));
}
-
- /* Bind to xfconf to react on changes */
- priv->xfconfActivationCornerBindingID=
- xfconf_g_property_bind(priv->xfconfChannel,
- ACTIVATION_CORNER_XFCONF_PROP,
- G_TYPE_STRING,
- self,
- "activation-corner");
-
- priv->xfconfActivationRadiusBindingID=
- xfconf_g_property_bind(priv->xfconfChannel,
- ACTIVATION_RADIUS_XFCONF_PROP,
- G_TYPE_INT,
- self,
- "activation-radius");
-
- priv->xfconfActivationDurationBindingID=
- xfconf_g_property_bind(priv->xfconfChannel,
- ACTIVATION_DURATION_XFCONF_PROP,
- G_TYPE_INT64,
- self,
- "activation-duration");
}
@@ -539,87 +400,3 @@ XfdashboardHotCorner* xfdashboard_hot_corner_new(void)
return(XFDASHBOARD_HOT_CORNER(hotCorner));
}
-
-/* Get/set hot corner */
-XfdashboardHotCornerActivationCorner xfdashboard_hot_corner_get_activation_corner(XfdashboardHotCorner *self)
-{
- g_return_val_if_fail(XFDASHBOARD_IS_HOT_CORNER(self), XFDASHBOARD_HOT_CORNER_ACTIVATION_CORNER_TOP_LEFT);
-
- return(self->priv->activationCorner);
-}
-
-void xfdashboard_hot_corner_set_activation_corner(XfdashboardHotCorner *self, XfdashboardHotCornerActivationCorner inCorner)
-{
- XfdashboardHotCornerPrivate *priv;
-
- g_return_if_fail(XFDASHBOARD_IS_HOT_CORNER(self));
- g_return_if_fail(inCorner<=XFDASHBOARD_HOT_CORNER_ACTIVATION_CORNER_BOTTOM_RIGHT);
-
- priv=self->priv;
-
- /* Set value if changed */
- if(priv->activationCorner!=inCorner)
- {
- /* Set value */
- priv->activationCorner=inCorner;
-
- /* Notify about property change */
- g_object_notify_by_pspec(G_OBJECT(self), XfdashboardHotCornerProperties[PROP_ACTIVATION_CORNER]);
- }
-}
-
-/* Get/set radius around hot corner */
-gint xfdashboard_hot_corner_get_activation_radius(XfdashboardHotCorner *self)
-{
- g_return_val_if_fail(XFDASHBOARD_IS_HOT_CORNER(self), 0);
-
- return(self->priv->activationRadius);
-}
-
-void xfdashboard_hot_corner_set_activation_radius(XfdashboardHotCorner *self, gint inRadius)
-{
- XfdashboardHotCornerPrivate *priv;
-
- g_return_if_fail(XFDASHBOARD_IS_HOT_CORNER(self));
- g_return_if_fail(inRadius>0);
-
- priv=self->priv;
-
- /* Set value if changed */
- if(priv->activationRadius!=inRadius)
- {
- /* Set value */
- priv->activationRadius=inRadius;
-
- /* Notify about property change */
- g_object_notify_by_pspec(G_OBJECT(self), XfdashboardHotCornerProperties[PROP_ACTIVATION_RADIUS]);
- }
-}
-
-/* Get/set duration when to trigger hot corner */
-gint64 xfdashboard_hot_corner_get_activation_duration(XfdashboardHotCorner *self)
-{
- g_return_val_if_fail(XFDASHBOARD_IS_HOT_CORNER(self), 0);
-
- return(self->priv->activationDuration);
-}
-
-void xfdashboard_hot_corner_set_activation_duration(XfdashboardHotCorner *self, gint64 inDuration)
-{
- XfdashboardHotCornerPrivate *priv;
-
- g_return_if_fail(XFDASHBOARD_IS_HOT_CORNER(self));
- g_return_if_fail(inDuration>0);
-
- priv=self->priv;
-
- /* Set value if changed */
- if(priv->activationDuration!=inDuration)
- {
- /* Set value */
- priv->activationDuration=inDuration;
-
- /* Notify about property change */
- g_object_notify_by_pspec(G_OBJECT(self), XfdashboardHotCornerProperties[PROP_ACTIVATION_DURATION]);
- }
-}
diff --git a/plugins/hot-corner/hot-corner.h b/plugins/hot-corner/hot-corner.h
index ca201e3..8c5c69d 100644
--- a/plugins/hot-corner/hot-corner.h
+++ b/plugins/hot-corner/hot-corner.h
@@ -76,15 +76,6 @@ XFDASHBOARD_DECLARE_PLUGIN_TYPE(xfdashboard_hot_corner);
XfdashboardHotCorner* xfdashboard_hot_corner_new(void);
-XfdashboardHotCornerActivationCorner xfdashboard_hot_corner_get_activation_corner(XfdashboardHotCorner *self);
-void xfdashboard_hot_corner_set_activation_corner(XfdashboardHotCorner *self, const XfdashboardHotCornerActivationCorner inCorner);
-
-gint xfdashboard_hot_corner_get_activation_radius(XfdashboardHotCorner *self);
-void xfdashboard_hot_corner_set_activation_radius(XfdashboardHotCorner *self, gint inRadius);
-
-gint64 xfdashboard_hot_corner_get_activation_duration(XfdashboardHotCorner *self);
-void xfdashboard_hot_corner_set_activation_duration(XfdashboardHotCorner *self, gint64 inDuration);
-
G_END_DECLS
#endif
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list