[libslab] Use accessor functions instead direct access (GSEAL fixes)



commit c86c8e28dd010da19f0ee5f3d12a284bfad6d548
Author: Javier Jardón <jjardon gnome org>
Date:   Wed Jun 23 04:17:20 2010 +0200

    Use accessor functions instead direct access (GSEAL fixes)
    
    Bump required GTK+ version to 2.21.3
    Still remaining:
    image->data.name.pixbuf
    GTK_WIDGET_*SET_FLAGS (widget, GTK_HAS_FOCUS)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=622467

 configure.ac                    |    2 +-
 libslab/app-resizer.c           |   75 ++++++++++++++++++++++++++-------------
 libslab/app-shell.c             |   10 +++--
 libslab/application-tile.c      |    2 +-
 libslab/document-tile.c         |    2 +-
 libslab/gnome-utils.c           |    9 +++--
 libslab/nameplate-tile.c        |   10 ++++--
 libslab/search-context-picker.c |   11 ++++--
 libslab/search-entry.c          |    9 +++--
 libslab/shell-window.c          |   22 +++++++----
 libslab/slab-section.c          |   10 ++++--
 libslab/tile.c                  |    8 +++--
 12 files changed, 109 insertions(+), 61 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0b38415..33b76c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,7 +48,7 @@ dnl Check that we meet the dependencies
 dnl ==============================================
 
 GLIB_REQUIRED=2.18.0
-GTK_REQUIRED=2.20.0
+GTK_REQUIRED=2.21.3
 
 AM_PATH_GLIB_2_0($GLIB_REQUIRED,,,gobject)
 
diff --git a/libslab/app-resizer.c b/libslab/app-resizer.c
index 118406d..50d1587 100644
--- a/libslab/app-resizer.c
+++ b/libslab/app-resizer.c
@@ -85,8 +85,10 @@ resize_table (GtkTable * table, gint columns, GList * launcher_list)
 static void
 relayout_table (GtkTable * table, GList * element_list)
 {
-	gint maxcols = (GTK_TABLE (table))->ncols;
+	guint maxcols;
 	gint row = 0, col = 0;
+
+	gtk_table_get_size (table, NULL, &maxcols);
 	do
 	{
 		GtkWidget *element = GTK_WIDGET (element_list->data);
@@ -140,8 +142,10 @@ calculate_num_cols (AppResizer * resizer, gint avail_width)
 			GList *children = gtk_container_get_children (GTK_CONTAINER (table));
 			GtkWidget *table_element = GTK_WIDGET (children->data);
 			g_list_free (children);
+			GtkAllocation allocation;
 
-			resizer->cached_element_width = table_element->allocation.width;
+			gtk_widget_get_allocation (table_element, &allocation);
+			resizer->cached_element_width = allocation.width;
 			resizer->cached_table_spacing = gtk_table_get_default_col_spacing (table);
 		}
 
@@ -190,11 +194,15 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
 	/* printf("ENTER - app_resizer_size_allocate\n"); */
 	AppResizer *resizer = APP_RESIZER (widget);
 	GtkWidget *child = GTK_WIDGET (APP_RESIZER (resizer)->child);
+	GtkAllocation child_allocation;
+	GtkRequisition child_requisition, requisition;
 
 	static gboolean first_time = TRUE;
 	gint new_num_cols;
 	gint useable_area;
 
+	gtk_widget_get_requisition (child, &child_requisition);
+
 	if (first_time)
 	{
 		/* we are letting the first show be the "natural" size of the child widget so do nothing. */
@@ -202,32 +210,35 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
 			(*GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate) (widget, allocation);
 
 		first_time = FALSE;
-		gtk_layout_set_size (GTK_LAYOUT (resizer), child->allocation.width,
-			child->allocation.height);
+
+		gtk_widget_get_allocation (child, &child_allocation);
+		gtk_layout_set_size (GTK_LAYOUT (resizer),
+		                     child_allocation.width,
+		                     child_allocation.height);
 		return;
 	}
 
 	if (!resizer->cached_tables_list)	/* if everthing is currently filtered out - just return */
 	{
-		GtkAllocation child_allocation;
-
 		if (GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate)
 			(*GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate) (widget, allocation);
 
 		/* We want the message to center itself and only scroll if it's bigger than the available real size. */
 		child_allocation.x = 0;
 		child_allocation.y = 0;
-		child_allocation.width = MAX (allocation->width, child->requisition.width);
-		child_allocation.height = MAX (allocation->height, child->requisition.height);
+		child_allocation.width = MAX (allocation->width, child_requisition.width);
+		child_allocation.height = MAX (allocation->height, child_requisition.height);
 
 		gtk_widget_size_allocate (child, &child_allocation);
-		gtk_layout_set_size (GTK_LAYOUT (resizer), child_allocation.width,
-			child_allocation.height);
+		gtk_layout_set_size (GTK_LAYOUT (resizer),
+		                     child_allocation.width,
+		                     child_allocation.height);
 		return;
 	}
-	useable_area =
-		allocation->width - (child->requisition.width -
-		GTK_WIDGET (resizer->cached_tables_list->data)->requisition.width);
+
+	gtk_widget_get_requisition (GTK_WIDGET (resizer->cached_tables_list->data), &requisition);
+
+	useable_area = 	allocation->width - (child_requisition.width - requisition.width);
 	new_num_cols =
 		relayout_tables_if_needed (APP_RESIZER (resizer), useable_area,
 		resizer->cur_num_cols);
@@ -243,8 +254,11 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
 
 	if (GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate)
 		(*GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate) (widget, allocation);
-	gtk_layout_set_size (GTK_LAYOUT (resizer), child->allocation.width,
-		child->allocation.height);
+
+	gtk_widget_get_allocation (child, &child_allocation);
+	gtk_layout_set_size (GTK_LAYOUT (resizer),
+	                     child_allocation.width,
+	                     child_allocation.height);
 }
 
 GtkWidget *
