[Xfce4-commits] [apps/xfdashboard] 01/03: Add or remove CSS class "primary-monitor" to XfdashboardStageInterface depending on the primary state of associated monitor. With this CSS class the stage interface of the primary monitor could be themed different as the others non-primary or secondary ones.
noreply at xfce.org
noreply at xfce.org
Wed Dec 21 18:17:38 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 984a111ad6576ff285cadfd330abd0125107e0db
Author: Stephan Haller <nomad at froevel.de>
Date: Wed Dec 21 18:00:55 2016 +0100
Add or remove CSS class "primary-monitor" to XfdashboardStageInterface depending on the primary state of associated monitor. With this CSS class the stage interface of the primary monitor could be themed different as the others non-primary or secondary ones.
---
libxfdashboard/stage-interface.c | 44 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/libxfdashboard/stage-interface.c b/libxfdashboard/stage-interface.c
index f53706f..4ffcf21 100644
--- a/libxfdashboard/stage-interface.c
+++ b/libxfdashboard/stage-interface.c
@@ -32,6 +32,7 @@
#include <libxfdashboard/actor.h>
#include <libxfdashboard/enums.h>
#include <libxfdashboard/stage.h>
+#include <libxfdashboard/stylable.h>
#include <libxfdashboard/compat.h>
@@ -57,6 +58,7 @@ struct _XfdashboardStageInterfacePrivate
GBinding *bindingBackgroundColor;
guint geometryChangedID;
+ guint primaryChangedID;
};
/* Properties */
@@ -99,6 +101,28 @@ static void _xfdashboard_stage_interface_on_geometry_changed(XfdashboardStageInt
xfdashboard_window_tracker_monitor_get_number(priv->monitor));
}
+/* Monitor changed primary state */
+static void _xfdashboard_stage_interface_on_primary_changed(XfdashboardStageInterface *self, gpointer inUserData)
+{
+ XfdashboardStageInterfacePrivate *priv;
+ gboolean isPrimary;
+
+ g_return_if_fail(XFDASHBOARD_IS_STAGE_INTERFACE(self));
+
+ priv=self->priv;
+
+ /* Get new primary state of monitor */
+ isPrimary=xfdashboard_window_tracker_monitor_is_primary(priv->monitor);
+
+ /* Depending on primary state set CSS class */
+ if(isPrimary) xfdashboard_stylable_add_class(XFDASHBOARD_STYLABLE(self), "primary-monitor");
+ else xfdashboard_stylable_remove_class(XFDASHBOARD_STYLABLE(self), "primary-monitor");
+
+ g_debug("Stage interface changed primary state to %s because of monitor %d",
+ xfdashboard_window_tracker_monitor_is_primary(priv->monitor) ? "primary" : "non-primary",
+ xfdashboard_window_tracker_monitor_get_number(priv->monitor));
+}
+
/* IMPLEMENTATION: ClutterActor */
/* Actor was (re)parented */
@@ -231,6 +255,12 @@ static void _xfdashboard_stage_interface_dispose(GObject *inObject)
priv->geometryChangedID=0;
}
+ if(priv->primaryChangedID)
+ {
+ g_signal_handler_disconnect(priv->monitor, priv->primaryChangedID);
+ priv->primaryChangedID=0;
+ }
+
g_object_unref(priv->monitor);
priv->monitor=NULL;
}
@@ -365,6 +395,7 @@ static void xfdashboard_stage_interface_init(XfdashboardStageInterface *self)
/* Set default values */
priv->monitor=NULL;
priv->geometryChangedID=0;
+ priv->primaryChangedID=0;
priv->backgroundType=XFDASHBOARD_STAGE_BACKGROUND_IMAGE_TYPE_NONE;
priv->backgroundColor=NULL;
priv->bindingBackgroundImageType=NULL;
@@ -411,6 +442,12 @@ void xfdashboard_stage_interface_set_monitor(XfdashboardStageInterface *self, Xf
priv->geometryChangedID=0;
}
+ if(priv->primaryChangedID)
+ {
+ g_signal_handler_disconnect(priv->monitor, priv->primaryChangedID);
+ priv->primaryChangedID=0;
+ }
+
g_object_unref(priv->monitor);
priv->monitor=NULL;
}
@@ -422,10 +459,17 @@ void xfdashboard_stage_interface_set_monitor(XfdashboardStageInterface *self, Xf
"geometry-changed",
G_CALLBACK(_xfdashboard_stage_interface_on_geometry_changed),
self);
+ priv->primaryChangedID=g_signal_connect_swapped(priv->monitor,
+ "primary-changed",
+ G_CALLBACK(_xfdashboard_stage_interface_on_primary_changed),
+ self);
/* Resize actor to new monitor */
_xfdashboard_stage_interface_on_geometry_changed(self, priv->monitor);
+ /* Update actor from primary state */
+ _xfdashboard_stage_interface_on_primary_changed(self, priv->monitor);
+
/* Notify about property change */
g_object_notify_by_pspec(G_OBJECT(self), XfdashboardStageInterfaceProperties[PROP_MONITOR]);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list