Mahjongg Patch
- From: Josh Barrow <drleary mac com>
- To: desktop-devel-list gnome org
- Subject: Mahjongg Patch
- Date: 17 Dec 2001 18:25:43 -0600
This patch makes Mahjongg compile and run with G_DISABLE_DEPRECATED,
GTK_DISABLE_DEPRECATED, and GNOME_DISABLE_DEPRECATED. There are a
couple of issues that are stated as comments in the patch.
Comments welcome.
Josh
Carbamide
? mahjongg_patch
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/17 23:18:05
@@ -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: 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/17 23:18:10
@@ -11,6 +11,9 @@
* pancho nuclecu unam mx
*
*/
+#define GTK_DISABLE_DEPRECATED
+#define G_DISABLE_DEPRECATED
+#define GNOME_DISABLE_DEPRECATED
#include <sys/types.h>
#include <string.h>
@@ -248,6 +251,7 @@
tile tiles[MAX_TILES];
GtkWidget *window, *pref_dialog, *appbar;
+gint response;
#ifdef NEED_UNUSED_CODE
GtkWidget *hint_dialog;
#endif
@@ -348,7 +352,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),
@@ -358,10 +362,12 @@
GNOMEUIINFO_MENU_REDO_MOVE_ITEM(redo_tile_callback, NULL),
GNOMEUIINFO_MENU_HINT_ITEM(hint_callback, NULL),
-
+ /* There isn't a GTK_STOCK_MENU_BLANK, what should I use here? */
+ /*
{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_STOCK,
+ GNOME_STOCK_MENU_BLANK, 0, 0, NULL},
+ */
GNOMEUIINFO_SEPARATOR,
@@ -405,38 +411,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_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_PIXMAP_STOCK, GTK_STOCK_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 +548,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 +656,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 +800,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,17 +822,17 @@
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",
+ g_signal_connect (GTK_OBJECT(item), "activate",
(GtkSignalFunc)set_tile_selection, s);
- gtk_signal_connect (GTK_OBJECT(item), "destroy",
+ g_signal_connect (GTK_OBJECT(item), "destroy",
(GtkSignalFunc) free_str, s);
}
else {
- gtk_signal_connect (GTK_OBJECT(item), "activate",
+ g_signal_connect (GTK_OBJECT(item), "activate",
(GtkSignalFunc)set_bg_selection, s);
- gtk_signal_connect (GTK_OBJECT(item), "destroy",
+ g_signal_connect (GTK_OBJECT(item), "destroy",
(GtkSignalFunc) free_str, s);
}
@@ -854,10 +859,10 @@
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",
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
+ g_signal_connect (GTK_OBJECT(item), "activate",
(GtkSignalFunc)set_map_selection, &maps[lp]);
- gtk_signal_connect (GTK_OBJECT(item), "destroy",
+ g_signal_connect (GTK_OBJECT(item), "destroy",
(GtkSignalFunc) free_str, str);
if (!g_strcasecmp(mapset, maps[lp].name))
gtk_menu_set_active(GTK_MENU(menu), itemno);
@@ -904,14 +909,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,12 +941,11 @@
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);
}
game_over = GAME_LOST;
@@ -991,7 +994,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,7 +1002,7 @@
pref_dialog = gtk_dialog_new ();
d = GTK_DIALOG(pref_dialog);
- gtk_signal_connect (GTK_OBJECT(pref_dialog), "close",
+ g_signal_connect (GTK_OBJECT(pref_dialog), "close",
(GtkSignalFunc)pref_cancel, NULL);
/* The Tile sub-menu */
@@ -1011,7 +1013,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 +1025,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",
+ g_signal_connect (GTK_OBJECT(cb), "clicked",
(GtkSignalFunc)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 +1047,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 +1059,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", */
+ g_signal_connect (GTK_OBJECT(cb), "clicked", */
(GtkSignalFunc)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 +1081,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 +1090,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",
+ g_signal_connect (GTK_OBJECT(cb), "clicked",
(GtkSignalFunc)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 +1103,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,38 +1114,26 @@
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(GTK_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",
+ g_signal_connect (GTK_OBJECT(cb), "clicked",
(GtkSignalFunc)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,
+static void prefs_clicked_callback(GtkWidget * dialog, gint button_number,
gpointer data)
{
switch (button_number) {
@@ -1151,13 +1141,13 @@
apply_preferences();
break;
};
- gnome_dialog_close(dialog);
+ gtk_widget_destroy (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,14 +1155,21 @@
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",
+ d = GTK_DIALOG(pref_dialog);
+ g_signal_connect(GTK_OBJECT(pref_dialog), "clicked",
GTK_SIGNAL_FUNC(prefs_clicked_callback),
NULL);
- gtk_signal_connect (GTK_OBJECT(pref_dialog), "close",
+ g_signal_connect (GTK_OBJECT(pref_dialog), "close",
(GtkSignalFunc)pref_cancel, NULL);
cols = gtk_hbox_new (FALSE, FALSE);
@@ -1186,7 +1183,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 +1193,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",
+ g_signal_connect (GTK_OBJECT(cb), "clicked",
(GtkSignalFunc)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 +1211,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 +1221,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",
+ g_signal_connect (GTK_OBJECT(cb), "clicked",
(GtkSignalFunc)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 +1239,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 +1248,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",
+ g_signal_connect (GTK_OBJECT(cb), "clicked",
(GtkSignalFunc)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 +1261,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 +1272,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(GTK_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",
+ g_signal_connect (GTK_OBJECT(cb), "clicked",
(GtkSignalFunc)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,20 +1291,20 @@
/* 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",
+ g_signal_connect (GTK_OBJECT(cb), "clicked",
(GtkSignalFunc)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",
+ g_signal_connect (GTK_OBJECT(cb), "clicked",
(GtkSignalFunc)set_popup_def, &(popup_config.confirm));
gtk_box_pack_start_defaults (GTK_BOX(fv), cb);
@@ -1318,8 +1315,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,7 +1437,6 @@
(const char *)translator_credits,
NULL);
- gnome_dialog_set_parent(GNOME_DIALOG(about),GTK_WINDOW(window));
gtk_widget_show (about);
}
@@ -1447,7 +1450,7 @@
{
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 +1479,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 +1497,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 ;
@@ -1507,7 +1510,7 @@
void confirm_callback (gint reply, gpointer data)
{
- if (reply == GNOME_OK)
+ if (reply == 0)
switch ((int)data)
{
case NEW_GAME:
@@ -1531,6 +1534,12 @@
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
@@ -1539,23 +1548,24 @@
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);
+
+ gnome_app_ok_cancel_modal (GNOME_APP(window), confirm_text,
+ confirm_callback, data);
+ } else
+ confirm_callback (0, data);
}
void exit_game_callback (GtkWidget *widget, gpointer data)
@@ -1567,7 +1577,7 @@
void new_game_reply_callback (gint reply, gpointer data)
{
- if (reply == GNOME_YES) {
+ if (reply == 0) {
ensure_pause_off ();
new_game ();
}
@@ -1620,7 +1630,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 +1665,60 @@
}
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,
+void seed_dialog_clicked_cb (GtkWidget * dialog, gint button_number,
gpointer data)
{
switch (button_number) {
- case 0: /* OK button */
+ case 0: /* Cancel Button */
+ break;
+ case 1: /* 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);
+ gtk_widget_destroy (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,7 +1859,7 @@
"height", (double)TILE_HEIGHT,
NULL);
- gtk_signal_connect (GTK_OBJECT (tiles[i].canvas_item), "event",
+ g_signal_connect (GTK_OBJECT (tiles[i].canvas_item), "event",
(GtkSignalFunc) tile_event,
&tiles[i]);
}
@@ -1855,29 +1872,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,13 +1931,11 @@
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);
@@ -2000,12 +2024,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 +2065,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 +2121,7 @@
NULL, NULL);
gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
- gtk_signal_connect (GTK_OBJECT (window), "delete_event",
+ g_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (exit_game_callback_query), (gpointer)QUIT_GAME);
mbox = gtk_vbox_new (FALSE, 0);
@@ -2108,9 +2132,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]