From: Nathaniel Wesley Filardo Date: Fri, 29 Jan 2016 06:55:02 +0000 (-0500) Subject: Steve Kemp's special-to-self patch X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=HEAD;p=gtetrinet Steve Kemp's special-to-self patch Originally from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=291844 --- diff --git a/src/config.c b/src/config.c index e36b172..cb80e7c 100644 --- a/src/config.c +++ b/src/config.c @@ -72,7 +72,8 @@ guint defaultkeys[K_NUM] = { GDK_3, GDK_4, GDK_5, - GDK_6 + GDK_6, + GDK_s }; guint keys[K_NUM]; @@ -367,6 +368,14 @@ void config_loadconfig (void) else keys[K_SPECIAL6] = defaultkeys[K_SPECIAL6]; + p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special_self", NULL); + if (p) + { + keys[K_SPECIAL_SELF] = gdk_keyval_to_lower (gdk_keyval_from_name (p)); + g_free (p); + } + else + keys[K_SPECIAL_SELF] = defaultkeys[K_SPECIAL_SELF]; /* Get the timestamp option. */ timestampsenable = gconf_client_get_bool (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", NULL); @@ -624,6 +633,18 @@ keys_special6_changed (GConfClient *client, keys[K_SPECIAL6] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry)))); } +void +keys_special_self_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry) +{ + + client = client; + cnxn_id = cnxn_id; + + keys[K_SPECIAL_SELF] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry)))); +} + void partyline_enable_timestamps_changed (GConfClient *client, guint cnxn_id, diff --git a/src/dialogs.c b/src/dialogs.c index 0d63305..a2984fa 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -548,6 +548,7 @@ void prefdialog_drawkeys (void) actions[K_SPECIAL4] = _("Special to field 4"); actions[K_SPECIAL5] = _("Special to field 5"); actions[K_SPECIAL6] = _("Special to field 6"); + actions[K_SPECIAL_SELF] = _("Special to self"); gconf_keys[K_RIGHT] = g_strdup ("/apps/gtetrinet/keys/right"); gconf_keys[K_LEFT] = g_strdup ("/apps/gtetrinet/keys/left"); @@ -563,6 +564,7 @@ void prefdialog_drawkeys (void) gconf_keys[K_SPECIAL4] = g_strdup ("/apps/gtetrinet/keys/special4"); gconf_keys[K_SPECIAL5] = g_strdup ("/apps/gtetrinet/keys/special5"); gconf_keys[K_SPECIAL6] = g_strdup ("/apps/gtetrinet/keys/special6"); + gconf_keys[K_SPECIAL_SELF] = g_strdup ("/apps/gtetrinet/keys/special_self"); for (i = 0; i < K_NUM; i ++) { gtk_list_store_append (keys_store, &iter); diff --git a/src/gtet_config.h b/src/gtet_config.h index 37ea825..f388856 100644 --- a/src/gtet_config.h +++ b/src/gtet_config.h @@ -101,6 +101,11 @@ keys_special6_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry); +void +keys_special_self_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry); + void partyline_enable_timestamps_changed (GConfClient *client, guint cnxn_id, @@ -131,6 +136,7 @@ typedef enum K_SPECIAL4, K_SPECIAL5, K_SPECIAL6, + K_SPECIAL_SELF, /* not a key but the number of configurable keys */ K_NUM } GTetrinetKeys; diff --git a/src/gtetrinet.c b/src/gtetrinet.c index 4450dd5..cf03084 100644 --- a/src/gtetrinet.c +++ b/src/gtetrinet.c @@ -210,6 +210,10 @@ int main (int argc, char *argv[]) (GConfClientNotifyFunc) keys_special6_changed, NULL, NULL, NULL); + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special_self", + (GConfClientNotifyFunc) keys_special_self_changed, + NULL, NULL, NULL); + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", (GConfClientNotifyFunc) partyline_enable_timestamps_changed, NULL, NULL, NULL); diff --git a/src/tetrinet.c b/src/tetrinet.c index ca5c5cf..7f97093 100644 --- a/src/tetrinet.c +++ b/src/tetrinet.c @@ -1811,6 +1811,16 @@ notfieldkey: tetris_drawcurrentblock (); return TRUE; } + else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL_SELF]) { + tetrinet_specialkey(playernum); + tetris_drawcurrentblock (); + return TRUE; + } + else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL_SELF]) { + tetrinet_specialkey(playernum); + tetris_drawcurrentblock (); + return TRUE; + } tetris_drawcurrentblock (); return FALSE; }