[gnome-games] Use accessor functions for -DGSEAL_ENABLE



commit 9feda692f0628ffb66ecfd194d022842976eb7cc
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date:   Tue Jun 23 11:25:01 2009 +0200

    Use accessor functions for -DGSEAL_ENABLE
    
    Fixes glines, gnobots2 and libgames-support.
    Still needs work for GtkWidget allocation and GtkObject flags as no solution for these exists.
    
    GNOME bug #586731

 glines/glines.c                        |   48 ++++++++++++++++---------------
 gnobots2/game.c                        |    2 +-
 gnobots2/gnobots.c                     |   13 ++------
 gnobots2/graphics.c                    |   18 ++++++-----
 gnobots2/properties.c                  |   12 ++++----
 libgames-support/games-gridframe.c     |    6 ++--
 libgames-support/games-scores-dialog.c |    8 ++--
 7 files changed, 52 insertions(+), 55 deletions(-)
---
diff --git a/glines/glines.c b/glines/glines.c
index 325db6c..2123303 100644
--- a/glines/glines.c
+++ b/glines/glines.c
@@ -345,13 +345,13 @@ refresh_preview_pixmaps (void)
 
 
   for (i = 0; i < 7; i++) {
-    preview_pixmaps[i] = gdk_pixmap_new (widget->window,
+    preview_pixmaps[i] = gdk_pixmap_new (gtk_widget_get_window (widget),
                                          preview_width, preview_height, -1);
     gdk_draw_rectangle (preview_pixmaps[i],
-                        widget->style->bg_gc[GTK_STATE_NORMAL],
+                        gtk_widget_get_style (widget)->bg_gc[GTK_STATE_NORMAL],
                         TRUE, 0, 0, preview_width, preview_height);
 
-    gdk_draw_pixbuf (preview_pixmaps[i], widget->style->white_gc,
+    gdk_draw_pixbuf (preview_pixmaps[i], gtk_widget_get_style (widget)->white_gc,
                      scaled, 0, i * preview_height, 0, 0,
                      preview_width, preview_height,
                      GDK_RGB_DITHER_NORMAL, 0, 0);
@@ -359,11 +359,11 @@ refresh_preview_pixmaps (void)
 
   if (blank_preview_pixmap)
     g_object_unref (blank_preview_pixmap);
-  blank_preview_pixmap =
-    gdk_pixmap_new (widget->window, preview_width, preview_height, -1);
+  blank_preview_pixmap = gdk_pixmap_new (gtk_widget_get_window (widget), 
+                                         preview_width, preview_height, -1);
   gdk_draw_rectangle (blank_preview_pixmap,
-                      widget->style->bg_gc[GTK_STATE_NORMAL], TRUE, 0, 0,
-                      preview_width, preview_height);
+                      gtk_widget_get_style (widget)->bg_gc[GTK_STATE_NORMAL], 
+                      TRUE, 0, 0, preview_width, preview_height);
 
   g_object_unref (scaled);
 
@@ -372,7 +372,7 @@ refresh_preview_pixmaps (void)
 static void
 draw_all_balls (GtkWidget * widget)
 {
-  gdk_window_invalidate_rect (widget->window, NULL, FALSE);
+  gdk_window_invalidate_rect (gtk_widget_get_window (widget), NULL, FALSE);
 }
 
 static void
@@ -463,13 +463,13 @@ draw_preview (void)
   for (i = 0; i < MAXNPIECES; i++) {
 
     if (i < npieces)
-      gdk_window_set_back_pixmap (preview_widgets[i]->window,
+      gdk_window_set_back_pixmap (gtk_widget_get_window (preview_widgets[i]),
                                   preview_pixmaps[preview[i] - 1], FALSE);
     else
-      gdk_window_set_back_pixmap (preview_widgets[i]->window,
+      gdk_window_set_back_pixmap (gtk_widget_get_window (preview_widgets[i]),
                                   blank_preview_pixmap, FALSE);
 
-    gdk_window_clear (preview_widgets[i]->window);
+    gdk_window_clear (gtk_widget_get_window (preview_widgets[i]));
   }
 
 }
@@ -827,7 +827,7 @@ draw_grid (void)
     GdkColormap *cmap;
     GdkColor color;
 
-    grid_gc = gdk_gc_new (draw_area->window);
+    grid_gc = gdk_gc_new (gtk_widget_get_window (draw_area));
 
     gdk_color_parse ("#525F6C", &color);
     cmap = gtk_widget_get_colormap (draw_area);
@@ -836,19 +836,20 @@ draw_grid (void)
   }
 
   for (i = boxsize; i < w; i = i + boxsize)
-    gdk_draw_line (draw_area->window, grid_gc, i, 0, i, h);
+    gdk_draw_line (gtk_widget_get_window (draw_area), grid_gc, i, 0, i, h);
 
   for (i = boxsize; i < h; i = i + boxsize)
-    gdk_draw_line (draw_area->window, grid_gc, 0, i, w, i);
+    gdk_draw_line (gtk_widget_get_window (draw_area), grid_gc, 0, i, w, i);
 
-  gdk_draw_rectangle (draw_area->window, grid_gc, FALSE, 0, 0, w - 1, h - 1);
+  gdk_draw_rectangle (gtk_widget_get_window (draw_area), grid_gc, FALSE, 0, 0, 
+                      w - 1, h - 1);
 }
 
 /* Redraw a part of the field */
 static gint
 field_expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer gp)
 {
-  GdkWindow *window = widget->window;
+  GdkWindow *window = gtk_widget_get_window (widget);
   GdkGC *gc;
   guint x_start, x_end, y_start, y_end, i, j, idx;
 
@@ -858,7 +859,7 @@ field_expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer gp)
   y_start = event->area.y / boxsize;
   y_end = (event->area.y + event->area.height - 1) / boxsize + 1;
 
