[Xfce4-commits] [apps/xfdashboard] 01/02: Make XfdashboardLiveWindowSimple themable if a live window preview should be shown or just only the window's icon

noreply at xfce.org noreply at xfce.org
Mon Jan 23 18:45:32 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 5552bdc0cf37c0dca9b4835d687407ab35d57743
Author: Stephan Haller <nomad at froevel.de>
Date:   Mon Jan 23 18:39:24 2017 +0100

    Make XfdashboardLiveWindowSimple themable if a live window preview should be shown or just only the window's icon
---
 libxfdashboard/live-window-simple.c | 113 +++++++++++++++++++++++++++++++++---
 libxfdashboard/live-window-simple.h |  20 ++++++-
 libxfdashboard/live-workspace.c     |   6 +-
 3 files changed, 126 insertions(+), 13 deletions(-)

diff --git a/libxfdashboard/live-window-simple.c b/libxfdashboard/live-window-simple.c
index 8be8a17..5cf557b 100644
--- a/libxfdashboard/live-window-simple.c
+++ b/libxfdashboard/live-window-simple.c
@@ -32,7 +32,9 @@
 
 #include <libxfdashboard/click-action.h>
 #include <libxfdashboard/window-content.h>
+#include <libxfdashboard/image-content.h>
 #include <libxfdashboard/stylable.h>
+#include <libxfdashboard/enums.h>
 #include <libxfdashboard/compat.h>
 
 
@@ -48,14 +50,15 @@ G_DEFINE_TYPE(XfdashboardLiveWindowSimple,
 struct _XfdashboardLiveWindowSimplePrivate
 {
 	/* Properties related */
-	XfdashboardWindowTrackerWindow		*window;
+	XfdashboardWindowTrackerWindow			*window;
+	XfdashboardLiveWindowSimpleDisplayType	displayType;
 
 	/* Instance related */
-	XfdashboardWindowTracker			*windowTracker;
+	XfdashboardWindowTracker				*windowTracker;
 
-	gboolean							isVisible;
+	gboolean								isVisible;
 
-	ClutterActor						*actorWindow;
+	ClutterActor							*actorWindow;
 };
 
 /* Properties */
@@ -64,6 +67,7 @@ enum
 	PROP_0,
 
 	PROP_WINDOW,
+	PROP_DISPLAY_TYPE,
 
 	PROP_LAST
 };
@@ -206,6 +210,48 @@ static void _xfdashboard_live_window_simple_on_workspace_changed(XfdashboardLive
 	g_signal_emit(self, XfdashboardLiveWindowSimpleSignals[SIGNAL_WORKSPACE_CHANGED], 0);
 }
 
+/* Set up actor's content depending on display. If no window is set the current
+ * content of this actor is destroyed and a new one is not set up. The actor will
+ * be displayed empty.
+ */
+static void _xfdashboard_live_window_simple_setup_content(XfdashboardLiveWindowSimple *self)
+{
+	XfdashboardLiveWindowSimplePrivate	*priv;
+	ClutterContent						*content;
+
+	g_return_if_fail(XFDASHBOARD_IS_LIVE_WINDOW_SIMPLE(self));
+
+	priv=self->priv;
+
+	/* Destroy old actor's content */
+	clutter_actor_set_content(priv->actorWindow, NULL);
+
+	/* If no window is set we cannot set up actor's content but only destroy the
+	 * old. So return here if no window is set.
+	 */
+	if(!priv->window) return;
+
+	/* Setup actor's content depending on display type */
+	switch(priv->displayType)
+	{
+		case XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_LIVE_PREVIEW:
+			content=xfdashboard_window_content_new_for_window(priv->window);
+			clutter_actor_set_content(priv->actorWindow, content);
+			g_object_unref(content);
+			break;
+
+		case XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_ICON:
+			content=xfdashboard_image_content_new_for_pixbuf(xfdashboard_window_tracker_window_get_icon(priv->window));
+			clutter_actor_set_content(priv->actorWindow, content);
+			g_object_unref(content);
+			break;
+
+		default:
+			g_assert_not_reached();
+			break;
+	}
+}
+
 /* IMPLEMENTATION: ClutterActor */
 
 /* Get preferred width/height */
