[gnome-subtitles] Set GtkApplication to support multiple instances
- From: Pedro Castro <pcastro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-subtitles] Set GtkApplication to support multiple instances
- Date: Sun, 13 Oct 2019 21:15:35 +0000 (UTC)
commit dbff39f688b467cc61012568b55c0d7a3bef4c4a
Author: Pedro Castro <pedro gnomesubtitles org>
Date: Sun Oct 13 22:09:56 2019 +0100
Set GtkApplication to support multiple instances
In commit 7924058, Gtk.Application started setting application id in
order to allow for better desktop integration. However, by default,
Gtk.Application prevents multiple instances when an application id is
set. The GLib.Application.NON_UNIQUE flag is now set to allow for
multiple applications with the application id set.
Fixes #139: Impossible to open a subtitles file via the file manager
while Gnome Subtitles is already running
src/GnomeSubtitles/Dialog/BaseDialog.cs | 4 ++--
src/GnomeSubtitles/Execution/ExecutionContext.cs | 10 ++++++----
2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/GnomeSubtitles/Dialog/BaseDialog.cs b/src/GnomeSubtitles/Dialog/BaseDialog.cs
index f506cf8..394ce2b 100644
--- a/src/GnomeSubtitles/Dialog/BaseDialog.cs
+++ b/src/GnomeSubtitles/Dialog/BaseDialog.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2009-2017 Pedro Castro
+ * Copyright (C) 2009-2019 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@ public abstract class BaseDialog {
private bool returnValue = false;
- //Hack because gtk# doesn't support this flag yet (as of 2017). Ref:
https://git.gnome.org/browse/gtk+/tree/gtk/gtkdialog.h (GTK_DIALOG_USE_HEADER_BAR)
+ //Hack because gtk# doesn't support this flag yet (as of 2019). Ref: gtk/gtkdialog.h
(GtkDialogFlags.GTK_DIALOG_USE_HEADER_BAR)
protected const DialogFlags DialogFlagsUseHeaderBar = (DialogFlags)4;
public BaseDialog () {
diff --git a/src/GnomeSubtitles/Execution/ExecutionContext.cs
b/src/GnomeSubtitles/Execution/ExecutionContext.cs
index 3831657..c3c9b9b 100644
--- a/src/GnomeSubtitles/Execution/ExecutionContext.cs
+++ b/src/GnomeSubtitles/Execution/ExecutionContext.cs
@@ -24,6 +24,9 @@ namespace GnomeSubtitles.Execution {
public class ExecutionContext {
private Gtk.Application app = null;
+
+ //Hack because gtk# doesn't support this flag yet (as of 2019). Ref: glib/gio/gioenums.h
(GApplicationFlags.G_APPLICATION_NON_UNIQUE)
+ private const GLib.ApplicationFlags GLibApplicationFlagsNonUnique = (GLib.ApplicationFlags)(1 << 5);
/* Constant strings */
private const string applicationName = "Gnome Subtitles";
@@ -89,13 +92,12 @@ public class ExecutionContext {
public void Execute (Action methodToExecute) {
GLib.Global.ApplicationName = applicationName;
-
- app = new Gtk.Application(applicationID, GLib.ApplicationFlags.None);
-
+
+ app = new Gtk.Application(applicationID, GLibApplicationFlagsNonUnique);
app.Activated += (sender, e) => {
methodToExecute();
};
-
+
app.Run(0, "");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]