@@ -281,9 +295,14 @@ void
 app_resizer_set_vadjustment_value (GtkWidget * widget, gdouble value)
 {
 	GtkAdjustment *adjust = gtk_layout_get_vadjustment (GTK_LAYOUT (widget));
-	if (value > adjust->upper - adjust->page_size)
+	gdouble upper, page_size;
+
+	upper = gtk_adjustment_get_upper (adjust);
+	page_size = gtk_adjustment_get_page_size (adjust);
+
+	if (value > upper - page_size)
 	{
-		value = adjust->upper - adjust->page_size;
+		value = upper - page_size;
 	}
 	gtk_adjustment_set_value (adjust, value);
 }
@@ -297,18 +316,24 @@ app_resizer_paint_window (GtkWidget * widget, GdkEventExpose * event, AppShellDa
 	printf("Allocation:%d, %d, %d, %d\n\n", widget->allocation.x, widget->allocation.y, widget->allocation.width, widget->allocation.height);
 	*/
 
-	gdk_draw_rectangle (GTK_LAYOUT (widget)->bin_window,
-		widget->style->base_gc[GTK_STATE_NORMAL], TRUE, event->area.x, event->area.y,
-		event->area.width, event->area.height);
+	gdk_draw_rectangle (gtk_layout_get_bin_window (GTK_LAYOUT (widget)),
+	                    gtk_widget_get_style (widget)->base_gc[GTK_STATE_NORMAL],
+	                    TRUE, event->area.x, event->area.y,
+	                    event->area.width, event->area.height);
 
 	if (app_data->selected_group)
 	{
 		GtkWidget *selected_widget = GTK_WIDGET (app_data->selected_group);
-		gdk_draw_rectangle (selected_widget->window,	/* drawing on child window and child coordinates */
-			selected_widget->style->light_gc[GTK_STATE_SELECTED], TRUE,
-			selected_widget->allocation.x, selected_widget->allocation.y,
-			widget->allocation.width,	/* drawing with our coordinates here to draw all the way to the edge. */
-			selected_widget->allocation.height);
+		GtkAllocation allocation, selected_allocation;
+
+		gtk_widget_get_allocation (widget, &allocation);
+		gtk_widget_get_allocation (selected_widget, &selected_allocation);
+
+		gdk_draw_rectangle (gtk_widget_get_window (selected_widget),	/* drawing on child window and child coordinates */
+		                    gtk_widget_get_style (selected_widget)->light_gc[GTK_STATE_SELECTED], TRUE,
+		                    selected_allocation.x, selected_allocation.y,
+		                    allocation.width,	/* drawing with our coordinates here to draw all the way to the edge. */
+		                    selected_allocation.height);
 	}
 
 	return FALSE;
diff --git a/libslab/app-shell.c b/libslab/app-shell.c
index 1f4eb8b..a7a91ef 100644
--- a/libslab/app-shell.c
+++ b/libslab/app-shell.c
@@ -337,7 +337,7 @@ relayout_shell_partial (gpointer user_data)
 	populate_groups_section (app_data);
 
 	gtk_widget_show_all (app_data->category_layout);
-	gdk_window_set_cursor (app_data->shell->window, NULL);
+	gdk_window_set_cursor (gtk_widget_get_window (app_data->shell), NULL);
 
 	app_data->stop_incremental_relayout = TRUE;
 	return FALSE;
@@ -468,6 +468,7 @@ handle_group_clicked (Tile * tile, TileEvent * event, gpointer user_data)
 {
 	AppShellData *app_data = (AppShellData *) user_data;
 	GtkWidget *section = NULL;
+	GtkAllocation allocation;
 
 	gint clicked_pos =
 		GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tile), GROUP_POSITION_NUMBER_KEY));
