[metacity] build: Use accessor functions



commit 63834e0040d7d651f5ae61c80b1c8cf5e57e57be
Author: Florian MÃllner <fmuellner gnome org>
Date:   Tue May 24 21:23:36 2011 +0200

    build: Use accessor functions
    
    Direct struct access has been deprecated, so use the appropriate
    replacements to build with GSEAL enabled.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=612491

 src/ui/frames.c         |   29 +++++++++++++++++---
 src/ui/metaaccellabel.c |   39 +++++++++++++++++-----------
 src/ui/preview-widget.c |   13 +++++----
 src/ui/resizepopup.c    |    4 +-
 src/ui/tabpopup.c       |   65 +++++++++++++++++++++++++++++-----------------
 src/ui/theme-viewer.c   |   17 +++++++-----
 src/ui/themewidget.c    |   24 +++++++++++------
 src/ui/ui.c             |   14 ++++++----
 8 files changed, 131 insertions(+), 74 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 65dfcf8..be4e781 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -110,6 +110,25 @@ static GtkWidgetClass *parent_class = NULL;
 
 G_DEFINE_TYPE (MetaFrames, meta_frames, GTK_TYPE_WINDOW);
 
+
+static GObject *
+meta_frames_constructor (GType                  gtype,
+                         guint                  n_properties,
+                         GObjectConstructParam *properties)
+{
+  GObject *object;
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (parent_class);
+  object = gobject_class->constructor (gtype, n_properties, properties);
+
+  g_object_set (object,
+                "type", GTK_WINDOW_POPUP,
+                NULL);
+
+  return object;
+}
+
 static void
 meta_frames_class_init (MetaFramesClass *class)
 {
@@ -123,6 +142,7 @@ meta_frames_class_init (MetaFramesClass *class)
 
   parent_class = g_type_class_peek_parent (class);
 
+  gobject_class->constructor = meta_frames_constructor;
   gobject_class->finalize = meta_frames_finalize;
   object_class->destroy = meta_frames_destroy;
 
@@ -180,8 +200,6 @@ prefs_changed_callback (MetaPreference pref,
 static void
 meta_frames_init (MetaFrames *frames)
 {
-  GTK_WINDOW (frames)->type = GTK_WINDOW_POPUP;
-
   frames->text_heights = g_hash_table_new (NULL, NULL);
   
   frames->frames = g_hash_table_new (unsigned_long_hash, unsigned_long_equal);
@@ -570,8 +588,9 @@ meta_frames_attach_style (MetaFrames  *frames,
     gtk_style_detach (frame->style);
 
   /* Weirdly, gtk_style_attach() steals a reference count from the style passed in */
-  g_object_ref (GTK_WIDGET (frames)->style);
-  frame->style = gtk_style_attach (GTK_WIDGET (frames)->style, frame->window);
+  g_object_ref (gtk_widget_get_style (GTK_WIDGET (frames)));
+  frame->style = gtk_style_attach (gtk_widget_get_style (GTK_WIDGET (frames)),
+                                   frame->window);
 }
 
 void
@@ -2549,7 +2568,7 @@ meta_frames_set_window_background (MetaFrames   *frames,
       /* Set A in ARGB to window_background_alpha, if we have ARGB */
 
       visual = gtk_widget_get_visual (GTK_WIDGET (frames));
-      if (visual->depth == 32) /* we have ARGB */
+      if (gdk_visual_get_depth (visual) == 32) /* we have ARGB */
         {
           color.pixel = (color.pixel & 0xffffff) &
             style->window_background_alpha << 24;
diff --git a/src/ui/metaaccellabel.c b/src/ui/metaaccellabel.c
index 6b02fc4..1018f20 100644
--- a/src/ui/metaaccellabel.c
+++ b/src/ui/metaaccellabel.c
@@ -240,49 +240,58 @@ meta_accel_label_expose_event (GtkWidget      *widget,
 
   if (gtk_widget_is_drawable (GTK_WIDGET (accel_label)))
     {
+      GtkAllocation allocation;
+      GtkRequisition requisition;
       int ac_width;
 
+      gtk_widget_get_allocation (widget, &allocation);
+      gtk_widget_get_requisition (widget, &requisition);
       ac_width = meta_accel_label_get_accel_width (accel_label);
 
-      if (widget->allocation.width >= widget->requisition.width + ac_width)
+      if (allocation.width >= requisition.width + ac_width)
 	{
           GtkTextDirection direction = gtk_widget_get_direction (widget);
-	  gint x;
-	  gint y;
+	  gfloat xalign, yalign;
+	  gint x, y;
+	  gint xpad, ypad;
+
+	  gtk_misc_get_padding (misc, &xpad, &ypad);
+	  gtk_misc_get_alignment (misc, &xalign, &yalign);
 
           if (direction == GTK_TEXT_DIR_RTL)
             {
-              widget->allocation.x += ac_width;
+              allocation.x += ac_width;
             }
-	  widget->allocation.width -= ac_width;
+	  allocation.width -= ac_width;
+	  gtk_widget_set_allocation (widget, &allocation);
 
 	  if (GTK_WIDGET_CLASS (parent_class)->expose_event)
 	    GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
 
           if (direction == GTK_TEXT_DIR_RTL)
             {
-              widget->allocation.x -= ac_width;
+              allocation.x -= ac_width;
             }
-          widget->allocation.width += ac_width;
+          allocation.width += ac_width;
+	  gtk_widget_set_allocation (widget, &allocation);
 
           if (direction == GTK_TEXT_DIR_RTL)
             {
-              x = widget->allocation.x + misc->xpad;
+              x = allocation.x + xpad;
             }
           else
             {
-              x = widget->allocation.x + widget->allocation.width - misc->xpad - ac_width;
+              x = allocation.x + allocation.width - xpad - ac_width;
             }
 
-	  y = (widget->allocation.y * (1.0 - misc->yalign) +
-	       (widget->allocation.y + widget->allocation.height -
-		(widget->requisition.height - misc->ypad * 2)) *
-	       misc->yalign) + 1.5;
+	  y = (allocation.y * (1.0 - yalign) +
+	       (allocation.y + allocation.height -
+		(requisition.height - ypad * 2)) * yalign) + 1.5;
 
 	  layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string);
 
-          gtk_paint_layout (widget->style,
-                            widget->window,
+          gtk_paint_layout (gtk_widget_get_style (widget),
+                            gtk_widget_get_window (widget),
                             gtk_widget_get_state (widget),
 			    FALSE,
                             &event->area,
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index 422d9a6..7a7b19f 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -293,14 +293,14 @@ meta_preview_size_allocate (GtkWidget         *widget,
 {
   MetaPreview *preview;
   int border_width;
-  GtkAllocation child_allocation;
+  GtkAllocation widget_allocation, child_allocation;
   GtkWidget *child;
   
   preview = META_PREVIEW (widget);
 
   ensure_info (preview);
   
-  widget->allocation = *allocation;
+  gtk_widget_set_allocation (widget, allocation);
 
   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
   
@@ -308,11 +308,12 @@ meta_preview_size_allocate (GtkWidget         *widget,
   if (child &&
       gtk_widget_get_visible (child))
     {
-      child_allocation.x = widget->allocation.x + border_width + preview->left_width;
-      child_allocation.y = widget->allocation.y + border_width + preview->top_height;
+      gtk_widget_get_allocation (widget, &widget_allocation);
+      child_allocation.x = widget_allocation.x + border_width + preview->left_width;
+      child_allocation.y = widget_allocation.y + border_width + preview->top_height;
       
-      child_allocation.width = MAX (1, widget->allocation.width - border_width * 2 - preview->left_width - preview->right_width);
-      child_allocation.height = MAX (1, widget->allocation.height - border_width * 2 - preview->top_height - preview->bottom_height);
+      child_allocation.width = MAX (1, widget_allocation.width - border_width * 2 - preview->left_width - preview->right_width);
+      child_allocation.height = MAX (1, widget_allocation.height - border_width * 2 - preview->top_height - preview->bottom_height);
 
       gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)), &child_allocation);
     }
diff --git a/src/ui/resizepopup.c b/src/ui/resizepopup.c
index 3b200c0..c9e69fc 100644
--- a/src/ui/resizepopup.c
+++ b/src/ui/resizepopup.c
@@ -126,7 +126,7 @@ update_size_window (MetaResizePopup *popup)
   if (gtk_widget_get_realized (popup->size_window))
     {
       /* using move_resize to avoid jumpiness */
-      gdk_window_move_resize (popup->size_window->window,
+      gdk_window_move_resize (gtk_widget_get_window (popup->size_window),
                               x, y,
                               width, height);
     }
@@ -146,7 +146,7 @@ sync_showing (MetaResizePopup *popup)
         gtk_widget_show (popup->size_window);
       
       if (popup->size_window && gtk_widget_get_realized (popup->size_window))
-        gdk_window_raise (popup->size_window->window);
+        gdk_window_raise (gtk_widget_get_window (popup->size_window));
     }
   else
     {
diff --git a/src/ui/tabpopup.c b/src/ui/tabpopup.c
index 0d2ed89..2f1776a 100644
--- a/src/ui/tabpopup.c
+++ b/src/ui/tabpopup.c
@@ -458,6 +458,7 @@ display_entry (MetaTabPopup *popup,
   GdkRectangle rect;
   GdkRegion *region;
   GdkRegion *inner_region;
+  GdkWindow *window;
 
   
   if (popup->current_selected_entry)
@@ -477,27 +478,29 @@ display_entry (MetaTabPopup *popup,
 
   if (popup->outline)
     {
+      window = gtk_widget_get_window (popup->outline_window);
+
       /* Do stuff behind gtk's back */
-      gdk_window_hide (popup->outline_window->window);
+      gdk_window_hide (window);
       meta_core_increment_event_serial (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
   
       rect = te->rect;
       rect.x = 0;
       rect.y = 0;
 
-      gdk_window_move_resize (popup->outline_window->window,
+      gdk_window_move_resize (window,
                               te->rect.x, te->rect.y,
                               te->rect.width, te->rect.height);
   
-      gdk_window_set_background (popup->outline_window->window,
-                                 &popup->outline_window->style->black);
+      gdk_window_set_background (window,
+                                 &gtk_widget_get_style (popup->outline_window)->black);
   
       region = gdk_region_rectangle (&rect);
       inner_region = gdk_region_rectangle (&te->inner_rect);
       gdk_region_subtract (region, inner_region);
       gdk_region_destroy (inner_region);
   
-      gdk_window_shape_combine_region (popup->outline_window->window,
+      gdk_window_shape_combine_region (window,
                                        region,
                                        0, 0);
 
@@ -509,7 +512,7 @@ display_entry (MetaTabPopup *popup,
        * with gdk functions.
        */
       gtk_widget_set_mapped (popup->outline_window, TRUE);
-      gdk_window_show_unraised (popup->outline_window->window);
+      gdk_window_show_unraised (window);
     }
 
   /* Must be before we handle an expose for the outline window */
@@ -694,32 +697,41 @@ meta_select_image_expose_event (GtkWidget      *widget,
 {
   if (META_SELECT_IMAGE (widget)->selected)
     {
-      int x, y, w, h;
+      GtkAllocation allocation;
+      GtkRequisition requisition;
       GtkMisc *misc;
       GtkStyle *style;
       GtkStateType state;
+      GdkWindow *window;
+      int x, y, w, h;
+      int xpad, ypad;
+      float xalign, yalign;
       cairo_t *cr;
 
       misc = GTK_MISC (widget);
       
-      x = (widget->allocation.x * (1.0 - misc->xalign) +
-           (widget->allocation.x + widget->allocation.width
-            - (widget->requisition.width - misc->xpad * 2)) *
-           misc->xalign) + 0.5;
-      y = (widget->allocation.y * (1.0 - misc->yalign) +
-           (widget->allocation.y + widget->allocation.height
-            - (widget->requisition.height - misc->ypad * 2)) *
-           misc->yalign) + 0.5;
+      gtk_widget_get_allocation (widget, &allocation);
+      gtk_widget_get_requisition (widget, &requisition);
+      gtk_misc_get_padding (misc, &xpad, &ypad);
+      gtk_misc_get_alignment (misc, &xalign, &yalign);
+
+      x = (allocation.x * (1.0 - xalign) +
+           (allocation.x + allocation.width
+            - (requisition.width - xpad * 2)) * xalign) + 0.5;
+      y = (allocation.y * (1.0 - yalign) +
+           (allocation.y + allocation.height
+            - (requisition.height - ypad * 2)) * yalign) + 0.5;
 
       x -= INSIDE_SELECT_RECT + 1;
       y -= INSIDE_SELECT_RECT + 1;      
       
-      w = widget->requisition.width - OUTSIDE_SELECT_RECT * 2 - 1;
-      h = widget->requisition.height - OUTSIDE_SELECT_RECT * 2 - 1;
+      w = requisition.width - OUTSIDE_SELECT_RECT * 2 - 1;
+      h = requisition.height - OUTSIDE_SELECT_RECT * 2 - 1;
 
+      window = gtk_widget_get_window (widget);
       style = gtk_widget_get_style (widget);
       state = gtk_widget_get_state (widget);
-      cr = gdk_cairo_create (widget->window);
+      cr = gdk_cairo_create (window);
 
       cairo_set_line_width (cr, 2.0);
       gdk_cairo_set_source_color (cr, &style->fg[state]);
@@ -889,7 +901,9 @@ meta_select_workspace_expose_event (GtkWidget      *widget,
 {
   MetaWorkspace *workspace;
   WnckWindowDisplayInfo *windows;
+  GtkAllocation allocation;
   GtkStyle *style;
+  GdkWindow *window;
   cairo_t *cr;
   int i, n_windows;
   GList *tmp, *list;
@@ -929,12 +943,15 @@ meta_select_workspace_expose_event (GtkWidget      *widget,
 
   g_list_free (list);
 
+  window = gtk_widget_get_window (widget);
+  gtk_widget_get_allocation (widget, &allocation);
+
   wnck_draw_workspace (widget,
-                       widget->window,
+                       window,
                        SELECT_OUTLINE_WIDTH,
                        SELECT_OUTLINE_WIDTH,
-                       widget->allocation.width - SELECT_OUTLINE_WIDTH * 2,
-                       widget->allocation.height - SELECT_OUTLINE_WIDTH * 2,
+                       allocation.width - SELECT_OUTLINE_WIDTH * 2,
+                       allocation.height - SELECT_OUTLINE_WIDTH * 2,
                        workspace->screen->rect.width,
                        workspace->screen->rect.height,
                        NULL,
@@ -947,7 +964,7 @@ meta_select_workspace_expose_event (GtkWidget      *widget,
   if (META_SELECT_WORKSPACE (widget)->selected)
     {
       style = gtk_widget_get_style (widget);
-      cr = gdk_cairo_create (widget->window);
+      cr = gdk_cairo_create (window);
 
       gdk_cairo_set_source_color (cr,
                                   &style->fg[gtk_widget_get_state (widget)]);
@@ -955,8 +972,8 @@ meta_select_workspace_expose_event (GtkWidget      *widget,
 
       cairo_rectangle (cr,
                        SELECT_OUTLINE_WIDTH / 2.0, SELECT_OUTLINE_WIDTH / 2.0,
-                       widget->allocation.width - SELECT_OUTLINE_WIDTH,
-                       widget->allocation.height - SELECT_OUTLINE_WIDTH);
+                       allocation.width - SELECT_OUTLINE_WIDTH,
+                       allocation.height - SELECT_OUTLINE_WIDTH);
       cairo_stroke (cr);
 
       cairo_destroy (cr);
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index 7067d59..ab4a6b5 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -776,6 +776,7 @@ main (int argc, char **argv)
 {
   GtkWidget *window;
   GtkWidget *collection;
+  GtkStyle *style;
   GError *err;
   clock_t start, end;
   GtkWidget *notebook;
@@ -850,26 +851,28 @@ main (int argc, char **argv)
                     G_CALLBACK (gtk_main_quit), NULL);
 
   gtk_widget_realize (window);
-  g_assert (window->style);
-  g_assert (window->style->font_desc);
+  style = gtk_widget_get_style (window);
+
+  g_assert (style);
+  g_assert (style->font_desc);
   
   notebook = gtk_notebook_new ();
   gtk_container_add (GTK_CONTAINER (window), notebook);
 
   collection = preview_collection (FONT_SIZE_NORMAL,
-                                   window->style->font_desc);
+                                   style->font_desc);
   gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                             collection,
                             gtk_label_new (_("Normal Title Font")));
   
   collection = preview_collection (FONT_SIZE_SMALL,
-                                   window->style->font_desc);
+                                   style->font_desc);
   gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                             collection,
                             gtk_label_new (_("Small Title Font")));
   
   collection = preview_collection (FONT_SIZE_LARGE,
-                                   window->style->font_desc);
+                                   style->font_desc);
   gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                             collection,
                             gtk_label_new (_("Large Title Font")));
@@ -920,7 +923,7 @@ get_flags (GtkWidget *widget)
 static int
 get_text_height (GtkWidget *widget)
 {
-  return meta_pango_font_desc_get_text_height (widget->style->font_desc,
+  return meta_pango_font_desc_get_text_height (gtk_widget_get_style (widget)->font_desc,
                                                gtk_widget_get_pango_context (widget));
 }
 
@@ -1001,7 +1004,7 @@ run_theme_benchmark (void)
       /* Creating the pixmap in the loop is right, since
        * GDK does the same with its double buffering.
        */
-      pixmap = gdk_pixmap_new (widget->window,
+      pixmap = gdk_pixmap_new (gtk_widget_get_window (widget),
                                client_width + left_width + right_width,
                                client_height + top_height + bottom_height,
                                -1);
diff --git a/src/ui/themewidget.c b/src/ui/themewidget.c
index 1af0518..21227d7 100644
--- a/src/ui/themewidget.c
+++ b/src/ui/themewidget.c
@@ -86,9 +86,12 @@ meta_area_expose (GtkWidget      *widget,
                   GdkEventExpose *event)
 {
   MetaArea *area;
+  GtkAllocation allocation;
+  GtkRequisition requisition;
   GtkMisc *misc;
   gint x, y;
-  gfloat xalign;
+  gint xpad, ypad;
+  gfloat xalign, yalign;
 
   g_return_val_if_fail (META_IS_AREA (widget), FALSE);
   g_return_val_if_fail (event != NULL, FALSE);
@@ -98,16 +101,19 @@ meta_area_expose (GtkWidget      *widget,
       area = META_AREA (widget);
       misc = GTK_MISC (widget);
 
-      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
-	xalign = misc->xalign;
-      else
-	xalign = 1.0 - misc->xalign;
+      gtk_widget_get_allocation (widget, &allocation);
+      gtk_widget_get_requisition (widget, &requisition);
+      gtk_misc_get_alignment (misc, &xalign, &yalign);
+      gtk_misc_get_padding (misc, &xpad, &ypad);
+
+      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+	xalign = 1.0 - xalign;
   
-      x = floor (widget->allocation.x + misc->xpad
-		 + ((widget->allocation.width - widget->requisition.width) * xalign)
+      x = floor (allocation.x + xpad
+		 + ((allocation.width - requisition.width) * xalign)
 		 + 0.5);
-      y = floor (widget->allocation.y + misc->ypad 
-		 + ((widget->allocation.height - widget->requisition.height) * misc->yalign)
+      y = floor (allocation.y + ypad
+		 + ((allocation.height - requisition.height) * yalign)
 		 + 0.5);
       
       if (area->expose_func)
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 5ef4f52..33adb0f 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -520,7 +520,7 @@ meta_image_window_new (Display *xdisplay,
   gtk_window_set_screen (GTK_WINDOW (iw->window), gscreen);
  
   gtk_widget_realize (iw->window);
-  iw->pixmap = gdk_pixmap_new (iw->window->window,
+  iw->pixmap = gdk_pixmap_new (gtk_widget_get_window (iw->window),
                                max_width, max_height,
                                -1);
   
@@ -558,6 +558,7 @@ meta_image_window_set (MetaImageWindow *iw,
                        int              x,
                        int              y)
 {
+  GdkWindow *window;
   cairo_t *cr;
 
   /* We use a back pixmap to avoid having to handle exposes, because
@@ -566,7 +567,7 @@ meta_image_window_set (MetaImageWindow *iw,
    */
 
   gdk_draw_pixbuf (iw->pixmap,
-                   iw->window->style->black_gc,
+                   gtk_widget_get_style (iw->window)->black_gc,
 		   pixbuf,
                    0, 0,
                    0, 0,
@@ -579,16 +580,17 @@ meta_image_window_set (MetaImageWindow *iw,
   cairo_paint (cr);
   cairo_destroy (cr);
 
-  gdk_window_set_back_pixmap (iw->window->window,
+  window = gtk_widget_get_window (iw->window);
+  gdk_window_set_back_pixmap (window,
                               iw->pixmap,
                               FALSE);
   
-  gdk_window_move_resize (iw->window->window,
+  gdk_window_move_resize (window,
                           x, y,
                           gdk_pixbuf_get_width (pixbuf),
                           gdk_pixbuf_get_height (pixbuf));
 
-  gdk_window_clear (iw->window->window);
+  gdk_window_clear (window);
 }
 
 static GdkColormap*
@@ -618,7 +620,7 @@ get_cmap (GdkPixmap *pixmap)
 
   /* Be sure we aren't going to blow up due to visual mismatch */
   if (cmap &&
-      (gdk_colormap_get_visual (cmap)->depth !=
+      (gdk_visual_get_depth (gdk_colormap_get_visual (cmap)) !=
        gdk_drawable_get_depth (pixmap)))
     {
       cmap = NULL;



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