[cheese] Use accessor functions instead direct access. Final patch



commit cb325851850fdb6ead4feabc83b34d50d4752f5e
Author: Javier Jardón <jjardon gnome org>
Date:   Tue Dec 8 03:28:12 2009 +0100

    Use accessor functions instead direct access. Final patch
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=585210

 libcheese/cheese-camera.c    |    7 ++++-
 libcheese/cheese-countdown.c |   13 +++++++---
 libcheese/cheese-widget.c    |    8 ++++--
 libcheese/um-crop-area.c     |   49 ++++++++++++++++++++++++-----------------
 src/cheese-effect-chooser.c  |   21 +++++++++++------
 src/cheese-no-camera.c       |    4 +-
 src/cheese-window.c          |    6 +++-
 7 files changed, 67 insertions(+), 41 deletions(-)
---
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index 5bdaa5e..453fcde 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -193,6 +193,7 @@ static gboolean
 cheese_camera_expose_cb (GtkWidget *widget, GdkEventExpose *event, CheeseCamera *camera)
 {
   CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+  GtkAllocation        allocation;
   GstState             state;
   GstXOverlay         *overlay = GST_X_OVERLAY (gst_bin_get_by_interface (GST_BIN (priv->pipeline),
                                                                           GST_TYPE_X_OVERLAY));
@@ -201,8 +202,10 @@ cheese_camera_expose_cb (GtkWidget *widget, GdkEventExpose *event, CheeseCamera
 
   if ((state < GST_STATE_PLAYING) || (overlay == NULL))
   {
-    gdk_draw_rectangle (widget->window, widget->style->black_gc, TRUE,
-                        0, 0, widget->allocation.width, widget->allocation.height);
+    gtk_widget_get_allocation (widget, &allocation);
+    gdk_draw_rectangle (gtk_widget_get_window (widget),
+                        gtk_widget_get_style (widget)->black_gc, TRUE,
+                        0, 0, allocation.width, allocation.height);
   }
   else
   {
diff --git a/libcheese/cheese-countdown.c b/libcheese/cheese-countdown.c
index d849594..b3c6a79 100644
--- a/libcheese/cheese-countdown.c
+++ b/libcheese/cheese-countdown.c
@@ -334,6 +334,7 @@ static gboolean
 on_expose (GtkWidget *widget, GdkEventExpose *pEvent, gpointer data)
 {
   CheeseCountdownPrivate *priv     = CHEESE_COUNTDOWN_GET_PRIVATE (widget);
+  GtkAllocation           allocation;
   cairo_t                *pContext = NULL;
   cairo_pattern_t        *pattern;
   CairoColor              bgBorder;
@@ -342,12 +343,16 @@ on_expose (GtkWidget *widget, GdkEventExpose *pEvent, gpointer data)
   CairoColor              bgShade2;
   CairoColor              bgShade3;
   CairoColor              bgShade4;
-  gdouble                 fWidth  = (gdouble) widget->allocation.width;
-  gdouble                 fHeight = (gdouble) widget->allocation.height;
+  gdouble                 fWidth;
+  gdouble                 fHeight;
+
+  gtk_widget_get_allocation (widget, &allocation);
+  fWidth = (gdouble) allocation.width;
+  fHeight = (gdouble) allocation.height;
 
   /* 3 * 26 are the three numbers, 30 is the width of camera-icon.svg */
-  int     iOffsetX = (widget->allocation.width - 3 * 26 - 30) / 2;
-  int     iOffsetY = (widget->allocation.height - 30) / 2;
+  int     iOffsetX = (allocation.width - 3 * 26 - 30) / 2;
+  int     iOffsetY = (allocation.height - 30) / 2;
   gdouble fAlpha1;
   gdouble fAlpha2;
   gdouble fAlpha3;
diff --git a/libcheese/cheese-widget.c b/libcheese/cheese-widget.c
index 99672c6..d61b956 100644
--- a/libcheese/cheese-widget.c
+++ b/libcheese/cheese-widget.c
@@ -93,15 +93,17 @@ cheese_widget_logo_expose (GtkWidget      *w,
   guint         s_width, s_height, d_width, d_height;
   float         ratio;
 
-  gdk_draw_rectangle (w->window, w->style->black_gc, TRUE,
-                      0, 0, w->allocation.width, w->allocation.height);
+  gtk_widget_get_allocation (w, &allocation);
+
+  gdk_draw_rectangle (gtk_widget_get_window (w),
+                      gtk_widget_get_style (w)->black_gc, TRUE,
+                      0, 0, allocation.width, allocation.height);
   icon_name = g_object_get_data (G_OBJECT (w), "icon-name");
   if (icon_name == NULL)
     return FALSE;
 
   cr = gdk_cairo_create (gtk_widget_get_window (w));
   cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
-  gtk_widget_get_allocation (w, &allocation);
   cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
 
   d_width  = allocation.width;
diff --git a/libcheese/um-crop-area.c b/libcheese/um-crop-area.c
index a10340c..d463658 100644
--- a/libcheese/um-crop-area.c
+++ b/libcheese/um-crop-area.c
@@ -85,14 +85,15 @@ shift_colors (GdkPixbuf *pixbuf,
 static void
 update_pixbufs (UmCropArea *area)
 {
-	gint width;
-	gint height;
 	GtkAllocation allocation;
-	gdouble scale;
+	GtkStyle *style;
+	GtkWidget *widget;
 	GdkColor *color;
-	guint32 pixel;
+	gdouble scale;
+	gint width;
+	gint height;
 	gint dest_x, dest_y, dest_width, dest_height;
-	GtkWidget *widget;
+	guint32 pixel;
 
 	widget = GTK_WIDGET (area);
 	gtk_widget_get_allocation (widget, &allocation);
@@ -105,7 +106,8 @@ update_pixbufs (UmCropArea *area)
 		area->priv->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
 					     allocation.width, allocation.height);
 
-		color = &widget->style->bg[GTK_WIDGET_STATE (widget)];
+		style = gtk_widget_get_style (widget);
+		color = &style->bg[gtk_widget_get_state (widget)];
   		pixel = ((color->red & 0xff00) << 16) |
        			((color->green & 0xff00) << 8) |
          		 (color->blue & 0xff00);
@@ -178,9 +180,12 @@ static gboolean
 um_crop_area_expose (GtkWidget      *widget,
 		     GdkEventExpose *event)
 {
+	GtkStateType state;
+	GtkStyle *style;
 	cairo_t *cr;
 	GdkRectangle area;
 	GdkRectangle crop;
+	GdkWindow *window;
 	gint width, height;
 	UmCropArea *uarea = UM_CROP_AREA (widget);
 
@@ -189,6 +194,10 @@ um_crop_area_expose (GtkWidget      *widget,
 
 	update_pixbufs (uarea);
 
+	window = gtk_widget_get_window (widget);
+	style = gtk_widget_get_style (widget);
+	state = gtk_widget_get_state (widget);
+
 	width = gdk_pixbuf_get_width (uarea->priv->pixbuf);
 	height = gdk_pixbuf_get_height (uarea->priv->pixbuf);
 	crop_to_widget (uarea, &crop);
@@ -198,8 +207,8 @@ um_crop_area_expose (GtkWidget      *widget,
 	area.width = width;
 	area.height = crop.y;
 	gdk_rectangle_intersect (&area, &event->area, &area);
-	gdk_draw_pixbuf (widget->window,
-		 	 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+	gdk_draw_pixbuf (window,
+	                 style->fg_gc[state],
 			 uarea->priv->color_shifted,
 		 	 area.x, area.y,
 		 	 area.x, area.y,
@@ -211,8 +220,8 @@ um_crop_area_expose (GtkWidget      *widget,
 	area.width = crop.x;
 	area.height = crop.height;
 	gdk_rectangle_intersect (&area, &event->area, &area);
-	gdk_draw_pixbuf (widget->window,
-		 	 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+	gdk_draw_pixbuf (window,
+	                 style->fg_gc[state],
 			 uarea->priv->color_shifted,
 		 	 area.x, area.y,
 		 	 area.x, area.y,
@@ -224,8 +233,8 @@ um_crop_area_expose (GtkWidget      *widget,
 	area.width = crop.width;
 	area.height = crop.height;
 	gdk_rectangle_intersect (&area, &event->area, &area);
-	gdk_draw_pixbuf (widget->window,
-			 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+	gdk_draw_pixbuf (window,
+	                 style->fg_gc[state],
 			 uarea->priv->pixbuf,
 			 area.x, area.y,
 			 area.x, area.y,
@@ -237,8 +246,8 @@ um_crop_area_expose (GtkWidget      *widget,
 	area.width = width - area.x;
 	area.height = crop.height;
 	gdk_rectangle_intersect (&area, &event->area, &area);
-	gdk_draw_pixbuf (widget->window,
-		 	 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+	gdk_draw_pixbuf (window,
+	                 style->fg_gc[state],
 			 uarea->priv->color_shifted,
 		 	 area.x, area.y,
 		 	 area.x, area.y,
@@ -250,21 +259,21 @@ um_crop_area_expose (GtkWidget      *widget,
 	area.width = width;
 	area.height = height - area.y;
 	gdk_rectangle_intersect (&area, &event->area, &area);
-	gdk_draw_pixbuf (widget->window,
-		 	 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+	gdk_draw_pixbuf (window,
+	                 style->fg_gc[state],
 			 uarea->priv->color_shifted,
 		 	 area.x, area.y,
 		 	 area.x, area.y,
 		 	 area.width, area.height,
 		 	 GDK_RGB_DITHER_NONE, 0, 0);
 
-	cr = gdk_cairo_create (widget->window);
+	cr = gdk_cairo_create (window);
 	gdk_cairo_rectangle (cr, &event->area);
 	cairo_clip (cr);
 
 	if (uarea->priv->active_region != OUTSIDE) {
 		gint x1, x2, y1, y2;
-		gdk_cairo_set_source_color (cr, &widget->style->white);
+		gdk_cairo_set_source_color (cr, &style->white);
 		cairo_set_line_width (cr, 1.0);
 		x1 = crop.x + crop.width / 3.0;
 		x2 = crop.x + 2 * crop.width / 3.0;
@@ -285,7 +294,7 @@ um_crop_area_expose (GtkWidget      *widget,
 		cairo_stroke (cr);
 	}
 
-	gdk_cairo_set_source_color (cr, &widget->style->black);
+	gdk_cairo_set_source_color (cr, &style->black);
 	cairo_set_line_width (cr, 1.0);
 	cairo_rectangle (cr,
                          crop.x + 0.5,
@@ -294,7 +303,7 @@ um_crop_area_expose (GtkWidget      *widget,
                          crop.height - 1.0);
         cairo_stroke (cr);
 
-	gdk_cairo_set_source_color (cr, &widget->style->white);
+	gdk_cairo_set_source_color (cr, &style->white);
 	cairo_set_line_width (cr, 2.0);
 	cairo_rectangle (cr,
                          crop.x + 2.0,
diff --git a/src/cheese-effect-chooser.c b/src/cheese-effect-chooser.c
index 8716117..36d0b89 100644
--- a/src/cheese-effect-chooser.c
+++ b/src/cheese-effect-chooser.c
@@ -205,12 +205,14 @@ cheese_effect_chooser_expose_cb (GtkWidget *widget, GdkEventExpose *expose_event
 {
   CheeseEffectChooserPrivate *priv = CHEESE_EFFECT_CHOOSER_GET_PRIVATE (widget);
 
-  int      width, height;
-  int      i;
-  cairo_t *cr;
+  GtkAllocation  allocation;
+  int            width, height;
+  int            i;
+  cairo_t       *cr;
 
-  width  = widget->allocation.width;
-  height = widget->allocation.height;
+  gtk_widget_get_allocation (widget, &allocation);
+  width  = allocation.width;
+  height = allocation.height;
 
   cr = gdk_cairo_create (gtk_widget_get_window (widget));
 
@@ -234,12 +236,15 @@ static gboolean
 cheese_effect_chooser_button_press_event_cb (GtkWidget *widget, GdkEventButton *button_event, gpointer data)
 {
   CheeseEffectChooserPrivate *priv = CHEESE_EFFECT_CHOOSER_GET_PRIVATE (widget);
-
+  GtkAllocation allocation;
   int i;
-  int col  = (int) (button_event->x / widget->allocation.width * BOARD_COLS);
-  int row  = (int) (button_event->y / widget->allocation.height * BOARD_ROWS);
+  int col, row;
   int slot = (row * BOARD_COLS + col);
 
+  gtk_widget_get_allocation (widget, &allocation);
+  col  = (int) (button_event->x / allocation.width * BOARD_COLS);
+  row  = (int) (button_event->y / allocation.height * BOARD_ROWS);
+
   priv->selected[slot] = !priv->selected[slot];
 
   if (priv->selected[0] == TRUE)
diff --git a/src/cheese-no-camera.c b/src/cheese-no-camera.c
index aabca08..62eb423 100644
--- a/src/cheese-no-camera.c
+++ b/src/cheese-no-camera.c
@@ -61,7 +61,7 @@ cheese_no_camera_set_info_bar_text_and_icon (GtkInfoBar  *info_bar,
   gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
   gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
   gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5);
-  GTK_WIDGET_SET_FLAGS (primary_label, GTK_CAN_FOCUS);
+  gtk_widget_set_can_focus (primary_label, TRUE);
   gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
 
   if (secondary_text != NULL)
@@ -72,7 +72,7 @@ cheese_no_camera_set_info_bar_text_and_icon (GtkInfoBar  *info_bar,
     g_free (secondary_markup);
     gtk_widget_show (secondary_label);
     gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
-    GTK_WIDGET_SET_FLAGS (secondary_label, GTK_CAN_FOCUS);
+    gtk_widget_set_can_focus (secondary_label, TRUE);
     gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
     gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
     gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
diff --git a/src/cheese-window.c b/src/cheese-window.c
index 60dbe96..7678d5d 100644
--- a/src/cheese-window.c
+++ b/src/cheese-window.c
@@ -371,12 +371,14 @@ cheese_window_fullscreen_leave_notify_cb (GtkWidget        *widget,
 void
 cheese_window_toggle_wide_mode (GtkWidget *widget, CheeseWindow *cheese_window)
 {
+  GtkAllocation allocation;
   CheeseWindowPrivate *priv = CHEESE_WINDOW_GET_PRIVATE (cheese_window);
   gboolean toggled = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (widget));
 
+  gtk_widget_get_allocation (GTK_WIDGET (priv->thewidget), &allocation);
   gtk_widget_set_size_request (priv->thewidget,
-                               GTK_WIDGET (priv->thewidget)->allocation.width,
-                               GTK_WIDGET (priv->thewidget)->allocation.height);
+                               allocation.width,
+                               allocation.height);
 
   /* set a single column in wide mode */
   gtk_icon_view_set_columns (GTK_ICON_VIEW (priv->thumb_view), toggled ? 1 : G_MAXINT);



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