[gnome-games] Gseal: mostly allocation fixes



commit fe67e7f530bb5838045f0e03bdac344543b62897
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date:   Tue Sep 1 01:17:10 2009 +0200

    Gseal: mostly allocation fixes
    
    Bug #586731

 aisleriot/board-noclutter.c            |   21 ++++++++++++++-------
 aisleriot/stats-dialog.c               |    9 ++++++---
 aisleriot/window.c                     |    8 ++++----
 glines/glines.c                        |    7 +++++--
 gnomine/gnomine.c                      |    8 ++++++--
 gnomine/minefield.c                    |   14 +++++++++-----
 gnotravex/gnotravex.c                  |    8 +++++---
 libgames-support/games-scores-dialog.c |    1 +
 mahjongg/drawing.c                     |    1 +
 9 files changed, 51 insertions(+), 26 deletions(-)
---
diff --git a/aisleriot/board-noclutter.c b/aisleriot/board-noclutter.c
index 8641d23..2c95832 100644
--- a/aisleriot/board-noclutter.c
+++ b/aisleriot/board-noclutter.c
@@ -114,6 +114,8 @@ struct _AisleriotBoardPrivate
   GamesCardTheme *theme;
   CardSize card_size;
 
+  GtkAllocation allocation;
+
   double width;
   double height;
 
