[Xfce4-commits] [apps/xfdashboard] 01/01: Make showing sub-windows at XfdashboardLiveWindow themable

noreply at xfce.org noreply at xfce.org
Mon Feb 6 08:01:07 CET 2017


This is an automated email from the git hooks/post-receive script.

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit fe179d12a525b8fd0a596b085952f19337330247
Author: Stephan Haller <nomad at froevel.de>
Date:   Mon Feb 6 08:00:50 2017 +0100

    Make showing sub-windows at XfdashboardLiveWindow themable
---
 libxfdashboard/live-window.c | 105 ++++++++++++++++++++++++++++++++++++-------
 libxfdashboard/live-window.h |   3 ++
 2 files changed, 92 insertions(+), 16 deletions(-)

diff --git a/libxfdashboard/live-window.c b/libxfdashboard/live-window.c
index 22b9c2e..076cbfb 100644
--- a/libxfdashboard/live-window.c
+++ b/libxfdashboard/live-window.c
@@ -61,6 +61,8 @@ struct _XfdashboardLiveWindowPrivate
 	gfloat								paddingClose;
 	gfloat								paddingTitle;
 
+	gboolean							showSubwindows;
+
 	/* Instance related */
 	XfdashboardWindowTracker			*windowTracker;
 
@@ -81,6 +83,8 @@ enum
 	PROP_CLOSE_BUTTON_PADDING,
 	PROP_TITLE_ACTOR_PADDING,
 
+	PROP_SHOW_SUBWINDOWS,
+
 	PROP_LAST
 };
 
@@ -495,33 +499,29 @@ static void _xfdashboard_live_window_set_window_number(XfdashboardLiveWindow *se
 	}
 }
 
