[geany/geany] 2e1117: Greatly simplify trigger callback

Colomban Wendling git-noreply at xxxxx
Sun Jan 17 03:04:27 UTC 2016


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Wed, 04 Mar 2015 18:27:35 UTC
Commit:      2e1117e027ec6e4cbcfaaf22516b368b61a9d1b3
             https://github.com/geany/geany/commit/2e1117e027ec6e4cbcfaaf22516b368b61a9d1b3

Log Message:
-----------
Greatly simplify trigger callback


Modified Paths:
--------------
    src/gb.c

Modified: src/gb.c
54 lines changed, 10 insertions(+), 44 deletions(-)
===================================================================
@@ -469,54 +469,20 @@ static GtkWidget *geany_pong_new(GtkWindow *parent)
 
 static gboolean gb_on_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 {
-	static gchar text[] = "00000";
+	static gchar text[] = "geany";
 
-	switch (event->keyval)
+	if (event->keyval < 0x80)
 	{
-		case 'g':
-		{
-			text[0] = 'g';
-			text[1] = '\0';
-			return TRUE;
-			break;
-		}
-		case 'e':
-		{
-			text[1] = 'e';
-			text[2] = '\0';
-			return TRUE;
-			break;
-		}
-		case 'a':
-		{
-			text[2] = 'a';
-			text[3] = '\0';
-			return TRUE;
-			break;
-		}
-		case 'n':
-		{
-			text[3] = 'n';
-			text[4] = '\0';
-			return TRUE;
-			break;
-		}
-		case 'y':
+		memmove (text, &text[1], G_N_ELEMENTS(text) - 1);
+		text[G_N_ELEMENTS(text) - 2] = (gchar) event->keyval;
+
+		if (utils_str_equal(text, "geany"))
 		{
-			text[4] = 'y';
-			text[5] = '\0';
-			if (utils_str_equal(text, "geany"))
-			{
-				GtkWidget *pong = geany_pong_new(GTK_WINDOW(widget));
-				gtk_widget_show(pong);
-			}
+			GtkWidget *pong = geany_pong_new(GTK_WINDOW(widget));
+			gtk_widget_show(pong);
 			return TRUE;
-			break;
-		}
-		default:
-		{
-			text[0] = '\0';
-			return FALSE;
 		}
 	}
+
+	return FALSE;
 }



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list