Re: Mahjongg Patch
- From: Josh Barrow <drleary mac com>
- To: Havoc Pennington <hp redhat com>
- Cc: desktop-devel-list gnome org
- Subject: Re: Mahjongg Patch
- Date: 18 Dec 2001 15:17:34 -0600
This patch has issues. They are talked about in a comment on line 718
of the patch.
Perhaps more eyes looking at this will help. I'm stumped. I've been
working on that one thing all day.
Josh
Carbamide
? mahjongg_patch3
? .mahjongg.c.swp
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-games/mahjongg/ChangeLog,v
retrieving revision 1.59
diff -u -r1.59 ChangeLog
--- ChangeLog 2001/12/17 02:48:45 1.59
+++ ChangeLog 2001/12/18 21:17:50
@@ -1,3 +1,17 @@
+2001-12-17 Josh Barrow <drleary mac com>
+
+ * mahjongg.c: (update_moves_left), (tile_event), (fill_tile_menu),
+ (fill_map_menu), (no_match), (check_free), (properties_callback),
+ (prefs_clicked_callback), (about_callback), (pause_callback),
+ (ensure_pause_off), (init_game), (confirm_callback),
+ (exit_game_callback_query), (new_game_reply_callback),
+ (redo_tile_callback), (undo_tile_callback),
+ (seed_dialog_clicked_cb), (select_game), (create_canvas_items),
+ (load_tiles), (create_mahjongg_board), (shuffle_tiles_callback),
+ (main):
+ Made to work with G_DISABLE_DEPRECATED, GTK_DISABLE_DEPRECATE,
+ and GNOME_DISABLE_DEPRECATED.
+
2001-12-16 Juan Pablo Mendoza <jpablo gnome org>
* mahjongg.c: Hide/Show toolbar works again.
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-games/mahjongg/Makefile.am,v
retrieving revision 1.18
diff -u -r1.18 Makefile.am
--- Makefile.am 2001/11/22 23:26:33 1.18
+++ Makefile.am 2001/12/18 21:17:50
@@ -6,6 +6,7 @@
INCLUDES = -I.. -I$(srcdir)/.. \
$(GNOME_GAMES_CFLAGS) \
+ -DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGNOME_DISABLE_DEPRECATED \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir)
Index: mahjongg.c
===================================================================
RCS file: /cvs/gnome/gnome-games/mahjongg/mahjongg.c,v
retrieving revision 1.78
diff -u -r1.78 mahjongg.c
--- mahjongg.c 2001/12/17 02:48:45 1.78
+++ mahjongg.c 2001/12/18 21:17:55
@@ -248,6 +248,7 @@
tile tiles[MAX_TILES];
GtkWidget *window, *pref_dialog, *appbar;
+gint response;
#ifdef NEED_UNUSED_CODE
GtkWidget *hint_dialog;
#endif
@@ -348,7 +349,7 @@
{GNOME_APP_UI_ITEM, N_("New game with _seed..."), N_("Start a new game giving a seed number..."),
exit_game_callback, (gpointer)SELECT_GAME, NULL, GNOME_APP_PIXMAP_STOCK,
- GNOME_STOCK_MENU_NEW, 0, 0, NULL},
+ GTK_STOCK_NEW, 0, 0, NULL},
GNOMEUIINFO_MENU_RESTART_GAME_ITEM(exit_game_callback, RESTART_GAME),
@@ -360,8 +361,8 @@
GNOMEUIINFO_MENU_HINT_ITEM(hint_callback, NULL),
{GNOME_APP_UI_ITEM, N_("Shu_ffle tiles"), N_("Shuffle tiles"),
- shuffle_tiles_callback, NULL, NULL, GNOME_APP_PIXMAP_STOCK,
- GNOME_STOCK_MENU_BLANK, 0, 0, NULL},
+ shuffle_tiles_callback, NULL, NULL, GNOME_APP_PIXMAP_NONE,
+ NULL, 0, 0, NULL},
GNOMEUIINFO_SEPARATOR,
@@ -405,38 +406,37 @@
GnomeUIInfo toolbar_uiinfo [] = {
{GNOME_APP_UI_ITEM, N_("New"), NULL, exit_game_callback, (gpointer)NEW_GAME, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_NEW, 0, 0, NULL},
+ GNOME_APP_PIXMAP_STOCK, GTK_STOCK_NEW, 0, 0, NULL},
-/* {GNOME_APP_UI_ITEM, N_("Seed"), NULL, exit_game_callback, (gpointer)SELECT_GAME, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_NEW, 0, 0, NULL},*/
-
{GNOME_APP_UI_ITEM, N_("Restart"), NULL, exit_game_callback, (gpointer)RESTART_GAME, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_REFRESH, 0, 0, NULL},
+ GNOME_APP_PIXMAP_STOCK, GTK_STOCK_REFRESH, 0, 0, NULL},
{GNOME_APP_UI_ITEM, N_("Hint"), NULL, hint_callback, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_HELP, GDK_H, GDK_CONTROL_MASK, NULL},
+ GNOME_APP_PIXMAP_STOCK, GTK_STOCK_HELP, GDK_H, GDK_CONTROL_MASK, NULL},
{GNOME_APP_UI_ITEM, N_("Undo"), NULL, undo_tile_callback, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_UNDO, 0, 0, NULL},
+ GNOME_APP_PIXMAP_STOCK, GTK_STOCK_UNDO, 0, 0, NULL},
{GNOME_APP_UI_ITEM, N_("Redo"), NULL, redo_tile_callback, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_REDO, 0, 0, NULL},
+ GNOME_APP_PIXMAP_STOCK, GTK_STOCK_REDO, 0, 0, NULL},
/* If you change the place for this button, change the index in
the definition of PAUSE_BUTTON below */
{GNOME_APP_UI_TOGGLEITEM, N_("Pause"), NULL, pause_callback, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_TIMER, 0, 0, NULL},
+ GNOME_APP_PIXMAP_STOCK, GTK_STOCK_STOP, 0, 0, NULL},
#ifdef SOUND_SUPPORT_FINISHED
{GNOME_APP_UI_TOGGLEITEM, N_("Sound"), NULL, sound_on_callback, NULL, NULL,
GNOME_APP_PIXMAP_DATA, mini_sound_xpm, 0, 0, NULL},
#endif
-
+ /* There isn't a GTK_STOCK_MULTIPLE, what should I replace it with? */
+ /*
{GNOME_APP_UI_ITEM, N_("Shuffle"), NULL, shuffle_tiles_callback, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_MULTIPLE, 0, 0, NULL},
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_MULTIPLE, 0, 0, NULL},
+ */
{GNOME_APP_UI_ITEM, N_("Prefs"), NULL, properties_callback, NULL, NULL,
- GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_PREFERENCES, 0, 0, NULL},
+ GNOME_APP_PIXMAP_STOCK, GTK_STOCK_PREFERENCES, 0, 0, NULL},
{GNOME_APP_UI_SEPARATOR},
@@ -543,7 +543,7 @@
check_free();
sprintf(tmpchar, "%2d", moves_left);
- gtk_label_set (GTK_LABEL(moves_label), tmpchar);
+ gtk_label_set_text (GTK_LABEL(moves_label), tmpchar);
return moves_left;
}
@@ -651,10 +651,10 @@
selected_tile = MAX_TILES + 1;
visible_tiles -= 2;
sprintf(tmpchar, "%3d", visible_tiles);
- gtk_label_set (GTK_LABEL(tiles_label), tmpchar);
+ gtk_label_set_text (GTK_LABEL(tiles_label), tmpchar);
check_free();
sprintf(tmpchar, "%2d", moves_left);
- gtk_label_set (GTK_LABEL(moves_label), tmpchar);
+ gtk_label_set_text (GTK_LABEL(moves_label), tmpchar);
if (visible_tiles <= 0) {
#if 0
@@ -795,7 +795,7 @@
struct dirent *e;
DIR *dir;
int itemno = 0;
- char *dname = gnome_unconditional_pixmap_file (sdir);
+ char *dname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, (sdir), FALSE, NULL);
dir = opendir (dname);
@@ -817,18 +817,18 @@
item = gtk_menu_item_new_with_label (s);
gtk_widget_show (item);
- gtk_menu_append (GTK_MENU(menu), item);
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
if (is_tile) {
- gtk_signal_connect (GTK_OBJECT(item), "activate",
- (GtkSignalFunc)set_tile_selection, s);
- gtk_signal_connect (GTK_OBJECT(item), "destroy",
- (GtkSignalFunc) free_str, s);
+ g_signal_connect (G_OBJECT(item), "activate",
+ G_CALLBACK(set_tile_selection), s);
+ g_signal_connect (G_OBJECT(item), "destroy",
+ G_CALLBACK(free_str), s);
}
else {
- gtk_signal_connect (GTK_OBJECT(item), "activate",
- (GtkSignalFunc)set_bg_selection, s);
- gtk_signal_connect (GTK_OBJECT(item), "destroy",
- (GtkSignalFunc) free_str, s);
+ g_signal_connect (G_OBJECT(item), "activate",
+ G_CALLBACK(set_bg_selection), s);
+ g_signal_connect (G_OBJECT(item), "destroy",
+ G_CALLBACK(free_str), s);
}
if (!strcmp(tileset, s))
@@ -854,11 +854,11 @@
item = gtk_menu_item_new_with_label (str) ;
gtk_widget_show (item);
- gtk_menu_append (GTK_MENU(menu), item);
- gtk_signal_connect (GTK_OBJECT(item), "activate",
- (GtkSignalFunc)set_map_selection, &maps[lp]);
- gtk_signal_connect (GTK_OBJECT(item), "destroy",
- (GtkSignalFunc) free_str, str);
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
+ g_signal_connect (G_OBJECT(item), "activate",
+ G_CALLBACK(set_map_selection), &maps[lp]);
+ g_signal_connect (G_OBJECT(item), "destroy",
+ G_CALLBACK(free_str), str);
if (!g_strcasecmp(mapset, maps[lp].name))
gtk_menu_set_active(GTK_MENU(menu), itemno);
itemno++ ;
@@ -904,14 +904,13 @@
{
GtkWidget *mb;
if (popup_config.warn.popup) {
- mb = gnome_message_box_new (_("Tiles don't match!"),
- GNOME_MESSAGE_BOX_INFO,
- GNOME_STOCK_BUTTON_OK, NULL);
- GTK_WINDOW (mb)->position = GTK_WIN_POS_MOUSE;
- gtk_window_set_modal (&GNOME_MESSAGE_BOX(mb)->dialog.window, TRUE);
-
- gnome_dialog_set_parent (&GNOME_MESSAGE_BOX(mb)->dialog, GTK_WINDOW (window));
- gtk_widget_show (mb);
+ mb = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ "Tiles don't match!");
+ gtk_dialog_run (GTK_DIALOG(mb));
+ gtk_widget_destroy (mb);
}
else gnome_app_flash (GNOME_APP (window), "Tiles don't match !");
}
@@ -937,13 +936,15 @@
if ((moves_left == 0) && (visible_tiles>0)) {
GtkWidget *mb;
if (!game_over) {
- mb = gnome_message_box_new (_("No more moves"),
- GNOME_MESSAGE_BOX_INFO,
- GNOME_STOCK_BUTTON_OK, NULL);
- GTK_WINDOW (mb)->position = GTK_WIN_POS_MOUSE;
- gtk_window_set_modal (&GNOME_MESSAGE_BOX (mb)->dialog.window, TRUE);
- gnome_dialog_set_parent(&GNOME_MESSAGE_BOX (mb)->dialog, GTK_WINDOW (window));
+ mb = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ _("Sorry, there are no more moves left."));
gtk_widget_show (mb);
+
+ g_signal_connect (G_OBJECT (mb), "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
}
game_over = GAME_LOST;
}
@@ -991,7 +992,6 @@
void properties_callback (GtkWidget *widget, gpointer data)
{
GtkDialog *d;
- GtkWidget *button;
GtkWidget *tmenu, *mmenu, *otmenu, *ommenu, *l, *hb, *cb, *f, *fv;
GtkWidget *bcolour_gcs ;
@@ -1000,8 +1000,8 @@
pref_dialog = gtk_dialog_new ();
d = GTK_DIALOG(pref_dialog);
- gtk_signal_connect (GTK_OBJECT(pref_dialog), "close",
- (GtkSignalFunc)pref_cancel, NULL);
+ g_signal_connect (G_OBJECT(pref_dialog), "destroy",
+ G_CALLBACK(pref_cancel), NULL);
/* The Tile sub-menu */
otmenu = gtk_option_menu_new ();
@@ -1011,7 +1011,7 @@
gtk_option_menu_set_menu (GTK_OPTION_MENU(otmenu), tmenu);
f = gtk_frame_new (_ ("Tiles"));
- gtk_container_border_width (GTK_CONTAINER (f), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (f), 5);
hb = gtk_hbox_new (FALSE, FALSE);
gtk_widget_show (hb);
@@ -1023,12 +1023,12 @@
gtk_box_pack_start_defaults (GTK_BOX(hb), otmenu);
cb = gtk_check_button_new_with_label ( _("Make it the default") );
- gtk_signal_connect (GTK_OBJECT(cb), "clicked",
- (GtkSignalFunc)set_tile_selection_def, NULL);
+ g_signal_connect (G_OBJECT(cb), "clicked",
+ G_CALLBACK(set_tile_selection_def), NULL);
gtk_widget_show (cb);
fv = gtk_vbox_new (0, 5);
- gtk_container_border_width (GTK_CONTAINER (fv), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (fv), 5);
gtk_widget_show (fv);
gtk_box_pack_start_defaults (GTK_BOX(fv), hb);
@@ -1045,7 +1045,7 @@
gtk_option_menu_set_menu (GTK_OPTION_MENU(otmenu), tmenu);
f = gtk_frame_new (_ ("Tile Background:"));
- gtk_container_border_width (GTK_CONTAINER (f), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (f), 5);
hb = gtk_hbox_new (FALSE, FALSE);
gtk_widget_show (hb);
@@ -1057,12 +1057,12 @@
gtk_box_pack_start_defaults (GTK_BOX(hb), otmenu);
cb = gtk_check_button_new_with_label ( _("Make it the default") );
- gtk_signal_connect (GTK_OBJECT(cb), "clicked", */
- (GtkSignalFunc)set_bg_selection_def, NULL);
+ g_signal_connect (G_OBJECT(cb), "clicked", */
+ G_CALLBACK(set_bg_selection_def), NULL);
gtk_widget_show (cb);
fv = gtk_vbox_new (0, 5);
- gtk_container_border_width (GTK_CONTAINER (fv), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (fv), 5);
gtk_widget_show (fv);
gtk_box_pack_start_defaults (GTK_BOX(fv), hb);
@@ -1079,7 +1079,7 @@
gtk_option_menu_set_menu (GTK_OPTION_MENU(ommenu), mmenu);
f = gtk_frame_new (_ ("Maps"));
- gtk_container_border_width (GTK_CONTAINER (f), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (f), 5);
hb = gtk_hbox_new (FALSE, FALSE);
l = gtk_label_new (_("Select Map:"));
@@ -1088,11 +1088,11 @@
gtk_box_pack_start_defaults (GTK_BOX(hb), ommenu);
cb = gtk_check_button_new_with_label ( _("Make it the default") );
- gtk_signal_connect (GTK_OBJECT(cb), "clicked",
- (GtkSignalFunc)set_map_selection_def, NULL);
+ g_signal_connect (G_OBJECT(cb), "clicked",
+ G_CALLBACK(set_map_selection_def), NULL);
fv = gtk_vbox_new (0, 5);
- gtk_container_border_width (GTK_CONTAINER (fv), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (fv), 5);
gtk_box_pack_start_defaults (GTK_BOX(fv), hb);
gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
@@ -1101,7 +1101,7 @@
/* The colour */
f = gtk_frame_new (_ ("Colours"));
- gtk_container_border_width (GTK_CONTAINER (f), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (f), 5);
hb = gtk_hbox_new (FALSE, FALSE);
l = gtk_label_new (_("Background:")); */
@@ -1112,52 +1112,29 @@
sscanf( backgnd.name, "#%02x%02x%02x", &ur,&ug,&ub );
gnome_color_picker_set_i8( GNOME_COLOR_PICKER(bcolour_gcs), ur,
ug, ub, 0);
- gtk_signal_connect(GTK_OBJECT(bcolour_gcs), "color_set",
+ g_signal_connect(G_OBJECT(bcolour_gcs), "color_set",
GTK_SIGNAL_FUNC(colour_changed_cb), &backgnd.name);
}
gtk_box_pack_start_defaults (GTK_BOX(hb), bcolour_gcs);
cb = gtk_check_button_new_with_label ( _("Make it the default") );
- gtk_signal_connect (GTK_OBJECT(cb), "clicked",
- (GtkSignalFunc)set_backgnd_selection_def, NULL);
+ g_signal_connect (G_OBJECT(cb), "clicked",
+ G_CALLBACK(set_backgnd_selection_def), NULL);
fv = gtk_vbox_new (0, 5);
- gtk_container_border_width (GTK_CONTAINER (fv), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (fv), 5);
gtk_box_pack_start_defaults (GTK_BOX(fv), hb);
gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
gtk_box_pack_start_defaults (GTK_BOX(d->vbox), f) ;
gtk_container_add (GTK_CONTAINER (f), fv);
-
- /* Misc bottom buttons */
- button = gnome_stock_button(GNOME_STOCK_BUTTON_OK);
- gtk_signal_connect(GTK_OBJECT(button), "clicked",
- GTK_SIGNAL_FUNC(load_callback), NULL);
- gtk_box_pack_start(GTK_BOX(d->action_area), button, TRUE, TRUE, 5);
- button = gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL);
- gtk_signal_connect(GTK_OBJECT(button), "clicked",
- (GtkSignalFunc)pref_cancel,
- NULL);
- gtk_box_pack_start(GTK_BOX(d->action_area), button, TRUE, TRUE, 5);
- gtk_widget_show_all (pref_dialog);
}
#else
-static void prefs_clicked_callback(GnomeDialog * dialog, gint button_number,
- gpointer data)
-{
- switch (button_number) {
- case 0: /* OK button */
- apply_preferences();
- break;
- };
- gnome_dialog_close(dialog);
- pref_dialog = 0;
-}
-
+
void properties_callback (GtkWidget *widget, gpointer data)
{
- GnomeDialog *d;
+ GtkDialog *d;
GtkWidget *button;
GtkWidget *tmenu, *mmenu, *otmenu, *ommenu, *l, *hb, *cb, *f, *fv, *cols, *col1, *col2;
GtkWidget *bcolour_gcs ;
@@ -1165,15 +1142,19 @@
if (pref_dialog)
return;
- pref_dialog = gnome_dialog_new (_ ("Preferences"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL );
+ pref_dialog = gtk_dialog_new_with_buttons ("Preferences",
+ GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK,
+ GTK_RESPONSE_OK,
+ NULL);
- d = GNOME_DIALOG(pref_dialog);
- gtk_signal_connect(GTK_OBJECT(pref_dialog), "clicked",
- GTK_SIGNAL_FUNC(prefs_clicked_callback),
- NULL);
+ d = GTK_DIALOG(pref_dialog);
- gtk_signal_connect (GTK_OBJECT(pref_dialog), "close",
- (GtkSignalFunc)pref_cancel, NULL);
+ g_signal_connect (G_OBJECT(pref_dialog), "destroy",
+ G_CALLBACK(pref_cancel), NULL);
cols = gtk_hbox_new (FALSE, FALSE);
col1 = gtk_vbox_new (FALSE, FALSE);
@@ -1186,7 +1167,7 @@
gtk_option_menu_set_menu (GTK_OPTION_MENU(otmenu), tmenu);
f = gtk_frame_new (_ ("Tiles"));
- gtk_container_border_width (GTK_CONTAINER (f), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (f), 5);
hb = gtk_hbox_new (FALSE, FALSE);
@@ -1196,11 +1177,11 @@
gtk_box_pack_start_defaults (GTK_BOX(hb), otmenu);
cb = gtk_check_button_new_with_label ( _("Make it the default") );
- gtk_signal_connect (GTK_OBJECT(cb), "clicked",
- (GtkSignalFunc)set_tile_selection_def, NULL);
+ g_signal_connect (G_OBJECT(cb), "clicked",
+ G_CALLBACK(set_tile_selection_def), NULL);
fv = gtk_vbox_new (0, 5);
- gtk_container_border_width (GTK_CONTAINER (fv), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (fv), 5);
gtk_box_pack_start_defaults (GTK_BOX(fv), hb);
gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
@@ -1214,7 +1195,7 @@
gtk_option_menu_set_menu (GTK_OPTION_MENU(otmenu), tmenu);
f = gtk_frame_new (_ ("Tile Background"));
- gtk_container_border_width (GTK_CONTAINER (f), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (f), 5);
hb = gtk_hbox_new (FALSE, FALSE);
@@ -1224,11 +1205,11 @@
gtk_box_pack_start_defaults (GTK_BOX(hb), otmenu);
cb = gtk_check_button_new_with_label ( _("Make it the default") );
- gtk_signal_connect (GTK_OBJECT(cb), "clicked",
- (GtkSignalFunc)set_bg_selection_def, NULL);
+ g_signal_connect (G_OBJECT(cb), "clicked",
+ G_CALLBACK(set_bg_selection_def), NULL);
fv = gtk_vbox_new (0, 5);
- gtk_container_border_width (GTK_CONTAINER (fv), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (fv), 5);
gtk_box_pack_start_defaults (GTK_BOX(fv), hb);
gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
@@ -1242,7 +1223,7 @@
gtk_option_menu_set_menu (GTK_OPTION_MENU(ommenu), mmenu);
f = gtk_frame_new (_ ("Maps"));
- gtk_container_border_width (GTK_CONTAINER (f), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (f), 5);
hb = gtk_hbox_new (FALSE, FALSE);
l = gtk_label_new (_("Select Map:"));
@@ -1251,11 +1232,11 @@
gtk_box_pack_start_defaults (GTK_BOX(hb), ommenu);
cb = gtk_check_button_new_with_label ( _("Make it the default") );
- gtk_signal_connect (GTK_OBJECT(cb), "clicked",
- (GtkSignalFunc)set_map_selection_def, NULL);
+ g_signal_connect (G_OBJECT(cb), "clicked",
+ G_CALLBACK(set_map_selection_def), NULL);
fv = gtk_vbox_new (0, 5);
- gtk_container_border_width (GTK_CONTAINER (fv), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (fv), 5);
gtk_box_pack_start_defaults (GTK_BOX(fv), hb);
gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
@@ -1264,7 +1245,7 @@
/* The colour */
f = gtk_frame_new (_ ("Colours"));
- gtk_container_border_width (GTK_CONTAINER (f), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (f), 5);
hb = gtk_hbox_new (FALSE, FALSE);
l = gtk_label_new (_("Background:"));
@@ -1275,17 +1256,17 @@
sscanf( backgnd.name, "#%02x%02x%02x", &ur,&ug,&ub );
gnome_color_picker_set_i8( GNOME_COLOR_PICKER(bcolour_gcs), ur,
ug, ub, 0);
- gtk_signal_connect(GTK_OBJECT(bcolour_gcs), "color_set",
+ g_signal_connect(G_OBJECT(bcolour_gcs), "color_set",
GTK_SIGNAL_FUNC(colour_changed_cb), &backgnd.name);
}
gtk_box_pack_start_defaults (GTK_BOX(hb), bcolour_gcs);
cb = gtk_check_button_new_with_label ( _("Make it the default") );
- gtk_signal_connect (GTK_OBJECT(cb), "clicked",
- (GtkSignalFunc)set_backgnd_selection_def, NULL);
+ g_signal_connect (G_OBJECT(cb), "clicked",
+ G_CALLBACK(set_backgnd_selection_def), NULL);
fv = gtk_vbox_new (0, 5);
- gtk_container_border_width (GTK_CONTAINER (fv), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (fv), 5);
gtk_box_pack_start_defaults (GTK_BOX(fv), hb);
gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
@@ -1294,21 +1275,21 @@
/* Warning submenu */
f = gtk_frame_new (_ ("Warnings"));
- gtk_container_border_width (GTK_CONTAINER (f), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (f), 5);
fv = gtk_vbox_new (0,5);
- gtk_container_border_width (GTK_CONTAINER (fv), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (fv), 5);
cb = gtk_check_button_new_with_label (_("Warn when tiles don't match"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(cb), popup_config.warn.popup);
- gtk_signal_connect (GTK_OBJECT(cb), "clicked",
- (GtkSignalFunc)set_popup_def, &(popup_config.warn));
+ g_signal_connect (G_OBJECT(cb), "clicked",
+ G_CALLBACK(set_popup_def), &(popup_config.warn));
gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
cb = gtk_check_button_new_with_label (_("Confirm before quitting game"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(cb), popup_config.confirm.popup);
- gtk_signal_connect (GTK_OBJECT(cb), "clicked",
- (GtkSignalFunc)set_popup_def, &(popup_config.confirm));
+ g_signal_connect (G_OBJECT(cb), "clicked",
+ G_CALLBACK(set_popup_def), &(popup_config.confirm));
gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
gtk_box_pack_start_defaults (GTK_BOX(col2), f) ;
@@ -1318,8 +1299,15 @@
gtk_box_pack_start_defaults (GTK_BOX(cols), col2);
gtk_box_pack_start_defaults (GTK_BOX(d->vbox), cols);
- gnome_dialog_set_parent(d, GTK_WINDOW(window));
gtk_widget_show_all (pref_dialog);
+
+ response = gtk_dialog_run (GTK_DIALOG (pref_dialog));
+
+ if (response == GTK_RESPONSE_OK)
+ {
+ apply_preferences();
+ }
+ pref_cancel(NULL, NULL);
}
#endif
@@ -1433,21 +1421,15 @@
(const char *)translator_credits,
NULL);
- gnome_dialog_set_parent(GNOME_DIALOG(about),GTK_WINDOW(window));
gtk_widget_show (about);
}
-void quit_game ()
-{
- gnome_config_sync();
- gtk_main_quit ();
-}
void pause_callback()
{
int i;
if(game_over) {
- gtk_toggle_button_set_state (PAUSE_BUTTON, FALSE);
+ gtk_toggle_button_set_active (PAUSE_BUTTON, FALSE);
return;
}
paused = !paused;
@@ -1476,7 +1458,7 @@
int i;
if (paused) {
- gtk_toggle_button_set_state (PAUSE_BUTTON, FALSE);
+ gtk_toggle_button_set_active (PAUSE_BUTTON, FALSE);
for (i = 0; i < MAX_TILES; i++)
if (tiles[i].visible)
gnome_canvas_item_show (tiles[i].image_item);
@@ -1494,7 +1476,7 @@
{
gchar tmpchar[16] ;
- gtk_label_set(GTK_LABEL(tiles_label), MAX_TILES_STR);
+ gtk_label_set_text(GTK_LABEL(tiles_label), MAX_TILES_STR);
update_moves_left ();
game_over = GAME_RUNNING;
sequence_number = 1 ;
@@ -1505,9 +1487,10 @@
chrono_start();
}
-void confirm_callback (gint reply, gpointer data)
+void confirm_callback (gint response, gpointer data)
{
- if (reply == GNOME_OK)
+ if (response == GTK_RESPONSE_YES)
+ {
switch ((int)data)
{
case NEW_GAME:
@@ -1521,41 +1504,81 @@
select_game ();
break;
case QUIT_GAME:
- quit_game ();
+ /* This was the only place that used quit_game,
+ so I thought it would be cleaner just to put
+ the code that *was* in it here. */
+ gnome_config_sync();
+ gtk_main_quit ();
break;
default:
break;
}
+ }
}
void exit_game_callback_query (GtkWidget *widget, gboolean *quit, gpointer data)
{
const char *confirm_text;
+ GtkWidget *dialog;
+ GtkWidget *hbox;
+ GtkWidget *stock;
+ GtkWidget *table;
+ GtkWidget *label;
+ gint response;
if ( popup_config.confirm.popup
&& game_over != GAME_WON
- && game_over != GAME_DEAD
- && sequence_number > 1 ) {
+ && game_over != GAME_DEAD ) {
switch ((game_state)data)
{
case RESTART_GAME :
- confirm_text = "Really restart this game ?";
+ confirm_text = _("Really restart this game?");
break;
case QUIT_GAME :
- confirm_text = "Really exit Gnome Mahjongg ?";
+ confirm_text = _("Really exit Gnome Mahjongg?");
break;
case NEW_GAME:
case SELECT_GAME:
- confirm_text = "Really start a new game ?";
+ confirm_text = _("Really start a new game?");
break;
default:
- confirm_text = "Serious internal error";
+ confirm_text = _("Serious internal error!");
break;
}
- gnome_app_ok_cancel_modal (GNOME_APP(window), confirm_text,
- confirm_callback, data);
- } else
- confirm_callback (GNOME_OK, data);
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ confirm_text);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_NO, GTK_RESPONSE_NO,
+ GTK_STOCK_YES, GTK_RESPONSE_YES,
+ NULL);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+
+ if (response == GTK_RESPONSE_YES)
+ {
+ confirm_callback (response, data);
+ }
+ else
+ {
+ /* If you do gtk_widget_hide (dialog) for cases
+ other than QUIT_GAME, it doesn't hide the
+ dialog. If you do gtk_widget_destroy on QUIT_GAME,
+ it destroys both window and dialog. This is sick.
+ What am I doing wrong here? */
+
+ gtk_widget_hide (dialog);
+
+ }
+
+
+ }
+
}
void exit_game_callback (GtkWidget *widget, gpointer data)
@@ -1567,7 +1590,7 @@
void new_game_reply_callback (gint reply, gpointer data)
{
- if (reply == GNOME_YES) {
+ if (reply == 0) {
ensure_pause_off ();
new_game ();
}
@@ -1620,7 +1643,7 @@
else
gnome_app_flash (GNOME_APP (window), "No more redo!");
sprintf(tmpchar,"%3d",visible_tiles) ;
- gtk_label_set(GTK_LABEL (tiles_label), tmpchar);
+ gtk_label_set_text(GTK_LABEL (tiles_label), tmpchar);
update_moves_left ();
gnome_canvas_update_now (GNOME_CANVAS (canvas));
@@ -1655,53 +1678,44 @@
}
sprintf (tmpchar, "%3d", visible_tiles) ;
- gtk_label_set (GTK_LABEL(tiles_label), tmpchar);
+ gtk_label_set_text (GTK_LABEL(tiles_label), tmpchar);
gnome_canvas_update_now (GNOME_CANVAS (canvas));
update_moves_left ();
}
-void seed_dialog_clicked_cb (GnomeDialog * dialog, gint button_number,
- gpointer data)
-{
- switch (button_number) {
- case 0: /* OK button */
- srand (atoi (gtk_entry_get_text (GTK_ENTRY (data))));
- new_game ();
- break;
-
- case 1: /* Cancel Button */
- break;
-
- default:
- break;
- };
- gnome_dialog_close(dialog);
-}
-
void select_game ()
{
- GtkWidget *dialog, *entry, *label;
-
+ GtkWidget *dialog, *entry, *label;
ensure_pause_off();
- dialog = gnome_dialog_new (_("Select Game"),
- GNOME_STOCK_BUTTON_OK,
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- GTK_WINDOW (dialog)->position = GTK_WIN_POS_MOUSE;
- label = gtk_label_new (_("Game Number:"));
- gtk_box_pack_start_defaults (GTK_BOX(GNOME_DIALOG(dialog)->vbox), label);
-
- entry = gtk_entry_new ();
- gtk_box_pack_start_defaults (GTK_BOX(GNOME_DIALOG(dialog)->vbox), entry);
- gtk_signal_connect (GTK_OBJECT (dialog), "clicked",
- GTK_SIGNAL_FUNC (seed_dialog_clicked_cb),
- (gpointer)entry);
- gnome_dialog_set_default (GNOME_DIALOG(dialog), 0);
- gnome_dialog_editable_enters (GNOME_DIALOG(dialog),(GTK_EDITABLE(entry)));
+ dialog = gtk_dialog_new_with_buttons ("Select a game",
+ GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK,
+ GTK_RESPONSE_OK,
+ NULL);
+ label = gtk_label_new (_("Game Number:"));
+ gtk_box_pack_start_defaults (GTK_BOX(GTK_DIALOG(dialog)->vbox), label);
+ entry = gtk_entry_new ();
+ gtk_box_pack_start_defaults (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry);
+ gtk_widget_show_all (dialog);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ if (response == GTK_RESPONSE_OK)
+ {
+ srand (atoi (gtk_entry_get_text (GTK_ENTRY (entry))));
+ new_game ();
+ gtk_widget_destroy (dialog);
+ }
+ else
+ {
+ gtk_widget_destroy (dialog);
+ }
+
- gnome_dialog_set_parent(GNOME_DIALOG(dialog),GTK_WINDOW(window));
- gtk_widget_show_all (dialog);
}
void show_tb_callback (GtkWidget *widget, gpointer data)
@@ -1842,8 +1856,8 @@
"height", (double)TILE_HEIGHT,
NULL);
- gtk_signal_connect (GTK_OBJECT (tiles[i].canvas_item), "event",
- (GtkSignalFunc) tile_event,
+ g_signal_connect (G_OBJECT (tiles[i].canvas_item), "event",
+ G_CALLBACK(tile_event),
&tiles[i]);
}
}
@@ -1855,29 +1869,38 @@
tmp = g_strconcat ("mahjongg/", fname, NULL);
- fn = gnome_unconditional_pixmap_file (tmp);
+ fn = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, (tmp), FALSE, NULL);
g_free (tmp);
tmp = g_strconcat ("mahjongg/bg/", bg_fname, NULL);
- bg_fn = gnome_unconditional_pixmap_file (tmp);
+ bg_fn = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_PIXMAP, (tmp), FALSE, NULL);
g_free (tmp);
- if (!g_file_exists (fn)) {
+ if (!g_file_test ((fn), G_FILE_TEST_EXISTS)) {
char *s = g_strdup_printf (_("Could not find file %s"), fn);
GtkWidget *box;
-
- box = gnome_message_box_new (s, GNOME_MESSAGE_BOX_ERROR, GNOME_STOCK_BUTTON_OK, NULL);
- gnome_dialog_run (GNOME_DIALOG (box));
+
+ box = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ s);
+ gtk_dialog_run (GTK_DIALOG (box));
exit (1);
}
- if (!g_file_exists (bg_fn)) {
+ if (!g_file_test ((bg_fn), G_FILE_TEST_EXISTS)) {
char *s = g_strdup_printf (_("Could not find file %s"), bg_fn);
GtkWidget *box;
- box = gnome_message_box_new (s, GNOME_MESSAGE_BOX_ERROR, GNOME_STOCK_BUTTON_OK, NULL);
- gnome_dialog_run (GNOME_DIALOG (box));
+
+ box = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ s);
+ gtk_dialog_run (GTK_DIALOG (box));
exit (1);
}
@@ -1905,14 +1928,10 @@
gchar *buf, *buf2;
gint ibuf;
- gtk_widget_push_visual (gdk_rgb_get_visual ());
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
canvas = gnome_canvas_new();
- gtk_widget_pop_colormap ();
- gtk_widget_pop_visual ();
-
gtk_box_pack_start_defaults (GTK_BOX (mbox), canvas);
gtk_widget_set_usize(canvas, AREA_WIDTH, AREA_HEIGHT);
@@ -2000,12 +2019,12 @@
#if 0
gtk_clock_stop (GTK_CLOCK (chrono));
#endif
- mb = gnome_message_box_new (_("Sorry, I can't find\na playable configuration."),
- GNOME_MESSAGE_BOX_INFO,
- GNOME_STOCK_BUTTON_OK, NULL);
- GTK_WINDOW (mb)->position = GTK_WIN_POS_MOUSE;
- gtk_window_set_modal (&GNOME_MESSAGE_BOX (mb)->dialog.window, TRUE);
- gnome_dialog_set_parent(&GNOME_MESSAGE_BOX (mb)->dialog, GTK_WINDOW (window));
+ mb = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ _("Sorry, I can't find\na playable configuration."));
+ gtk_dialog_run (GTK_DIALOG (mb));
gtk_widget_show (mb);
} else {
@@ -2041,7 +2060,7 @@
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- gnome_init (APPNAME, MAH_VERSION, argc, argv);
+ gnome_init_with_popt_table (APPNAME, MAH_VERSION, argc, argv, NULL, 0, NULL);
gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/gnome-mahjongg.png");
srand (time (NULL));
@@ -2097,7 +2116,7 @@
NULL, NULL);
gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
- gtk_signal_connect (GTK_OBJECT (window), "delete_event",
+ g_signal_connect (G_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (exit_game_callback_query), (gpointer)QUIT_GAME);
mbox = gtk_vbox_new (FALSE, 0);
@@ -2108,9 +2127,9 @@
gtk_widget_show (window);
if(gnome_config_get_bool_with_default("/gmahjongg/toolbar/show",&show))
- gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(settingsmenu[0].widget), TRUE);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(settingsmenu[0].widget), TRUE);
else {
- gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(settingsmenu[0].widget), FALSE);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(settingsmenu[0].widget), FALSE);
#if 0
gdi = gnome_app_get_dock_item_by_name (GNOME_APP (window), GNOME_APP_TOOLBAR_NAME);
gtk_widget_hide(GTK_WIDGET(gdi)) ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]