[latexila] app: fix new-window action when launching primary instance
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] app: fix new-window action when launching primary instance
- Date: Sat, 19 Dec 2015 14:29:45 +0000 (UTC)
commit d9d9a8032010fcc17c00a2c0a0da62b414580aba
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Dec 19 14:41:13 2015 +0100
app: fix new-window action when launching primary instance
From gnome-shell, if latexila is present in the favorites, doing a right
click -> 'Open a New Window' works fine now. If latexila was not already
launched, only one window is created (not two). And if latexila was
already launched, a new window is created.
It also works when doing a right click -> 'Open a New Document'.
Or when opening files from Nautilus.
src/latexila_app.vala | 47 +++++++++++++++++++++++++++++++----------------
1 files changed, 31 insertions(+), 16 deletions(-)
---
diff --git a/src/latexila_app.vala b/src/latexila_app.vala
index 680b647..5451a5a 100644
--- a/src/latexila_app.vala
+++ b/src/latexila_app.vala
@@ -22,6 +22,7 @@
public class LatexilaApp : Gtk.Application
{
static Gtk.CssProvider? _provider = null;
+ private bool _activate_called = false;
private const GLib.ActionEntry[] _app_actions =
{
@@ -44,16 +45,8 @@ public class LatexilaApp : Gtk.Application
setup_main_option_entries ();
startup.connect (startup_cb);
-
- activate.connect (() =>
- {
- hold ();
- active_window.present ();
- release ();
- });
-
+ activate.connect (activate_cb);
open.connect (open_documents);
-
shutdown.connect (shutdown_cb);
}
@@ -129,12 +122,25 @@ public class LatexilaApp : Gtk.Application
Latexila.utils_register_icons ();
StockIcons.register_stock_icons ();
setup_theme_extensions ();
-
AppSettings.get_default ();
- create_window ();
- reopen_files ();
- Gtk.AccelMap.load (get_accel_filename ());
support_backward_search ();
+ Gtk.AccelMap.load (get_accel_filename ());
+ release ();
+ }
+
+ private void activate_cb ()
+ {
+ hold ();
+
+ if (! _activate_called)
+ {
+ _activate_called = true;
+ create_window ();
+ reopen_files ();
+ }
+ else
+ active_window.present ();
+
release ();
}
@@ -163,14 +169,20 @@ public class LatexilaApp : Gtk.Application
private void new_document_cb ()
{
+ if (! _activate_called)
+ activate ();
+
MainWindow? window = get_active_main_window ();
- if (window != null)
- window.create_tab (true);
+ return_if_fail (window != null);
+ window.create_tab (true);
}
private void new_window_cb ()
{
- create_window ();
+ if (_activate_called)
+ create_window ();
+ else
+ activate ();
}
private void preferences_cb ()
@@ -405,6 +417,9 @@ public class LatexilaApp : Gtk.Application
public void open_documents (File[] files)
{
+ if (! _activate_called)
+ activate ();
+
MainWindow? main_window = get_active_main_window ();
return_if_fail (main_window != null);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]