-  gc = gdk_gc_new (draw_area->window);
+  gc = gdk_gc_new (gtk_widget_get_window (draw_area));
 
   for (i = y_start; i < y_end; i++) {
     for (j = x_start; j < x_end; j++) {
@@ -1455,12 +1456,12 @@ game_props_callback (void)
 
     gtk_window_set_resizable (GTK_WINDOW (pref_dialog), FALSE);
     gtk_container_set_border_width (GTK_CONTAINER (pref_dialog), 5);
-    gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (pref_dialog)->vbox), 2);
+    gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pref_dialog))), 2);
 
     vbox = gtk_vbox_new (FALSE, 18);
     gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pref_dialog)->vbox), vbox,
-                        FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (pref_dialog))),
+                        vbox, FALSE, FALSE, 0);
 
     frame = games_frame_new (_("Themes"));
     table = gtk_table_new (2, 2, FALSE);
@@ -1577,9 +1578,10 @@ configure_event_callback (GtkWidget * widget, GdkEventConfigure * event)
     g_object_unref (blank_pixmap);
 
   boxsize = (event->width - 1) / hfieldsize;
-  ball_pixmap = gdk_pixmap_new (draw_area->window, boxsize * 4, boxsize * 7,
-                                -1);
-  blank_pixmap = gdk_pixmap_new (draw_area->window, boxsize, boxsize, -1);
+  ball_pixmap = gdk_pixmap_new (gtk_widget_get_window (draw_area), boxsize * 4, 
+                                boxsize * 7, -1);
+  blank_pixmap = gdk_pixmap_new (gtk_widget_get_window (draw_area), boxsize, 
+                                 boxsize, -1);
   refresh_pixmaps ();
 
   refresh_screen ();
diff --git a/gnobots2/game.c b/gnobots2/game.c
index 41d2b9a..0ccf5fb 100644
--- a/gnobots2/game.c
+++ b/gnobots2/game.c
@@ -1470,7 +1470,7 @@ move_cb (GtkWidget * widget, GdkEventMotion * e, gpointer data)
 
   get_dir (e->x, e->y, &dx, &dy);
 
-  set_cursor_by_direction (widget->window, dx, dy);
+  set_cursor_by_direction (gtk_widget_get_window (widget), dx, dy);
 
   return TRUE;
 }
