]> hydra-www.ietfng.org Git - gtetrinet/commitdiff
port to libgnomeui-2
authorDaniel Carbonell Fraj <bocata@src.gnome.org>
Tue, 4 Feb 2003 16:39:15 +0000 (16:39 +0000)
committerDaniel Carbonell Fraj <bocata@src.gnome.org>
Tue, 4 Feb 2003 16:39:15 +0000 (16:39 +0000)
ChangeLog
src/config.c
src/dialogs.c
src/fields.c
src/gtetrinet.c
src/misc.c
src/tetrinet.c

index ab69d2c3dd54ae74b6a7282f0381b3af98328509..9bd42de4ebcb7458efcba663857259eacf61988e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2003-02-04  Dani Carbonell  <bocata@panete.net
+
+       * src/config.c (config_loadtheme): ported to libgnomeui-2.
+
+       * src/dialogs.c: ported to libgnomeui-2.
+       (connectdialog_button): ported and a minor bugfix.
+       (teamdialog_button): bugfix, new team name was not being saved to
+       GConf.
+       
+       * src/fields.c: ported to libgnomeui-2.
+       (fields_cleanup): ported to GDK 2.x
+       (fields_drawblock): likewise.
+       
+       * src/gtetrinet.c: ported to libgnomeui-2.
+       
+       * src/tetrinet.c: ported to libgnomeui-2.
+
 2003-02-04  Jordi Mallach  <jordi@sindominio.net>
 
        * gtetrinet.desktop.in: add Encoding and Categories fields.
index 010491b2c23c004736ddc6ea955153537ecfddc7..85c3449f8facded017e255d77176a7761870ca5a 100644 (file)
@@ -84,10 +84,14 @@ void config_loadtheme (const gchar *themedir)
 
     p = gnome_config_get_string ("Theme/Name");
     if (p == 0) {
-        GtkWidget *mb;
-        mb = gnome_message_box_new (_("Warning: theme does not have a name"),
-                                    GNOME_MESSAGE_BOX_WARNING, GNOME_STOCK_BUTTON_OK, NULL);
-        gnome_dialog_run (GNOME_DIALOG(mb));
+      GtkWidget *mb;
+      mb = gtk_message_dialog_new (NULL,
+                                   0,
+                                   GTK_MESSAGE_WARNING,
+                                   GTK_BUTTONS_OK,
+                                   _("Warning: theme does not have a name"));
+      gtk_dialog_run (GTK_DIALOG (mb));
+      gtk_widget_destroy (mb);
     }
     else g_free (p);
 
index b55e979fc4a52ad565e02ca131b74e1e3a0cd99c..005fad096793252fc062f969bf3814b326852ff2 100644 (file)
@@ -34,6 +34,7 @@
 #include "fields.h"
 #include "misc.h"
 #include "sound.h"
+#include "string.h"
 
 extern GConfClient *gconf_client;
 extern GtkWidget *app;
@@ -47,11 +48,11 @@ static gint timeouttag = 0;
 
 GtkWidget *team_dialog;
 
