]> hydra-www.ietfng.org Git - gtetrinet/commitdiff
Make the "use special" keys configurable. This helps people using Azerty keyboards...
authorJordi Mallach <jordim@src.gnome.org>
Fri, 6 Jun 2003 11:05:00 +0000 (11:05 +0000)
committerJordi Mallach <jordim@src.gnome.org>
Fri, 6 Jun 2003 11:05:00 +0000 (11:05 +0000)
ChangeLog
gtetrinet.schemas.in
src/config.c
src/config.h
src/dialogs.c
src/gtetrinet.c
src/tetrinet.c

index a228a057ae40fed30f0ab7d4b7f44caca4030028..87f1eacebc14d19ef8be6691f0fa27cae9a6120f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2003-06-06  Jordi Mallach  <jordi@sindominio.net>
+
+       * src/config.c (config_loadconfig): load values for new keys.
+       Add notify functions for new gconf keys.
+       * src/config.h: Add new declarations and key defines.
+       * src/dialogs.c (prefdialog_drawkeys): Add new actions to treeview.
+       * src/gtetrinet (main): Notify gconf of changes to new keys.
+       * src/tetrinet.c (tetrinet_key): Handle new special keys. Closes
+       Bugzilla Bug#105117.
+
+       * gtetrinet.schemas.in: Add schemas for new configurable game keys.
+
 2003-06-05  Jordi Mallach  <jordi@sindominio.net>
 
        * NEWS: Update for 0.7.2.
index fdfb049474b86e09db1ce219955de52ffeff2cd1..34acebb26658f0160f4baec4af2623e23a9c4ebb 100644 (file)
@@ -9,7 +9,7 @@
       <default></default>
 
       <locale name="C">
-        <short>Theme directory, should end with a '/'.</short>
+        <short>Theme directory, should end with a '/'</short>
         <long>The current theme directory. It should contain a readable
         "blocks.png" and a "theme.cfg".</long>
       </locale>
@@ -24,7 +24,7 @@
       <default>while true; do playmidi $MIDIFILE; done</default>
 
       <locale name="C">
-        <short>Command to run to play midi files.</short>
+        <short>Command to run to play midi files</short>
         <long>This command is run when a midi file is to be played. The name of
         the midi file is placed in the environment variable MIDIFILE.</long>
       </locale>
@@ -39,7 +39,7 @@
       <default>0</default>
 
       <locale name="C">
-        <short>Enable/disable sound.</short>
+        <short>Enable/disable sound</short>
         <long>Enables/Disables sound. Keep in mind that the theme
         that you're using must provide sounds.</long>
       </locale>
@@ -54,7 +54,7 @@
       <default>0</default>
 
       <locale name="C">
-        <short>Enable/disable midi music.</short>
+        <short>Enable/disable midi music</short>
         <long>Enables/disables midi music. You'll need to enable
         sound if you want music to work.</long>
       </locale>
@@ -69,7 +69,7 @@
       <default></default>
 
       <locale name="C">
-        <short>Your nickname.</short>
+        <short>Your nickname</short>
         <long>This will be your nickname in the game.</long>
       </locale>
     </schema>
@@ -83,7 +83,7 @@
       <default>tetrinet.org</default>
 
       <locale name="C">
-        <short>Server where you want to play.</short>
+        <short>Server where you want to play</short>
         <long>This is the server where GTetrinet will try to connect.</long>
       </locale>
     </schema>
@@ -97,7 +97,7 @@
       <default></default>
       
       <locale name="C">
-        <short>Your team.</short>
+        <short>Your team</short>
         <long>This will be the name of your team.</long>
       </locale>
     </schema>
       <default>Right</default>
 
       <locale name="C">
-        <short>Key to move right.</short>
+        <short>Key to move right</short>
         <long>This key moves the block to the right. This is case insensitive.</long>
       </locale>
     </schema>
       <default>Left</default>
 
       <locale name="C">
