[Xfce4-commits] [apps/xfdashboard] 06/19: Redirect xfdashboard_window_tracker_get_default() to accessor function of new window tracker backend interface.
noreply at xfce.org
noreply at xfce.org
Fri Jun 16 10:56:37 CEST 2017
This is an automated email from the git hooks/post-receive script.
n o m a d p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfdashboard.
commit 34c55e2eeea7fb0546068d5da8195ace942dfb21
Author: Stephan Haller <nomad at froevel.de>
Date: Tue Jun 13 08:30:18 2017 +0200
Redirect xfdashboard_window_tracker_get_default() to accessor function of new window tracker backend interface.
Enhancement for issue GH #129
---
libxfdashboard/application.c | 57 +++++++++++++++++++++----------
libxfdashboard/window-tracker-backend.c | 1 -
libxfdashboard/window-tracker.c | 59 +++++++++++++++------------------
3 files changed, 65 insertions(+), 52 deletions(-)
diff --git a/libxfdashboard/application.c b/libxfdashboard/application.c
index cc5483a..fff97f1 100644
--- a/libxfdashboard/application.c
+++ b/libxfdashboard/application.c
@@ -59,6 +59,7 @@
#include <libxfdashboard/application-database.h>
#include <libxfdashboard/application-tracker.h>
#include <libxfdashboard/plugins-manager.h>
+#include <libxfdashboard/window-tracker-backend.h>
#include <libxfdashboard/marshal.h>
#include <libxfdashboard/compat.h>
#include <libxfdashboard/debug.h>
@@ -76,32 +77,34 @@ G_DEFINE_TYPE(XfdashboardApplication,
struct _XfdashboardApplicationPrivate
{
/* Properties related */
- gboolean isDaemon;
- gboolean isSuspended;
- gchar *themeName;
+ gboolean isDaemon;
+ gboolean isSuspended;
+ gchar *themeName;
/* Instance related */
- gboolean initialized;
- gboolean isQuitting;
- gboolean forcedNewInstance;
+ gboolean initialized;
+ gboolean isQuitting;
+ gboolean forcedNewInstance;
- XfconfChannel *xfconfChannel;
- XfdashboardStage *stage;
- XfdashboardViewManager *viewManager;
- XfdashboardSearchManager *searchManager;
- XfdashboardFocusManager *focusManager;
+ XfconfChannel *xfconfChannel;
+ XfdashboardStage *stage;
+ XfdashboardViewManager *viewManager;
+ XfdashboardSearchManager *searchManager;
+ XfdashboardFocusManager *focusManager;
- XfdashboardTheme *theme;
- gulong xfconfThemeChangedSignalID;
+ XfdashboardTheme *theme;
+ gulong xfconfThemeChangedSignalID;
+
+ XfdashboardBindingsPool *bindings;
- XfdashboardBindingsPool *bindings;
+ XfdashboardApplicationDatabase *appDatabase;
+ XfdashboardApplicationTracker *appTracker;
- XfdashboardApplicationDatabase *appDatabase;
- XfdashboardApplicationTracker *appTracker;
+ XfceSMClient *sessionManagementClient;
- XfceSMClient *sessionManagementClient;
+ XfdashboardPluginsManager *pluginManager;
- XfdashboardPluginsManager *pluginManager;
+ XfdashboardWindowTrackerBackend *windowTrackerBackend;
};
/* Properties */
@@ -414,6 +417,17 @@ static gboolean _xfdashboard_application_initialize_full(XfdashboardApplication
return(FALSE);
}
+ /* Create single-instance of window tracker backend to keep it alive while
+ * application is running and to avoid multiple reinitializations. It must
+ * be create before any class using a window tracker.
+ */
+ priv->windowTrackerBackend=xfdashboard_window_tracker_backend_get_default();
+ if(!priv->windowTrackerBackend)
+ {
+ g_critical(_("Could not setup window tracker backend"));
+ return(FALSE);
+ }
+
/* Set up application database */
priv->appDatabase=xfdashboard_application_database_get_default();
if(!priv->appDatabase)
@@ -981,6 +995,12 @@ static void _xfdashboard_application_dispose(GObject *inObject)
g_signal_emit(self, XfdashboardApplicationSignals[SIGNAL_SHUTDOWN_FINAL], 0);
/* Release allocated resources */
+ if(priv->windowTrackerBackend)
+ {
+ g_object_unref(priv->windowTrackerBackend);
+ priv->windowTrackerBackend=NULL;
+ }
+
if(priv->pluginManager)
{
g_object_unref(priv->pluginManager);
@@ -1452,6 +1472,7 @@ static void xfdashboard_application_init(XfdashboardApplication *self)
priv->sessionManagementClient=NULL;
priv->pluginManager=NULL;
priv->forcedNewInstance=FALSE;
+ priv->windowTrackerBackend=NULL;
/* Add callable DBUS actions for this application */
action=g_simple_action_new("Quit", NULL);
diff --git a/libxfdashboard/window-tracker-backend.c b/libxfdashboard/window-tracker-backend.c
index 118daf5..a2ebd10 100644
--- a/libxfdashboard/window-tracker-backend.c
+++ b/libxfdashboard/window-tracker-backend.c
@@ -114,7 +114,6 @@ XfdashboardWindowTrackerBackend* xfdashboard_window_tracker_backend_get_default(
else g_object_ref(_xfdashboard_window_tracker_backend_singleton);
return(_xfdashboard_window_tracker_backend_singleton);
-
}
/**
diff --git a/libxfdashboard/window-tracker.c b/libxfdashboard/window-tracker.c
index 92c3a7f..39f71e5 100644
--- a/libxfdashboard/window-tracker.c
+++ b/libxfdashboard/window-tracker.c
@@ -31,8 +31,7 @@
#include <glib/gi18n-lib.h>
-#include <libxfdashboard/x11/window-tracker-x11.h>
-#include <libxfdashboard/gdk/window-tracker-gdk.h>
+#include <libxfdashboard/window-tracker-backend.h>
#include <libxfdashboard/marshal.h>
#include <libxfdashboard/compat.h>
#include <libxfdashboard/debug.h>
@@ -85,8 +84,6 @@ static guint XfdashboardWindowTrackerSignals[SIGNAL_LAST]={ 0, };
G_OBJECT_TYPE_NAME(self), \
vfunc);
-static XfdashboardWindowTracker *_xfdashboard_window_tracker_singleton=NULL;
-
/* IMPLEMENTATION: GObject */
@@ -574,43 +571,39 @@ void xfdashboard_window_tracker_default_init(XfdashboardWindowTrackerInterface *
* Retrieves the singleton instance of #XfdashboardWindowTracker. If not needed
* anymore the caller must unreference the returned object instance.
*
+ * This function is the logical equivalent of:
+ *
+ * |[<!-- language="C" -->
+ * XfdashboardWindowTrackerBackend *backend;
+ * XfdashboardWindowTracker *tracker;
+ *
+ * backend=xfdashboard_window_tracker_backend_get_default();
+ * tracker=xfdashboard_window_tracker_backend_get_window_tracker(backend);
+ * ]|
+ *
* Return value: (transfer full): The instance of #XfdashboardWindowTracker.
*/
XfdashboardWindowTracker* xfdashboard_window_tracker_get_default(void)
{
- if(G_UNLIKELY(_xfdashboard_window_tracker_singleton==NULL))
+ XfdashboardWindowTrackerBackend *backend;
+ XfdashboardWindowTracker *windowTracker;
+
+ /* Get default window tracker backend */
+ backend=xfdashboard_window_tracker_backend_get_default();
+ if(!backend)
{
- GType windowTrackerBackendType=G_TYPE_INVALID;
- const gchar *windowTrackerBackend;
-
- /* Check if a specific backend was requested */
- windowTrackerBackend=g_getenv("XFDASHBOARD_BACKEND");
-
- if(g_strcmp0(windowTrackerBackend, "gdk")==0)
- {
- windowTrackerBackendType=XFDASHBOARD_TYPE_WINDOW_TRACKER_GDK;
- }
-
- /* If no specific backend was requested use default one */
- if(windowTrackerBackendType==G_TYPE_INVALID)
- {
- windowTrackerBackendType=XFDASHBOARD_TYPE_WINDOW_TRACKER_X11;
- XFDASHBOARD_DEBUG(NULL, WINDOWS,
- "Using default backend %s",
- g_type_name(windowTrackerBackendType));
- }
-
- /* Create singleton */
- _xfdashboard_window_tracker_singleton=XFDASHBOARD_WINDOW_TRACKER(g_object_new(windowTrackerBackendType, NULL));
- XFDASHBOARD_DEBUG(_xfdashboard_window_tracker_singleton, WINDOWS,
- "Created window tracker of type %s for %s backend",
- _xfdashboard_window_tracker_singleton ? G_OBJECT_TYPE_NAME(_xfdashboard_window_tracker_singleton) : "<<unknown>>",
- windowTrackerBackend ? windowTrackerBackend : "default");
+ g_critical(_("Could not get default window tracker backend"));
+ return(NULL);
}
- else g_object_ref(_xfdashboard_window_tracker_singleton);
- return(_xfdashboard_window_tracker_singleton);
+ /* Get window tracker object instance of backend */
+ windowTracker=xfdashboard_window_tracker_backend_get_window_tracker(backend);
+
+ /* Release allocated resources */
+ if(backend) g_object_unref(backend);
+ /* Return window tracker object instance */
+ return(windowTracker);
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list