-void connectingdialog_button (GnomeDialog *dialog, gint button)
+void connectingdialog_button (GtkWidget *dialog, gint button)
 {
     dialog = dialog;
     switch (button) {
-    case 0:
+    case GTK_RESPONSE_CANCEL:
         gtk_timeout_remove (timeouttag);
         timeouttag = 0;
         if (connectingdialog == 0) return;
@@ -80,17 +81,19 @@ void connectingdialog_new (void)
       gtk_window_present (GTK_WINDOW (connectingdialog));
       return;
     }
-    connectingdialog = gnome_dialog_new (_("Connect to server"),
-                                         GNOME_STOCK_BUTTON_CANCEL,
-                                         NULL);
+    connectingdialog = gtk_dialog_new_with_buttons (_("Connect to server"),
+                                                    NULL,
+                                                    0,
+                                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                                    NULL);
     progressbar = gtk_progress_bar_new ();
     gtk_widget_show (progressbar);
-    gtk_box_pack_start (GTK_BOX(GNOME_DIALOG(connectingdialog)->vbox),
+    gtk_box_pack_start (GTK_BOX (GTK_DIALOG(connectingdialog)->vbox),
                         progressbar, TRUE, TRUE, 0);
 
     timeouttag = gtk_timeout_add (20, (GtkFunction)connectingdialog_timeout,
                                   NULL);
-    g_signal_connect (G_OBJECT(connectingdialog), "clicked",
+    g_signal_connect (G_OBJECT(connectingdialog), "response",
                         GTK_SIGNAL_FUNC(connectingdialog_button), NULL);
     g_signal_connect (G_OBJECT(connectingdialog), "delete_event",
                         GTK_SIGNAL_FUNC(connectingdialog_delete), NULL);
@@ -127,6 +130,8 @@ void teamdialog_button (GtkWidget *button, gint response, gpointer data)
       case GTK_RESPONSE_OK :
       {
         aux = g_locale_from_utf8 (gtk_entry_get_text (entry), -1, NULL, NULL, NULL);
+        gconf_client_set_string (gconf_client, "/apps/gtetrinet/player/team",
+                                 gtk_entry_get_text (entry), NULL);
         tetrinet_changeteam (aux);
         g_free (aux);
       }; break;
@@ -186,47 +191,75 @@ static GtkWidget *originalradio, *tetrifastradio;
 static GSList *gametypegroup;
 static int oldgamemode;
 
-void connectdialog_button (GnomeDialog *dialog, gint button)
+void connectdialog_button (GtkDialog *dialog, gint button)
 {
-    gchar *team_utf8, *nick; /* intermediate buffer for recoding purposes */
+    gchar *team_utf8, *nick, *nick1; /* intermediate buffer for recoding purposes */
     const gchar *server1;
+    GtkWidget *dialog_error;
 
     switch (button) {
     case GTK_RESPONSE_OK:
         /* connect now */
         server1 = gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (serveraddressentry))));
-        if (strlen (server1) <= 0)
+        if (g_utf8_strlen (server1, -1) <= 0)
         {
-          gnome_error_dialog_parented (_("You must specify a server name."), GTK_WINDOW (dialog));
+          dialog_error = gtk_message_dialog_new (GTK_WINDOW (dialog),
+                                                 GTK_DIALOG_MODAL,
+                                                 GTK_MESSAGE_ERROR,
+                                                 GTK_BUTTONS_OK,
+                                                 _("You must specify a server name."));
+          gtk_dialog_run (GTK_DIALOG (dialog_error));
+          gtk_widget_destroy (dialog_error);
           return;
         }
     
         spectating = GTK_TOGGLE_BUTTON(spectatorcheck)->active ? TRUE : FALSE;
         if (spectating)
         {
-          GTET_O_STRCPY (specpassword, gtk_entry_get_text (GTK_ENTRY(passwordentry)));
-          if (strlen (specpassword) <= 0)
+          g_utf8_strncpy (specpassword, gtk_entry_get_text (GTK_ENTRY(passwordentry)),
+                          g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (passwordentry)), -1));
+          if (g_utf8_strlen (specpassword, -1) <= 0)
           {
-            gnome_error_dialog_parented (_("Please specify a password to connect as spectator."), GTK_WINDOW (dialog));
+            dialog_error = gtk_message_dialog_new (GTK_WINDOW (dialog),
+                                                   GTK_DIALOG_MODAL,
+                                                   GTK_MESSAGE_ERROR,
+                                                   GTK_BUTTONS_OK,
+                                                   _("Please specify a password to connect as spectator."));
+            gtk_dialog_run (GTK_DIALOG (dialog_error));
+            gtk_widget_destroy (dialog_error);
             return;
           }
         }
         
         team_utf8 = g_locale_from_utf8 (gtk_entry_get_text (GTK_ENTRY(gnome_entry_gtk_entry(GNOME_ENTRY(teamnameentry)))),
                                         -1, NULL, NULL, NULL);