diff --git a/gnobots2/gnobots.c b/gnobots2/gnobots.c
index 3c804e5..1e3d6fe 100644
--- a/gnobots2/gnobots.c
+++ b/gnobots2/gnobots.c
@@ -153,7 +153,7 @@ save_state_cb (EggSMClient *client,
   int i;
   int xpos, ypos;
 
-  gdk_window_get_origin (app->window, &xpos, &ypos);
+  gdk_window_get_origin (gtk_widget_get_window (app), &xpos, &ypos);
 
   i = 0;
   argv[i++] = (char *) client_data;
@@ -316,15 +316,12 @@ main (int argc, char *argv[])
 
   if (!load_game_configs ()) {
     /* Oops, no configs, we probably haven't been installed properly. */
-    errordialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
+    errordialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR,
 					  GTK_BUTTONS_OK,
 					  "<b>%s</b>\n\n%s",
 					  _("No game data could be found."),
 					  _
 					  ("The program Robots was unable to find any valid game configuration files. Please check that the program is installed correctly."));
-    gtk_label_set_use_markup (GTK_LABEL
-			      (GTK_MESSAGE_DIALOG (errordialog)->label),
-			      TRUE);
     gtk_window_set_resizable (GTK_WINDOW (errordialog), FALSE);
     gtk_dialog_run (GTK_DIALOG (errordialog));
     exit (1);
@@ -334,7 +331,7 @@ main (int argc, char *argv[])
 
   if (!load_game_graphics ()) {
     /* Oops, no graphics, we probably haven't been installed properly. */
-    errordialog = gtk_message_dialog_new (GTK_WINDOW (app),
+    errordialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (app),
 					  GTK_DIALOG_MODAL,
 					  GTK_MESSAGE_ERROR,
 					  GTK_BUTTONS_OK,
@@ -343,10 +340,6 @@ main (int argc, char *argv[])
 					  ("Some graphics files are missing or corrupt."),
 					  _
 					  ("The program Robots was unable to load all the necessary graphics files. Please check that the program is installed correctly."));
-    gtk_label_set_use_markup (GTK_LABEL
-			      (GTK_MESSAGE_DIALOG (errordialog)->label),
-			      TRUE);
-
     gtk_dialog_run (GTK_DIALOG (errordialog));
     exit (1);
   }
diff --git a/gnobots2/graphics.c b/gnobots2/graphics.c
index f3ac89c..6e9c19e 100644
--- a/gnobots2/graphics.c
+++ b/gnobots2/graphics.c
@@ -297,10 +297,10 @@ set_background_color (GdkColor color)
     return;
 
   if (dark_bggc == NULL) {
-    dark_bggc = gdk_gc_new (game_area->window);
-    gdk_gc_copy (dark_bggc, game_area->style->black_gc);
-    light_bggc = gdk_gc_new (game_area->window);
-    gdk_gc_copy (light_bggc, game_area->style->white_gc);
+    dark_bggc = gdk_gc_new (gtk_widget_get_window (game_area));
+    gdk_gc_copy (dark_bggc, gtk_widget_get_style (game_area)->black_gc);
+    light_bggc = gdk_gc_new (gtk_widget_get_window (game_area));
+    gdk_gc_copy (light_bggc, gtk_widget_get_style (game_area)->white_gc);
   }
 
   /* While the two colours are labelled "light" and "dark" which one is
@@ -371,7 +371,8 @@ draw_tile_pixmap (gint tileno, gint x, gint y, GtkWidget * area)
   x *= tile_width;
   y *= tile_height;
 
-  gdk_draw_rectangle (area->window, bg, TRUE, x, y, tile_width, tile_height);
+  gdk_draw_rectangle (gtk_widget_get_window (area), bg, TRUE, x, y, tile_width,
+                      tile_height);
 
   if (rerender_needed)
     render_graphics ();
@@ -379,8 +380,8 @@ draw_tile_pixmap (gint tileno, gint x, gint y, GtkWidget * area)
   if ((tileno < 0) || (tileno >= SCENARIO_PIXMAP_WIDTH)) {
     /* nothing */
   } else {
-    gdk_draw_pixbuf (area->window, area->style->black_gc,
-		     theme_pixbuf,
+    gdk_draw_pixbuf (gtk_widget_get_window (area),
+             gtk_widget_get_style (area)->black_gc, theme_pixbuf,
 		     tileno * tile_width, 0,
 		     x, y, tile_width, tile_height,
 		     GDK_RGB_DITHER_NORMAL, 0, 0);
@@ -573,7 +574,8 @@ draw_bubble (void)
     pmap = splat_pixbuf;
   }
 
-  gdk_draw_pixbuf (game_area->window, game_area->style->black_gc, pmap,
+  gdk_draw_pixbuf (gtk_widget_get_window (game_area), 
+           gtk_widget_get_style (game_area)->black_gc, pmap,
 		   bubble_xo, bubble_yo, bubble_xpos, bubble_ypos,
 		   BUBBLE_WIDTH, BUBBLE_HEIGHT, GDK_RGB_DITHER_NORMAL, 0, 0);
 }
diff --git a/gnobots2/properties.c b/gnobots2/properties.c
index 44ffdf5..aa34db8 100644
--- a/gnobots2/properties.c
+++ b/gnobots2/properties.c
@@ -236,7 +236,7 @@ type_selection (GtkWidget * widget, gpointer data)
 static void
 safe_cb (GtkWidget * widget, gpointer data)
 {
-  properties.safe_moves = GTK_TOGGLE_BUTTON (widget)->active;
+  properties.safe_moves = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
   conf_set_use_safe_moves (properties.safe_moves);
 }
 
@@ -252,7 +252,7 @@ safe_cb (GtkWidget * widget, gpointer data)
 static void
 super_safe_cb (GtkWidget * widget, gpointer data)
 {
-  properties.super_safe_moves = GTK_TOGGLE_BUTTON (widget)->active;
+  properties.super_safe_moves = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
   conf_set_use_super_safe_moves (properties.super_safe_moves);
 }
 
@@ -268,7 +268,7 @@ super_safe_cb (GtkWidget * widget, gpointer data)
 static void
 sound_cb (GtkWidget * widget, gpointer data)
 {
-  properties.sound = GTK_TOGGLE_BUTTON (widget)->active;
+  properties.sound = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
   games_sound_enable (properties.sound);
   conf_set_enable_sound (properties.sound);
 }
@@ -423,15 +423,15 @@ show_properties_dialog (void)
 					 NULL);
   gtk_dialog_set_has_separator (GTK_DIALOG (propbox), FALSE);
   gtk_container_set_border_width (GTK_CONTAINER (propbox), 5);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (propbox)->vbox), 2);
