[dia] GSEAL: use gtk_widget_get_style() instead of GtkWidget::style



commit 05f7fb675c1aea421d9bcef5da2a6af0566dcc30
Author: Hans Breuer <hans breuer org>
Date:   Sun Mar 27 21:07:35 2011 +0200

    GSEAL: use gtk_widget_get_style() instead of GtkWidget::style

 app/color_area.c        |   12 +++++++-----
 app/diagram_tree_view.c |    4 +++-
 app/display.c           |    2 +-
 app/linewidth_area.c    |    4 +++-
 app/navigation.c        |   19 +++++++++++++------
 lib/diaarrowchooser.c   |    9 +++++----
 lib/dialinechooser.c    |    4 +++-
 7 files changed, 35 insertions(+), 19 deletions(-)
---
diff --git a/app/color_area.c b/app/color_area.c
index 4db31ca..f91edc0 100644
--- a/app/color_area.c
+++ b/app/color_area.c
@@ -119,6 +119,7 @@ color_area_draw ()
   gint def_width, def_height;
   gint swap_width, swap_height;
   GdkColor  mask_pattern;
+  GtkStyle *style;
 
   /* Check we haven't gotten initial expose yet,
    * no point in drawing anything
@@ -128,7 +129,8 @@ color_area_draw ()
 
   gdk_drawable_get_size (color_area_pixmap, &width, &height);
 
-  win_bg = &(color_area->style->bg[GTK_STATE_NORMAL]);
+  style = gtk_widget_get_style(color_area);
+  win_bg = &(style->bg[GTK_STATE_NORMAL]);
   col = attributes_get_foreground();
   color_convert(&col, &fg);
   col = attributes_get_background();
@@ -157,13 +159,13 @@ color_area_draw ()
 		      (width - rect_w), (height - rect_h), rect_w, rect_h);
 
   if (active_color == FOREGROUND)
-    gtk_paint_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL,
+    gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
                       GTK_SHADOW_OUT,
                       NULL, color_area, NULL,
 		      (width - rect_w), (height - rect_h),
                       rect_w, rect_h);
   else
-    gtk_paint_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL,
+    gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
                       GTK_SHADOW_IN,
                       NULL, color_area, NULL,
 		      (width - rect_w), (height - rect_h),
@@ -176,13 +178,13 @@ color_area_draw ()
 		      0, 0, rect_w, rect_h);
 
   if (active_color == FOREGROUND)
-    gtk_paint_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL,
+    gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
                       GTK_SHADOW_IN,
                       NULL, color_area, NULL,
                       0, 0,
                       rect_w, rect_h);
   else
-    gtk_paint_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL,
+    gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
                       GTK_SHADOW_OUT,
                       NULL, color_area, NULL,
                       0, 0,
diff --git a/app/diagram_tree_view.c b/app/diagram_tree_view.c
index a297160..dd601eb 100644
--- a/app/diagram_tree_view.c
+++ b/app/diagram_tree_view.c
@@ -475,6 +475,7 @@ _dtv_init (DiagramTreeView *dtv)
   GtkTreeViewColumn *column;
   GtkCellRenderer   *cell;
   gint               font_size;
+  GtkStyle          *style;
 
   /* connect the model with the view */
   gtk_tree_view_set_model (GTK_TREE_VIEW (dtv), diagram_tree_model_new ());
@@ -485,7 +486,8 @@ _dtv_init (DiagramTreeView *dtv)
   gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (dtv), TRUE);
 #endif
 
-  font_size = pango_font_description_get_size (GTK_WIDGET (dtv)->style->font_desc);
+  style = gtk_widget_get_style (GTK_WIDGET (dtv));
+  font_size = pango_font_description_get_size (style->font_desc);
   font_size = PANGO_PIXELS (font_size);
 
   /* first colum: name of diagram/layer/object - here is the tree */
