[gnote] Add shortcuts window with main window shortcuts



commit 3f6ab3e132406cc1a399f90e57f80092f7a97ae8
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Jul 17 21:28:55 2016 +0300

    Add shortcuts window with main window shortcuts

 configure.ac               |    3 +-
 data/Makefile.am           |    2 +-
 data/ui/Makefile.am        |    8 +++++++
 data/ui/shortcuts-gnote.ui |   47 ++++++++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in             |    1 +
 src/actionmanager.cpp      |    2 +
 src/gnote.cpp              |   16 +++++++++++++++
 src/gnote.hpp              |    1 +
 8 files changed, 78 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a4faeda..890b5bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,7 +25,7 @@ AC_DEFINE_UNQUOTED([LIBGNOTE_VERSION_INFO], ["$LIBGNOTE_VERSION_INFO"], [libgnot
 dnl all the library version.
 dnl if one is harcoded elsewhere, it is a bug
 
-GTK_VERSION=3.16
+GTK_VERSION=3.20
 LIBGLIBMM_VERSION=2.32
 LIBGTKMM_VERSION=3.18
 GTKSPELL_VERSION=3.0.0
@@ -149,6 +149,7 @@ data/Makefile
 data/gnote.desktop.in
 data/icons/Makefile
 data/appdata/Makefile
+data/ui/Makefile
 src/Makefile
 src/addins/Makefile
 src/addins/addins.mk
diff --git a/data/Makefile.am b/data/Makefile.am
index 34bc699..10b6ae1 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,5 @@
 
-SUBDIRS = appdata icons
+SUBDIRS = appdata icons ui
 
 @INTLTOOL_DESKTOP_RULE@
 
diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am
new file mode 100644
index 0000000..5a812a1
--- /dev/null
+++ b/data/ui/Makefile.am
@@ -0,0 +1,8 @@
+
+uidir = $(datadir)/gnote
+ui_DATA = shortcuts-gnote.ui
+
+@INTLTOOL_XML_RULE@
+
+EXTRA_DIST = shortcuts-gnote.ui
+
diff --git a/data/ui/shortcuts-gnote.ui b/data/ui/shortcuts-gnote.ui
new file mode 100644
index 0000000..9c85168
--- /dev/null
+++ b/data/ui/shortcuts-gnote.ui
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkShortcutsWindow" id="shortcuts-gnote">
+    <property name="modal">1</property>
+    <child>
+      <object class="GtkShortcutsSection">
+        <property name="visible">1</property>
+        <property name="section-name">main-window</property>
+        <property name="title" translatable="yes">Main Window</property>
+        <child>
+         <object class="GtkShortcutsGroup">
+            <property name="visible">1</property>
+            <property name="title" translatable="yes">Notes list</property>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;N</property>
+                <property name="title" translatable="yes">Create new note</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;O</property>
+                <property name="title" translatable="yes">Open selected note</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;alt&gt;W</property>
+                <property name="title" translatable="yes">Open selected note in new window</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>
+                <property name="accelerator">Delete</property>
+                <property name="title" translatable="yes">Delete selected note</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3d5f370..4387894 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,4 +1,5 @@
 data/appdata/gnote.appdata.xml.in
+data/ui/shortcuts-gnote.ui
 data/gnote.desktop.in.in
 data/org.gnome.gnote.gschema.xml.in
 src/actionmanager.cpp
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 06d5167..2bc6f42 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -98,6 +98,7 @@ namespace gnote {
     add_app_action("show-preferences");
     add_app_action("about");
     add_app_action("help-contents");
+    add_app_action("help-shortcuts");
     add_app_action("quit");
   }
 
@@ -132,6 +133,7 @@ namespace gnote {
     add_app_menu_item(APP_ACTION_NEW, 200, _("New _Window"), "app.new-window");
     add_app_menu_item(APP_ACTION_MANAGE, 100, _("_Preferences"), "app.show-preferences");
     add_app_menu_item(APP_ACTION_LAST, 100, _("_Help"), "app.help-contents");
+    add_app_menu_item(APP_ACTION_LAST, 100, _("_Shortcuts"), "app.help-shortcuts");
     add_app_menu_item(APP_ACTION_LAST, 200, _("_About"), "app.about");
     add_app_menu_item(APP_ACTION_LAST, 300, _("_Quit"), "app.quit");
   }
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 52d90d1..ed90e61 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -35,6 +35,8 @@
 #include <glibmm/optionentry.h>
 #include <gtkmm/main.h>
 #include <gtkmm/aboutdialog.h>
+#include <gtkmm/builder.h>
+#include <gtkmm/shortcutswindow.h>
 
 #include "gnote.hpp"
 #include "actionmanager.hpp"
@@ -263,6 +265,19 @@ namespace gnote {
     utils::show_help("gnote", "", cscreen, NULL);
   }
 
+  void Gnote::on_show_help_shortcust_action(const Glib::VariantBase&)
+  {
+    Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file(DATADIR"/gnote/shortcuts-gnote.ui");
+    Gtk::ShortcutsWindow *win = nullptr;
+    builder->get_widget("shortcuts-gnote", win);
+    if(win == nullptr) {
+      ERR_OUT(_("Failed to get shortcuts window!"));
+      return;
+    }
+
+    win->show();
+  }
+
   void Gnote::on_show_about_action(const Glib::VariantBase&)
   {
     std::vector<Glib::ustring> authors;
@@ -399,6 +414,7 @@ namespace gnote {
       sigc::mem_fun(*this, &Gnote::on_show_preferences_action));
     am.get_app_action("sync-notes")->signal_activate().connect(sigc::mem_fun(*this, 
&Gnote::open_note_sync_window));
     am.get_app_action("help-contents")->signal_activate().connect(sigc::mem_fun(*this, 
&Gnote::on_show_help_action));
+    am.get_app_action("help-shortcuts")->signal_activate().connect(sigc::mem_fun(*this, 
&Gnote::on_show_help_shortcust_action));
     am.get_app_action("about")->signal_activate().connect(sigc::mem_fun(*this, 
&Gnote::on_show_about_action));
     am.get_app_action("quit")->signal_activate().connect(sigc::mem_fun(*this, &Gnote::on_quit_gnote_action));
 
diff --git a/src/gnote.hpp b/src/gnote.hpp
index fd3a8b5..e36e2b3 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -154,6 +154,7 @@ private:
   void make_app_menu();
   void on_new_window_action(const Glib::VariantBase&);
   void on_new_note_app_action(const Glib::VariantBase&);
+  void on_show_help_shortcust_action(const Glib::VariantBase&);
   MainWindow *get_active_window();
   void register_object();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]