@@ -760,7 +762,7 @@ slot_update_geometry (AisleriotBoard *board,
         max_dy = slot->expansion.dy;
 
       /* Calculate the compressed_dy that will let us fit within the board */
-      y_from_bottom = ((double) (widget->allocation.height - slot->rect.y)) / ((double) priv->card_size.height);
+      y_from_bottom = ((double) (priv->allocation.height - slot->rect.y)) / ((double) priv->card_size.height);
       dy = (y_from_bottom - MAX_OVERHANG) / n_cards;
       dy = CLAMP (dy, MIN_DELTA, max_dy);
     } else if (slot->expanded_right) {
@@ -782,7 +784,7 @@ slot_update_geometry (AisleriotBoard *board,
         if (slot->dx_set)
           max_dx = slot->expansion.dx;
 
-        x_from_right = ((double) (widget->allocation.width - slot->rect.x)) / ((double) priv->card_size.width);
+        x_from_right = ((double) (priv->allocation.width - slot->rect.x)) / ((double) priv->card_size.width);
         dx = (x_from_right - MAX_OVERHANG) / n_cards;
         dx = CLAMP (dx, MIN_DELTA, max_dx);
 
@@ -931,8 +933,8 @@ aisleriot_board_setup_geometry (AisleriotBoard *board)
   g_return_if_fail (GTK_WIDGET_REALIZED (widget));
   g_return_if_fail (priv->width > 0 && priv->height > 0);
 
-  priv->xslotstep = ((double) widget->allocation.width) / priv->width;
-  priv->yslotstep = ((double) widget->allocation.height) / priv->height;
+  priv->xslotstep = ((double) priv->allocation.width) / priv->width;
+  priv->yslotstep = ((double) priv->allocation.height) / priv->height;
 
   size_changed = games_card_images_set_size (priv->images,
                                              priv->xslotstep,
@@ -947,12 +949,12 @@ aisleriot_board_setup_geometry (AisleriotBoard *board)
   if (priv->xslotstep > (card_size.width * 3) / 2) {
     priv->xslotstep = (card_size.width * 3) / 2;
     /* FIXMEchpe: if there are expand-right slots, reserve the space for them instead? */
-    priv->xbaseoffset = (widget->allocation.width - priv->xslotstep * priv->width) / 2;
+    priv->xbaseoffset = (priv->allocation.width - priv->xslotstep * priv->width) / 2;
   }
   if (priv->yslotstep > (card_size.height * 3) / 2) {
     priv->yslotstep = (card_size.height * 3) / 2;
     /* FIXMEchpe: if there are expand-down slots, reserve the space for them instead?
-       priv->ybaseoffset = (widget->allocation.height - priv->yslotstep * priv->height) / 2;
+       priv->ybaseoffset = (priv->allocation.height - priv->yslotstep * priv->height) / 2;
     */
   }
 
@@ -2599,7 +2601,7 @@ aisleriot_board_size_allocate (GtkWidget *widget,
   AisleriotBoardPrivate *priv = board->priv;
   gboolean is_same;
 
-  is_same = (memcmp (&widget->allocation, allocation, sizeof (GtkAllocation)) == 0);
+  is_same = (memcmp (&priv->allocation, allocation, sizeof (GtkAllocation)) == 0);
   
   GTK_WIDGET_CLASS (aisleriot_board_parent_class)->size_allocate (widget, allocation);
 
@@ -2608,6 +2610,11 @@ aisleriot_board_size_allocate (GtkWidget *widget,
 
   priv->force_geometry_update = FALSE;
 
+  priv->allocation.x = allocation->x;
+  priv->allocation.y = allocation->y;
+  priv->allocation.width = allocation->width;
+  priv->allocation.height = allocation->height;
+
   if (GTK_WIDGET_REALIZED (widget)) {
     aisleriot_board_setup_geometry (board);
   }
diff --git a/aisleriot/stats-dialog.c b/aisleriot/stats-dialog.c
index 13dbe93..d86cfca 100644
--- a/aisleriot/stats-dialog.c
+++ b/aisleriot/stats-dialog.c
@@ -22,6 +22,7 @@
 
 #include <gtk/gtk.h>
 
+#include <libgames-support/games-gtk-compat.h>
 #include <libgames-support/games-stock.h>
 
 #ifndef HAVE_HILDON
@@ -116,20 +117,22 @@ aisleriot_stats_dialog_init (AisleriotStatsDialog *stats_dialog)
 {
   AisleriotStatsDialogPrivate *priv;
   GtkDialog *dialog = GTK_DIALOG (stats_dialog);
-  GtkWidget *vbox, *hbox;
+  GtkWidget *vbox, *hbox, *content_area;
   GtkTable *table;
 
   priv = stats_dialog->priv = AISLERIOT_STATS_DIALOG_GET_PRIVATE (stats_dialog);
 
   gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
 
+  content_area = gtk_dialog_get_content_area (dialog);
+
   gtk_dialog_set_has_separator (dialog, FALSE);
   gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
+  gtk_box_set_spacing (GTK_BOX (content_area), 2);
 
   vbox = gtk_vbox_new (FALSE, 18);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-  gtk_box_pack_start (GTK_BOX (dialog->vbox), vbox, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (content_area), vbox, FALSE, FALSE, 0);
   gtk_widget_show (vbox);
 
   priv->game_label = GTK_LABEL (gtk_label_new (NULL));
diff --git a/aisleriot/window.c b/aisleriot/window.c
index e4a9a4a..e558e40 100644
--- a/aisleriot/window.c
+++ b/aisleriot/window.c
@@ -222,7 +222,7 @@ select_game_cb (GtkAction *action,
   GtkWidget *scrolled_window;
   GtkTreeViewColumn *column;
   GtkCellRenderer *renderer;
-  GtkWidget *hbox;
+  GtkWidget *hbox, *content_area;
   GtkTreeIter current_iter, selection_iter;
   gboolean current_iter_set = FALSE;
   const char *current_game_file;
@@ -298,12 +298,12 @@ select_game_cb (GtkAction *action,
 
   gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
   gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
+  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+  gtk_box_set_spacing (GTK_BOX (content_area), 2);
 
   hbox = gtk_hbox_new (FALSE, 12);
   gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
-                      hbox, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
   g_signal_connect (list_view, "row-activated",
                     G_CALLBACK (select_game_row_activated_cb), dialog);
 
diff --git a/glines/glines.c b/glines/glines.c
index 2123303..84ffb22 100644
--- a/glines/glines.c
+++ b/glines/glines.c
@@ -39,6 +39,7 @@
 #include <libgames-support/games-files.h>
 #include <libgames-support/games-frame.h>
 #include <libgames-support/games-gridframe.h>
+#include <libgames-support/games-gtk-compat.h>
 #include <libgames-support/games-help.h>
 #include <libgames-support/games-preimage.h>
 #include <libgames-support/games-runtime.h>
@@ -819,9 +820,11 @@ draw_grid (void)
   static GdkGC *grid_gc;
   guint w, h;
   guint i;
+  GtkAllocation allocation;
 
-  w = draw_area->allocation.width;
-  h = draw_area->allocation.height;
+  gtk_widget_get_allocation (draw_area, &allocation);
+  w = allocation.width;
+  h = allocation.height;
 
   if (!grid_gc) {
     GdkColormap *cmap;
diff --git a/gnomine/gnomine.c b/gnomine/gnomine.c
index 537d029..2a39bdb 100644
--- a/gnomine/gnomine.c
+++ b/gnomine/gnomine.c
@@ -35,6 +35,7 @@
 #include <libgames-support/games-clock.h>
 #include <libgames-support/games-conf.h>
 #include <libgames-support/games-frame.h>
+#include <libgames-support/games-gtk-compat.h>
 #include <libgames-support/games-help.h>
 #include <libgames-support/games-runtime.h>
 #include <libgames-support/games-scores.c>
@@ -262,16 +263,19 @@ new_game (void)
   gint x, y;
   static gint size_table[3][3] = { {8, 8, 10}, {16, 16, 40}, {30, 16, 99} };
   GtkMineField *mf = GTK_MINEFIELD (mfield);
+  GtkAllocation allocation;
 
   games_clock_stop (GAMES_CLOCK (clk));
   games_clock_reset (GAMES_CLOCK (clk));
   show_face (pm_smile);
 
+
   /* get window size and mine square size (gtk_minefield_restart() may change it) */
   gtk_window_get_size (GTK_WINDOW (window), &width, &height);
   size = mf->minesizepixels;
-  w_diff = width - mfield->allocation.width;
-  h_diff = height - mfield->allocation.height;
+  gtk_widget_get_allocation (mfield, &allocation);
+  w_diff = width - allocation.width;
+  h_diff = height - allocation.height;
 
   if (fsize == 3) {
     x = xsize;
diff --git a/gnomine/minefield.c b/gnomine/minefield.c
index f16725b..6d554d6 100644
--- a/gnomine/minefield.c
+++ b/gnomine/minefield.c
@@ -31,6 +31,7 @@
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
+#include <libgames-support/games-gtk-compat.h>
 #include <libgames-support/games-runtime.h>
 #include <libgames-support/games-preimage.h>
 
@@ -330,6 +331,7 @@ gtk_minefield_realize (GtkWidget * widget)
   GtkMineField *mfield;
   GdkWindowAttr attributes;
   gint attributes_mask;
+  GtkAllocation allocation;
 
   g_return_if_fail (widget != NULL);
   g_return_if_fail (GTK_IS_MINEFIELD (widget));
@@ -337,11 +339,13 @@ gtk_minefield_realize (GtkWidget * widget)
   mfield = GTK_MINEFIELD (widget);
   GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
 
+  gtk_widget_get_allocation (widget, &allocation);
+
   attributes.window_type = GDK_WINDOW_CHILD;
-  attributes.x = widget->allocation.x;
-  attributes.y = widget->allocation.y;
-  attributes.width = widget->allocation.width;
-  attributes.height = widget->allocation.height;
+  attributes.x = allocation.x;
+  attributes.y = allocation.y;
+  attributes.width = allocation.width;
+  attributes.height = allocation.height;
   attributes.wclass = GDK_INPUT_OUTPUT;
   attributes.visual = gtk_widget_get_visual (widget);
   attributes.colormap = gtk_widget_get_colormap (widget);
@@ -378,7 +382,7 @@ gtk_minefield_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
   guint xofs, yofs;
   GtkMineField *mfield;
 
-  widget->allocation = *allocation;
+  gtk_widget_set_allocation (widget, allocation);
 
   mfield = GTK_MINEFIELD (widget);
 
diff --git a/gnotravex/gnotravex.c b/gnotravex/gnotravex.c
index 11333e1..e76c88e 100644
--- a/gnotravex/gnotravex.c
+++ b/gnotravex/gnotravex.c
@@ -32,6 +32,7 @@
 
 #include <libgames-support/games-clock.h>
 #include <libgames-support/games-conf.h>
+#include <libgames-support/games-gtk-compat.h>
 #include <libgames-support/games-help.h>
 #include <libgames-support/games-scores.h>
 #include <libgames-support/games-scores-dialog.h>
@@ -1594,14 +1595,15 @@ create_menu (GtkUIManager * ui_manager)
 void
 make_buffer (GtkWidget * widget)
 {
+  GtkAllocation allocation;
 
   if (buffer)
     g_object_unref (buffer);
 
+  gtk_widget_get_allocation (widget, &allocation);
   buffer = gdk_pixmap_new (gtk_widget_get_window (widget),
-                           widget->allocation.width,
-                           widget->allocation.height, -1);
-
+                           allocation.width,
+                           allocation.height, -1);
 }
 
 void
diff --git a/libgames-support/games-scores-dialog.c b/libgames-support/games-scores-dialog.c
index 90857a2..4f96aae 100644
--- a/libgames-support/games-scores-dialog.c
+++ b/libgames-support/games-scores-dialog.c
@@ -28,6 +28,7 @@
 
 #include "games-scores-dialog.h"
 #include "games-scores-dialog-private.h"
+#include "games-gtk-compat.h"
 
 G_DEFINE_TYPE (GamesScoresDialog, games_scores_dialog, GTK_TYPE_DIALOG);
 
diff --git a/mahjongg/drawing.c b/mahjongg/drawing.c
index 72e2de3..f93a130 100644
--- a/mahjongg/drawing.c
+++ b/mahjongg/drawing.c
@@ -20,6 +20,7 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#include <libgames-support/games-gtk-compat.h>
 #include <libgames-support/games-preimage.h>
 #include <libgames-support/games-runtime.h>
 



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