Implement basic unique app behaviour via GApplication. (#8808)
Requires GIO 2.28, checks for it will be added later.
This commit is contained in:
20
src/main.c
20
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));
|
||||
|
||||
Reference in New Issue
Block a user