]> hydra-www.ietfng.org Git - gtetrinet/commitdiff
Patch from Dani Carbonell. Fix memory leak in winlist.c. More UTF-8 conversion fixes...
authorJordi Albornoz <jordi@src.gnome.org>
Sun, 5 Jan 2003 18:25:56 +0000 (18:25 +0000)
committerJordi Albornoz <jordi@src.gnome.org>
Sun, 5 Jan 2003 18:25:56 +0000 (18:25 +0000)
ChangeLog
TODO
src/fields.c
src/fields.h
src/gtetrinet.c
src/misc.c
src/partyline.c
src/tetrinet.c
src/winlist.c

index 90763f2168080d788dd7ea2d269c6138bf8339c7..2805a3f1d42071a3beb75295581e53314e52a6db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2003-01-05  Dani Carbonell <bocata@panete.net>
+
+       * TODO: updated.
+
+       * src/tetrinet.c (tetrinet_inmessage): converted reason to disconnect
+       to UTF-8 so it can be displayed properly.
+
+       * src/winlist.c (winlist_additem): fixed memory leak.
+
+       * src/misc.c (nocolor): it wasn't doing anything, reverted to its
+       previous behaviour, but now it doesn't cut accented characters ( < 0 ).
+
+       * src/fields.c (fields_setlabel): now displays correctly all the UTF-8
+       characters, applying the nocolor () function to the ASCII strings
+       before recoding them to UTF-8.
+
+       * src/partyline.c (partyline_namelabel): likewise.
+       (partyline_page_new): added a horizontal scrollbar to the playerlist.
+
+       * src/gtetrinet.c (keypress): string "Playing Fields" wasn't been
+       translated, and gtk_object_get_data ported to g_object_get_data.
+       (keyreleased): likewise.
+
 2003-01-05  Jordi Mallach  <jordi@sindominio.net>
 
        * TODO: updated.
diff --git a/TODO b/TODO
index e864330b234ee10af414981ba0800bad22861aeb..72a7544dfa09a8a515c9b650e5b7d3ad5824d8f3 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,5 +9,8 @@ GTetrinet's TODO list
   + problem when typing composed letters (รก) in fields messages
   + add real tooltips
   + port deprecated widgets (-DGTK_DISABLE_DEPRECATED)
+  + pressing a key when a game is in progress, but you are not playing it, 
+    causes a Gtk-CRITICAL
+  + detaching and reattaching the Menu Bar causes two Bonobo-CRITICAL
 - Make gtetrinet resizeable (at least the fields messages bit)
 - Write a User Manual
index f3f0c76fa0ac11fcc0c6520de92467fd7b6f0b93..4d7b9818e327bb8c0187fe56460494d5158ffc0b 100644 (file)
@@ -411,13 +411,13 @@ void fields_setlabel (int field, char *name, char *team, int num)
         gtk_label_set (GTK_LABEL(fieldlabels[field][5]), "");
     }
     else {
-        name_utf8 = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
+        name_utf8 = g_locale_to_utf8 (nocolor (name), -1, NULL, NULL, NULL);
         gtk_widget_show (fieldlabels[field][0]);
         gtk_widget_show (fieldlabels[field][1]);
         gtk_widget_show (fieldlabels[field][2]);
         gtk_widget_hide (fieldlabels[field][3]);
         gtk_label_set (GTK_LABEL(fieldlabels[field][0]), buf);
-        gtk_label_set (GTK_LABEL(fieldlabels[field][2]), nocolor(name_utf8));
+        gtk_label_set (GTK_LABEL(fieldlabels[field][2]), name_utf8);
         gtk_label_set (GTK_LABEL(fieldlabels[field][3]), "");
         if (team == NULL || team[0] == 0) {
             gtk_widget_hide (fieldlabels[field][4]);
@@ -425,10 +425,10 @@ void fields_setlabel (int field, char *name, char *team, int num)
             gtk_label_set (GTK_LABEL(fieldlabels[field][5]), "");
         }
         else {
-            team_utf8 = g_locale_to_utf8 (team, -1, NULL, NULL, NULL);
+            team_utf8 = g_locale_to_utf8 (nocolor (team), -1, NULL, NULL, NULL);
             gtk_widget_show (fieldlabels[field][4]);
             gtk_widget_show (fieldlabels[field][5]);
-            gtk_label_set (GTK_LABEL(fieldlabels[field][5]), nocolor(team_utf8));
+            gtk_label_set (GTK_LABEL(fieldlabels[field][5]), team_utf8);
             g_free (team_utf8);
         }
         g_free (name_utf8);
index f935019b551f1cf861c344814d62eee9245773af..17a8a271809a2bd3eb2ebcac19773b981a461345 100644 (file)
@@ -1,4 +1,5 @@
 #include <gtk/gtk.h>
+
 extern GtkWidget *fields_page_new (void);
 extern void fields_page_destroy_contents (void);
 extern void fields_init (void);
index de5757314e9cb74b07354d9513ffb51819c6d8a0..798a9d3494a94069d87a8ab53a913ec82f03fd5e 100644 (file)
@@ -325,8 +325,8 @@ gint keypress (GtkWidget *widget, GdkEventKey *key)
         /* Sub-window - find out which */
         char *title = NULL;
 
-        title = gtk_object_get_data(GTK_OBJECT(widget), "title");
-        game_area =  title && !strcmp( title, "Playing Fields" );
+        title = g_object_get_data(G_OBJECT(widget), "title");
+        game_area =  title && !strcmp( title, _("Playing Fields"));
     }
 
     if (game_area)
