[latexila/wip/app-menu: 2/2] app: implement new_window action
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/wip/app-menu: 2/2] app: implement new_window action
- Date: Fri, 6 Nov 2015 12:17:16 +0000 (UTC)
commit 81171dbaa872456c7f6f1d808cb18e507902ed1b
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Nov 6 12:24:19 2015 +0100
app: implement new_window action
src/latexila.gresource.xml | 2 +-
src/latexila_app.vala | 16 +++++++++++++---
src/main_window_file.vala | 2 +-
src/ui/app_menu.ui | 26 ++------------------------
4 files changed, 17 insertions(+), 29 deletions(-)
---
diff --git a/src/latexila.gresource.xml b/src/latexila.gresource.xml
index 1a7dc1e..7f4ad21 100644
--- a/src/latexila.gresource.xml
+++ b/src/latexila.gresource.xml
@@ -2,7 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/latexila">
- <file>ui/app_menu.ui</file>
+ <file preprocess="xml-stripblanks">ui/app_menu.ui</file>
<file>ui/latexila.adwaita.css</file>
</gresource>
diff --git a/src/latexila_app.vala b/src/latexila_app.vala
index 5275597..daf3bff 100644
--- a/src/latexila_app.vala
+++ b/src/latexila_app.vala
@@ -198,12 +198,22 @@ public class LatexilaApp : Gtk.Application
private void setup_app_menu ()
{
+ message ("setup_app_menu()");
+
+ if (! prefers_app_menu ())
+ {
+ message ("do not prefer app menu");
+ return;
+ }
+
Gtk.Builder builder =
new Gtk.Builder.from_resource ("/org/gnome/latexila/ui/app_menu.ui");
builder.set_translation_domain (Config.GETTEXT_PACKAGE);
- unowned GLib.MenuModel app_menu = builder.get_object ("app_menu")
- as GLib.MenuModel;
- set_app_menu (app_menu);
+ GLib.MenuModel menu_model = builder.get_object ("app-menu") as GLib.MenuModel;
+
+ return_if_fail (menu_model != null);
+ message ("n_items=%d", menu_model.get_n_items ());
+ set_app_menu (menu_model);
}
private void reopen_files ()
diff --git a/src/main_window_file.vala b/src/main_window_file.vala
index 0743e91..7401dff 100644
--- a/src/main_window_file.vala
+++ b/src/main_window_file.vala
@@ -142,7 +142,7 @@ public class MainWindowFile
public void on_new_window ()
{
- LatexilaApp.get_instance ().create_window ();
+ LatexilaApp.get_instance ().activate_action ("new-window", null);
}
public void on_file_open ()
diff --git a/src/ui/app_menu.ui b/src/ui/app_menu.ui
index 295c1a8..b3b9d84 100644
--- a/src/ui/app_menu.ui
+++ b/src/ui/app_menu.ui
@@ -1,36 +1,14 @@
<?xml version="1.0"?>
<interface>
- <menu id="app_menu">
+ <menu id="app-menu">
<section>
<item>
<attribute name="label" translatable="yes">_New Window</attribute>
- <attribute name="action">app.new_window</attribute>
+ <attribute name="action">app.new-window</attribute>
</item>
</section>
<section>
<item>
- <attribute name="label" translatable="yes">_Preferences</attribute>
- <attribute name="action">app.preferences</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Manage Build Tools</attribute>
- <attribute name="action">app.manage_build_tools</attribute>
- </item>
- </section>
- <section>
- <item>
- <attribute name="label" translatable="yes">_Help</attribute>
- <attribute name="action">app.help</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">LaTeXila _Fundraiser</attribute>
- <attribute name="action">app.fundraiser</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_About</attribute>
- <attribute name="action">app.about</attribute>
- </item>
- <item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
</item>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]