@@ -336,6 +382,10 @@ static void _xfdashboard_live_window_simple_set_property(GObject *inObject,
 			xfdashboard_live_window_simple_set_window(self, g_value_get_object(inValue));
 			break;
 
+		case PROP_DISPLAY_TYPE:
+			xfdashboard_live_window_simple_set_display_type(self, g_value_get_enum(inValue));
+			break;
+
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
 			break;
@@ -355,6 +405,10 @@ static void _xfdashboard_live_window_simple_get_property(GObject *inObject,
 			g_value_set_object(outValue, self->priv->window);
 			break;
 
+		case PROP_DISPLAY_TYPE:
+			g_value_set_enum(outValue, self->priv->displayType);
+			break;
+
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
 			break;
@@ -367,6 +421,7 @@ static void _xfdashboard_live_window_simple_get_property(GObject *inObject,
  */
 static void xfdashboard_live_window_simple_class_init(XfdashboardLiveWindowSimpleClass *klass)
 {
+	XfdashboardActorClass	*actorClass=XFDASHBOARD_ACTOR_CLASS(klass);
 	ClutterActorClass		*clutterActorClass=CLUTTER_ACTOR_CLASS(klass);
 	GObjectClass			*gobjectClass=G_OBJECT_CLASS(klass);
 
@@ -390,8 +445,19 @@ static void xfdashboard_live_window_simple_class_init(XfdashboardLiveWindowSimpl
 								XFDASHBOARD_TYPE_WINDOW_TRACKER_WINDOW,
 								G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+	XfdashboardLiveWindowSimpleProperties[PROP_DISPLAY_TYPE]=
+		g_param_spec_enum("display-type",
+							_("Display type"),
+							_("How to display the window"),
+							XFDASHBOARD_TYPE_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE,
+							XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_LIVE_PREVIEW,
+							G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
 	g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardLiveWindowSimpleProperties);
 
+	/* Define stylable properties */
+	xfdashboard_actor_install_stylable_property(actorClass, XfdashboardLiveWindowSimpleProperties[PROP_DISPLAY_TYPE]);
+
 	/* Define signals */
 	XfdashboardLiveWindowSimpleSignals[SIGNAL_GEOMETRY_CHANGED]=
 		g_signal_new("geometry-changed",
@@ -443,6 +509,7 @@ static void xfdashboard_live_window_simple_init(XfdashboardLiveWindowSimple *sel
 	/* Set default values */
 	priv->windowTracker=xfdashboard_window_tracker_get_default();
 	priv->window=NULL;
+	priv->displayType=XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_LIVE_PREVIEW;
 
 	/* Set up child actors (order is important) */
 	priv->actorWindow=clutter_actor_new();
@@ -483,7 +550,6 @@ XfdashboardWindowTrackerWindow* xfdashboard_live_window_simple_get_window(Xfdash
 void xfdashboard_live_window_simple_set_window(XfdashboardLiveWindowSimple *self, XfdashboardWindowTrackerWindow *inWindow)
 {
 	XfdashboardLiveWindowSimplePrivate	*priv;
-	ClutterContent						*content;
 
 	g_return_if_fail(XFDASHBOARD_IS_LIVE_WINDOW_SIMPLE(self));
 	g_return_if_fail(!inWindow || XFDASHBOARD_IS_WINDOW_TRACKER_WINDOW(inWindow));
@@ -509,10 +575,8 @@ void xfdashboard_live_window_simple_set_window(XfdashboardLiveWindowSimple *self
 		/* Get visibility state of window */
 		priv->isVisible=_xfdashboard_live_window_simple_is_visible_window(self, priv->window);
 
-		/* Setup window actor */
-		content=xfdashboard_window_content_new_for_window(priv->window);
-		clutter_actor_set_content(priv->actorWindow, content);
-		g_object_unref(content);
+		/* Setup window actor content */
+		_xfdashboard_live_window_simple_setup_content(self);
 
 		/* Set up this actor and child actor by calling each signal handler now */
 		_xfdashboard_live_window_simple_on_geometry_changed(self, priv->window, priv->windowTracker);
@@ -531,3 +595,34 @@ void xfdashboard_live_window_simple_set_window(XfdashboardLiveWindowSimple *self
 	/* Notify about property change */
 	g_object_notify_by_pspec(G_OBJECT(self), XfdashboardLiveWindowSimpleProperties[PROP_WINDOW]);
 }
+
+/* Get/set display type of window */
+XfdashboardLiveWindowSimpleDisplayType xfdashboard_live_window_simple_get_display_type(XfdashboardLiveWindowSimple *self)
+{
+	g_return_val_if_fail(XFDASHBOARD_IS_LIVE_WINDOW_SIMPLE(self), XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_LIVE_PREVIEW);
+
+	return(self->priv->displayType);
+}
+
+void xfdashboard_live_window_simple_set_display_type(XfdashboardLiveWindowSimple *self, XfdashboardLiveWindowSimpleDisplayType inType)
+{
+	XfdashboardLiveWindowSimplePrivate	*priv;
+
+	g_return_if_fail(XFDASHBOARD_IS_LIVE_WINDOW_SIMPLE(self));
+	g_return_if_fail(inType>=XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_LIVE_PREVIEW && inType<=XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_ICON);
+
+	priv=self->priv;
+
+	/* Only set value if it changes */
+	if(priv->displayType!=inType)
+	{
+		/* Set value */
+		priv->displayType=inType;
+
+		/* Setup window actor content */
+		_xfdashboard_live_window_simple_setup_content(self);
+
+		/* Notify about property change */
+		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardLiveWindowSimpleProperties[PROP_DISPLAY_TYPE]);
+	}
+}
diff --git a/libxfdashboard/live-window-simple.h b/libxfdashboard/live-window-simple.h
index 64e4c39..2cecdff 100644
--- a/libxfdashboard/live-window-simple.h
+++ b/libxfdashboard/live-window-simple.h
@@ -32,11 +32,26 @@
 #include <clutter/clutter.h>
 
 #include <libxfdashboard/background.h>
-#include <libxfdashboard/button.h>
 #include <libxfdashboard/window-tracker.h>
 
 G_BEGIN_DECLS
 
+/* Public definitions */
+/**
+ * XfdashboardLiveWindowSimpleDisplayType:
+ * @XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_LIVE_PREVIEW: The actor will show a live preview of window
+ * @XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_ICON: The actor will show the window's icon in size of window
+ *
+ * Determines how the window will be displayed.
+ */
+typedef enum /*< prefix=XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE >*/
+{
+	XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_LIVE_PREVIEW=0,
+	XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_ICON,
+} XfdashboardLiveWindowSimpleDisplayType;
+
+
+/* Object declaration */
 #define XFDASHBOARD_TYPE_LIVE_WINDOW_SIMPLE				(xfdashboard_live_window_simple_get_type())
 #define XFDASHBOARD_LIVE_WINDOW_SIMPLE(obj)				(G_TYPE_CHECK_INSTANCE_CAST((obj), XFDASHBOARD_TYPE_LIVE_WINDOW_SIMPLE, XfdashboardLiveWindowSimple))
 #define XFDASHBOARD_IS_LIVE_WINDOW_SIMPLE(obj)			(G_TYPE_CHECK_INSTANCE_TYPE((obj), XFDASHBOARD_TYPE_LIVE_WINDOW_SIMPLE))
@@ -80,6 +95,9 @@ ClutterActor* xfdashboard_live_window_simple_new_for_window(XfdashboardWindowTra
 XfdashboardWindowTrackerWindow* xfdashboard_live_window_simple_get_window(XfdashboardLiveWindowSimple *self);
 void xfdashboard_live_window_simple_set_window(XfdashboardLiveWindowSimple *self, XfdashboardWindowTrackerWindow *inWindow);
 
+XfdashboardLiveWindowSimpleDisplayType xfdashboard_live_window_simple_get_display_type(XfdashboardLiveWindowSimple *self);
+void xfdashboard_live_window_simple_set_display_type(XfdashboardLiveWindowSimple *self, XfdashboardLiveWindowSimpleDisplayType inType);
+
 G_END_DECLS
 
 #endif	/* __LIBXFDASHBOARD_LIVE_WINDOW_SIMPLE__ */
diff --git a/libxfdashboard/live-workspace.c b/libxfdashboard/live-workspace.c
index 5f758ae..08a150c 100644
--- a/libxfdashboard/live-workspace.c
+++ b/libxfdashboard/live-workspace.c
@@ -198,7 +198,7 @@ static ClutterActor* _xfdashboard_live_workspace_create_and_add_window_actor(Xfd
 		{
 			/* Create actor */
 			actor=xfdashboard_live_window_simple_new_for_window(inWindow);
-			// TODO: if(!priv->showWindowContent) xfdashboard_live_window_simple_set_type(actor, XFDASHBOARD_LIVE_WINDOW_SIMPLE_TYPE_ICON);
+			if(!priv->showWindowContent) xfdashboard_live_window_simple_set_display_type(actor, XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_ICON);
 
 			/* Add new actor at right stacking position */
 			if(lastWindowActor) clutter_actor_insert_child_above(CLUTTER_ACTOR(self), actor, lastWindowActor);
@@ -1122,11 +1122,11 @@ void xfdashboard_live_workspace_set_show_window_content(XfdashboardLiveWorkspace
 			/* Replace content depending on this new value if neccessary */
 			if(priv->showWindowContent)
 			{
-				// TODO: xfdashboard_live_window_simple_set_type(XFDASHBOARD_LIVE_WINDOW_SIMPLE(child), XFDASHBOARD_LIVE_WINDOW_SIMPLE_TYPE_LIVE_PREVIEW);
+				xfdashboard_live_window_simple_set_display_type(XFDASHBOARD_LIVE_WINDOW_SIMPLE(child), XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_LIVE_PREVIEW);
 			}
 				else
 				{
-					// TODO: if(!priv->showWindowContent) xfdashboard_live_window_simple_set_type(XFDASHBOARD_LIVE_WINDOW_SIMPLE(child), XFDASHBOARD_LIVE_WINDOW_SIMPLE_TYPE_ICON);
+					xfdashboard_live_window_simple_set_display_type(XFDASHBOARD_LIVE_WINDOW_SIMPLE(child), XFDASHBOARD_LIVE_WINDOW_SIMPLE_DISPLAY_TYPE_ICON);
 				}
 		}
 

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


More information about the Xfce4-commits mailing list