]> git.street.me.uk Git - andy/viking.git/commitdiff
SF Bugs#114: Fix Shortcut keys get reset next start
authorRob Norris <rw_norris@hotmail.com>
Tue, 21 Oct 2014 19:38:56 +0000 (20:38 +0100)
committerRob Norris <rw_norris@hotmail.com>
Wed, 29 Oct 2014 00:56:36 +0000 (00:56 +0000)
Load / save the GTK+ Accelerator key map on program start / exit.

help/C/viking.xml
help/viking.xml
src/vikwindow.c

index d95b9d0cbd24d976d31912803657c5346cecafc3..c30dea8ddfd6f7315aff9a8face1f8d931ca11ff 100644 (file)
@@ -325,7 +325,7 @@ This is to increase the compatibility between &appname; and similar applications
 &appname; has several shortcut keys or key combinations for commands as listed in the main window along side the command.
 </para>
 <para>
-Some function keys follow standard GUI behaviour:
+By default some function keys follow standard GUI behaviour:
 </para>
 <itemizedlist>
 <listitem><para><keycap>F1</keycap> Help (view this manual)</para></listitem>
@@ -362,12 +362,33 @@ Then there are shortcuts specific to &appname; to switch projection modes, zoom
 <listitem><para><keycap>Ctrl+Left</keycap> Pan the viewport West</para></listitem>
 <listitem><para><keycap>Ctrl+Keypad+</keycap> Zoom In</para></listitem>
 <listitem><para><keycap>Ctrl+Keypad-</keycap> Zoom Out</para></listitem>
-<listitem><note><para>These work irrespective of the <xref linkend="tools"/> mode selected</para></note></listitem>
 </itemizedlist>
+<important><para>These work irrespective of the <xref linkend="tools"/> mode selected</para></important>
 For other combinations see the menu entry themselves.
 </para>
 </section>
 
+<section>
+<title>Keyboard Configuration</title>
+<para>Keyboard configuration is supported by the standard GTK+ way of changing shortcuts for menu entries.</para>
+<para>Hover over the menu option with the mouse pointer and press the keyboard shortcut you want to bind it to.</para>
+<para>To delete a keyboard assignment, press <keycap>Backspace</keycap> whilst over the menu entry.</para>
+<note>
+<para>
+       If the keyboard shortcut is already in use you will not receive any notification that new action replaces the old action.
+       This is probably why most distributions have this facility disabled by default.
+       Thus you will need to enable <emphasis>Editable menu accelerators</emphasis> for your system.
+       Check the Desktop Menu and Toolbar Control or other User Interface preferences for this setting.
+</para>
+</note>
+<note>
+<para>
+       For Windows systems this can be done by adding the line <emphasis>gtk-can-change-accels=1</emphasis> to <filename>%USERPROFILE%\.gtkrc-2.0</filename> (create the file if it does not exist).
+</para>
+</note>
+<para>From &app; 1.6+ the keyboard configuration is automatically loaded and saved between sessions in the <xref linkend="config_keys"/></para>
+</section>
+
 <section><title>Tracks vs Routes</title>
 <para>
 In theory a route is path you are planning to follow and a track of where you have actually been. The GPX specification splits these into two separate catergories, although tracks contain everything route may have.
@@ -3345,8 +3366,16 @@ Accept: */*
           </variablelist>
          </para>
        </section>
+
       </section>
 
+    <section id="config_keys" xreflabel="Keyboard Shortcuts File">
+      <title>Keyboard Shortcuts (Accelerator) Settings</title>
+      <para>This is held in the file <filename>~/.viking/keys.rc</filename></para>
+      <para>It is in the standard GTK Accelerator map format. Values are automatically read in and saved between &app; sessions.</para>
+      <para>This file is not intended to be manually edited, but since it is a plain text file it can be changed if desired.</para>
+    </section>
+
 </section>
 <!-- End of Extending Viking -->
 
index 631b0291f6ed7b622c0b9940c0cf69052a052f18..7cc0263487e72197443327289f17fca2cac3f30d 100644 (file)
@@ -529,6 +529,13 @@ and docbook-xsl in your Build-Depends control field.
          <para>However some finer control of default internal values can be set.</para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term><filename>~/.viking/keys.rc</filename></term>
+        <listitem>
+          <para>File containing short cut key accelerators.</para>
+          <para>This is in the standard GTK Accelerator map format.</para>
+       </listitem>
+      </varlistentry>
       <varlistentry>
         <term><filename>~/.viking/cookies.txt</filename></term>
         <listitem>
index 7364bd985e5295cfeabf00a56ce9a9c89753618c..fbc115b265acf4f2ff7da5bfc2b9aeb1df34e9d9 100644 (file)
@@ -44,6 +44,7 @@
 #include "vikmapslayer.h"
 #include "geonamessearch.h"
 #include "vikutils.h"
+#include "dir.h"
 
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
@@ -731,6 +732,8 @@ static void toolbar_reload_cb ( GtkActionGroup *grp, gpointer gp )
 #define VIK_SETTINGS_WIN_SAVE_IMAGE_PNG "window_save_image_as_png"
 #define VIK_SETTINGS_WIN_COPY_CENTRE_FULL_FORMAT "window_copy_centre_full_format"
 
+#define VIKING_ACCELERATOR_KEY_FILE "keys.rc"
+
 static void vik_window_init ( VikWindow *vw )
 {
   vw->action_group = NULL;
@@ -907,6 +910,10 @@ static void vik_window_init ( VikWindow *vw )
   // Set the default tool + mode
   gtk_action_activate ( gtk_action_group_get_action ( vw->action_group, "Pan" ) );
   gtk_action_activate ( gtk_action_group_get_action ( vw->action_group, "ModeMercator" ) );
+
+  gchar *accel_file_name = g_build_filename ( a_get_viking_dir(), VIKING_ACCELERATOR_KEY_FILE, NULL );
+  gtk_accel_map_load ( accel_file_name );
+  g_free ( accel_file_name );
 }
 
 static VikWindow *window_new ()
@@ -1062,6 +1069,10 @@ static gboolean delete_event( VikWindow *vw )
     a_settings_set_integer ( VIK_SETTINGS_WIN_SAVE_IMAGE_WIDTH, vw->draw_image_width );
     a_settings_set_integer ( VIK_SETTINGS_WIN_SAVE_IMAGE_HEIGHT, vw->draw_image_height );
     a_settings_set_boolean ( VIK_SETTINGS_WIN_SAVE_IMAGE_PNG, vw->draw_image_save_as_png );
+
+    gchar *accel_file_name = g_build_filename ( a_get_viking_dir(), VIKING_ACCELERATOR_KEY_FILE, NULL );
+    gtk_accel_map_save ( accel_file_name );
+    g_free ( accel_file_name );
   }
 
   return FALSE;