-        <short>Key to move left.</short>
+        <short>Key to move left</short>
         <long>This key moves the block to the left. This is case insensitive.</long>
       </locale>
     </schema>
       <default>Up</default>
       
       <locale name="C">
-        <short>Key to rotate clockwise.</short>
+        <short>Key to rotate clockwise</short>
         <long>This key rotates the block clockwise. This is case insensitive.</long>
       </locale>
     </schema>
       <default>Control_R</default>
       
       <locale name="C">
-        <short>Key to rotate counterclockwise.</short>
+        <short>Key to rotate counterclockwise</short>
         <long>This key rotates the block counterclockwise. This is case insensitive.</long>
       </locale>
     </schema>
       <default>Down</default>
       
       <locale name="C">
-        <short>Key to move down.</short>
+        <short>Key to move down</short>
         <long>This key moves the block down. This is case insensitive.</long>
       </locale>
     </schema>
       <default>space</default>
       
       <locale name="C">
-        <short>Key to drop piece.</short>
+        <short>Key to drop piece</short>
         <long>This key drops the block to the ground. This is case insensitive.</long>
       </locale>
     </schema>
     
     
+    <schema>
+      <key>/schemas/apps/gtetrinet/keys/message</key>
+      <applyto>/apps/gtetrinet/keys/message</applyto>
+      <owner>gtetrinet</owner>
+      <type>string</type>
+      <default>t</default>
+      
+      <locale name="C">
+        <short>Key to open the fields' message dialog</short>
+        <long>This key displays the fields' message dialog. This is case insensitive.</long>
+      </locale>
+    </schema>
+    
+
     <schema>
       <key>/schemas/apps/gtetrinet/keys/discard</key>
       <applyto>/apps/gtetrinet/keys/discard</applyto>
       <default>d</default>
       
       <locale name="C">
-        <short>Key to discard special.</short>
+        <short>Key to discard special</short>
         <long>This key discards the current special. This is case insensitive.</long>
       </locale>
     </schema>
     
     
     <schema>
-      <key>/schemas/apps/gtetrinet/keys/message</key>
-      <applyto>/apps/gtetrinet/keys/message</applyto>
+      <key>/schemas/apps/gtetrinet/keys/special1</key>
+      <applyto>/apps/gtetrinet/keys/special1</applyto>
       <owner>gtetrinet</owner>
       <type>string</type>
-      <default>t</default>
+      <default>1</default>
       
       <locale name="C">
-        <short>Key to open the fields' message dialog.</short>
-        <long>This key displays the fields' message dialog. This is case insensitive.</long>
+        <short>Key to use the current special on field 1</short>
+        <long>This key uses the current special on Player 1's game field.</long>
+      </locale>
+    </schema>
+    
+
+    <schema>
+      <key>/schemas/apps/gtetrinet/keys/special2</key>
+      <applyto>/apps/gtetrinet/keys/special2</applyto>
+      <owner>gtetrinet</owner>
+      <type>string</type>
+      <default>2</default>
+      
+      <locale name="C">
+        <short>Key to use the current special on field 2</short>
+        <long>This key uses the current special on Player 2's game field.</long>
+      </locale>
+    </schema>
+    
+
+    <schema>
+      <key>/schemas/apps/gtetrinet/keys/special3</key>
+      <applyto>/apps/gtetrinet/keys/special3</applyto>
+      <owner>gtetrinet</owner>
+      <type>string</type>
+      <default>3</default>
+      
+      <locale name="C">
+        <short>Key to use the current special on field 3</short>
+        <long>This key uses the current special on Player 3's game field.</long>
+      </locale>
+    </schema>
+    
+
+    <schema>
+      <key>/schemas/apps/gtetrinet/keys/special4</key>
+      <applyto>/apps/gtetrinet/keys/special4</applyto>
+      <owner>gtetrinet</owner>
+      <type>string</type>
+      <default>4</default>
+      
+      <locale name="C">
+        <short>Key to use the current special on field 4</short>
+        <long>This key uses the current special on Player 4's game field.</long>
+      </locale>
+    </schema>
+    
+
+    <schema>
+      <key>/schemas/apps/gtetrinet/keys/special5</key>
+      <applyto>/apps/gtetrinet/keys/special5</applyto>
+      <owner>gtetrinet</owner>
+      <type>string</type>
+      <default>5</default>
+      
+      <locale name="C">
+        <short>Key to use the current special on field 5</short>
+        <long>This key uses the current special on Player 5's game field.</long>
+      </locale>
+    </schema>
+    
+
+    <schema>
+      <key>/schemas/apps/gtetrinet/keys/special6</key>
+      <applyto>/apps/gtetrinet/keys/special6</applyto>
+      <owner>gtetrinet</owner>
+      <type>string</type>
+      <default>6</default>
+      
+      <locale name="C">
+        <short>Key to use the current special on field 6</short>
+        <long>This key uses the current special on Player 6's game field.</long>
       </locale>
     </schema>
     