@@ -334,16 +334,22 @@ gint keypress (GtkWidget *widget, GdkEventKey *key)
       if (keytimeoutid && key->time == k.time)
         gtk_timeout_remove (keytimeoutid);
     }
+
     if (gtetrinet_key(key->keyval, key->state & (GDK_MOD1_MASK |
                                                  GDK_CONTROL_MASK |
                                                  GDK_SHIFT_MASK)))
-      goto keyprocessed;
-    if (game_area && tetrinet_key (key->keyval, key->string)) goto keyprocessed;
+    {
+      gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event");
+      return TRUE;
+    }
 
+    if (game_area && tetrinet_key (key->keyval, key->string))
+    {
+      gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event");
+      return TRUE;
+    }
+    
     return FALSE;
-keyprocessed:
-    gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event");
-    return TRUE;
 }
 
 gint keyrelease (GtkWidget *widget, GdkEventKey *key)
@@ -363,8 +369,8 @@ gint keyrelease (GtkWidget *widget, GdkEventKey *key)
         /* Sub-window - find out which */
         char *title = NULL;
 
-        title = gtk_object_get_data(GTK_OBJECT(widget), "title");
-        game_area =  title && !strcmp( title, "Playing Fields" );
+        title = g_object_get_data(G_OBJECT(widget), "title");
+        game_area =  title && !strcmp( title, _("Playing Fields"));
     }
 
     if (game_area)
index f41d55e02033e3970f8a4a514c7812bac58003c1..fb5e43be14155b7ab5b6e45656769588c21a04d0 100644 (file)
@@ -119,8 +119,6 @@ void textbox_setup (void)
         gtet_text_tags[n].t_c = gtk_text_buffer_create_tag (buffer, NULL,
                                                             "foreground-gdk",
                                                             &gtet_text_tags[n].c,
-//                                                            "background",
-//                                                            "white",
                                                             NULL);
 
     t_bold = gtk_text_buffer_create_tag (buffer, NULL,
@@ -295,6 +293,11 @@ char *nocolor (char *str)
   g_string_assign(ret, str);
 
   p = scan = ret->str;
+  while (*scan != 0)
+  {
+    if ((*scan > 0x1F) || (*scan < 0x0)) *p++ = *scan;
+    scan++;
+  }
   if (scan != p)
     g_string_truncate(ret, len - (scan - p));
   
index 1733c62c203e7b50344b504b2b53f1d8660a50b8..129bab7b671d50fbaff8ec4a3daaca39e4f9b810 100644 (file)
@@ -35,7 +35,7 @@
 
 /* widgets that we have to do stuff with */
 static GtkWidget *playerlist, *textbox, *entrybox,
-    *namelabel, *teamlabel, *infolabel, *textboxscroll;
+    *namelabel, *teamlabel, *infolabel, *textboxscroll, *playerlist_scroll;
 
 /* some more widgets for layout */
 static GtkWidget *table, *leftbox, *rightbox;
@@ -82,7 +82,7 @@ GtkWidget *partyline_page_new (void)
     gtk_box_pack_start (GTK_BOX(leftbox), entrybox, FALSE, FALSE, 0);
     gtk_widget_show (leftbox);
 
-    /* player list */
+    /* player list with scrollbar */
     playerlist = GTK_WIDGET (gtk_tree_view_new_with_model (GTK_TREE_MODEL (playerlist_model)));
     gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (playerlist), -1, "", renderer,
                                                  "text", 0, NULL);
