[Xfce4-commits] [apps/xfce4-taskmanager] 02/02: Implement basic unique app behaviour via GApplication. (#8808)
noreply at xfce.org
noreply at xfce.org
Wed Dec 3 10:27:57 CET 2014
This is an automated email from the git hooks/post-receive script.
landry pushed a commit to branch master
in repository apps/xfce4-taskmanager.
commit 03a86667d3623ca5cd608f37be676969040292ed
Author: Landry Breuil <landry at xfce.org>
Date: Wed Dec 3 10:26:21 2014 +0100
Implement basic unique app behaviour via GApplication. (#8808)
Requires GIO 2.28, checks for it will be added later.
---
src/main.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/main.c b/src/main.c
index 6425013..aaa8452 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,6 +14,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <gio/gio.h>
#include "settings.h"
#include "process-window.h"
@@ -146,6 +147,8 @@ refresh_rate_changed (void)
int main (int argc, char *argv[])
{
+ GApplication *app;
+ GError *error = NULL;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -155,6 +158,22 @@ int main (int argc, char *argv[])
gtk_init (&argc, &argv);
g_set_application_name (_("Task Manager"));
+ app = g_application_new ("xfce.taskmanager", 0);
+ g_application_register (G_APPLICATION (app), NULL, &error);
+ if (error != NULL)
+ {
+ g_warning ("Unable to register GApplication: %s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ if (g_application_get_is_remote (G_APPLICATION (app)))
+ {
+ g_application_activate (G_APPLICATION (app));
+ g_object_unref (app);
+ return 0;
+ }
+
settings = xtm_settings_get_default ();
status_icon = gtk_status_icon_new_from_icon_name ("utilities-system-monitor");
@@ -164,6 +183,7 @@ int main (int argc, char *argv[])
window = xtm_process_window_new ();
gtk_widget_show (window);
+ g_signal_connect_swapped (app, "activate", G_CALLBACK (xtm_process_window_show), window);
task_manager = xtm_task_manager_new (xtm_process_window_get_model (XTM_PROCESS_WINDOW (window)));
g_message ("Running as %s on %s", xtm_task_manager_get_username (task_manager), xtm_task_manager_get_hostname (task_manager));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list