@@ -489,8 +490,8 @@ handle_group_clicked (Tile * tile, TileEvent * event, gpointer user_data)
 
 		if (NULL != cat_data->filtered_launcher_list)
 		{
-			total += GTK_WIDGET (cat_data->section)->allocation.height +
-				CATEGORY_SPACING;
+			gtk_widget_get_allocation (GTK_WIDGET (cat_data->section), &allocation);
+			total += allocation.height + CATEGORY_SPACING;
 		}
 	}
 	while (NULL != (cat_list = g_list_next (cat_list)));
@@ -557,7 +558,8 @@ handle_filter_changed_delayed (gpointer user_data)
 	gtk_widget_hide (app_data->category_layout);
 	app_data->busy_cursor =
 		gdk_cursor_new_for_display (gtk_widget_get_display (app_data->shell), GDK_WATCH);
-	gdk_window_set_cursor (app_data->shell->window, app_data->busy_cursor);
+	gdk_window_set_cursor (gtk_widget_get_window (app_data->shell),
+	                       app_data->busy_cursor);
 	gdk_cursor_unref (app_data->busy_cursor);
 
 	set_state (app_data, NULL);
diff --git a/libslab/application-tile.c b/libslab/application-tile.c
index eee281e..244c197 100644
--- a/libslab/application-tile.c
+++ b/libslab/application-tile.c
@@ -493,7 +493,7 @@ create_subheader (const gchar *desc)
 	gtk_widget_modify_fg (
 		subheader,
 		GTK_STATE_NORMAL,
-		& subheader->style->fg [GTK_STATE_INSENSITIVE]);
+		& gtk_widget_get_style (subheader)->fg [GTK_STATE_INSENSITIVE]);
 
 	return subheader;
 }
diff --git a/libslab/document-tile.c b/libslab/document-tile.c
index 99bde93..e4ad7ad 100644
--- a/libslab/document-tile.c
+++ b/libslab/document-tile.c
@@ -713,7 +713,7 @@ create_subheader (const gchar *desc)
 	gtk_label_set_ellipsize (GTK_LABEL (subheader), PANGO_ELLIPSIZE_END);
 	gtk_misc_set_alignment (GTK_MISC (subheader), 0.0, 0.5);
 	gtk_widget_modify_fg (subheader, GTK_STATE_NORMAL,
-		&subheader->style->fg[GTK_STATE_INSENSITIVE]);
+		&gtk_widget_get_style (subheader)->fg[GTK_STATE_INSENSITIVE]);
 
 	return subheader;
 }
diff --git a/libslab/gnome-utils.c b/libslab/gnome-utils.c
index ad5c767..893b5fb 100644
--- a/libslab/gnome-utils.c
+++ b/libslab/gnome-utils.c
@@ -337,10 +337,11 @@ get_main_menu_section_header (const gchar * markup)
 static void
 section_header_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data)
 {
-	if (prev_style
-		&& widget->style->fg[GTK_STATE_SELECTED].green ==
-		prev_style->fg[GTK_STATE_SELECTED].green)
+	GtkStyle *style = gtk_widget_get_style (widget);
+
+	if (prev_style &&
+	    style->fg[GTK_STATE_SELECTED].green == prev_style->fg[GTK_STATE_SELECTED].green)
 		return;
 
-	gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &widget->style->bg[GTK_STATE_SELECTED]);
+	gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &style->bg[GTK_STATE_SELECTED]);
 }
diff --git a/libslab/nameplate-tile.c b/libslab/nameplate-tile.c
index f3f4516..769cb93 100644
--- a/libslab/nameplate-tile.c
+++ b/libslab/nameplate-tile.c
@@ -262,6 +262,8 @@ nameplate_tile_drag_begin (GtkWidget * widget, GdkDragContext * context)
 {
 	NameplateTile *this = NAMEPLATE_TILE (widget);
 	GtkImage *image;
+	GtkImageType storage_type;
+	GdkPixbuf *pixbuf;
 
 	(*GTK_WIDGET_CLASS (nameplate_tile_parent_class)->drag_begin) (widget, context);
 
@@ -269,12 +271,14 @@ nameplate_tile_drag_begin (GtkWidget * widget, GdkDragContext * context)
 		return;
 
 	image = GTK_IMAGE (this->image);
+	storage_type = gtk_image_get_storage_type (image);
 
-	switch (image->storage_type)
+	switch (storage_type)
 	{
 	case GTK_IMAGE_PIXBUF:
-		if (image->data.pixbuf.pixbuf)
-			gtk_drag_set_icon_pixbuf (context, image->data.pixbuf.pixbuf, 0, 0);
+		pixbuf = gtk_image_get_pixbuf (image);
+		if (pixbuf)
+			gtk_drag_set_icon_pixbuf (context, pixbuf, 0, 0);
 
 		break;
 
diff --git a/libslab/search-context-picker.c b/libslab/search-context-picker.c
index 449c629..b35781b 100644
--- a/libslab/search-context-picker.c
+++ b/libslab/search-context-picker.c
@@ -94,16 +94,19 @@ static void
 menu_position_func (GtkMenu * menu, int *x, int *y, gboolean * push_in, gpointer picker)
 {
 	GtkWidget *widget = GTK_WIDGET (picker);
+	GtkAllocation allocation;
 
-	gdk_window_get_origin (widget->window, x, y);
-	*x += widget->allocation.x;
-	*y += widget->allocation.y + widget->allocation.height;
+	gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
+	gtk_widget_get_allocation (widget, &allocation);
+
+	*x += allocation.x;
+	*y += allocation.y + allocation.height;
 
 	if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
 	{
 		GtkRequisition req;
 		gtk_widget_size_request (GTK_WIDGET (menu), &req);
-		*x += widget->allocation.width - req.width;
+		*x += allocation.width - req.width;
 	}
 
 	*push_in = FALSE;
diff --git a/libslab/search-entry.c b/libslab/search-entry.c
index 416f337..41603c7 100644
--- a/libslab/search-entry.c
+++ b/libslab/search-entry.c
@@ -90,13 +90,14 @@ nld_search_entry_realize (GtkWidget * widget)
 
 	GTK_WIDGET_CLASS (nld_search_entry_parent_class)->realize (widget);
 
-	gdk_window_get_geometry (GTK_ENTRY (widget)->text_area, NULL, NULL, NULL, &height, NULL);
+	gdk_window_get_geometry (gtk_entry_get_text_window (GTK_ENTRY (widget)),
+	                         NULL, NULL, NULL, &height, NULL);
 
 	if (height - 2 == priv->height)
 		return;
 	priv->height = height - 2;
 
-	gdkcolor = &widget->style->fg[gtk_widget_get_state (widget)];
+	gdkcolor = &gtk_widget_get_style (widget)->fg[gtk_widget_get_state (widget)];
 	snprintf (color, 6, "%02x%02x%02x", gdkcolor->red >> 8, gdkcolor->green >> 8,
 		gdkcolor->blue >> 8);
 	svg = g_strdup_printf (SEARCH_ENTRY_WATERMARK_SVG, color, color);
@@ -119,7 +120,7 @@ nld_search_entry_expose_event (GtkWidget * widget, GdkEventExpose * event)
 	NldSearchEntryPrivate *priv = NLD_SEARCH_ENTRY_GET_PRIVATE (widget);
 	GTK_WIDGET_CLASS (nld_search_entry_parent_class)->expose_event (widget, event);
 
-	if (event->window == GTK_ENTRY (widget)->text_area)
+	if (event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
 	{
 		int width, height, x;
 
@@ -130,7 +131,7 @@ nld_search_entry_expose_event (GtkWidget * widget, GdkEventExpose * event)
 		}
 		else
 			x = 1;
-		gdk_draw_pixbuf (event->window, widget->style->fg_gc[gtk_widget_get_state (widget)],
+		gdk_draw_pixbuf (event->window, gtk_widget_get_style (widget)->fg_gc[gtk_widget_get_state (widget)],
 			priv->watermark, 0, 0, x, 1, priv->width, priv->height,
 			GDK_RGB_DITHER_NORMAL, 0, 0);
 	}
diff --git a/libslab/shell-window.c b/libslab/shell-window.c
index 23656a5..33a0ce6 100644
--- a/libslab/shell-window.c
+++ b/libslab/shell-window.c
@@ -87,6 +87,7 @@ static void
 shell_window_handle_size_request (GtkWidget * widget, GtkRequisition * requisition,
 	AppShellData * app_data)
 {
+	GtkRequisition child_requisition;
 	gint height;
 
 	/*
@@ -98,15 +99,14 @@ shell_window_handle_size_request (GtkWidget * widget, GtkRequisition * requisiti
 	printf("right side width:%d\n", GTK_WIDGET(APP_RESIZER(app_data->category_layout)->child)->requisition.width);
 	*/
 
-	requisition->width +=
-		GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child)->requisition.width;
+	gtk_widget_get_requisition (GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child),
+	                            &child_requisition);
+	requisition->width += child_requisition.width;
 
 	/* use the left side as a minimum height, if the right side is taller,
 	   use it up to SIZING_HEIGHT_PERCENT of the screen height
 	*/
-	height =
-		GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child)->requisition.height +
-		10;
+	height = child_requisition.height + 10;
 	if (height > requisition->height)
 	{
 		requisition->height =
@@ -134,14 +134,20 @@ gboolean
 shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer data)
 {
 	GtkWidget *left_pane, *right_pane;
+	GtkAllocation allocation;
 
 	left_pane = SHELL_WINDOW (widget)->_left_pane;
 	right_pane = SHELL_WINDOW (widget)->_right_pane;
 
+	gtk_widget_get_allocation (left_pane, &allocation);
+
 	/* draw left pane background */
-	gtk_paint_flat_box (widget->style, widget->window, widget->state, GTK_SHADOW_NONE, NULL, widget, "",
-		left_pane->allocation.x, left_pane->allocation.y, left_pane->allocation.width,
-		left_pane->allocation.height);
+	gtk_paint_flat_box (gtk_widget_get_style (widget),
+	                    gtk_widget_get_window (widget),
+	                    gtk_widget_get_state (widget),
+	                    GTK_SHADOW_NONE, NULL, widget, "",
+	                    allocation.x, allocation.y,
+	                    allocation.width, allocation.height);
 
 	return FALSE;
 }
diff --git a/libslab/slab-section.c b/libslab/slab-section.c
index 6fbf700..b05921f 100644
--- a/libslab/slab-section.c
+++ b/libslab/slab-section.c
@@ -48,19 +48,23 @@ slab_section_finalize (GObject * obj)
 static void
 slab_section_set_title_color (GtkWidget * widget)
 {
+	GtkStyle *style;
+
+	style = gtk_widget_get_style (widget);
+
 	switch (SLAB_SECTION (widget)->style)
 	{
 	case Style1:
 		gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
-			&widget->style->bg[GTK_STATE_SELECTED]);
+		                      &style->bg[GTK_STATE_SELECTED]);
 		break;
 	case Style2:
 		if (SLAB_SECTION (widget)->selected)
 			gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
-				&widget->style->dark[GTK_STATE_SELECTED]);
+			                      &style->dark[GTK_STATE_SELECTED]);
 		else
 			gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
-				&widget->style->text[GTK_STATE_INSENSITIVE]);
+			                      &style->text[GTK_STATE_INSENSITIVE]);
 		break;
 	default:
 		g_assert_not_reached ();
diff --git a/libslab/tile.c b/libslab/tile.c
index 72045ef..44fdd0f 100644
--- a/libslab/tile.c
+++ b/libslab/tile.c
@@ -440,6 +440,7 @@ tile_popup_menu_position (GtkMenu * menu, gint * x, gint * y, gboolean * push_in
 
 	GtkRequisition req;
 	GtkWidget *top;
+	GtkAllocation allocation;
 
 	if (!gtk_widget_get_realized (GTK_WIDGET (tile)))
 		return;
@@ -448,10 +449,11 @@ tile_popup_menu_position (GtkMenu * menu, gint * x, gint * y, gboolean * push_in
 
 	top = gtk_widget_get_toplevel (GTK_WIDGET (tile));
 
-	gdk_window_get_origin (top->window, x, y);
+	gdk_window_get_origin (gtk_widget_get_window (top), x, y);
 
-	*x += (top->allocation.width / 2) - (req.width / 2);
-	*y += (top->allocation.height / 2) - (req.height / 2);
+	gtk_widget_get_allocation (top, &allocation);
+	*x += (allocation.width / 2) - (req.width / 2);
+	*y += (allocation.height / 2) - (req.height / 2);
 
 	*push_in = FALSE;
 }



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