]> hydra-www.ietfng.org Git - gtetrinet/commitdiff
hide the window only if it really existed (fixes the -c bug).
authorDani Carbonell <bocata@panete.net>
Fri, 10 Jan 2003 18:30:08 +0000 (18:30 +0000)
committerJordi Albornoz <jordi@src.gnome.org>
Fri, 10 Jan 2003 18:30:08 +0000 (18:30 +0000)
2003-01-10  Dani Carbonell  <bocata@panete.net>

        * src/dialogs.c (connectdialog_connected): hide the window only if
        it really existed (fixes the -c bug).

        * src/fields.c (fields_gmsginputadd): this function was useless,
        removed.
        (fields_gmsginputback): likewise

        * src/fields.h: removed those two function's declarations.

        * src/gtetrinet.c (switch_focus): new function, will handle the
        notebook's tab switching, sending focus where it should be.
        (gtetrinet_key): function cleaned.

        * src/gtetrinet.h: added the function declaration.

        * src/partyline.c (partyline_entryfocus): now it clears all the text
        in the partyline's gtk_entry.

        * src/tetrinet.c (tetrinet_endgame): now it properly closes the field's
        gtk_entry, if it's open when the game ends.
        (tetrinet_inmessage): now it properly takes into account that a
        player has left the game, so no one can attack him after he's gone.

        * src/winlist.c (winlist_focus): new function that will focus the
        winlist when the user switches to that tab.

        * src/winlist.h: added the function declaration.

ChangeLog
src/dialogs.c
src/fields.c
src/fields.h
src/gtetrinet.c
src/gtetrinet.h
src/partyline.c
src/tetrinet.c
src/winlist.c
src/winlist.h

index 2a4bfcc45231abe0551f48c7b7b0e8385d27c42a..16788d8d5b3b378ab71b6431d8713ece559837e9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2003-01-10  Dani Carbonell  <bocata@panete.net>
+
+       * src/dialogs.c (connectdialog_connected): hide the window only if
+       it really existed (fixes the -c bug).
+
+       * src/fields.c (fields_gmsginputadd): this function was useless,
+       removed.
+       (fields_gmsginputback): likewise
+
+       * src/fields.h: removed those two function's declarations.
+
+       * src/gtetrinet.c (switch_focus): new function, will handle the
+       notebook's tab switching, sending focus where it should be.
+       (gtetrinet_key): function cleaned.
+
+       * src/gtetrinet.h: added the function declaration.
+
+       * src/partyline.c (partyline_entryfocus): now it clears all the text
+       in the partyline's gtk_entry.
+
+       * src/tetrinet.c (tetrinet_endgame): now it properly closes the field's
+       gtk_entry, if it's open when the game ends.
+       (tetrinet_inmessage): now it properly takes into account that a
+       player has left the game, so no one can attack him after he's gone.
+
+       * src/winlist.c (winlist_focus): new function that will focus the
+       winlist when the user switches to that tab.
+
+       * src/winlist.h: added the function declaration.
+
 2003-01-08  Jordi Mallach  <jordi@sindominio.net>
 
        * configure.in (AC_OUTPUT): sigh, I suck. Remove gtetrinet.desktop.
index 81fc867449f959ba35da84ce145710ecc1623e26..993a9f34306913338b2eecb50819628a97d20a68 100644 (file)
@@ -275,7 +275,7 @@ void connectdialog_tetrifasttoggle (GtkWidget *widget)
 
 void connectdialog_connected (void)
 {
-    gtk_widget_destroy (connectdialog);
+    if (connectdialog != NULL) gtk_widget_destroy (connectdialog);
 }
 
 void connectdialog_destroy (void)
index 400429604fb7bf011fc00392cbf60d31105cbeda..7f56a35502ef5ae2e1e2691e7d0b529b3ba30cfd 100644 (file)
@@ -596,15 +596,6 @@ void fields_gmsginputactivate (int t)
         { /* do nothing */; }
 }
 