diff --git a/app/display.c b/app/display.c
index 26110b0..b8f2d98 100644
--- a/app/display.c
+++ b/app/display.c
@@ -530,7 +530,7 @@ ddisplay_add_display_area(DDisplay *ddisp,
     bottom = dia_renderer_get_height_pixels (ddisp->renderer); 
   
   /* draw some rectangles to show where updates are...*/
-  /*  gdk_draw_rectangle(gtk_widget_get_window(ddisp->canvas), ddisp->canvas->style->black_gc, TRUE, left, top, right-left,bottom-top); */
+  /*  gdk_draw_rectangle(gtk_widget_get_window(ddisp->canvas), gtk_widget_get_style(ddisp->canvas)->black_gc, TRUE, left, top, right-left,bottom-top); */
 
   /* Temporarily just do a union of all Irectangles: */
   if (ddisp->display_areas==NULL) {
diff --git a/app/linewidth_area.c b/app/linewidth_area.c
index 0437a28..65e7b0f 100644
--- a/app/linewidth_area.c
+++ b/app/linewidth_area.c
@@ -72,6 +72,7 @@ linewidth_area_draw (GtkWidget *linewidth_area)
   int width, height;
   int i;
   int x_offs;
+  GtkStyle *style;
   
   if (!linewidth_area_pixmap)     /* we haven't gotten initial expose yet,
                                * no point in drawing anything */
@@ -88,7 +89,8 @@ linewidth_area_draw (GtkWidget *linewidth_area)
 
   gdk_drawable_get_size (linewidth_area_pixmap, &width, &height);
 
-  win_bg = &(linewidth_area->style->bg[GTK_STATE_NORMAL]);
+  style = gtk_widget_get_style (linewidth_area);
+  win_bg = &(style->bg[GTK_STATE_NORMAL]);
   line = color_gdk_black;
 
   gdk_gc_set_foreground (linewidth_area_gc, win_bg);
diff --git a/app/navigation.c b/app/navigation.c
index 4d3facc..f268ebe 100644
--- a/app/navigation.c
+++ b/app/navigation.c
@@ -107,6 +107,7 @@ navigation_popup_new (DDisplay *ddisp)
   GtkWidget * image;
   GdkPixmap * pixmap;
   GdkBitmap * mask = NULL;
+  GtkStyle  * style;
 
   button = gtk_button_new ();
   gtk_container_set_border_width (GTK_CONTAINER (button), 0);
@@ -117,10 +118,11 @@ navigation_popup_new (DDisplay *ddisp)
   g_signal_connect (G_OBJECT (button), "released",
                     G_CALLBACK (on_button_navigation_popup_released), NULL);
 
+  style = gtk_widget_get_style (button);
   pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL,
                                                  gtk_widget_get_colormap(button),
                                                  &mask,
-                                                 &(button->style->bg[GTK_STATE_NORMAL]),
+                                                 &(style->bg[GTK_STATE_NORMAL]),
                                                  nav_xpm);
 
   image = gtk_image_new_from_pixmap (pixmap, mask);
@@ -148,6 +150,7 @@ on_button_navigation_popup_pressed (GtkButton * button, gpointer _ddisp)
   Rectangle rect;/*diagram's extents*/
   real zoom;/*zoom factor for thumbnail rendering*/
 
+  GtkStyle *style;
 
   memset (nav, 0, sizeof(NavigationWindow));
   /*--Retrieve the diagram's data*/
@@ -262,8 +265,9 @@ on_button_navigation_popup_pressed (GtkButton * button, gpointer _ddisp)
   /*buffer to draw the thumbnail on*/
   nav->buffer = gdk_pixmap_new (gtk_widget_get_window (drawing_area),
                                 nav->width, nav->height, -1);
+  style = gtk_widget_get_style (drawing_area);
   gdk_draw_rectangle (nav->buffer,
-                      drawing_area->style->black_gc, TRUE,
+                      style->black_gc, TRUE,
                       0, 0, nav->width, nav->height);
 
   {/*--Render the thumbnail*/
@@ -310,12 +314,13 @@ reset_sc_adj (GtkAdjustment * adj, gdouble lower, gdouble upper, gdouble page)
 static gboolean
 on_da_expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer unused)
 {
+  GtkStyle *style = gtk_widget_get_style (widget);
   /*refresh the part outdated by the event*/
   gdk_draw_drawable (gtk_widget_get_window (widget),
 #if GTK_CHECK_VERSION(2,18,0)
-                     widget->style->fg_gc[gtk_widget_get_state (widget)],
+                     style->fg_gc[gtk_widget_get_state (widget)],
 #else
-                     widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+                     style->fg_gc[GTK_WIDGET_STATE (widget)],
 #endif
                      GDK_PIXMAP(nav->buffer),
                      event->area.x, event->area.y,
@@ -350,6 +355,7 @@ on_da_motion_notify_event (GtkWidget * drawing_area, GdkEventMotion * event, gpo
 {
   GtkAdjustment * adj;
   gboolean value_changed;
+  GtkStyle *style;
 
   int w = nav->frame_w;
   int h = nav->frame_h;
@@ -397,11 +403,12 @@ on_da_motion_notify_event (GtkWidget * drawing_area, GdkEventMotion * event, gpo
 
 /*--Draw the miniframe*/
 /*refresh from the buffer*/
+  style = gtk_widget_get_style (drawing_area);
   gdk_draw_drawable (gtk_widget_get_window (drawing_area),
 #if GTK_CHECK_VERSION(2,18,0)
-                     drawing_area->style->fg_gc[gtk_widget_get_state (drawing_area)],
+                     style->fg_gc[gtk_widget_get_state (drawing_area)],
 #else
-                     drawing_area->style->fg_gc[GTK_WIDGET_STATE (drawing_area)],
+                     style->fg_gc[GTK_WIDGET_STATE (drawing_area)],
 #endif
                      GDK_PIXMAP(nav->buffer),
                      0, 0, 0, 0, nav->width, nav->height);
diff --git a/lib/diaarrowchooser.c b/lib/diaarrowchooser.c
index 02c8509..8a091c4 100644
--- a/lib/diaarrowchooser.c
+++ b/lib/diaarrowchooser.c
@@ -228,16 +228,17 @@ dia_arrow_preview_expose(GtkWidget *widget, GdkEventExpose *event)
     renderer_ops->set_linewidth(renderer, linewidth);
     {
       Color color_bg, color_fg;
+      GtkStyle *style = gtk_widget_get_style (widget);
       /* the text colors are the best approximation to what we had */
 #if GTK_CHECK_VERSION(2,18,0)
-      GdkColor bg = widget->style->base[gtk_widget_get_state(widget)];
+      GdkColor bg = style->base[gtk_widget_get_state(widget)];
 #else
-      GdkColor bg = widget->style->base[GTK_WIDGET_STATE(widget)];
+      GdkColor bg = style->base[GTK_WIDGET_STATE(widget)];
 #endif
 #if GTK_CHECK_VERSION(2,18,0)
-      GdkColor fg = widget->style->text[gtk_widget_get_state(widget)];
+      GdkColor fg = style->text[gtk_widget_get_state(widget)];
 #else
-      GdkColor fg = widget->style->text[GTK_WIDGET_STATE(widget)];
+      GdkColor fg = style->text[GTK_WIDGET_STATE(widget)];
 #endif
 
       GDK_COLOR_TO_DIA(bg, color_bg);
diff --git a/lib/dialinechooser.c b/lib/dialinechooser.c
index c4ede50..fb15520 100644
--- a/lib/dialinechooser.c
+++ b/lib/dialinechooser.c
@@ -123,6 +123,7 @@ dia_line_preview_expose(GtkWidget *widget, GdkEventExpose *event)
   GdkGCValues gcvalues;
   gint8 dash_list[6];
   int line_width = 2;
+  GtkStyle *style;
 
 #if GTK_CHECK_VERSION(2,18,0)
   if (gtk_widget_is_drawable(widget)) {
@@ -135,7 +136,8 @@ dia_line_preview_expose(GtkWidget *widget, GdkEventExpose *event)
     y = (widget->allocation.y + misc->ypad);
 
     win = gtk_widget_get_window (widget);
-    gc = widget->style->fg_gc[widget->state];
+    style = gtk_widget_get_style (widget);
+    gc = style->fg_gc[widget->state];
 
     /* increase line width */
     gdk_gc_get_values(gc, &gcvalues);



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