@@ -90,9 +90,15 @@ GtkWidget *partyline_page_new (void)
                                                  "text", 1, NULL);
     gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (playerlist), -1, _("Team"), renderer,
                                                  "text", 2, NULL);
-    gtk_widget_set_usize (playerlist, 150, 200);
     gtk_widget_show (playerlist);
-
+    playerlist_scroll = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (playerlist_scroll),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_NEVER);
+    gtk_container_add (GTK_CONTAINER(playerlist_scroll), playerlist);
+    gtk_widget_set_usize (playerlist_scroll, 150, 200);
+    gtk_widget_show (playerlist_scroll);
+    
     /* right box */
     box = gtk_vbox_new (FALSE, 2);
 
@@ -131,7 +137,7 @@ GtkWidget *partyline_page_new (void)
     gtk_table_attach (GTK_TABLE(table), leftbox, 0, 1, 0, 2,
                       GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
                       0, 0);
-    gtk_table_attach (GTK_TABLE(table), playerlist, 1, 2, 0, 1,
+    gtk_table_attach (GTK_TABLE(table), playerlist_scroll, 1, 2, 0, 1,
                       GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0);
     gtk_table_attach (GTK_TABLE(table), rightbox, 1, 2, 1, 2,
                       GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0);
@@ -160,15 +166,15 @@ void partyline_namelabel (char *nick, char *team)
   
     if (nick)
     {
-      nick_utf8 = g_locale_to_utf8 (nick, -1, NULL, NULL, NULL);
-      gtk_label_set (GTK_LABEL(namelabel), nocolor(nick_utf8));
+      nick_utf8 = g_locale_to_utf8 (nocolor (nick), -1, NULL, NULL, NULL);
+      gtk_label_set (GTK_LABEL(namelabel), nick_utf8);
       g_free (nick_utf8);
     }
     else gtk_label_set (GTK_LABEL(namelabel), "");
     if (team)
     {
-      team_utf8 = g_locale_to_utf8 (team, -1, NULL, NULL, NULL);
-      gtk_label_set (GTK_LABEL(teamlabel), nocolor(team_utf8));
+      team_utf8 = g_locale_to_utf8 (nocolor (team), -1, NULL, NULL, NULL);
+      gtk_label_set (GTK_LABEL(teamlabel), team_utf8);
       g_free (team_utf8);
     }
     else gtk_label_set (GTK_LABEL(teamlabel), "");
index 9dee5e8b2c152c4bb044e8349d7616c515c9bd7d..b341914dbb1aa0aea7a6da6d13ce007ebfd487c3 100644 (file)
@@ -205,12 +205,15 @@ void tetrinet_inmessage (enum inmsg_type msgtype, char *data)
     connecterror:
         {
             GtkWidget *dialog;
+            gchar *data_utf8;
             connectingdialog_destroy ();
             GTET_O_STRCPY (buf, _("Error connecting: "));
-            GTET_O_STRCAT (buf, data);
+            data_utf8 = g_locale_to_utf8 (data, -1, NULL, NULL, NULL);
+            GTET_O_STRCAT (buf, data_utf8);
             dialog = gnome_message_box_new (buf, GNOME_MESSAGE_BOX_ERROR,
                                             GNOME_STOCK_BUTTON_OK, NULL);
             gtk_widget_show (dialog);
+            g_free (data_utf8);
         }
         break;
     case IN_PLAYERNUM:
index 7a491c4e50ed629f957c859bacbd0971fe1b384e..e1e582a5d275931b5dbb72a5c946f7b215bb6054 100644 (file)
@@ -85,4 +85,5 @@ void winlist_additem (int team, char *name, int score)
                         1, name_utf8,
                         2, item[2],
                         -1);
+    g_free (name_utf8);
 }