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

gEDA-cvs: gaf.git: branch: master updated (1.7.1-20110619-223-g6a2b3ff)



The branch, master has been updated
       via  6a2b3ff8557ebd8c321cdbe6e23abe1ef1df1580 (commit)
      from  1c00bf53cb8b49eb29e84a63e5c49253fc479f21 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/include/gschem_struct.h |    1 +
 gschem/scheme/gschem.scm       |    7 ++-
 gschem/src/g_keys.c            |   92 ++++++++++++++++++++++------------------
 gschem/src/gschem_toplevel.c   |    1 +
 4 files changed, 56 insertions(+), 45 deletions(-)


=================
 Commit Messages
=================

commit 6a2b3ff8557ebd8c321cdbe6e23abe1ef1df1580
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Tidy up status bar keystroke display.
    
    Tidies up the behaviour of the status bar when it displays user
    keystrokes.
    
    - If the keystroke is a prefix (i.e. it resolves to a keymap), the
      display will persist indefinitely.
    
    - Otherwise, the keystroke will be displayed for 400 ms or until
      another keystroke is typed, whichever is sooner.
    
    This also fixes a problem where keybindings that resolve to pure
    Scheme functions were not clearing the displayed key sequence.

:100644 100644 5f241e0... 91b29b4... M	gschem/include/gschem_struct.h
:100644 100644 508511f... ba0b587... M	gschem/scheme/gschem.scm
:100644 100644 d48f701... 6338f48... M	gschem/src/g_keys.c
:100644 100644 f962f78... db97e29... M	gschem/src/gschem_toplevel.c

=========
 Changes
=========

commit 6a2b3ff8557ebd8c321cdbe6e23abe1ef1df1580
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Tidy up status bar keystroke display.
    
    Tidies up the behaviour of the status bar when it displays user
    keystrokes.
    
    - If the keystroke is a prefix (i.e. it resolves to a keymap), the
      display will persist indefinitely.
    
    - Otherwise, the keystroke will be displayed for 400 ms or until
      another keystroke is typed, whichever is sooner.
    
    This also fixes a problem where keybindings that resolve to pure
    Scheme functions were not clearing the displayed key sequence.