+  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (propbox))), 2);
   /* Set up notebook and add it to hbox of the gtk_dialog */
   g_signal_connect (G_OBJECT (propbox), "destroy",
 		    G_CALLBACK (gtk_widget_destroyed), &propbox);
 
   notebook = gtk_notebook_new ();
   gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (propbox)->vbox), notebook,
-		      TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (propbox))),
+              notebook, TRUE, TRUE, 0);
 
   /* The configuration page */
   cpage = gtk_vbox_new (FALSE, 18);
diff --git a/libgames-support/games-gridframe.c b/libgames-support/games-gridframe.c
index 76ec8ce..3ec8ffa 100644
--- a/libgames-support/games-gridframe.c
+++ b/libgames-support/games-gridframe.c
@@ -154,7 +154,7 @@ static void
 games_grid_frame_size_request (GtkWidget * widget,
 			       GtkRequisition * requisition)
 {
-  GtkWidget *child = GTK_BIN (widget)->child;
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
 
   requisition->width = 1;
   requisition->height = 1;
@@ -169,7 +169,7 @@ games_grid_frame_size_allocate (GtkWidget * widget,
 				GtkAllocation * allocation)
 {
   GamesGridFrame *frame = GAMES_GRID_FRAME (widget);
-  GtkWidget *child = GTK_BIN (widget)->child;
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
   GtkAllocation child_allocation;
   gint xsize, ysize, size;
 
@@ -195,7 +195,7 @@ games_grid_frame_size_allocate (GtkWidget * widget,
        child_allocation.y != frame->old_allocation.y ||
        child_allocation.width != frame->old_allocation.width ||
        child_allocation.height != frame->old_allocation.height))
-    gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
+    gdk_window_invalidate_rect (gtk_widget_get_window (widget), &widget->allocation, FALSE);
 
   if (child && GTK_WIDGET_VISIBLE (child))
     gtk_widget_size_allocate (child, &child_allocation);
diff --git a/libgames-support/games-scores-dialog.c b/libgames-support/games-scores-dialog.c
index ba253a5..90857a2 100644
--- a/libgames-support/games-scores-dialog.c
+++ b/libgames-support/games-scores-dialog.c
@@ -412,7 +412,7 @@ void games_scores_dialog_set_hilight (GamesScoresDialog *self, guint pos)
 void games_scores_dialog_set_buttons (GamesScoresDialog *self, guint buttons)
 {
   /* Remove an existing buttons. */
-  gtk_container_foreach (GTK_CONTAINER (GTK_DIALOG (self)->action_area),
+  gtk_container_foreach (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (self))),
                          (GtkCallback) (gtk_widget_destroy), NULL);
 
   /* The default is a single close button, suitable for the scores
@@ -475,7 +475,7 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
 
   gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
   gtk_container_set_border_width (GTK_CONTAINER (self), 5);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (self)->vbox), 2);
+  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 2);
 
   g_signal_connect (G_OBJECT (self), "show", 
 		      G_CALLBACK (games_scores_dialog_show), NULL);
@@ -484,8 +484,8 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
 
   vbox = gtk_vbox_new (FALSE, 6);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-  gtk_box_pack_end (GTK_BOX (GTK_DIALOG (self)->vbox), vbox, TRUE, TRUE, 
-                    0);
+  gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))),
+                    vbox, TRUE, TRUE, 0);
 
   scroll = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]