[patch] gnibbles - first stage to compile without deprecated *
- From: Markus Bertheau <twanger bluetwanger de>
- To: jpablo <pablo_juan yahoo com>, desktop-devel-list <desktop-devel-list gnome org>
- Subject: [patch] gnibbles - first stage to compile without deprecated *
- Date: 18 Jan 2002 23:38:51 +0100
The property dialog box, which is a (which is a GnomePropertyBox) still
needs conversion. I'll work on this after tht patch.
Mostly pretty straightforward things like gdk_draw_pixmap ->
gdk_draw_drawable.
Thanks for reviewing.
Markus Bertheau
Index: gnibbles/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-games/gnibbles/ChangeLog,v
retrieving revision 1.60
diff -u -r1.60 ChangeLog
--- gnibbles/ChangeLog 2001/12/19 12:29:13 1.60
+++ gnibbles/ChangeLog 2002/01/18 22:45:05
@@ -1,3 +1,14 @@
+2002-01-18 Markus Bertheau <twanger bluetwanger de>
+
+ * Makefile.am:
+ * scoreboard.c:
+ * preferences.c:
+ * gnibbles.[ch]:
+ * main.c:
+
+ First part of making it compile without deprecated
+ functions.
+
2001-12-19 Seth Nickell <snickell stanford edu>
* Makefile.am:
Index: gnibbles/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-games/gnibbles/Makefile.am,v
retrieving revision 1.22
diff -u -r1.22 Makefile.am
--- gnibbles/Makefile.am 2002/01/13 21:48:12 1.22
+++ gnibbles/Makefile.am 2002/01/18 22:45:05
@@ -7,8 +7,8 @@
INCLUDES = \
$(GNOME_GAMES_CFLAGS) \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\"
-
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+ -DREAL_DATADIR=\""$(datadir)"\"
bin_PROGRAMS = gnibbles
Index: gnibbles/gnibbles.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gnibbles/gnibbles.c,v
retrieving revision 1.27
diff -u -r1.27 gnibbles.c
--- gnibbles/gnibbles.c 2001/11/22 23:23:42 1.27
+++ gnibbles/gnibbles.c 2002/01/18 22:45:06
@@ -50,6 +50,16 @@
extern guint properties->tilesize, properties->tilesize;
*/
+void gnibbles_error (GtkWidget *window, gchar *message)
+{
+ GtkWidget *w = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ message);
+ gtk_dialog_run (GTK_DIALOG (w));
+ gtk_widget_destroy (GTK_WIDGET (w));
+ exit (1);
+}
+
void gnibbles_copy_pixmap (GdkDrawable *drawable, gint which, gint x, gint y,
gboolean big)
{
@@ -57,7 +67,7 @@
h = properties->tilesize * (big ? 2 : 1);
guint nh = 10 / (big ? 2 : 1), nv = 10 / (big ? 2 : 1);
- gdk_draw_pixmap (drawable, drawing_area->style->fg_gc[GTK_WIDGET_STATE
+ gdk_draw_drawable (GDK_DRAWABLE (drawable), drawing_area->style->fg_gc[GTK_WIDGET_STATE
(drawing_area)], gnibbles_pixmap, (which % nh) * w,
((big ? 3 : 0) + which / nv) * h, x * properties->tilesize,
y * properties->tilesize, w, h);
@@ -85,48 +95,45 @@
gnibbles_copy_pixmap(buffer_pixmap, which, x, y, TRUE);
}
-void gnibbles_load_pixmap ()
+void gnibbles_load_pixmap (GtkWidget *window)
{
GdkPixbuf *image;
GdkPixbuf *tmp;
gchar *filename;
- filename = gnome_unconditional_pixmap_file ("gnibbles/gnibbles.png");
+ filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_DATADIR,
+ "pixmaps/gnibbles/gnibbles.png",
+ TRUE, NULL);
- if (!g_file_exists (filename)) {
+ if (!filename) {
char *message =
g_strdup_printf (_("Gnibbles couldn't find pixmap file:\n%s\n\n"
"Please check your Gnibbles installation"), filename);
- GtkWidget *w = gnome_error_dialog (message);
- gnome_dialog_run_and_close (GNOME_DIALOG(w));
- g_free (message);
- exit (1);
+ gnibbles_error (window, message);
}
image = gdk_pixbuf_new_from_file (filename, NULL);
if (gnibbles_pixmap)
- gdk_pixmap_unref (gnibbles_pixmap);
+ g_object_unref (G_OBJECT (gnibbles_pixmap));
tmp = gdk_pixbuf_scale_simple (image, 10 * properties->tilesize,
10 * properties->tilesize, GDK_INTERP_TILES);
gdk_pixbuf_render_pixmap_and_mask (tmp, &gnibbles_pixmap, NULL, 127);
- gdk_pixbuf_unref (image);
- gdk_pixbuf_unref (tmp);
+ g_object_unref (G_OBJECT (image));
+ g_object_unref (G_OBJECT (tmp));
g_free (filename);
- filename = gnome_unconditional_pixmap_file
- ("gnibbles/gnibbles-logo.png");
+ filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_DATADIR,
+ "pixmaps/gnibbles/gnibbles-logo.png",
+ TRUE, NULL);
- if (!g_file_exists (filename)) {
+ if (!filename) {
char *message = g_strdup_printf (_("Gnibbles Couldn't find pixmap file:\n%s\n\n"
"Please check your Gnibbles instalation"), filename);
- GtkWidget *w = gnome_error_dialog (message);
- gnome_dialog_run_and_close (GNOME_DIALOG(w));
- g_free (message);
- exit (1);
+ gnibbles_error (window, message);
}
image = gdk_pixbuf_new_from_file (filename, NULL);
@@ -135,16 +142,16 @@
GDK_INTERP_TILES);
if (logo_pixmap)
- gdk_pixmap_unref (logo_pixmap);
+ g_object_unref (G_OBJECT (logo_pixmap));
gdk_pixbuf_render_pixmap_and_mask (tmp, &logo_pixmap, NULL, 127);
- gdk_pixbuf_unref (image);
- gdk_pixbuf_unref (tmp);
+ g_object_unref (G_OBJECT (image));
+ g_object_unref (G_OBJECT (tmp));
g_free (filename);
}
-void gnibbles_load_level (int level)
+void gnibbles_load_level (GtkWidget *window, int level)
{
gchar tmp[30];
gchar *filename;
@@ -154,16 +161,14 @@
int count = 0;
sprintf (tmp, "gnibbles/level%03d.gnl", level);
- filename = gnome_unconditional_datadir_file (tmp);
+ filename = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_DATADIR,
+ tmp, TRUE, NULL);
if ((in = fopen (filename, "r")) == NULL) {
char *message = g_strdup_printf (
_("Gnibbles couldn't load level file:\n%s\n\n"
"Please check your Gnibbles installation"), filename);
- GtkWidget *w = gnome_error_dialog (message);
- gnome_dialog_run_and_close (GNOME_DIALOG(w));
- g_free (message);
- exit (1);
+ gnibbles_error (window, message);
}
g_free (filename);
@@ -249,7 +254,7 @@
}
}
- gdk_draw_pixmap (drawing_area->window, drawing_area->style->fg_gc
+ gdk_draw_drawable (GDK_DRAWABLE (drawing_area->window), drawing_area->style->fg_gc
[GTK_WIDGET_STATE (drawing_area)], buffer_pixmap, 0, 0,
0, 0, BOARDWIDTH * 10, BOARDHEIGHT * 10);
Index: gnibbles/gnibbles.h
===================================================================
RCS file: /cvs/gnome/gnome-games/gnibbles/gnibbles.h,v
retrieving revision 1.7
diff -u -r1.7 gnibbles.h
--- gnibbles/gnibbles.h 2000/03/10 21:57:02 1.7
+++ gnibbles/gnibbles.h 2002/01/18 22:45:06
@@ -55,8 +55,8 @@
void gnibbles_draw_big_pixmap (gint which, gint x, gint y);
void gnibbles_draw_pixmap_buffer (gint which, gint x, gint y);
void gnibbles_draw_big_pixmap_buffer (gint which, gint x, gint y);
-void gnibbles_load_pixmap ();
-void gnibbles_load_level (int level);
+void gnibbles_load_pixmap (GtkWidget *window);
+void gnibbles_load_level (GtkWidget *window, int level);
void gnibbles_init ();
void gnibbles_add_bonus (int regular);
void gnibbles_destroy ();
Index: gnibbles/main.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gnibbles/main.c,v
retrieving revision 1.35
diff -u -r1.35 main.c
--- gnibbles/main.c 2001/11/27 01:11:35 1.35
+++ gnibbles/main.c 2002/01/18 22:45:07
@@ -150,15 +150,12 @@
pause_state = paused;
if (!paused)
pause_game_cb (NULL, (gpointer) 0);
- box = gnome_message_box_new (
- _("Do you really want to end this game?"),
- GNOME_MESSAGE_BOX_QUESTION,
- GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO,
- NULL);
- gnome_dialog_set_parent (GNOME_DIALOG (box), GTK_WINDOW
- (window));
- gnome_dialog_set_default (GNOME_DIALOG (box), 0);
- status = gnome_dialog_run (GNOME_DIALOG (box));
+ box = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ _("Do you really want to end this game?"));
+ status = gtk_dialog_run (GTK_DIALOG (box)) == GTK_RESPONSE_NO;
+ gtk_widget_destroy (GTK_WIDGET (box));
box = NULL;
if (!pause_state && status)
pause_game_cb (NULL, (gpointer) 0);
@@ -199,16 +196,14 @@
(const char **)documenters,
(const char *)translator_credits,
NULL);
- gtk_signal_connect (GTK_OBJECT (about), "destroy", GTK_SIGNAL_FUNC
+ g_signal_connect (G_OBJECT (about), "destroy", G_CALLBACK
(gtk_widget_destroyed), &about);
- gnome_dialog_set_parent (GNOME_DIALOG (about), GTK_WINDOW (window));
-
gtk_widget_show (about);
}
static gint expose_event_cb (GtkWidget *widget, GdkEventExpose *event)
{
- gdk_draw_pixmap (widget->window, widget->style->fg_gc[GTK_WIDGET_STATE
+ gdk_draw_drawable (GDK_DRAWABLE (widget->window), widget->style->fg_gc[GTK_WIDGET_STATE
(widget)], buffer_pixmap, event->area.x, event->area.y,
event->area.x, event->area.y, event->area.width,
event->area.height);
@@ -248,7 +243,7 @@
for (i=0; i<boni->numbonuses; i++)
gnibbles_bonus_draw (boni->bonuses[i]);
- gdk_draw_pixmap (drawing_area->window,
+ gdk_draw_drawable (GDK_DRAWABLE (drawing_area->window),
drawing_area->style->fg_gc[GTK_WIDGET_STATE
(drawing_area)], buffer_pixmap, 0, 0, 0, 0,
BOARDWIDTH*properties->tilesize, BOARDHEIGHT*properties->tilesize);
@@ -257,11 +252,9 @@
static gint configure_event_cb (GtkWidget *widget, GdkEventConfigure *event)
{
- int i, j;
-
- gnibbles_load_pixmap();
+ gnibbles_load_pixmap (window);
if (buffer_pixmap)
- gdk_pixmap_unref (buffer_pixmap);
+ g_object_unref (G_OBJECT (buffer_pixmap));
buffer_pixmap = gdk_pixmap_new (drawing_area->window,
BOARDWIDTH * properties->tilesize,
BOARDHEIGHT * properties->tilesize, -1);
@@ -278,9 +271,9 @@
{
if (!paused) {
if (!keyboard_id)
- keyboard_id = gtk_signal_connect (GTK_OBJECT (window),
+ keyboard_id = g_signal_connect (G_OBJECT (window),
"key_press_event",
- GTK_SIGNAL_FUNC (key_press_cb), NULL);
+ G_CALLBACK (key_press_cb), NULL);
if (!main_id)
main_id = gtk_timeout_add (GAMEDELAY * properties->gamespeed,
(GtkFunction) main_loop, NULL);
@@ -319,7 +312,7 @@
else
current_level = rand () % MAXLEVEL + 1;
- gnibbles_load_level (current_level);
+ gnibbles_load_level (GTK_WIDGET (window), current_level);
gnibbles_add_bonus (1);
@@ -371,7 +364,7 @@
main_id = 0;
}
if (keyboard_id) {
- gtk_signal_disconnect (GTK_OBJECT (window),
+ g_signal_handler_disconnect (G_OBJECT (window),
keyboard_id);
keyboard_id = 0;
}
@@ -399,7 +392,7 @@
}
if (keyboard_id) {
- gtk_signal_disconnect (GTK_OBJECT (window), keyboard_id);
+ g_signal_handler_disconnect (G_OBJECT (window), keyboard_id);
keyboard_id = 0;
}
@@ -446,7 +439,7 @@
static gint restart_game (gpointer data)
{
- gnibbles_load_level (current_level);
+ gnibbles_load_level (GTK_WIDGET (window), current_level);
gnibbles_add_bonus (1);
@@ -484,7 +477,7 @@
gnibbles_scoreboard_update (scoreboard);
if (status == GAMEOVER) {
- gtk_signal_disconnect (GTK_OBJECT (window), keyboard_id);
+ g_signal_handler_disconnect (G_OBJECT (window), keyboard_id);
keyboard_id = 0;
main_id = 0;
gtk_timeout_remove (add_bonus_id);
@@ -497,7 +490,7 @@
}
if (status == NEWROUND) {
- gtk_signal_disconnect (GTK_OBJECT (window), keyboard_id);
+ g_signal_handler_disconnect (G_OBJECT (window), keyboard_id);
keyboard_id = 0;
gtk_timeout_remove (add_bonus_id);
add_bonus_id = 0;
@@ -511,7 +504,7 @@
}
if (boni->numleft == 0) {
- gtk_signal_disconnect (GTK_OBJECT (window), keyboard_id);
+ g_signal_handler_disconnect (G_OBJECT (window), keyboard_id);
keyboard_id = 0;
gtk_timeout_remove (add_bonus_id);
add_bonus_id = 0;
@@ -537,10 +530,10 @@
GdkImage *tmp_image;
GdkColor bgcolor;
- tmp_image = gdk_image_get (gnibbles_pixmap, 0, 0, 1, 1);
+ tmp_image = gdk_drawable_get_image (GDK_DRAWABLE (gnibbles_pixmap), 0, 0, 1, 1);
bgcolor.pixel = gdk_image_get_pixel (tmp_image, 0, 0);
gdk_window_set_background (drawing_area->window, &bgcolor);
- gdk_image_destroy (tmp_image);
+ g_object_unref (G_OBJECT (tmp_image));
}
gboolean
@@ -556,13 +549,10 @@
GdkPixmap *cursor_dot_pm;
window = gnome_app_new ("gnibbles", "GNOME Nibbles");
- gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, TRUE);
+ gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_widget_realize (window);
- gtk_signal_connect (GTK_OBJECT (window), "delete_event",
- GTK_SIGNAL_FUNC (quit_cb), NULL);
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
+ g_signal_connect (G_OBJECT (window), "delete_event",
+ G_CALLBACK (quit_cb), NULL);
drawing_area = gtk_drawing_area_new ();
@@ -576,24 +566,21 @@
&drawing_area->style->fg[GTK_STATE_ACTIVE],
&drawing_area->style->bg[GTK_STATE_ACTIVE], 0, 0);
- gtk_widget_pop_colormap ();
- gtk_widget_pop_visual ();
-
gnome_app_set_contents (GNOME_APP (window), drawing_area);
- gtk_signal_connect (GTK_OBJECT (drawing_area), "configure_event",
- GTK_SIGNAL_FUNC (configure_event_cb), NULL);
+ g_signal_connect (G_OBJECT (drawing_area), "configure_event",
+ G_CALLBACK (configure_event_cb), NULL);
- gtk_signal_connect (GTK_OBJECT(drawing_area), "motion_notify_event",
- GTK_SIGNAL_FUNC (show_cursor_cb), NULL);
+ g_signal_connect (G_OBJECT(drawing_area), "motion_notify_event",
+ G_CALLBACK (show_cursor_cb), NULL);
- gtk_signal_connect (GTK_OBJECT(window), "focus_out_event",
- GTK_SIGNAL_FUNC (show_cursor_cb), NULL);
+ g_signal_connect (G_OBJECT(window), "focus_out_event",
+ G_CALLBACK (show_cursor_cb), NULL);
- gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area),
+ gtk_widget_set_size_request (GTK_WIDGET (drawing_area),
BOARDWIDTH*properties->tilesize, BOARDHEIGHT*properties->tilesize);
- gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
- GTK_SIGNAL_FUNC (expose_event_cb), NULL);
+ g_signal_connect (G_OBJECT (drawing_area), "expose_event",
+ G_CALLBACK (expose_event_cb), NULL);
gtk_widget_set_events (drawing_area, GDK_BUTTON_PRESS_MASK |
GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK);
gtk_widget_show (drawing_area);
@@ -618,12 +605,12 @@
zero_board ();
- gdk_draw_pixmap (buffer_pixmap,
+ gdk_draw_drawable (GDK_DRAWABLE (buffer_pixmap),
drawing_area->style->fg_gc[GTK_WIDGET_STATE (drawing_area)], logo_pixmap,
0, 0, 0, 0, BOARDWIDTH*properties->tilesize,
BOARDHEIGHT*properties->tilesize);
- gdk_draw_pixmap (drawing_area->window,
+ gdk_draw_drawable (GDK_DRAWABLE (drawing_area->window),
drawing_area->style->fg_gc[GTK_WIDGET_STATE (drawing_area)],
buffer_pixmap, 0, 0, 0, 0, BOARDWIDTH*properties->tilesize,
BOARDHEIGHT*properties->tilesize);
@@ -639,7 +626,11 @@
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
- gnome_init ("Gnibbles", VERSION, argc, argv);
+ gnome_program_init ("Gnibbles", VERSION, LIBGNOMEUI_MODULE,
+ argc, argv,
+ GNOME_PARAM_POPT_TABLE, NULL,
+ GNOME_PARAM_APP_DATADIR, REAL_DATADIR,
+ NULL);
gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/gnome-nibbles.png");
srand (time (NULL));
@@ -647,7 +638,7 @@
setup_window ();
- gnibbles_load_pixmap ();
+ gnibbles_load_pixmap (window);
gtk_widget_show (window);
Index: gnibbles/preferences.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gnibbles/preferences.c,v
retrieving revision 1.25
diff -u -r1.25 preferences.c
--- gnibbles/preferences.c 2000/04/26 21:40:39 1.25
+++ gnibbles/preferences.c 2002/01/18 22:45:08
@@ -62,7 +62,7 @@
{
if (pagenum == -1) {
if (t_properties->tilesize != properties->tilesize) {
- gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area),
+ gtk_widget_set_size_request (GTK_WIDGET (drawing_area),
t_properties->tilesize * BOARDWIDTH,
t_properties->tilesize * BOARDHEIGHT);
}
Index: gnibbles/scoreboard.c
===================================================================
RCS file: /cvs/gnome/gnome-games/gnibbles/scoreboard.c,v
retrieving revision 1.7
diff -u -r1.7 scoreboard.c
--- gnibbles/scoreboard.c 1999/03/12 07:05:10 1.7
+++ gnibbles/scoreboard.c 2002/01/18 22:45:08
@@ -18,6 +18,7 @@
*/
#include <config.h>
+#include <string.h>
#include <gnome.h>
#include "gnibbles.h"
@@ -90,7 +91,7 @@
(scoreboard->worms[i]->lives > -1) ?
scoreboard->worms[i]->lives : 0,
scoreboard->worms[i]->score);
- gtk_label_get (GTK_LABEL (scoreboard->data[i]), &buffer2);
+ buffer2 = gtk_label_get_text (GTK_LABEL (scoreboard->data[i]));
if (strcmp (buffer, buffer2))
gtk_label_set_text (GTK_LABEL (scoreboard->data[i]),
buffer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]