+        
         GTET_O_STRCPY (team, team_utf8);
         
-        nick =  g_locale_from_utf8 (gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (nicknameentry)))),
-                                     -1, NULL, NULL, NULL);
+        nick = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (nicknameentry)))));
         g_strstrip (nick); /* we remove leading and trailing whitespaces */
-        if (strlen (nick) > 0)
-            client_init (server1, nick);
+        if (g_utf8_strlen (nick, -1) > 0)
+        {
+          nick1 = g_locale_from_utf8 (nick, -1, NULL, NULL, NULL);
+          client_init (server1, nick1);
+          g_free (nick1);
+        }
         else
-            gnome_error_dialog_parented (_("Please specify a valid nickname."), GTK_WINDOW (dialog));
+        {
+            dialog_error = gtk_message_dialog_new (GTK_WINDOW (dialog),
+                                                   GTK_DIALOG_MODAL,
+                                                   GTK_MESSAGE_ERROR,
+                                                   GTK_BUTTONS_OK,
+                                                   _("Please specify a valid nickname."));
+            gtk_dialog_run (GTK_DIALOG (dialog_error));
+            gtk_widget_destroy (dialog_error);
+            return;
+        }
         
         gconf_client_set_string (gconf_client, "/apps/gtetrinet/player/server", server1, NULL);
         gconf_client_set_string (gconf_client, "/apps/gtetrinet/player/nickname", nick, NULL);
-        gconf_client_set_string (gconf_client, "/apps/gtetrinet/player/team", team_utf8, NULL);
+        gconf_client_set_string (gconf_client, "/apps/gtetrinet/player/team",
+                                 gtk_entry_get_text (GTK_ENTRY(gnome_entry_gtk_entry(GNOME_ENTRY(teamnameentry)))), NULL);
         g_free (team_utf8);
         g_free (nick);
         break;
@@ -673,15 +706,15 @@ void prefdialog_themelist ()
 {
     DIR *d;
     struct dirent *de;
-    char buf[1024], str[1024], dir[1024];
+    char str[1024], buf[1024];
+    gchar *dir;
     int i;
     char *basedir[2];
     GtkListStore *theme_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (themelist)));
     GtkTreeSelection *theme_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (themelist));
     GtkTreeIter iter, iter_selected;
 
-    GTET_O_STRCPY (dir, getenv ("HOME"));
-    GTET_O_STRCAT (dir, "/.gtetrinet/themes");
+    dir = g_build_filename (getenv ("HOME"), ".gtetrinet", "themes", NULL);
 
     basedir[0] = dir; /* load users themes first ... in case we run out */
     basedir[1] = GTETRINET_THEMES;
@@ -712,6 +745,7 @@ void prefdialog_themelist ()
             closedir (d);
         }
     }
+    g_free (dir);
  too_many_themes:
     qsort (themes, themecount, sizeof(struct themelistentry), themelistcomp);
 
@@ -723,7 +757,7 @@ void prefdialog_themelist ()
         text[1] = 0;
         gtk_list_store_append (theme_store, &iter);
         gtk_list_store_set (theme_store, &iter, 0, themes[i].name, 1, i, -1);