index d7fe692174abf741c3a2522d01b14c79550186eb..c7b4ad878240bb8638a8c6afbfce635a3050838a 100644 (file)
@@ -305,6 +305,61 @@ void config_loadconfig (void)
     else
       keys[K_GAMEMSG] = defaultkeys[K_GAMEMSG];
 
+    p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special1", NULL);
+    if (p)
+    {
+      keys[K_SPECIAL1] = gdk_keyval_to_lower (gdk_keyval_from_name (p));
+      g_free (p);
+    }
+    else
+      keys[K_SPECIAL1] = defaultkeys[K_SPECIAL1];
+
+    p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special2", NULL);
+    if (p)
+    {
+      keys[K_SPECIAL2] = gdk_keyval_to_lower (gdk_keyval_from_name (p));
+      g_free (p);
+    }
+    else
+      keys[K_SPECIAL2] = defaultkeys[K_SPECIAL2];
+
+    p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special3", NULL);
+    if (p)
+    {
+      keys[K_SPECIAL3] = gdk_keyval_to_lower (gdk_keyval_from_name (p));
+      g_free (p);
+    }
+    else
+      keys[K_SPECIAL3] = defaultkeys[K_SPECIAL3];
+
+    p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special4", NULL);
+    if (p)
+    {
+      keys[K_SPECIAL4] = gdk_keyval_to_lower (gdk_keyval_from_name (p));
+      g_free (p);
+    }
+    else
+      keys[K_SPECIAL4] = defaultkeys[K_SPECIAL4];
+
+    p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special5", NULL);
+    if (p)
+    {
+      keys[K_SPECIAL5] = gdk_keyval_to_lower (gdk_keyval_from_name (p));
+      g_free (p);
+    }
+    else
+      keys[K_SPECIAL5] = defaultkeys[K_SPECIAL5];
+
+    p = gconf_client_get_string (gconf_client, "/apps/gtetrinet/keys/special6", NULL);
+    if (p)
+    {
+      keys[K_SPECIAL6] = gdk_keyval_to_lower (gdk_keyval_from_name (p));
+      g_free (p);
+    }
+    else
+      keys[K_SPECIAL6] = defaultkeys[K_SPECIAL6];
+
+
     /* Get the timestamp option. */
     timestampsenable = gconf_client_get_bool (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", NULL);
 
@@ -489,6 +544,78 @@ keys_discard_changed (GConfClient *client,
   keys[K_DISCARD] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry))));
 }
 
