[Xfce4-commits] [apps/xfdashboard] 01/01: Split out function to find parent XfdashboardStageInterface or XfdashboardStage of an actor into a seperate function and use it for applicable.
noreply at xfce.org
noreply at xfce.org
Tue Dec 8 21:34:38 CET 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 dc5ec8d5b7bb9b636640c3a9be8e3a9a844328e2
Author: Stephan Haller <nomad at froevel.de>
Date: Tue Dec 8 21:00:07 2015 +0100
Split out function to find parent XfdashboardStageInterface or XfdashboardStage of an actor into a seperate function and use it for applicable.
---
xfdashboard/utils.c | 75 ++++++++++++++++++++++++++++++++++++++
xfdashboard/utils.h | 5 +++
xfdashboard/windows-view.c | 10 +----
xfdashboard/workspace-selector.c | 25 ++-----------
4 files changed, 84 insertions(+), 31 deletions(-)
diff --git a/xfdashboard/utils.c b/xfdashboard/utils.c
index a1e1854..6afd09b 100644
--- a/xfdashboard/utils.c
+++ b/xfdashboard/utils.c
@@ -404,6 +404,81 @@ ClutterActor* xfdashboard_find_actor_by_name(ClutterActor *inActor, const gchar
}
/**
+ * xfdashboard_get_stage_of_actor:
+ * @inActor: The #ClutterActor for which to find the stage
+ *
+ * Gets the #XfdashboardStageInterface of the monitor where
+ * @inActor belongs to.
+ *
+ * Return value: (transfer none): The #XfdashboardStageInterface
+ * found or %NULL if none was found.
+ */
+XfdashboardStageInterface* xfdashboard_get_stage_of_actor(ClutterActor *inActor)
+{
+ ClutterActor *parent;
+
+ g_return_val_if_fail(CLUTTER_IS_ACTOR(inActor), NULL);
+
+ /* Iterate through parents and return first XfdashboardStageInterface
+ * found. That's the stage of the monitor where the requested actor
+ * belongs to.
+ */
+ parent=clutter_actor_get_parent(inActor);
+ while(parent)
+ {
+ /* Check if current iterated parent is a XfdashboardStageInterface.
+ * If it is return it.
+ */
+ if(XFDASHBOARD_IS_STAGE_INTERFACE(parent)) return(XFDASHBOARD_STAGE_INTERFACE(parent));
+
+ /* Continue with next parent */
+ parent=clutter_actor_get_parent(parent);
+ }
+
+ /* If we get here we did not find the stage the actor belongs to,
+ * so return NULL.
+ */
+ return(NULL);
+}
+
+/**
+ * xfdashboard_get_global_stage_of_actor:
+ * @inActor: The #ClutterActor for which to find the global stage
+ *
+ * Gets the main #XfdashboardStage where @inActor belongs to.
+ *
+ * Return value: (transfer none): The #XfdashboardStage found
+ * or %NULL if none was found.
+ */
+XfdashboardStage* xfdashboard_get_global_stage_of_actor(ClutterActor *inActor)
+{
+ ClutterActor *parent;
+
+ g_return_val_if_fail(CLUTTER_IS_ACTOR(inActor), NULL);
+
+ /* Iterate through parents and return first XfdashboardStage
+ * found. That's the main global and all monitors spanning
+ * stage where the requested actor belongs to.
+ */
+ parent=clutter_actor_get_parent(inActor);
+ while(parent)
+ {
+ /* Check if current iterated parent is a XfdashboardStage.
+ * If it is return it.
+ */
+ if(XFDASHBOARD_IS_STAGE(parent)) return(XFDASHBOARD_STAGE(parent));
+
+ /* Continue with next parent */
+ parent=clutter_actor_get_parent(parent);
+ }
+
+ /* If we get here we did not find the global stage the actor
+ * belongs to, so return NULL.
+ */
+ return(NULL);
+}
+
+/**
* xfdashboard_split_string:
* @inString: The string to split
* @inDelimiters: A string containg the delimiters
diff --git a/xfdashboard/utils.h b/xfdashboard/utils.h
index 7a85c2e..c1d878f 100644
--- a/xfdashboard/utils.h
+++ b/xfdashboard/utils.h
@@ -28,6 +28,8 @@
#include <gio/gio.h>
#include "window-tracker-workspace.h"
+#include "stage-interface.h"
+#include "stage.h"
G_BEGIN_DECLS
@@ -85,6 +87,9 @@ void xfdashboard_register_gvalue_transformation_funcs(void);
ClutterActor* xfdashboard_find_actor_by_name(ClutterActor *inActor, const gchar *inName);
+XfdashboardStageInterface* xfdashboard_get_stage_of_actor(ClutterActor *inActor);
+XfdashboardStage* xfdashboard_get_global_stage_of_actor(ClutterActor *inActor);
+
gchar** xfdashboard_split_string(const gchar *inString, const gchar *inDelimiters);
gboolean xfdashboard_is_valid_id(const gchar *inString);
diff --git a/xfdashboard/windows-view.c b/xfdashboard/windows-view.c
index 20de112..99e9faf 100644
--- a/xfdashboard/windows-view.c
+++ b/xfdashboard/windows-view.c
@@ -153,22 +153,14 @@ static void _xfdashboard_windows_view_update_on_stage_monitor_changed(Xfdashboar
static gboolean _xfdashboard_windows_view_update_stage_and_monitor(XfdashboardWindowsView *self)
{
XfdashboardWindowsViewPrivate *priv;
- ClutterActor *parent;
XfdashboardStageInterface *newStage;
g_return_val_if_fail(XFDASHBOARD_IS_WINDOWS_VIEW(self), FALSE);
priv=self->priv;
- newStage=NULL;
/* Iterate through parent actors until stage interface is reached */
- parent=clutter_actor_get_parent(CLUTTER_ACTOR(self));
- while(parent && !XFDASHBOARD_IS_STAGE_INTERFACE(parent))
- {
- parent=clutter_actor_get_parent(parent);
- }
-
- if(parent) newStage=XFDASHBOARD_STAGE_INTERFACE(parent);
+ newStage=xfdashboard_get_stage_of_actor(CLUTTER_ACTOR(self));
/* If stage did not change return immediately */
if(newStage==priv->currentStage) return(FALSE);
diff --git a/xfdashboard/workspace-selector.c b/xfdashboard/workspace-selector.c
index 08aaa68..e0b10b0 100644
--- a/xfdashboard/workspace-selector.c
+++ b/xfdashboard/workspace-selector.c
@@ -96,25 +96,6 @@ static GParamSpec* XfdashboardWorkspaceSelectorProperties[PROP_LAST]={ 0, };
#define DEFAULT_USING_FRACTION TRUE
#define DEFAULT_ORIENTATION CLUTTER_ORIENTATION_VERTICAL
-/* Find stage interface whose child this actor is */
-static XfdashboardStageInterface* _xfdashboard_workspace_selector_get_stage_interface(XfdashboardWorkspaceSelector *self)
-{
- ClutterActor *stageInterface;
-
- g_return_val_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(self), NULL);
-
- /* Find parent stage interface */
- stageInterface=clutter_actor_get_parent(CLUTTER_ACTOR(self));
- while(stageInterface && !XFDASHBOARD_IS_STAGE_INTERFACE(stageInterface))
- {
- stageInterface=clutter_actor_get_parent(stageInterface);
- }
- if(stageInterface) return(XFDASHBOARD_STAGE_INTERFACE(stageInterface));
-
- /* If we get here we did not find parent stage interface */
- return(NULL);
-}
-
/* Get maximum (horizontal or vertical) size either by static size or fraction */
static gfloat _xfdashboard_workspace_selector_get_max_size_internal(XfdashboardWorkspaceSelector *self)
{
@@ -131,7 +112,7 @@ static gfloat _xfdashboard_workspace_selector_get_max_size_internal(XfdashboardW
* to determine maximum size by fraction or to update maximum size or
* fraction and send notifications.
*/
- stageInterface=_xfdashboard_workspace_selector_get_stage_interface(self);
+ stageInterface=xfdashboard_get_stage_of_actor(CLUTTER_ACTOR(self));
if(!stageInterface) return(0.0f);
clutter_actor_get_size(CLUTTER_ACTOR(stageInterface), &w, &h);
@@ -445,7 +426,7 @@ static void _xfdashboard_workspace_selector_on_workspace_added(XfdashboardWorksp
XfdashboardWindowTrackerMonitor *monitor;
/* Get parent stage interface */
- stageInterface=_xfdashboard_workspace_selector_get_stage_interface(self);
+ stageInterface=xfdashboard_get_stage_of_actor(CLUTTER_ACTOR(self));
/* Get monitor of stage interface if available */
monitor=NULL;
@@ -1592,7 +1573,7 @@ void xfdashboard_workspace_selector_set_show_current_monitor_only(XfdashboardWor
priv->showCurrentMonitorOnly=inShowCurrentMonitorOnly;
/* Get parent stage interface */
- stageInterface=_xfdashboard_workspace_selector_get_stage_interface(self);
+ stageInterface=xfdashboard_get_stage_of_actor(CLUTTER_ACTOR(self));
/* Get monitor of stage interface if available and if only windows
* of current monitor should be shown.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list