-        if (strcmp(themes[i].dir, currenttheme) == 0)
+        if (strcmp (themes[i].dir, currenttheme) == 0)
         {
             iter_selected = iter;
             theme_select = i;
index 061d845e23443a500d867a7f693c86e9c35d731b..5c32da94a15cf11e64f18c8b2a6505510e72b042 100644 (file)
@@ -32,6 +32,7 @@
 #include "fields.h"
 #include "misc.h"
 #include "gtetrinet.h"
+#include "string.h"
 
 #define BLOCKSIZE bsize
 #define SMALLBLOCKSIZE (BLOCKSIZE/2)
@@ -65,10 +66,14 @@ void fields_init (void)
     GdkBitmap *mask = NULL;
     
     if (!(pb = gdk_pixbuf_new_from_file(blocksfile, &err))) {
-        mb = gnome_message_box_new (_("Error loading theme: cannot load graphics file\n"
-                                      "Falling back to default"),
-                                    GNOME_MESSAGE_BOX_ERROR, GNOME_STOCK_BUTTON_OK, NULL);
-        gnome_dialog_run (GNOME_DIALOG(mb));
+        mb = gtk_message_dialog_new (NULL,
+                                     GTK_DIALOG_MODAL,
+                                     GTK_MESSAGE_ERROR,
+                                     GTK_BUTTONS_OK,
+                                     _("Error loading theme: cannot load graphics file\n"
+                                      "Falling back to default"));
+        gtk_dialog_run (GTK_DIALOG (mb));
+        gtk_widget_destroy (mb);
         config_loadtheme (DEFAULTTHEME);
         err = NULL;
         if (!(pb = gdk_pixbuf_new_from_file(blocksfile, &err))) {
@@ -85,7 +90,7 @@ void fields_init (void)
 
 void fields_cleanup (void)
 {
-  gdk_pixmap_unref(blockpix);
+  g_object_unref(blockpix);
 }
 
 /* a mess of functions here for creating the fields page */
@@ -376,10 +381,10 @@ void fields_drawblock (int field, int x, int y, char block)
     destx = blocksize * x;
     desty = blocksize * y;
 
-    gdk_draw_pixmap (fieldwidgets[field]->window,
-                     fieldwidgets[field]->style->black_gc,
-                     blockpix, srcx, srcy, destx, desty,
-                     blocksize, blocksize);
+    gdk_draw_drawable (fieldwidgets[field]->window,
+                       fieldwidgets[field]->style->black_gc,
+                       blockpix, srcx, srcy, destx, desty,
+                       blocksize, blocksize);
 }
 
 void fields_setlabel (int field, char *name, char *team, int num)
index a2360f030611b75e23d9eb1117b8e431f2043e3f..211a08f52c7474896295ef4475656b6e9cd0f024 100644 (file)
@@ -42,6 +42,7 @@
 #include "misc.h"
 #include "commands.h"
 #include "sound.h"
+#include "string.h"
 
 #include "images/fields.xpm"
 #include "images/partyline.xpm"
@@ -162,7 +163,10 @@ int main (int argc, char *argv[])
 
     srand (time(NULL));
 
-    gnome_init_with_popt_table (APPID, APPVERSION, argc, argv, options, 0 , NULL);
+    //gnome_init_with_popt_table (APPID, APPVERSION, argc, argv, options, 0 , NULL);
+    gnome_program_init (APPID, APPVERSION, LIBGNOMEUI_MODULE,
+                             argc, argv, GNOME_PARAM_POPT_TABLE, options,
+                                               GNOME_PARAM_NONE);
 
     textbox_setup (); /* needs to be done before text boxes are created */
     
index d5b9272ff6ec515b23bfb8c77ff0f2daf93b202a..a377b66d87980be10e7b45e36673e67241d21d4d 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "misc.h"
 #include "gtetrinet.h"
+#include "string.h"
 
 
 /* a left aligned label */
index e59cb364d63f9669b2c01e2a7e4f6dcba956cea1..f4bbd57f40895e6fa9a8bb2188a214b012f7f1a7 100644 (file)
@@ -42,6 +42,7 @@
 #include "commands.h"
 #include "dialogs.h"
 #include "sound.h"
+#include "string.h"
 
 #define NEXTBLOCKDELAY (gamemode==TETRIFAST?0:1000)
 #define DOWNDELAY 100
@@ -209,9 +210,12 @@ void tetrinet_inmessage (enum inmsg_type msgtype, char *data)
             GTET_O_STRCPY (buf, _("Error connecting: "));
             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);
+            dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+                                             GTK_MESSAGE_ERROR,
+                                             GTK_BUTTONS_OK,
+                                             buf);
+            gtk_dialog_run (GTK_DIALOG(dialog));
+            gtk_widget_destroy (dialog);
             g_free (data_utf8);
         }
         break;