+void
+keys_special1_changed (GConfClient *client,
+                       guint cnxn_id,
+                       GConfEntry *entry)
+{
+
+  client = client;
+  cnxn_id = cnxn_id;
+
+  keys[K_SPECIAL1] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry))));
+}
+
+void
+keys_special2_changed (GConfClient *client,
+                       guint cnxn_id,
+                       GConfEntry *entry)
+{
+
+  client = client;
+  cnxn_id = cnxn_id;
+
+  keys[K_SPECIAL2] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry))));
+}
+
+void
+keys_special3_changed (GConfClient *client,
+                       guint cnxn_id,
+                       GConfEntry *entry)
+{
+
+  client = client;
+  cnxn_id = cnxn_id;
+
+  keys[K_SPECIAL3] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry))));
+}
+
+void
+keys_special4_changed (GConfClient *client,
+                       guint cnxn_id,
+                       GConfEntry *entry)
+{
+
+  client = client;
+  cnxn_id = cnxn_id;
+
+  keys[K_SPECIAL4] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry))));
+}
+
+void
+keys_special5_changed (GConfClient *client,
+                       guint cnxn_id,
+                       GConfEntry *entry)
+{
+
+  client = client;
+  cnxn_id = cnxn_id;
+
+  keys[K_SPECIAL5] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry))));
+}
+
+void
+keys_special6_changed (GConfClient *client,
+                       guint cnxn_id,
+                       GConfEntry *entry)
+{
+
+  client = client;
+  cnxn_id = cnxn_id;
+
+  keys[K_SPECIAL6] = 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,
index fbba64e2e62309583e479e13ad4ca5dccf59bc74..d8818c061b4b502bd15857a7e2a7062abdfc2b74 100644 (file)
@@ -71,6 +71,36 @@ keys_discard_changed (GConfClient *client,
                    guint cnxn_id,
                    GConfEntry *entry);
 
+void
+keys_special1_changed (GConfClient *client,
+                   guint cnxn_id,
+                   GConfEntry *entry);
+
+void
+keys_special2_changed (GConfClient *client,
+                   guint cnxn_id,
+                   GConfEntry *entry);
+
+void
+keys_special3_changed (GConfClient *client,
+                   guint cnxn_id,
+                   GConfEntry *entry);
+
+void
+keys_special4_changed (GConfClient *client,
+                   guint cnxn_id,
+                   GConfEntry *entry);
+
+void
+keys_special5_changed (GConfClient *client,
+                   guint cnxn_id,
+                   GConfEntry *entry);
+
+void
+keys_special6_changed (GConfClient *client,
+                   guint cnxn_id,
+                   GConfEntry *entry);
+
 void
 partyline_enable_timestamps_changed (GConfClient *client,
                                      guint cnxn_id,
@@ -93,5 +123,11 @@ partyline_enable_channel_list_changed (GConfClient *client,
 #define K_DROP 5
 #define K_DISCARD 6
 #define K_GAMEMSG 7
+#define K_SPECIAL1 8
+#define K_SPECIAL2 9
+#define K_SPECIAL3 10 
+#define K_SPECIAL4 11
+#define K_SPECIAL5 12
+#define K_SPECIAL6 13
 /* not a key but the number of configurable keys */
-#define K_NUM 8
+#define K_NUM 14
index 757793cf6c24af5cf4fd84955df0219b5d31cafb..96483a013af5efb62737f79c95be5d60c5a27ac8 100644 (file)
@@ -549,6 +549,12 @@ void prefdialog_drawkeys (void)
     actions[K_DROP]     = _("Drop piece");
     actions[K_DISCARD]  = _("Discard special");
     actions[K_GAMEMSG]  = _("Send message");
+    actions[K_SPECIAL1] = _("Special to field 1");
+    actions[K_SPECIAL2] = _("Special to field 2");
+    actions[K_SPECIAL3] = _("Special to field 3");
+    actions[K_SPECIAL4] = _("Special to field 4");
+    actions[K_SPECIAL5] = _("Special to field 5");
+    actions[K_SPECIAL6] = _("Special to field 6");
   
     gconf_keys[K_RIGHT]    = g_strdup ("/apps/gtetrinet/keys/right");
     gconf_keys[K_LEFT]     = g_strdup ("/apps/gtetrinet/keys/left");
@@ -558,6 +564,12 @@ void prefdialog_drawkeys (void)
     gconf_keys[K_DROP]     = g_strdup ("/apps/gtetrinet/keys/drop");
     gconf_keys[K_DISCARD]  = g_strdup ("/apps/gtetrinet/keys/discard");
     gconf_keys[K_GAMEMSG]  = g_strdup ("/apps/gtetrinet/keys/message");
+    gconf_keys[K_SPECIAL1] = g_strdup ("/apps/gtetrinet/keys/special1");
+    gconf_keys[K_SPECIAL2] = g_strdup ("/apps/gtetrinet/keys/special2");
+    gconf_keys[K_SPECIAL3] = g_strdup ("/apps/gtetrinet/keys/special3");
+    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");
 
     for (i = 0; i < K_NUM; i ++) {
         gtk_list_store_append (keys_store, &iter);
index e3f9f69f5d0053b47c5d8f8bbaf16a3be2896713..f1568beb4a03e7ab3fea6357bc61e49b94bcc0de 100644 (file)
@@ -178,12 +178,36 @@ int main (int argc, char *argv[])
                              (GConfClientNotifyFunc) keys_drop_changed, NULL,
                             NULL, NULL);
 
+    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/message",
+                            (GConfClientNotifyFunc) keys_message_changed,
+                            NULL, NULL, NULL);
+
     gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/discard",
-                             (GConfClientNotifyFunc) keys_discard_changed,
+                            (GConfClientNotifyFunc) keys_discard_changed,
                             NULL, NULL, NULL);
 
-    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/message",
-                             (GConfClientNotifyFunc) keys_message_changed,
+    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special1",
+                             (GConfClientNotifyFunc) keys_special1_changed,
+                            NULL, NULL, NULL);
+
+    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special2",
+                             (GConfClientNotifyFunc) keys_special2_changed,
+                            NULL, NULL, NULL);
+
+    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special3",
+                             (GConfClientNotifyFunc) keys_special3_changed,
+                            NULL, NULL, NULL);
+
+    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special4",
+                             (GConfClientNotifyFunc) keys_special4_changed,
+                            NULL, NULL, NULL);
+
+    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special5",
+                             (GConfClientNotifyFunc) keys_special5_changed,
+                            NULL, NULL, NULL);
+
+    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special6",
+                             (GConfClientNotifyFunc) keys_special6_changed,
                             NULL, NULL, NULL);
 
     gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps",
index 879fb51a2aff7866e140d31b06958044ece1b80c..d275744c3121139e80e68e2233b45aa919713cf0 100644 (file)
@@ -1749,15 +1749,23 @@ notfieldkey:
     else if (gdk_keyval_to_lower (keyval) == keys[K_DISCARD]) {
         tetrinet_specialkey(-1);
     }
-    else switch (keyval) {
-    case GDK_1: tetrinet_specialkey(1); break;
-    case GDK_2: tetrinet_specialkey(2); break;
-    case GDK_3: tetrinet_specialkey(3); break;
-    case GDK_4: tetrinet_specialkey(4); break;
-    case GDK_5: tetrinet_specialkey(5); break;
-    case GDK_6: tetrinet_specialkey(6); break;
-    default:
-        return FALSE;
+    else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL1]) {
+       tetrinet_specialkey(1);
+    }
+    else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL2]) {
+       tetrinet_specialkey(2);
+    }
+    else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL3]) {
+       tetrinet_specialkey(3);
+    }
+    else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL4]) {
+       tetrinet_specialkey(4);
+    }
+    else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL5]) {
+       tetrinet_specialkey(5);
+    }
+    else if (gdk_keyval_to_lower (keyval) == keys[K_SPECIAL6]) {
+       tetrinet_specialkey(6);
     }
     tetris_drawcurrentblock ();
     return TRUE;