+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.
void connectdialog_connected (void)
{
- gtk_widget_destroy (connectdialog);
+ if (connectdialog != NULL) gtk_widget_destroy (connectdialog);
}
void connectdialog_destroy (void)
{ /* 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];
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));
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);
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;
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);
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;
}
{
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;
+ }
+}
extern void show_fields_page (void);
extern void show_partyline_page (void);
void unblock_keyboard_signal (void);
+gint get_current_notebook_page (void);
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)
/* update playerlist */
playernames[pnum][0] = 0;
teamnames[pnum][0] = 0;
+ playerplaying[pnum] = 0;
playerlistupdate ();
/* update fields display */
fieldslabelupdate ();
message is received (see above)
*/
playernames[pnum][0] = 0;
+ playerplaying[pnum] = 0;
}
break;
case IN_TEAM:
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)
-1);
g_free (name_utf8);
}
+
+void winlist_focus (void)
+{
+ gtk_widget_grab_focus (winlist);
+}
GtkWidget *winlist_page_new (void);
void winlist_clear (void);
void winlist_additem (int team, char *name, int score);
+void winlist_focus (void);