-void fields_gmsginputadd (char *c)
-{
-    gchar *utf8_c = g_locale_to_utf8 (c, -1, NULL, NULL, NULL);
-    gtk_entry_append_text (GTK_ENTRY(gmsginput), utf8_c);
-    gtk_entry_set_position (GTK_ENTRY(gmsginput),
-                            strlen(gtk_entry_get_text(GTK_ENTRY(gmsginput))));
-    g_free (utf8_c);
-}
-
 void gmsginput_activate (GtkEntry *entry, gpointer data)
 {
     gchar *locale_s, buf[256];
@@ -638,19 +629,6 @@ void gmsginput_activate (GtkEntry *entry, gpointer data)
     gmsgstate = 0;
 }
 
-void fields_gmsginputback (void)
-{
-    char buf[256];
-    gchar *prev;
-  
-    GTET_O_STRCPY (buf, gtk_entry_get_text(GTK_ENTRY(gmsginput)));
-    if (strlen(buf) == 0) return;
-    prev = g_utf8_prev_char (&buf[strlen(buf)]);
-    *prev = 0;
-    gtk_entry_set_text (GTK_ENTRY(gmsginput), buf);
-    gtk_entry_set_position (GTK_ENTRY(gmsginput), strlen(buf));
-}
-
 const char *fields_gmsginputtext (void)
 {
     return gtk_entry_get_text (GTK_ENTRY(gmsginput));
index 80f3b5633690e666bb4f288bca5375ca03b31634..b565656e07c82486ae2165efdbb6bce2eb0aad8f 100644 (file)
@@ -21,6 +21,4 @@ extern void fields_gmsgclear (void);
 extern void fields_gmsginput (int i);
 extern void fields_gmsginputclear (void);
 extern void fields_gmsginputactivate (int i);
-extern void fields_gmsginputadd (char *c);
-extern void fields_gmsginputback (void);
 extern const char *fields_gmsginputtext (void);
index 647b27b6d2d1e4631e5d56023b95ad11d35423fd..2518704df69e9be2f5202492dc7c0ccafac9063e 100644 (file)
@@ -49,6 +49,10 @@ static GtkWidget *pixmapdata_label (char **d, char *str);
 static int gtetrinet_key (int keyval, int mod);
 gint keypress (GtkWidget *widget, GdkEventKey *key);
 gint keyrelease (GtkWidget *widget, GdkEventKey *key);
+void switch_focus (GtkNotebook *notebook,
+                   GtkNotebookPage *page,
+                   guint page_num,
+                   gpointer user_data);
 
 static GtkWidget *app, *pfields, *pparty, *pwinlist;
 static GtkWidget *winlistwidget, *partywidget, *fieldswidget;
@@ -218,8 +222,8 @@ int main (int argc, char *argv[])
     gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pwinlist, label);
 
     /* add signal to focus the text entry when switching to the partyline page*/
-    g_signal_connect_after(G_OBJECT (notebook), "switch_page",
-                          GTK_SIGNAL_FUNC (partyline_switch_entryfocus),
+    g_signal_connect_after(G_OBJECT (notebook), "switch-page",
+                          GTK_SIGNAL_FUNC (switch_focus),
                           NULL);
 
     gtk_widget_show (notebook);
@@ -403,12 +407,9 @@ static int gtetrinet_key (int keyval, int mod)
     
     switch (keyval)
     {
-    case GDK_1: gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 0); break;
-    case GDK_2:
-        gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 1);
-        /* partyline_entryfocus(); */
-        break;
-    case GDK_3: gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 2); break;
+    case GDK_1: gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook), 0); break;
+    case GDK_2: gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook), 1); break;
+    case GDK_3: gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook), 2); break;
     default:
         return FALSE;
     }
@@ -517,3 +518,20 @@ void unblock_keyboard_signal (void)
 {
     g_signal_handler_unblock (app, keypress_signal);
 }
+
+void switch_focus (GtkNotebook *notebook,
+                   GtkNotebookPage *page,
+                   guint page_num,
+                   gpointer user_data)
+{
+    if (connected)
+      switch (page_num)
+      {
+        case 0:
+          if (gmsgstate) fields_gmsginputactivate (1);
+          else partyline_entryfocus ();
+          break;
+        case 1: partyline_entryfocus (); break;
+        case 2: winlist_focus (); break;
+      }
+}
index 8cde9d333cced4f57db944b656f153fb78571e4a..f73f4f25b46246b2a4d95913c985fb1a381f0236 100644 (file)
@@ -14,3 +14,4 @@ extern void move_current_page_to_window (void);
 extern void show_fields_page (void);
 extern void show_partyline_page (void);
 void unblock_keyboard_signal (void);
+gint get_current_notebook_page (void);
index 79e33d12c1bfa7c579e95537812eb549231b43c0..e8dae97db16b556b7e1d7a7fa5e7603c67f4ec5d 100644 (file)
@@ -249,12 +249,12 @@ void partyline_playerlist (int *numbers, char **names, char **teams, int n, char
 
 void partyline_entryfocus (void)
 {
-    if (connected) gtk_widget_grab_focus (entrybox);
-}
-
-void partyline_switch_entryfocus (void)
-{ /* FIXME: should only grab when in right notebook */
-    if (connected) gtk_widget_grab_focus (entrybox);
+    if (connected)
+    {
+      gtk_entry_set_text (GTK_ENTRY(entrybox), "");
+      gtk_entry_set_position (GTK_ENTRY(entrybox), 0);
+      gtk_widget_grab_focus (entrybox);
+    }
 }
 
 void textentry (GtkWidget *widget)
index ca5198cd5c6ae4872ae65042fc2af750418d7a3d..919cd639833d1084aef0a6a8c93c8348c81c690f 100644 (file)
@@ -313,6 +313,7 @@ void tetrinet_inmessage (enum inmsg_type msgtype, char *data)
             /* update playerlist */
             playernames[pnum][0] = 0;
             teamnames[pnum][0] = 0;
+            playerplaying[pnum] = 0;
             playerlistupdate ();
             /* update fields display */
             fieldslabelupdate ();
@@ -347,6 +348,7 @@ void tetrinet_inmessage (enum inmsg_type msgtype, char *data)
              message is received (see above)
              */
             playernames[pnum][0] = 0;
+            playerplaying[pnum] = 0;
         }
         break;
     case IN_TEAM:
@@ -1333,9 +1335,13 @@ void tetrinet_endgame (void)
     fields_setlevel (-1);
     fields_setactivelevel (-1);
     fields_setspeciallabel (NULL);
-    gmsgstate = 0;
-    fields_gmsginput (FALSE);
-    fields_gmsginputclear ();
+    if (gmsgstate)
+    {
+      gmsgstate = 0;
+      fields_gmsginput (FALSE);
+      fields_gmsginputclear ();
+      unblock_keyboard_signal ();
+    }
 }
 
 void tetrinet_updatelevels (void)
index 3e5cd0043fe4d38de9ede5501e4c819367b28c52..a7466b315860a3a9f632b2b98264489f9d53ccc6 100644 (file)
@@ -87,3 +87,8 @@ void winlist_additem (int team, char *name, int score)
                         -1);
     g_free (name_utf8);
 }
+
+void winlist_focus (void)
+{
+  gtk_widget_grab_focus (winlist);
+}
index 6992ea206e24662bb22b569449274efb47344846..736480dd850a78d0735eeca4af37bbc98dce51d5 100644 (file)
@@ -2,3 +2,4 @@
 GtkWidget *winlist_page_new (void);
 void winlist_clear (void);
 void winlist_additem (int team, char *name, int score);
+void winlist_focus (void);