-/* Window property changed so set up controls, title and icon */
-static void _xfdashboard_live_window_on_window_changed(GObject *inObject,
-														GParamSpec *inSpec,
-														gpointer inUserData)
+/* Set up sub-windows layer by destryoing all children and re-adding actors for
+ * each associated sub-window.
+ */
+static void _xfdashboard_live_window_setup_subwindows_layer(XfdashboardLiveWindow *self)
 {
-	XfdashboardLiveWindow			*self;
 	XfdashboardLiveWindowPrivate	*priv;
-	XfdashboardWindowTrackerWindow	*window;
 	GList							*windowList;
 	XfdashboardWindowTrackerWindow	*subwindow;
 
-	g_return_if_fail(XFDASHBOARD_IS_LIVE_WINDOW(inObject));
+	g_return_if_fail(XFDASHBOARD_IS_LIVE_WINDOW(self));
 
-	self=XFDASHBOARD_LIVE_WINDOW(inObject);
 	priv=self->priv;
 
-	/* Get new window set */
-	window=xfdashboard_live_window_simple_get_window(XFDASHBOARD_LIVE_WINDOW_SIMPLE(self));
+	/* Do not setup sub-windows layer if there is no such layer */
+	if(!priv->actorSubwindowsLayer) return;
 
-	/* Set up this actor and child actor by calling each signal handler now */
-	_xfdashboard_live_window_on_actions_changed(self, window, priv->windowTracker);
-	_xfdashboard_live_window_on_icon_changed(self, window, priv->windowTracker);
-	_xfdashboard_live_window_on_name_changed(self, window, priv->windowTracker);
-
-	/* Destroy all sub-windows and create the ones belonging to this new window */
+	/* Destroy all sub-windows and do not create sub-windows actor if showing
+	 * them was disabled.
+	 */
 	clutter_actor_destroy_all_children(priv->actorSubwindowsLayer);
+	if(!priv->showSubwindows) return;
 
+	/* Create sub-window actors for the windows belonging to this one */
 	windowList=xfdashboard_window_tracker_get_windows_stacked(priv->windowTracker);
 	for( ; windowList; windowList=g_list_next(windowList))
 	{
@@ -537,6 +537,32 @@ static void _xfdashboard_live_window_on_window_changed(GObject *inObject,
 	}
 }
 
+/* Window property changed so set up controls, title and icon */
+static void _xfdashboard_live_window_on_window_changed(GObject *inObject,
+														GParamSpec *inSpec,
+														gpointer inUserData)
+{
+	XfdashboardLiveWindow			*self;
+	XfdashboardLiveWindowPrivate	*priv;
+	XfdashboardWindowTrackerWindow	*window;
+
+	g_return_if_fail(XFDASHBOARD_IS_LIVE_WINDOW(inObject));
+
+	self=XFDASHBOARD_LIVE_WINDOW(inObject);
+	priv=self->priv;
+
+	/* Get new window set */
+	window=xfdashboard_live_window_simple_get_window(XFDASHBOARD_LIVE_WINDOW_SIMPLE(self));
+
+	/* Set up this actor and child actor by calling each signal handler now */
+	_xfdashboard_live_window_on_actions_changed(self, window, priv->windowTracker);
+	_xfdashboard_live_window_on_icon_changed(self, window, priv->windowTracker);
+	_xfdashboard_live_window_on_name_changed(self, window, priv->windowTracker);
+
+	/* Set up sub-windows layer */
+	_xfdashboard_live_window_setup_subwindows_layer(self);
+}
+
 /* IMPLEMENTATION: ClutterActor */
 
 /* Get preferred width/height */
@@ -947,6 +973,10 @@ static void _xfdashboard_live_window_set_property(GObject *inObject,
 			xfdashboard_live_window_set_title_actor_padding(self, g_value_get_float(inValue));
 			break;
 
+		case PROP_SHOW_SUBWINDOWS:
+			xfdashboard_live_window_set_show_subwindows(self, g_value_get_boolean(inValue));
+			break;
+
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
 			break;
@@ -974,6 +1004,10 @@ static void _xfdashboard_live_window_get_property(GObject *inObject,
 			g_value_set_float(outValue, self->priv->paddingTitle);
 			break;
 
+		case PROP_SHOW_SUBWINDOWS:
+			g_value_set_boolean(outValue, self->priv->showSubwindows);
+			break;
+
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
 			break;
@@ -1027,11 +1061,19 @@ static void xfdashboard_live_window_class_init(XfdashboardLiveWindowClass *klass
 							0.0f,
 							G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+	XfdashboardLiveWindowProperties[PROP_SHOW_SUBWINDOWS]=
+		g_param_spec_boolean("show-subwindows",
+								_("Show sub-windows"),
+								_("Whether to show sub-windows of this main window"),
+								TRUE,
+								G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
 	g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardLiveWindowProperties);
 
 	/* Define stylable properties */
 	xfdashboard_actor_install_stylable_property(actorClass, XfdashboardLiveWindowProperties[PROP_CLOSE_BUTTON_PADDING]);
 	xfdashboard_actor_install_stylable_property(actorClass, XfdashboardLiveWindowProperties[PROP_TITLE_ACTOR_PADDING]);
+	xfdashboard_actor_install_stylable_property(actorClass, XfdashboardLiveWindowProperties[PROP_SHOW_SUBWINDOWS]);
 
 	/* Define signals */
 	XfdashboardLiveWindowSignals[SIGNAL_CLICKED]=
@@ -1075,6 +1117,7 @@ static void xfdashboard_live_window_init(XfdashboardLiveWindow *self)
 	priv->windowNumber=0;
 	priv->paddingTitle=0.0f;
 	priv->paddingClose=0.0f;
+	priv->showSubwindows=TRUE;
 
 	/* Set up container for sub-windows and add it before the container for controls
 	 * to keep the controls on top.
@@ -1201,3 +1244,33 @@ void xfdashboard_live_window_set_close_button_padding(XfdashboardLiveWindow *sel
 		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardLiveWindowProperties[PROP_CLOSE_BUTTON_PADDING]);
 	}
 }
+
+/* Get/set flag to show sub-windows */
+gboolean xfdashboard_live_window_get_show_subwindows(XfdashboardLiveWindow *self)
+{
+	g_return_val_if_fail(XFDASHBOARD_IS_LIVE_WINDOW(self), FALSE);
+
+	return(self->priv->showSubwindows);
+}
+
+void xfdashboard_live_window_set_show_subwindows(XfdashboardLiveWindow *self, gboolean inShowSubwindows)
+{
+	XfdashboardLiveWindowPrivate	*priv;
+
+	g_return_if_fail(XFDASHBOARD_IS_LIVE_WINDOW(self));
+
+	priv=self->priv;
+
+	/* Set value if changed */
+	if(priv->showSubwindows!=inShowSubwindows)
+	{
+		/* Set value */
+		priv->showSubwindows=inShowSubwindows;
+
+		/* Set up sub-windows layer */
+		_xfdashboard_live_window_setup_subwindows_layer(self);
+
+		/* Notify about property change */
+		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardLiveWindowProperties[PROP_SHOW_SUBWINDOWS]);
+	}
+}
diff --git a/libxfdashboard/live-window.h b/libxfdashboard/live-window.h
index 5b9d684..9a1fdb8 100644
--- a/libxfdashboard/live-window.h
+++ b/libxfdashboard/live-window.h
@@ -82,6 +82,9 @@ void xfdashboard_live_window_set_title_actor_padding(XfdashboardLiveWindow *self
 gfloat xfdashboard_live_window_get_close_button_padding(XfdashboardLiveWindow *self);
 void xfdashboard_live_window_set_close_button_padding(XfdashboardLiveWindow *self, gfloat inPadding);
 
+gboolean xfdashboard_live_window_get_show_subwindows(XfdashboardLiveWindow *self);
+void xfdashboard_live_window_set_show_subwindows(XfdashboardLiveWindow *self, gboolean inShowSubwindows);
+
 G_END_DECLS
 
 #endif	/* __LIBXFDASHBOARD_LIVE_WINDOW__ */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list