diff --git a/gschem/include/gschem_struct.h b/gschem/include/gschem_struct.h
index 5f241e0..91b29b4 100644
--- a/gschem/include/gschem_struct.h
+++ b/gschem/include/gschem_struct.h
@@ -36,6 +36,7 @@ struct st_gschem_toplevel {
 
   gchar *keyaccel_string;               /* visual feedback when pressing
                                            keyboard accelerators */
+  gboolean keyaccel_string_source_id;   /* event source ID used by above */
 
   /* ------------ */
   /* Dialog boxes */
diff --git a/gschem/scheme/gschem.scm b/gschem/scheme/gschem.scm
index 508511f..ba0b587 100644
--- a/gschem/scheme/gschem.scm
+++ b/gschem/scheme/gschem.scm
@@ -44,8 +44,9 @@
 ;; Does the work of evaluating a key.  Adds the key to the current key
 ;; sequence, then looks up the key sequence in the current keymap.  If
 ;; the key sequence resolves to an action, calls the action.  If the
-;; key sequence can be resolved (either to a keymap or an action),
-;; returns #t; otherwise, returns #f.  If the key is #f, clears the
+;; key sequence can be resolved to an action, returns #t; if it
+;; resolves to a keymap (i.e. it's a prefix key), returns the "prefix"
+;; symbol; otherwise, returns #f.  If the key is #f, clears the
 ;; current key sequence.
 (define (eval-pressed-key keymap key)
   ;; Function for resetting current key sequence
@@ -59,7 +60,7 @@
                (bound (lookup-keys keymap keys)))
           (cond
            ;; Keys are a prefix -- do nothing successfully
-           ((keymap? bound) #t)
+           ((keymap? bound) 'prefix)
            ;; Keys are bound to something -- reset current key
            ;; sequence, then try to run the action
            (bound (begin
diff --git a/gschem/src/g_keys.c b/gschem/src/g_keys.c
index d48f701..6338f48 100644
--- a/gschem/src/g_keys.c
+++ b/gschem/src/g_keys.c
@@ -41,36 +41,11 @@
 
 #include <gdk/gdkkeysyms.h>
 
-/*! \brief Clear the current key accelerator string
- *
- *  \par Function Description
- *  This function clears the current keyboard accelerator
- *  string in the status bar of the relevant toplevel.
- *  Called after the action specifed by the keyboard
- *  accelerator is executed and the associated timeout interval
- *  has passed.
- *
- *  \param [in] data a pointer to the GSCHEM_TOPLEVEL
- */
-static gboolean clear_keyaccel_string(gpointer data)
-{
-  GSCHEM_TOPLEVEL *w_current = data;
-
-  /* Find out if the GSCHEM_TOPLEVEL is present... */
-  if (g_list_find(global_window_list, w_current) != NULL) {
-    g_free(w_current->keyaccel_string);
-    w_current->keyaccel_string = NULL;
-    i_show_state(w_current, NULL);
-  }
-
-  return FALSE;
-}
 
 #define DEFINE_G_KEYS(name)				\
 SCM g_keys_ ## name(SCM rest)				\
 {							\
    GSCHEM_TOPLEVEL *w_current = g_current_window ();	\
-   g_timeout_add(400, clear_keyaccel_string, w_current);       \
    i_callback_ ## name(w_current, 0, NULL);                   \
    return SCM_BOOL_T;				\
 }
@@ -483,6 +458,33 @@ g_key_free (SCM key) {
 }
 
 SCM_SYMBOL (press_key_sym, "press-key");
+SCM_SYMBOL (prefix_sym, "prefix");
+
+/*! \brief Clear the current key accelerator string.
+ * \par Function Description
+ * This function clears the current keyboard accelerator string in
+ * the status bar of the relevant toplevel.  Called some time after a
+ * keystroke is pressed.  If the current key sequence was a prefix,
+ * let it persist.
+ *
+ * \param [in] data a pointer to the GSCHEM_TOPLEVEL to update.
+ * \return FALSE (this is a one-shot timer).
+ */
+static gboolean clear_keyaccel_string(gpointer data)
+{
+  GSCHEM_TOPLEVEL *w_current = data;
+
+  /* If the window context has disappeared, do nothing. */
+  if (g_list_find(global_window_list, w_current) == NULL) {
+    return FALSE;
+  }
+
+  g_free(w_current->keyaccel_string);
+  w_current->keyaccel_string = NULL;
+  w_current->keyaccel_string_source_id = 0;
+  i_show_state(w_current, NULL);
+  return FALSE;
+}
 
 /*! \brief Evaluate a user keystroke.
  * \par Function Description
@@ -555,26 +557,17 @@ g_keys_execute(GSCHEM_TOPLEVEL *w_current, GdkEventKey *event)
   } else {
     gchar *keystr = gtk_accelerator_get_label (key, mods);
 
-    /* If no current hint string, use key string directly */
-    if (w_current->keyaccel_string == NULL) {
+    /* If no current hint string, or the hint string is going to be
+     * cleared anyway, use key string directly */
+    if ((w_current->keyaccel_string == NULL) ||
+        w_current->keyaccel_string_source_id) {
+      g_free (w_current->keyaccel_string);
       w_current->keyaccel_string = keystr;
 
     } else {
-      /* If concatenating key string onto current hint string would be
-       * longer than 14 characters, truncate and prefix with
-       * ellipsis. Otherwise, add key string to current hint
-       * string. */
-      /* FIXME this limit probably shouldn't be hardcoded */
-      if (strlen (w_current->keyaccel_string) + strlen (keystr) > 14) {
-        g_free (w_current->keyaccel_string);
-        w_current->keyaccel_string = g_strconcat ("\342\200\246 ",
-                                                  keystr, NULL);
-
-      } else {
-        gchar *p = w_current->keyaccel_string;
-        w_current->keyaccel_string = g_strconcat (p, " ", keystr, NULL);
-        g_free (p);
-      }
+      gchar *p = w_current->keyaccel_string;
+      w_current->keyaccel_string = g_strconcat (p, " ", keystr, NULL);
+      g_free (p);
       g_free (keystr);
     }
   }
@@ -589,6 +582,21 @@ g_keys_execute(GSCHEM_TOPLEVEL *w_current, GdkEventKey *event)
   s_retval = g_scm_eval_protected (s_expr, scm_interaction_environment ());
   scm_dynwind_end ();
 
+  /* If the keystroke was not part of a prefix, start a timer to clear
+   * the status bar display. */
+  if (w_current->keyaccel_string_source_id) {
+    /* Cancel any existing timers that haven't fired yet. */
+    GSource *timer =
+      g_main_context_find_source_by_id (NULL,
+                                        w_current->keyaccel_string_source_id);
+    g_source_destroy (timer);
+    w_current->keyaccel_string_source_id = 0;
+  }
+  if (!scm_is_eq (s_retval, prefix_sym)) {
+    w_current->keyaccel_string_source_id =
+      g_timeout_add(400, clear_keyaccel_string, w_current);
+  }
+
   return !scm_is_false (s_retval);
 }
 
diff --git a/gschem/src/gschem_toplevel.c b/gschem/src/gschem_toplevel.c
index f962f78..db97e29 100644
--- a/gschem/src/gschem_toplevel.c
+++ b/gschem/src/gschem_toplevel.c
@@ -51,6 +51,7 @@ GSCHEM_TOPLEVEL *gschem_toplevel_new ()
   w_current->toolbar_bus    = NULL;
 
   w_current->keyaccel_string = NULL;
+  w_current->keyaccel_string_source_id = FALSE;
 
   /* ------------ */
   /* Dialog boxes */




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs