[Xfce4-commits] [apps/xfdashboard] 01/02: Implement function to allow a single-time switch to another view on resume as configured in settings or to switch to a view at initial start-up.

noreply at xfce.org noreply at xfce.org
Tue Aug 25 07:11:15 CEST 2015


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

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

commit ff3886492e34554b7e4441c8798c01c99dc4e219
Author: Stephan Haller <nomad at froevel.de>
Date:   Mon Aug 24 21:03:39 2015 +0200

    Implement function to allow a single-time switch to another view on resume as configured in settings or to switch to a view at initial start-up.
    
    The view name set must be the internal view name of the view to switch to. This "switch" will only performed once, that means after the switch the name set will be resetted and the configured view in the settings will be considered again.
    
    This commit is part of implementation needed to fix bug #12144
---
 xfdashboard/stage.c |  112 ++++++++++++++++++++++++++++++++++++++++++++++++---
 xfdashboard/stage.h |    3 ++
 2 files changed, 110 insertions(+), 5 deletions(-)

diff --git a/xfdashboard/stage.c b/xfdashboard/stage.c
index 3bad33b..6702890 100644
--- a/xfdashboard/stage.c
+++ b/xfdashboard/stage.c
@@ -90,6 +90,7 @@ struct _XfdashboardStagePrivate
 	gboolean								searchActive;
 	gint									lastSearchTextLength;
 	XfdashboardView							*viewBeforeSearch;
+	gchar									*switchToView;
 
 	guint									notificationTimeoutID;
 
@@ -104,6 +105,8 @@ enum
 	PROP_BACKGROUND_IMAGE_TYPE,
 	PROP_BACKGROUND_COLOR,
 
+	PROP_SWITCH_TO_VIEW,
+
 	PROP_LAST
 };
 
@@ -655,11 +658,32 @@ static void _xfdashboard_stage_on_application_resume(XfdashboardStage *self, gpo
 
 		/* Find view to switch to if requested */
 		resumeView=NULL;
-		if(resumeViewInternalName)
+		if(resumeViewInternalName || priv->switchToView)
 		{
-			/* Lookup view by its internal name */
-			resumeView=xfdashboard_viewpad_find_view_by_name(XFDASHBOARD_VIEWPAD(priv->viewpad), resumeViewInternalName);
-			if(!resumeView) g_warning(_("Cannot switch to unknown view '%s'"), resumeViewInternalName);
+			/* First lookup view we should switch to by its internal name */
+			if(priv->switchToView)
+			{
+				resumeView=xfdashboard_viewpad_find_view_by_name(XFDASHBOARD_VIEWPAD(priv->viewpad), priv->switchToView);
+				if(!resumeView) g_warning(_("Will not switch to unknown view '%s'"), priv->switchToView);
+
+				/* Regardless if we could find view by its internal name or not
+				 * reset variable because the switch should happen once only.
+				 */
+				g_free(priv->switchToView);
+				priv->switchToView=NULL;
+
+				/* Notify about property change */
+				g_object_notify_by_pspec(G_OBJECT(self), XfdashboardStageProperties[PROP_SWITCH_TO_VIEW]);
+			}
+
+			/* If we have not to switch to a specific view or if this view cannot be found
+			 * then lookup the configured view in settings by its internal name
+			 */
+			if(!resumeView)
+			{
+				resumeView=xfdashboard_viewpad_find_view_by_name(XFDASHBOARD_VIEWPAD(priv->viewpad), resumeViewInternalName);
+				if(!resumeView) g_warning(_("Cannot switch to unknown view '%s'"), resumeViewInternalName);
+			}
 
 			/* If view to switch to is the search view behave like we did not find the view
 			 * because it does not make sense to switch to a view which might be hidden,
@@ -713,7 +737,9 @@ static void _xfdashboard_stage_on_application_resume(XfdashboardStage *self, gpo
 		/* ... otherwise set it up by calling clutter_actor_show() etc. */
 		else
 		{
-			/* Show stage and force window creation */
+			/* Show stage and force window creation. It will also handle
+			 * the switch to a specific view.
+			 */
 			clutter_actor_show(CLUTTER_ACTOR(self));
 		}
 
@@ -1280,12 +1306,34 @@ static void _xfdashboard_stage_show(ClutterActor *inActor)
 {
 	XfdashboardStage			*self;
 	XfdashboardStagePrivate		*priv;
+	XfdashboardView				*switchView;
 
 	g_return_if_fail(XFDASHBOARD_IS_STAGE(inActor));
 
 	self=XFDASHBOARD_STAGE(inActor);
 	priv=self->priv;
 
+	/* Lookup view we should switch to by its internal name if any */
+	if(priv->switchToView)
+	{
+		/* Look up view and switch to it if found */
+		switchView=xfdashboard_viewpad_find_view_by_name(XFDASHBOARD_VIEWPAD(priv->viewpad), priv->switchToView);
+		if(!switchView)
+		{
+			xfdashboard_viewpad_set_active_view(XFDASHBOARD_VIEWPAD(priv->viewpad), switchView);
+		}
+			else g_warning(_("Will not switch to unknown view '%s'"), priv->switchToView);
+
+		/* Regardless if we could find view by its internal name or not
+		 * reset variable because the switch should happen once only.
+		 */
+		g_free(priv->switchToView);
+		priv->switchToView=NULL;
+
+		/* Notify about property change */
+		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardStageProperties[PROP_SWITCH_TO_VIEW]);
+	}
+
 	/* Set stage to fullscreen just in case it forgot about it */
 	clutter_stage_set_fullscreen(CLUTTER_STAGE(self), TRUE);
 
@@ -1409,6 +1457,12 @@ static void _xfdashboard_stage_dispose(GObject *inObject)
 		priv->backgroundColorLayer=NULL;
 	}
 
+	if(priv->switchToView)
+	{
+		g_free(priv->switchToView);
+		priv->switchToView=NULL;
+	}
+
 	/* Call parent's class dispose method */
 	G_OBJECT_CLASS(xfdashboard_stage_parent_class)->dispose(inObject);
 }
