[Xfce4-commits] [apps/xfdashboard] 01/04: Add function to activate last active window of a running application instance or to force to start always a new instance of application for the application whose favourite button was clicked.
noreply at xfce.org
noreply at xfce.org
Wed Sep 16 16:09:39 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 d9831e22442db9e213d16e2e1267e924c1f386c5
Author: Stephan Haller <nomad at froevel.de>
Date: Wed Sep 16 15:44:52 2015 +0200
Add function to activate last active window of a running application instance or to force to start always a new instance of application for the application whose favourite button was clicked.
---
xfdashboard/quicklaunch.c | 79 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 77 insertions(+), 2 deletions(-)
diff --git a/xfdashboard/quicklaunch.c b/xfdashboard/quicklaunch.c
index d62ec5a..ab3bc29 100644
--- a/xfdashboard/quicklaunch.c
+++ b/xfdashboard/quicklaunch.c
@@ -45,6 +45,7 @@
#include "desktop-app-info.h"
#include "application-database.h"
#include "application-tracker.h"
+#include "window-tracker-window.h"
/* Define this class in GObject system */
static void _xfdashboard_quicklaunch_focusable_iface_init(XfdashboardFocusableInterface *iface);
@@ -305,18 +306,92 @@ static gboolean _xfdashboard_quicklaunch_has_favourite_appinfo(XfdashboardQuickl
/* An application icon (favourite) in quicklaunch was clicked */
static void _xfdashboard_quicklaunch_on_favourite_clicked(XfdashboardQuicklaunch *self, gpointer inUserData)
{
+ XfdashboardQuicklaunchPrivate *priv;
XfdashboardApplicationButton *button;
+ gboolean launchNewInstance;
g_return_if_fail(XFDASHBOARD_IS_QUICKLAUNCH(self));
g_return_if_fail(XFDASHBOARD_IS_APPLICATION_BUTTON(inUserData));
+ priv=self->priv;
button=XFDASHBOARD_APPLICATION_BUTTON(inUserData);
+ launchNewInstance=TRUE;
+
+ /* If user wants to activate the last active windows for a running instance
+ * of application whose button was clicked, then check if a window exists
+ * and activate it. Otherwise launch a new instance.
+ */
+ if(!launchNewInstance)
+ {
+ GAppInfo *appInfo;
+ const GList *windows;
+ XfdashboardWindowTrackerWindow *lastActiveWindow;
+
+ /* Get application information of application button */
+ appInfo=xfdashboard_application_button_get_app_info(button);
+ if(!appInfo)
+ {
+ xfdashboard_notify(CLUTTER_ACTOR(self),
+ "gtk-dialog-error",
+ _("Launching application '%s' failed: %s"),
+ xfdashboard_application_button_get_display_name(button),
+ _("No information available for application"));
+
+ g_warning(_("Launching application '%s' failed: %s"),
+ xfdashboard_application_button_get_display_name(button),
+ _("No information available for application"));
+
+ return;
+ }
+
+ /* Get list of windows for application */
+ windows=xfdashboard_application_tracker_get_window_list_by_app_info(priv->appTracker, appInfo);
+ if(windows)
+ {
+ /* Get last active window for application which is the first one in list */
+ lastActiveWindow=XFDASHBOARD_WINDOW_TRACKER_WINDOW(windows->data);
+
+ /* Activate last active window of application if available */
+ if(lastActiveWindow)
+ {
+ xfdashboard_window_tracker_window_activate(lastActiveWindow);
+
+ /* Activating last active window of application seems to be successfully
+ * so quit application.
+ */
+ xfdashboard_application_quit();
+
+ return;
+ }
+ }
+
+ /* If we get here we found the application but no active window,
+ * so check if application is running. If it is display a warning
+ * message as notification and return from this function. If it
+ * is not running, continue to start a new instance.
+ */
+ if(xfdashboard_application_tracker_is_running_by_app_info(priv->appTracker, appInfo))
+ {
+ xfdashboard_notify(CLUTTER_ACTOR(self),
+ "gtk-dialog-error",
+ _("Launching application '%s' failed: %s"),
+ xfdashboard_application_button_get_display_name(button),
+ _("No windows to activate for application"));
- /* Launch application */
+ g_warning(_("Launching application '%s' failed: %s"),
+ xfdashboard_application_button_get_display_name(button),
+ _("No windows to activate for application"));
+
+ return;
+ }
+ }
+
+ /* Launch a new instance of application whose button was clicked */
if(xfdashboard_application_button_execute(button, NULL))
{
- /* Launching application seems to be successfuly so quit application */
+ /* Launching application seems to be successfully so quit application */
xfdashboard_application_quit();
+
return;
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list