[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: g_keys.c
User: ahvezda
Date: 07/06/09 10:44:27
Modified: . g_keys.c i_basic.c
Log:
Applied patch from Ivan Stankovic that displays entered characters in
the status bar
Revision Changes Path
1.10 eda/geda/gaf/gschem/src/g_keys.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: g_keys.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_keys.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- g_keys.c 4 Jun 2007 16:15:38 -0000 1.9
+++ g_keys.c 9 Jun 2007 14:44:27 -0000 1.10
@@ -48,6 +48,7 @@
/* for now this only supports single chars, not shift/alt/ctrl etc... */
int g_keys_execute(int state, int keyval)
{
+ TOPLEVEL *w = global_window_current;
char *guile_string = NULL;
char *modifier = NULL;
char *key_name = NULL;
@@ -70,16 +71,37 @@
}
if (state & GDK_SHIFT_MASK) {
- modifier = g_strdup_printf("\"Shift ");
+ modifier = g_strdup_printf("Shift ");
} else if (state & GDK_CONTROL_MASK) {
- modifier = g_strdup_printf("\"Control ");
+ modifier = g_strdup_printf("Control ");
} else if (state & GDK_MOD1_MASK) {
- modifier = g_strdup_printf("\"Alt ");
+ modifier = g_strdup_printf("Alt ");
+ } else
+ modifier = g_strdup("");
+
+ if(strcmp(key_name, "Escape") == 0) {
+ g_free(w->keyaccel_string);
+ w->keyaccel_string = NULL;
+ } else if(w->keyaccel_string &&
+ strlen(w->keyaccel_string) + strlen(key_name) > 10) {
+ g_free(w->keyaccel_string);
+ w->keyaccel_string = g_strconcat(modifier, key_name, NULL);
} else {
- modifier = g_strdup_printf("\"");
+ gchar *p, *r;
+
+ p = w->keyaccel_string;
+ w->keyaccel_string = g_strconcat(modifier, key_name, NULL);
+ if(p) {
+ r = g_strconcat(p, w->keyaccel_string, NULL);
+ g_free(p);
+ g_free(w->keyaccel_string);
+ w->keyaccel_string = r;
+ }
}
- guile_string = g_strdup_printf("(press-key %s%s\")",
+ i_show_state(w, NULL);
+
+ guile_string = g_strdup_printf("(press-key \"%s%s\")",
modifier, key_name);
#if DEBUG
@@ -142,12 +164,43 @@
return ret;
}
-/*! \brief
+/*! \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 toplevel
*/
+static gboolean clear_keyaccel_string(gpointer data)
+{
+ TOPLEVEL *w = global_window_current;
+
+ /* Find out if the toplevel is present... */
+ while(w->prev)
+ w = w->prev;
+
+ while(w) {
+ if(w == (TOPLEVEL *) data) {
+ /* ... it is, update its status bar */
+ g_free(w->keyaccel_string);
+ w->keyaccel_string = NULL;
+ i_show_state(w, NULL);
+ break;
+ }
+ w = w->next;
+ }
+
+ return FALSE;
+}
+
#define DEFINE_G_KEYS(name) \
SCM g_keys_ ## name(void) \
{ \
+ g_timeout_add(400, clear_keyaccel_string, global_window_current); \
i_callback_ ## name(global_window_current, 0, NULL); \
return SCM_BOOL_T; \
}
1.19 eda/geda/gaf/gschem/src/i_basic.c
(In the diff below, changes in quantity of whitespace are not shown.)
Index: i_basic.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/i_basic.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- i_basic.c 31 May 2007 21:29:48 -0000 1.18
+++ i_basic.c 9 Jun 2007 14:44:27 -0000 1.19
@@ -184,6 +184,14 @@
what_to_say = g_strjoinv(" - ", (gchar **) array + i);
+ if(w_current->keyaccel_string) {
+ gchar *p = what_to_say;
+
+ what_to_say = g_strdup_printf("%s \t\t %s", w_current->keyaccel_string,
+ what_to_say);
+ g_free(p);
+ }
+
i_update_status(w_current, what_to_say);
g_free(what_to_say);
}
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs