[libgnomekbd] Fixing the issues with -DSEAL_ENABLED



commit 27532779bebfec737a5594438470d1851f451496
Author: Sergey V. Udaltsov <svu gnome org>
Date:   Thu Mar 11 21:09:25 2010 +0000

    Fixing the issues with -DSEAL_ENABLED
    
    https://bugzilla.gnome.org/show_bug.cgi?id=612488

 libgnomekbd/gkbd-indicator.c        |   40 ++++++++++--------
 libgnomekbd/gkbd-keyboard-drawing.c |   78 ++++++++++++++++++++---------------
 2 files changed, 68 insertions(+), 50 deletions(-)
---
diff --git a/libgnomekbd/gkbd-indicator.c b/libgnomekbd/gkbd-indicator.c
index 0c037a7..17162a6 100644
--- a/libgnomekbd/gkbd-indicator.c
+++ b/libgnomekbd/gkbd-indicator.c
@@ -117,7 +117,8 @@ gkbd_indicator_load_images ()
 							    GTK_BUTTONS_OK,
 							    _
 							    ("There was an error loading an image: %s"),
-							    gerror->message);
+							    gerror->
+							    message);
 				g_signal_connect (G_OBJECT (dialog),
 						  "response",
 						  G_CALLBACK
@@ -252,8 +253,10 @@ gkbd_indicator_button_pressed (GtkWidget *
 			       GdkEventButton * event, GkbdIndicator * gki)
 {
 	GtkWidget *img = gtk_bin_get_child (GTK_BIN (widget));
+	GtkAllocation allocation;
+	gtk_widget_get_allocation (img, &allocation);
 	xkl_debug (150, "Flag img size %d x %d\n",
-		   img->allocation.width, img->allocation.height);
+		   allocation.width, allocation.height);
 	if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
 		xkl_debug (150, "Mouse button pressed on applet\n");
 		gkbd_desktop_config_lock_next_group (&globals.cfg);
@@ -268,15 +271,18 @@ flag_exposed (GtkWidget * flag, GdkEventExpose * event, GdkPixbuf * image)
 	/* Image width and height */
 	int iw = gdk_pixbuf_get_width (image);
 	int ih = gdk_pixbuf_get_height (image);
-	gboolean scaling_needed =
-	    !((flag->allocation.width == iw &&
-	       flag->allocation.height <= ih) ||
-	      (flag->allocation.width >= iw &&
-	       flag->allocation.height == ih));
+	GtkAllocation allocation;
+	gboolean scaling_needed;
+
+	gtk_widget_get_allocation (flag, &allocation);
+	scaling_needed =
+	    !((allocation.width == iw &&
+	       allocation.height <= ih) ||
+	      (allocation.width >= iw && allocation.height == ih));
 
 	/* widget-to-image scales, X and Y */
-	double xwiratio = 1.0 * flag->allocation.width / iw;
-	double ywiratio = 1.0 * flag->allocation.height / ih;
+	double xwiratio = 1.0 * allocation.width / iw;
+	double ywiratio = 1.0 * allocation.height / ih;
 	double wiratio = xwiratio < ywiratio ? xwiratio : ywiratio;
 
 	/* scaled width and height */
@@ -284,15 +290,15 @@ flag_exposed (GtkWidget * flag, GdkEventExpose * event, GdkPixbuf * image)
 	int sh = ih * wiratio;
 
 	/* offsets */
-	int ox = (flag->allocation.width - sw) >> 1;
-	int oy = (flag->allocation.height - sh) >> 1;
+	int ox = (allocation.width - sw) >> 1;
+	int oy = (allocation.height - sh) >> 1;
 
 	GdkPixbuf *scaled =
 	    scaling_needed ? gdk_pixbuf_scale_simple (image, sw, sh,
 						      GDK_INTERP_HYPER) :
 	    image;
 
-	gdk_draw_pixbuf (GDK_DRAWABLE (flag->window),
+	gdk_draw_pixbuf (GDK_DRAWABLE (gtk_widget_get_window (flag)),
 			 NULL,
 			 scaled,
 			 0, 0,
@@ -348,8 +354,8 @@ gkbd_indicator_prepare_drawing (GkbdIndicator * gki, int group)
 			if (xkl_engine_get_features (globals.engine) &
 			    XKLF_MULTIPLE_LAYOUTS_SUPPORTED) {
 				char *full_layout_name = (char *)
-				    g_slist_nth_data (globals.
-						      kbd_cfg.layouts_variants,
+				    g_slist_nth_data (globals.kbd_cfg.
+						      layouts_variants,
 						      group);
 				char *variant_name;
 				if (!gkbd_keyboard_config_split_items
@@ -593,7 +599,8 @@ gkbd_indicator_set_current_page (GkbdIndicator * gki)
 	cur_state = xkl_engine_get_current_state (globals.engine);
 	if (cur_state->group >= 0)
 		gkbd_indicator_set_current_page_for_group (gki,
-							   cur_state->group);
+							   cur_state->
+							   group);
 }
 
 void
@@ -658,8 +665,7 @@ gkbd_indicator_start_listen (void)
 static void
 gkbd_indicator_stop_listen (void)
 {
-	xkl_engine_stop_listen (globals.engine,
-				XKLL_TRACK_KEYBOARD_STATE);
+	xkl_engine_stop_listen (globals.engine, XKLL_TRACK_KEYBOARD_STATE);
 
 	gdk_window_remove_filter (NULL, (GdkFilterFunc)
 				  gkbd_indicator_filter_x_evt, NULL);
diff --git a/libgnomekbd/gkbd-keyboard-drawing.c b/libgnomekbd/gkbd-keyboard-drawing.c
index 04ed42e..356b6f8 100644
--- a/libgnomekbd/gkbd-keyboard-drawing.c
+++ b/libgnomekbd/gkbd-keyboard-drawing.c
@@ -998,8 +998,8 @@ draw_key (GkbdKeyboardDrawingRenderContext * context,
 
 	if (key->pressed)
 		color =
-		    &(GTK_WIDGET (drawing)->
-		      style->base[GTK_STATE_SELECTED]);
+		    &gtk_widget_get_style (GTK_WIDGET (drawing))->base
+		    [GTK_STATE_SELECTED];
 	else
 		color = drawing->colors + key->xkbkey->color_ndx;
 
@@ -1296,11 +1296,11 @@ draw_keyboard_to_context (GkbdKeyboardDrawingRenderContext * context,
 static void
 create_cairo (GkbdKeyboardDrawing * drawing)
 {
-	GtkStateType state = GTK_WIDGET_STATE (GTK_WIDGET (drawing));
+	GtkStateType state = gtk_widget_get_state (GTK_WIDGET (drawing));
 	drawing->renderContext->cr =
 	    gdk_cairo_create (GDK_DRAWABLE (drawing->pixmap));
 	drawing->renderContext->dark_color =
-	    &GTK_WIDGET (drawing)->style->dark[state];
+	    &gtk_widget_get_style (GTK_WIDGET (drawing))->dark[state];
 }
 
 static void
@@ -1314,22 +1314,24 @@ destroy_cairo (GkbdKeyboardDrawing * drawing)
 static void
 draw_keyboard (GkbdKeyboardDrawing * drawing)
 {
-	GtkStateType state = GTK_WIDGET_STATE (GTK_WIDGET (drawing));
-	gint pixw, pixh;
+	GtkStateType state = gtk_widget_get_state (GTK_WIDGET (drawing));
+	GtkAllocation allocation;
 
 	if (!drawing->xkb)
 		return;
 
-	pixw = GTK_WIDGET (drawing)->allocation.width;
-	pixh = GTK_WIDGET (drawing)->allocation.height;
+	gtk_widget_get_allocation (GTK_WIDGET (drawing), &allocation);
 
 	drawing->pixmap =
-	    gdk_pixmap_new (GTK_WIDGET (drawing)->window, pixw, pixh, -1);
+	    gdk_pixmap_new (gtk_widget_get_window (GTK_WIDGET (drawing)),
+			    allocation.width, allocation.height, -1);
 
 	/* blank background */
 	gdk_draw_rectangle (drawing->pixmap,
-			    GTK_WIDGET (drawing)->style->base_gc[state],
-			    TRUE, 0, 0, pixw, pixh);
+			    gtk_widget_get_style (GTK_WIDGET
+						  (drawing))->base_gc
+			    [state], TRUE, 0, 0, allocation.width,
+			    allocation.height);
 
 	create_cairo (drawing);
 	draw_keyboard_to_context (drawing->renderContext, drawing);
@@ -1349,8 +1351,9 @@ alloc_render_context (GkbdKeyboardDrawing * drawing)
 	pango_layout_set_ellipsize (context->layout, PANGO_ELLIPSIZE_END);
 
 	context->font_desc =
-	    pango_font_description_copy (GTK_WIDGET (drawing)->
-					 style->font_desc);
+	    pango_font_description_copy (gtk_widget_get_style
+					 (GTK_WIDGET
+					  (drawing))->font_desc);
 	context->angle = 0;
 	context->scale_numerator = 1;
 	context->scale_denominator = 1;
@@ -1371,7 +1374,8 @@ static gboolean
 expose_event (GtkWidget * widget,
 	      GdkEventExpose * event, GkbdKeyboardDrawing * drawing)
 {
-	GtkStateType state = GTK_WIDGET_STATE (GTK_WIDGET (drawing));
+	GtkStateType state = gtk_widget_get_state (GTK_WIDGET (drawing));
+	GtkAllocation allocation;
 
 	if (!drawing->xkb)
 		return FALSE;
@@ -1379,20 +1383,22 @@ expose_event (GtkWidget * widget,
 	if (drawing->pixmap == NULL)
 		return FALSE;
 
-	gdk_draw_drawable (widget->window,
-			   widget->style->fg_gc[state],
+	gdk_draw_drawable (gtk_widget_get_window (widget),
+			   gtk_widget_get_style (widget)->fg_gc[state],
 			   drawing->pixmap,
 			   event->area.x, event->area.y,
 			   event->area.x, event->area.y,
 			   event->area.width, event->area.height);
 
-	if (GTK_WIDGET_HAS_FOCUS (widget))
-		gtk_paint_focus (widget->style, widget->window,
-				 GTK_WIDGET_STATE (widget), &event->area,
-				 widget, "keyboard-drawing",
-				 0, 0,
-				 widget->allocation.width,
-				 widget->allocation.height);
+	if (gtk_widget_has_focus (widget)) {
+		gtk_widget_get_allocation (widget, &allocation);
+		gtk_paint_focus (gtk_widget_get_style (widget),
+				 gtk_widget_get_window (widget),
+				 gtk_widget_get_state (widget),
+				 &event->area, widget, "keyboard-drawing",
+				 0, 0, allocation.width,
+				 allocation.height);
+	}
 
 	return FALSE;
 }
@@ -1845,6 +1851,7 @@ xkb_state_notify_event_filter (GdkXEvent * gdkxev,
 
 	if (((XEvent *) gdkxev)->type == drawing->xkb_event_type) {
 		XkbEvent *kev = (XkbEvent *) gdkxev;
+		GtkAllocation allocation;
 		switch (kev->any.xkb_type) {
 		case XkbStateNotify:
 			if (((kev->state.changed & modifier_change_mask) &&
@@ -1858,10 +1865,12 @@ xkb_state_notify_event_filter (GdkXEvent * gdkxev,
 				    g_new0 (GkbdKeyboardDrawingKey,
 					    drawing->xkb->max_key_code +
 					    1);
+
+				gtk_widget_get_allocation (GTK_WIDGET
+							   (drawing),
+							   &allocation);
 				size_allocate (GTK_WIDGET (drawing),
-					       &(GTK_WIDGET
-						 (drawing)->allocation),
-					       drawing);
+					       &allocation, drawing);
 
 				init_keys_and_doodads (drawing);
 				init_colors (drawing);
@@ -2046,7 +2055,7 @@ gkbd_keyboard_drawing_init (GkbdKeyboardDrawing * drawing)
 	init_colors (drawing);
 
 	/* required to get key events */
-	GTK_WIDGET_SET_FLAGS (GTK_WIDGET (drawing), GTK_CAN_FOCUS);
+	gtk_widget_set_can_focus (GTK_WIDGET (drawing), TRUE);
 
 	gtk_widget_set_events (GTK_WIDGET (drawing),
 			       GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK |
@@ -2183,11 +2192,12 @@ gkbd_keyboard_drawing_render (GkbdKeyboardDrawing * drawing,
 		cr,
 		drawing->renderContext->angle,
 		layout,
-		pango_font_description_copy (GTK_WIDGET (drawing)->
-					     style->font_desc),
+		pango_font_description_copy (gtk_widget_get_style
+					     (GTK_WIDGET
+					      (drawing))->font_desc),
 		1, 1,
-		&GTK_WIDGET (drawing)->style->dark[GTK_WIDGET_STATE
-						   (GTK_WIDGET (drawing))]
+		&gtk_widget_get_style (GTK_WIDGET (drawing))->dark
+		    [gtk_widget_get_state (GTK_WIDGET (drawing))]
 	};
 
 	if (!context_setup_scaling (&context, drawing, width, height,
@@ -2206,6 +2216,8 @@ gboolean
 gkbd_keyboard_drawing_set_keyboard (GkbdKeyboardDrawing * drawing,
 				    XkbComponentNamesRec * names)
 {
+	GtkAllocation allocation;
+
 	free_cdik (drawing);
 	if (drawing->xkb)
 		XkbFreeKeyboard (drawing->xkb, 0, TRUE);	/* free_all = TRUE */
@@ -2242,8 +2254,8 @@ gkbd_keyboard_drawing_set_keyboard (GkbdKeyboardDrawing * drawing,
 	init_keys_and_doodads (drawing);
 	init_colors (drawing);
 
-	size_allocate (GTK_WIDGET (drawing),
-		       &(GTK_WIDGET (drawing)->allocation), drawing);
+	gtk_widget_get_allocation (GTK_WIDGET (drawing), &allocation);
+	size_allocate (GTK_WIDGET (drawing), &allocation, drawing);
 	gtk_widget_queue_draw (GTK_WIDGET (drawing));
 
 	return TRUE;



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