@@ -1431,6 +1485,10 @@ static void _xfdashboard_stage_set_property(GObject *inObject,
 			xfdashboard_stage_set_background_color(self, clutter_value_get_color(inValue));
 			break;
 
+		case PROP_SWITCH_TO_VIEW:
+			xfdashboard_stage_set_switch_to_view(self, g_value_get_string(inValue));
+			break;
+
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
 			break;
@@ -1455,6 +1513,10 @@ static void _xfdashboard_stage_get_property(GObject *inObject,
 			clutter_value_set_color(outValue, priv->backgroundColor);
 			break;
 
+		case PROP_SWITCH_TO_VIEW:
+			g_value_set_string(outValue, priv->switchToView);
+			break;
+
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(inObject, inPropID, inSpec);
 			break;
@@ -1500,6 +1562,13 @@ static void xfdashboard_stage_class_init(XfdashboardStageClass *klass)
 									NULL,
 									G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+	XfdashboardStageProperties[PROP_SWITCH_TO_VIEW]=
+		g_param_spec_string("switch-to-view",
+							_("Switch to view"),
+							_("Switch to this named view as soon as stage gets visible"),
+							NULL,
+							G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
 	g_object_class_install_properties(gobjectClass, PROP_LAST, XfdashboardStageProperties);
 
 	/* Define signals */
@@ -1595,6 +1664,7 @@ static void xfdashboard_stage_init(XfdashboardStage *self)
 	priv->backgroundColor=NULL;
 	priv->backgroundColorLayer=NULL;
 	priv->backgroundImageLayer=NULL;
+	priv->switchToView=NULL;
 
 	/* Create background actors but order of adding background children is important */
 	widthConstraint=clutter_bind_constraint_new(CLUTTER_ACTOR(self), CLUTTER_BIND_WIDTH, 0.0f);
@@ -1798,6 +1868,38 @@ void xfdashboard_stage_set_background_color(XfdashboardStage *self, const Clutte
 	}
 }
 
+/* Set name of view to switch to at next resume */
+const gchar* xfdashboard_stage_get_switch_to_view(XfdashboardStage *self)
+{
+	g_return_val_if_fail(XFDASHBOARD_IS_STAGE(self), NULL);
+
+	return(self->priv->switchToView);
+}
+
+void xfdashboard_stage_set_switch_to_view(XfdashboardStage *self, const gchar *inViewInternalName)
+{
+	XfdashboardStagePrivate		*priv;
+
+	g_return_if_fail(XFDASHBOARD_IS_STAGE(self));
+
+	priv=self->priv;
+
+	/* Set value if changed */
+	if(g_strcmp0(priv->switchToView, inViewInternalName)!=0)
+	{
+		if(priv->switchToView)
+		{
+			g_free(priv->switchToView);
+			priv->switchToView=NULL;
+		}
+
+		if(inViewInternalName) priv->switchToView=g_strdup(inViewInternalName);
+
+		/* Notify about property change */
+		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardStageProperties[PROP_SWITCH_TO_VIEW]);
+	}
+}
+
 /* Show a notification on stage */
 void xfdashboard_stage_show_notification(XfdashboardStage *self, const gchar *inIconName, const gchar *inText)
 {
diff --git a/xfdashboard/stage.h b/xfdashboard/stage.h
index 4fdb1a1..5ad73d5 100644
--- a/xfdashboard/stage.h
+++ b/xfdashboard/stage.h
@@ -77,6 +77,9 @@ void xfdashboard_stage_set_background_image_type(XfdashboardStage *self, Xfdashb
 ClutterColor* xfdashboard_stage_get_background_color(XfdashboardStage *self);
 void xfdashboard_stage_set_background_color(XfdashboardStage *self, const ClutterColor *inColor);
 
+const gchar* xfdashboard_stage_get_switch_to_view(XfdashboardStage *self);
+void xfdashboard_stage_set_switch_to_view(XfdashboardStage *self, const gchar *inViewInternalName);
+
 void xfdashboard_stage_show_notification(XfdashboardStage *self, const gchar *inIconName, const gchar *inText);
 
 G_END_DECLS

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


More information about the Xfce4-commits mailing list