[dia/dia-next: 17/59] Further updates for new rendering system



commit efb3fd4dc477cf7caf2e335c81b18b7ca0baaa01
Author: Zander Brown <zbrown gnome org>
Date:   Sun Dec 23 19:37:39 2018 +0000

    Further updates for new rendering system

 app/color_area.c              | 117 ++++++++++++++++++------------------------
 app/commands.c                |   8 +--
 app/linewidth_area.c          |  26 ++--------
 app/modify_tool.c             |  25 +++++----
 app/navigation.c              |  94 ++++++++++++++++-----------------
 app/sheets_dialog_callbacks.c |  23 ++++-----
 6 files changed, 126 insertions(+), 167 deletions(-)
---
diff --git a/app/color_area.c b/app/color_area.c
index a904af57..a404a93a 100644
--- a/app/color_area.c
+++ b/app/color_area.c
@@ -41,7 +41,6 @@ int active_color = 0;
 
 /*  Static variables  */
 GtkWidget *color_area;
-static GdkPixmap *color_area_pixmap = NULL;
 static GdkPixbuf *default_pixmap = NULL;
 static GdkPixbuf *swap_pixmap = NULL;
 
@@ -80,7 +79,8 @@ color_area_target (int x,
   gint rect_w, rect_h;
   gint width, height;
 
-  gdk_drawable_get_size (color_area_pixmap, &width, &height);
+  width = gtk_widget_get_allocated_width (color_area);
+  height = gtk_widget_get_allocated_height (color_area);
 
   rect_w = width * 0.65;
   rect_h = height * 0.65;
@@ -103,7 +103,7 @@ color_area_target (int x,
 }
 
 static void
-color_area_draw (cairo_t *color_area_ctx)
+color_area_draw (GtkWidget *self, cairo_t *color_area_ctx)
 {
   GdkRGBA *win_bg;
   GdkRGBA fg, bg;
@@ -111,26 +111,20 @@ color_area_draw (cairo_t *color_area_ctx)
   gint width, height;
   gint img_width, img_height;
   GtkStyle *style;
+  GtkStyleContext *style_ctx;
 
-  /* Check we haven't gotten initial expose yet,
-   * no point in drawing anything
-   */
-  if (!color_area_pixmap || !color_area_ctx)
-    return;
+  width = gtk_widget_get_allocated_width (self);
+  height = gtk_widget_get_allocated_height (self);
 
-  gdk_drawable_get_size (color_area_pixmap, &width, &height);
-
-  style = gtk_widget_get_style(color_area);
-  win_bg = &(style->bg[GTK_STATE_NORMAL]);
+  style = gtk_widget_get_style (self);
+  style_ctx = gtk_widget_get_style_context (self);
   fg = attributes_get_foreground();
   bg = attributes_get_background();
 
   rect_w = width * 0.65;
   rect_h = height * 0.65;
 
-  gdk_cairo_set_source_rgba (color_area_ctx, win_bg);
-  cairo_rectangle (color_area_ctx, 0, 0, width, height);
-  cairo_fill (color_area_ctx);
+  gtk_render_background (style_ctx, color_area_ctx, 0, 0, width, height);
 
   gdk_cairo_set_source_rgba (color_area_ctx, &bg);
 
@@ -139,15 +133,15 @@ color_area_draw (cairo_t *color_area_ctx)
   cairo_fill (color_area_ctx);
 
   if (active_color == FOREGROUND)
-    gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
+    gtk_paint_shadow (style, color_area_ctx, GTK_STATE_NORMAL,
                       GTK_SHADOW_OUT,
-                      NULL, color_area, NULL,
+                      self, NULL,
                      (width - rect_w), (height - rect_h),
                       rect_w, rect_h);
   else
-    gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
+    gtk_paint_shadow (style, color_area_ctx, GTK_STATE_NORMAL,
                       GTK_SHADOW_IN,
-                      NULL, color_area, NULL,
+                      self, NULL,
                      (width - rect_w), (height - rect_h),
                       rect_w, rect_h);
 
@@ -156,15 +150,15 @@ color_area_draw (cairo_t *color_area_ctx)
   cairo_fill (color_area_ctx);
 
   if (active_color == FOREGROUND)
-    gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
+    gtk_paint_shadow (style, color_area_ctx, GTK_STATE_NORMAL,
                       GTK_SHADOW_IN,
-                      NULL, color_area, NULL,
+                      self, NULL,
                       0, 0,
                       rect_w, rect_h);
   else
-    gtk_paint_shadow (style, color_area_pixmap, GTK_STATE_NORMAL,
+    gtk_paint_shadow (style, color_area_ctx, GTK_STATE_NORMAL,
                       GTK_SHADOW_OUT,
-                      NULL, color_area, NULL,
+                      self, NULL,
                       0, 0,
                       rect_w, rect_h);
 
@@ -189,16 +183,15 @@ color_selection_ok (GtkWidget               *w,
 {
   GtkColorSelection *colorsel;
   GdkRGBA color;
-  guint alpha;
 
   colorsel=GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(cs));
 
   gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (colorsel), &color);
 
   if (edit_color == FOREGROUND) {
-    attributes_set_foreground(&col);
+    attributes_set_foreground(&color);
   } else {
-    attributes_set_background(&col);
+    attributes_set_background(&color);
   }
   /* Trigger redraw */
   gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
@@ -252,12 +245,12 @@ color_selection_changed (GtkWidget *w,
   colorsel=GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(cs));
 
   gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (colorsel), &color);
-  gtk_color_selection_get_current_color(colorsel,&color);
+  gtk_color_selection_get_current_rgba (colorsel,&color);
 
   if (edit_color == FOREGROUND) {
-    attributes_set_foreground(&col);
+    attributes_set_foreground(&color);
   } else {
-    attributes_set_background(&col);
+    attributes_set_background(&color);
   }
   /* Trigger redraw */
   gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
@@ -342,8 +335,7 @@ color_area_edit (void)
     gtk_widget_show_now (color_select);      
   }
 
-  gtk_color_selection_set_current_color(colorsel, &color);
-  gtk_color_selection_set_current_alpha(colorsel, (guint)(col.alpha * 65535.0));
+  gtk_color_selection_set_current_rgba(colorsel, &color);
 }
 
 static gint
@@ -354,51 +346,38 @@ color_area_events (GtkWidget *widget,
   int target;
   
   switch (event->type) {
-    case GDK_CONFIGURE:
-      if (color_area_pixmap) {
-        g_object_unref (color_area_pixmap);
-      }
-      color_area_pixmap = gdk_pixmap_new (gtk_widget_get_window (color_area),
-                                          color_area->allocation.width,
-                                          color_area->allocation.height, -1);
-      break;
-    case GDK_EXPOSE:
-      if (gtk_widget_is_drawable (color_area)) {
-        color_area_draw (gdk_cairo_create (gtk_widget_get_window (color_area)));
-      }
-      break;
     case GDK_BUTTON_PRESS:
       bevent = (GdkEventButton *) event;
 
       if (bevent->button == 1) {
-       switch ((target = color_area_target (bevent->x, bevent->y))) {
-       case FORE_AREA:
-       case BACK_AREA:
-         if (target == active_color) {
-           color_area_edit ();
-         } else {
-             active_color = target;
-      /* Trigger redraw */
-      gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
-         }
-         break;
-       case SWAP_AREA:
-         attributes_swap_fgbg();
-    /* Trigger redraw */
-    gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
-         break;
-       case DEF_AREA:
-         attributes_default_fgbg();
-    /* Trigger redraw */
-    gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
-         break;
-       }
+        switch ((target = color_area_target (bevent->x, bevent->y))) {
+          case FORE_AREA:
+          case BACK_AREA:
+            if (target == active_color) {
+              color_area_edit ();
+            } else {
+              active_color = target;
+              /* Trigger redraw */
+              gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
+            }
+            break;
+          case SWAP_AREA:
+            attributes_swap_fgbg();
+            /* Trigger redraw */
+            gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
+            break;
+          case DEF_AREA:
+            attributes_default_fgbg();
+            /* Trigger redraw */
+            gdk_window_invalidate_rect (gtk_widget_get_window (color_area), NULL, TRUE);
+            break;
+        }
       }
       break;
-
+    
     default:
       break;
-    }
+  }
 
   return FALSE;
 }
@@ -427,6 +406,8 @@ color_area_create (int width,
   g_signal_connect (G_OBJECT (color_area), "event",
                       G_CALLBACK(color_area_events),
                       NULL);
+  g_signal_connect (G_OBJECT (color_area), "draw",
+                    G_CALLBACK (color_area_draw), NULL);
 
   gtk_widget_show(color_area);
   gtk_container_add(GTK_CONTAINER(event_box), color_area);
diff --git a/app/commands.c b/app/commands.c
index a5ad14fe..81ee06d6 100644
--- a/app/commands.c
+++ b/app/commands.c
@@ -181,10 +181,10 @@ insert_text(DDisplay *ddisp, Focus *focus, const gchar *text)
     gchar *next_line = g_utf8_strchr(text, -1, '\n');
     if (next_line != text) {
       gint len = g_utf8_strlen(text, (next_line-text));
-      modified = (*focus->key_event)(focus, 0, GDK_A, text, len, &change);
+      modified = (*focus->key_event)(focus, 0, GDK_KEY_A, text, len, &change);
     }
     if (next_line != NULL) {
-      modified = (*focus->key_event)(focus, 0, GDK_Return, "\n", 1, &change);
+      modified = (*focus->key_event)(focus, 0, GDK_KEY_Return, "\n", 1, &change);
       text = g_utf8_next_char(next_line);
     } else {
       text = NULL;
@@ -1048,8 +1048,8 @@ help_about_callback (GtkAction *action)
         "name", "Dia",
        "version", VERSION,
        "comments", _("A program for drawing structured diagrams."),
-       "copyright", "(C) 1998-2011 The Free Software Foundation and the authors",
-       "website", "http://live.gnome.org/Dia";,
+       "copyright", "© 2018 Zander Brown et al\n(C) 1998-2011 The Free Software Foundation and the authors",
+       "website", "https://wiki.gnome.org/Apps/Dia/";,
        "authors", authors,
        "documenters", documentors,
        "translator-credits", strcmp (translators, "translator_credits-PLEASE_ADD_YOURSELF_HERE")
diff --git a/app/linewidth_area.c b/app/linewidth_area.c
index c503c0dc..326e66ec 100644
--- a/app/linewidth_area.c
+++ b/app/linewidth_area.c
@@ -42,7 +42,6 @@
 static void linewidth_create_dialog(GtkWindow *toplevel);
 
 static int active_linewidth = 2;
-static GdkPixmap *linewidth_area_pixmap = NULL;
 
 static GtkWidget *linewidth_area_widget = NULL;
 static GtkWidget *linewidth_dialog = NULL;
@@ -63,27 +62,22 @@ linewidth_area_target (int x, int y)
 }
 
 static void
-linewidth_area_draw (GtkWidget *linewidth_area)
+linewidth_area_draw (GtkWidget *linewidth_area, cairo_t *ctx)
 {
   GdkRGBA *win_bg, *win_fg;
   int width, height;
   int i;
   int x_offs;
   GtkStyle *style;
-  cairo_t *ctx;
   double dashes[] = { 3 };
 
-  if (!linewidth_area_pixmap)     /* we haven't gotten initial expose yet,
-                               * no point in drawing anything */
-    return;
-
-  ctx = gdk_cairo_create (gtk_widget_get_window (linewidth_area));
   cairo_set_line_width (ctx, 1);
   cairo_set_line_cap (ctx, CAIRO_LINE_CAP_BUTT);
   cairo_set_line_join (ctx, CAIRO_LINE_JOIN_MITER);
   cairo_set_dash (ctx, dashes, 1, 0);
 
-  gdk_drawable_get_size (linewidth_area_pixmap, &width, &height);
+  width = gtk_widget_get_allocated_width (linewidth_area);
+  height = gtk_widget_get_allocated_height (linewidth_area);
 
   style = gtk_widget_get_style (linewidth_area);
   win_bg = &(style->bg[GTK_STATE_NORMAL]);
@@ -119,18 +113,6 @@ linewidth_area_events (GtkWidget *widget,
   
   switch (event->type)
     {
-    case GDK_CONFIGURE:
-      cevent = (GdkEventConfigure *)  event;
-      if (cevent->width > 1) {
-       linewidth_area_pixmap = gdk_pixmap_new (gtk_widget_get_window(widget),
-                                               cevent->width,
-                                               cevent->height, -1);
-      }
-      break;
-    case GDK_EXPOSE:
-      linewidth_area_draw (linewidth_area_widget);
-      break;
-
     case GDK_BUTTON_PRESS:
       bevent = (GdkEventButton *) event;
       if (bevent->button == 1) {
@@ -189,6 +171,8 @@ linewidth_area_create (void)
   g_signal_connect (G_OBJECT (linewidth_area), "event",
                    G_CALLBACK(linewidth_area_events),
                      NULL);
+  g_signal_connect (G_OBJECT (linewidth_area), "draw",
+                    G_CALLBACK(linewidth_area_draw), NULL);
 
   linewidth_area_widget = linewidth_area;
 
diff --git a/app/modify_tool.c b/app/modify_tool.c
index f7556a61..c2e95ddd 100644
--- a/app/modify_tool.c
+++ b/app/modify_tool.c
@@ -68,7 +68,6 @@ struct _ModifyTool {
   Point last_to;
   Point start_at;
   time_t start_time;
-  GdkGC *gc;
   int x1, y1, x2, y2;
   Point start_box;
   Point end_box;
@@ -92,7 +91,6 @@ create_modify_tool(void)
   tool->tool.button_release_func = (ButtonReleaseFunc) &modify_button_release;
   tool->tool.motion_func = (MotionFunc) &modify_motion;
   tool->tool.double_click_func = (DoubleClickFunc) &modify_double_click;
-  tool->gc = NULL;
   tool->state = STATE_NONE;
   tool->break_connections = FALSE;
   tool->auto_scrolled = FALSE;
@@ -151,8 +149,6 @@ void
 free_modify_tool(Tool *tool)
 {
   ModifyTool *mtool = (ModifyTool *)tool;
-  if (mtool->gc)
-    g_object_unref(mtool->gc);
   g_free(mtool);
 }
 
@@ -296,21 +292,20 @@ modify_button_press(ModifyTool *tool, GdkEventButton *event,
     tool->x1 = tool->x2 = (int) event->x;
     tool->y1 = tool->y2 = (int) event->y;
 
-    if (tool->gc == NULL) {
-      GdkRGBA white;
-
-      gdk_rgba_parse (&white, "#FFFFFF");
 
+      /* TODO: Selection Box
       tool->gc = gdk_gc_new(gtk_widget_get_window(ddisp->canvas));
       gdk_gc_set_line_attributes(tool->gc, 1, GDK_LINE_ON_OFF_DASH, 
                                 GDK_CAP_BUTT, GDK_JOIN_MITER);
-      gdk_gc_set_foreground(tool->gc, &white);
+      gdk_gc_set_foreground(tool->gc, &color_white);
       gdk_gc_set_function(tool->gc, GDK_XOR);
-    }
+      */
 
+    /* TODO: Selection Box
     gdk_draw_rectangle (gtk_widget_get_window (ddisp->canvas), tool->gc, FALSE,
                        tool->x1, tool->y1,
                        tool->x2 - tool->x1, tool->y2 - tool->y1);
+    */
 
     gdk_pointer_grab (gtk_widget_get_window (ddisp->canvas), FALSE,
                       GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
@@ -640,9 +635,12 @@ modify_motion(ModifyTool *tool, GdkEventMotion *event,
 
     if (!auto_scroll && !tool->auto_scrolled)
     {
+          /* TODO: Selection Box
+
       gdk_draw_rectangle (gtk_widget_get_window (ddisp->canvas), tool->gc, FALSE,
                          tool->x1, tool->y1,
                          tool->x2 - tool->x1, tool->y2 - tool->y1);
+        */
     }
 
     tool->end_box = to;
@@ -656,9 +654,13 @@ modify_motion(ModifyTool *tool, GdkEventMotion *event,
                              MAX(tool->start_box.y, tool->end_box.y),
                              &tool->x2, &tool->y2);
 
+                /* TODO: Selection Box
+
+
     gdk_draw_rectangle (gtk_widget_get_window (ddisp->canvas), tool->gc, FALSE,
                        tool->x1, tool->y1,
                        tool->x2 - tool->x1, tool->y2 - tool->y1);
+      */
     break;
   case STATE_NONE:
     
@@ -794,9 +796,12 @@ modify_button_release(ModifyTool *tool, GdkEventButton *event,
     gdk_pointer_ungrab (event->time);
     /* Remove last box: */
     if (!tool->auto_scrolled) {
+          /* TODO: Selection Box
+
       gdk_draw_rectangle (gtk_widget_get_window (ddisp->canvas), tool->gc, FALSE,
                        tool->x1, tool->y1,
                        tool->x2 - tool->x1, tool->y2 - tool->y1);
+      */
     }
 
     {
diff --git a/app/navigation.c b/app/navigation.c
index 649adfc1..9deecb3e 100644
--- a/app/navigation.c
+++ b/app/navigation.c
@@ -77,7 +77,7 @@ static void on_button_navigation_popup_released (GtkButton * button, gpointer un
 
 static void reset_sc_adj (GtkAdjustment * adj, gdouble lower, gdouble upper, gdouble page);
 
-static gboolean on_da_expose_event         (GtkWidget * widget, GdkEventExpose * event, gpointer unused);
+static gboolean on_da_draw                 (GtkWidget * widget, cairo_t *ctx);
 static gboolean on_da_motion_notify_event  (GtkWidget * widget, GdkEventMotion * event, gpointer unused);
 static gboolean on_da_button_release_event (GtkWidget * widget, GdkEventButton * event, gpointer 
popup_window);
 
@@ -104,8 +104,7 @@ navigation_popup_new (DDisplay *ddisp)
   GtkWidget * button;
 
   GtkWidget * image;
-  GdkPixmap * pixmap;
-  GdkBitmap * mask = NULL;
+  GdkPixbuf * pixbuf;
   GtkStyle  * style;
 
   button = gtk_button_new ();
@@ -118,15 +117,10 @@ navigation_popup_new (DDisplay *ddisp)
                     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,
-                                                 &(style->bg[GTK_STATE_NORMAL]),
-                                                 nav_xpm);
+  pixbuf = gdk_pixbuf_new_from_xpm_data (nav_xpm);
 
-  image = gtk_image_new_from_pixmap (pixmap, mask);
-  g_object_unref(pixmap);
-  g_object_unref(mask);
+  image = gtk_image_new_from_pixbuf (pixbuf);
+  g_object_unref(pixbuf);
 
   gtk_container_add (GTK_CONTAINER (button), image);
   gtk_widget_show(image);
@@ -182,8 +176,8 @@ on_button_navigation_popup_pressed (GtkButton * button, gpointer _ddisp)
     if (diagram_width * diagram_height == 0)
       return; /* don't crash with no size, i.e. empty diagram */
 
-    canvas_width   = nav->ddisp->canvas->allocation.width;
-    canvas_height  = nav->ddisp->canvas->allocation.height;
+    canvas_width   = gtk_widget_get_allocated_width (nav->ddisp->canvas);
+    canvas_height  = gtk_widget_get_allocated_height (nav->ddisp->canvas);
 
     nav->frame_w = nav->width  * canvas_width  / diagram_width;
     nav->frame_h = nav->height * canvas_height / diagram_height;
@@ -193,11 +187,11 @@ on_button_navigation_popup_pressed (GtkButton * button, gpointer _ddisp)
     /*and store the ratio thumbnail/adjustement(speedup on motion)*/
     adj = nav->ddisp->hsbdata;
     reset_sc_adj (adj, rect.left, rect.right, canvas_width / nav->ddisp->zoom_factor);
-    nav->hadj_coef = (adj->upper - adj->page_size - adj->lower) / (nav->width - nav->frame_w);
+    nav->hadj_coef = (gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj) - 
gtk_adjustment_get_lower (adj)) / (nav->width - nav->frame_w);
 
     adj = nav->ddisp->vsbdata;
     reset_sc_adj (adj, rect.top, rect.bottom, canvas_height / nav->ddisp->zoom_factor);
-    nav->vadj_coef = (adj->upper - adj->page_size - adj->lower) / (nav->height - nav->frame_h);
+    nav->vadj_coef = (gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj) - 
gtk_adjustment_get_lower (adj)) / (nav->height - nav->frame_h);
   }
   
   /*--GUI*/
@@ -219,8 +213,8 @@ on_button_navigation_popup_pressed (GtkButton * button, gpointer _ddisp)
                          | GDK_BUTTON_RELEASE_MASK
                          );
 
-  g_signal_connect (G_OBJECT (drawing_area), "expose_event",
-                    G_CALLBACK (on_da_expose_event), NULL);
+  g_signal_connect (G_OBJECT (drawing_area), "draw",
+                    G_CALLBACK (on_da_draw), NULL);
   g_signal_connect (G_OBJECT (drawing_area), "motion_notify_event",
                     G_CALLBACK (on_da_motion_notify_event), NULL);
   g_signal_connect (G_OBJECT (drawing_area), "button_release_event",
@@ -237,14 +231,16 @@ on_button_navigation_popup_pressed (GtkButton * button, gpointer _ddisp)
   if (MIN(nav->frame_h, nav->frame_w) > STD_CURSOR_MIN) {
     nav->cursor = gdk_cursor_new (GDK_FLEUR);
   } else { /*the miniframe is very small, so we use a minimalist cursor*/
-    gchar cursor_none_data[] = { 0x00 };
-    GdkBitmap * bitmap;
-    GdkRGBA fg = { 0, 1, 1, 1 };
-    GdkRGBA bg = { 0, 0, 0, 0 };
-
-    bitmap = gdk_bitmap_create_from_data(NULL, cursor_none_data, 1, 1);
-    nav->cursor = gdk_cursor_new_from_pixmap(bitmap, bitmap, &fg, &bg, 1, 1);
-    g_object_unref(bitmap);
+    gchar cursor_none_data[] = { 0x00, 0xFF, 0xFF };
+    GdkPixbuf * pixbuf;
+
+    pixbuf = gdk_pixbuf_new_from_data (cursor_none_data,
+                                       GDK_COLORSPACE_RGB,
+                                       FALSE,
+                                       8, 1, 1, 0,
+                                       NULL, NULL);
+    nav->cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default(), pixbuf, 1, 1);
+    g_object_unref(pixbuf);
   }
 
   /*grab the pointer*/
@@ -275,42 +271,40 @@ on_button_navigation_popup_pressed (GtkButton * button, gpointer _ddisp)
 static void
 reset_sc_adj (GtkAdjustment * adj, gdouble lower, gdouble upper, gdouble page)
 {
-  adj->page_size = page;
+  gtk_adjustment_set_page_size (adj, page);
 
-  adj->lower = lower;
-  adj->upper = upper;
+  gtk_adjustment_set_lower (adj, lower);
+  gtk_adjustment_set_upper (adj, upper);
 
-  if (adj->value < lower) adj->value = lower;
-  if (adj->value > (upper - page)) adj->value = upper - page;
+  if (gtk_adjustment_get_value (adj) < lower) gtk_adjustment_set_value (adj, lower);
+  if (gtk_adjustment_get_value (adj) > (upper - page)) gtk_adjustment_set_value (adj, upper - page);
 
   gtk_adjustment_changed(adj);
 }
 
 
 static gboolean
-on_da_expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer unused)
+on_da_draw (GtkWidget * widget, cairo_t *ctx)
 {
   GtkAdjustment * adj;
   int x, y;
-  cairo_t *ctx;
 
-  ctx = gdk_cairo_create (gtk_widget_get_window (widget));
   cairo_set_line_width (ctx, FRAME_THICKNESS);
   cairo_set_line_cap (ctx, CAIRO_LINE_CAP_BUTT);
   cairo_set_line_join (ctx, CAIRO_LINE_JOIN_MITER);
 
   /*refresh the part outdated by the event*/
-  cairo_set_source_surface (ctx, nav->surface,
-                            event->area.x, event->area.y);
-  cairo_rectangle (ctx, event->area.x, event->area.y,
-                        event->area.width, event->area.height);
+  cairo_set_source_surface (ctx, nav->surface, 0, 0);
+  cairo_rectangle (ctx, 0, 0,
+                        gtk_widget_get_allocated_width (widget),
+                        gtk_widget_get_allocated_height (widget));
   cairo_fill (ctx);
 
   adj = nav->ddisp->hsbdata;
-  x = (adj->value - adj->lower) / (adj->upper - adj->lower) * (nav->width) +1;
+  x = (gtk_adjustment_get_value (adj) - gtk_adjustment_get_lower (adj)) / (gtk_adjustment_get_upper (adj) - 
gtk_adjustment_get_lower (adj)) * (nav->width) +1;
 
   adj = nav->ddisp->vsbdata;
-  y = (adj->value - adj->lower) / (adj->upper - adj->lower) * (nav->height) +1;
+  y = (gtk_adjustment_get_value (adj) - gtk_adjustment_get_lower (adj)) / (gtk_adjustment_get_upper (adj) - 
gtk_adjustment_get_lower (adj)) * (nav->height) +1;
 
   /*draw directly on the window, do not buffer the miniframe*/
   cairo_set_source_rgb (ctx, 0, 0, 0);
@@ -343,15 +337,15 @@ on_da_motion_notify_event (GtkWidget * drawing_area, GdkEventMotion * event, gpo
   adj = nav->ddisp->hsbdata;
   value_changed = FALSE;
   if (w/2 <= event->x && event->x <= (nav->width - w/2)){
-    adj->value = adj->lower + x * nav->hadj_coef;
+    gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj) + x * nav->hadj_coef);
     value_changed = TRUE;
   }
-  else if (x == 0 && adj->value != adj->lower){/*you've been too fast! :)*/
-    adj->value = adj->lower;
+  else if (x == 0 && gtk_adjustment_get_value (adj) != gtk_adjustment_get_lower (adj)){/*you've been too 
fast! :)*/
+    gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
     value_changed = TRUE;
   }
-  else if (x == (nav->width - w) && adj->value != (adj->upper - adj->page_size)){/*idem*/
-    adj->value = adj->upper - adj->page_size;
+  else if (x == (nav->width - w) && gtk_adjustment_get_value (adj) != (gtk_adjustment_get_upper (adj) - 
gtk_adjustment_get_page_size (adj))){/*idem*/
+    gtk_adjustment_set_value (adj, gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj));
     value_changed = TRUE;
   }
   if (value_changed) gtk_adjustment_value_changed(adj);
@@ -359,15 +353,15 @@ on_da_motion_notify_event (GtkWidget * drawing_area, GdkEventMotion * event, gpo
   adj = nav->ddisp->vsbdata;
   value_changed = FALSE;
   if (h/2 <= event->y && event->y <= (nav->height - h/2)){
-    adj->value = adj->lower + y * nav->vadj_coef;
+     gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj) + y * nav->vadj_coef);
     value_changed = TRUE;
   }
-  else if (y == 0 && adj->value != adj->lower){/*you've been too fast! :)*/
-    adj->value = adj->lower;
+  else if (y == 0 && gtk_adjustment_get_value (adj) != gtk_adjustment_get_lower (adj)){/*you've been too 
fast! :)*/
+     gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
     value_changed = TRUE;
   }
-  else if (y == (nav->height - h) && adj->value != (adj->upper - adj->page_size)){/*idem*/
-    adj->value = adj->upper - adj->page_size;
+  else if (y == (nav->height - h) && gtk_adjustment_get_value (adj) != (gtk_adjustment_get_upper (adj) - 
gtk_adjustment_get_page_size (adj))){/*idem*/
+    gtk_adjustment_set_value (adj, gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj));
     value_changed = TRUE;
   }
   if (value_changed) gtk_adjustment_value_changed(adj);
@@ -386,7 +380,7 @@ on_da_button_release_event (GtkWidget * widget, GdkEventButton * event, gpointer
    * Protected calls to avoid crashing on second pass.
    */
   if (nav->cursor)
-    gdk_cursor_unref (nav->cursor);
+    g_object_unref (nav->cursor);
   nav->cursor = NULL;
 
   if (nav->popup_window)
diff --git a/app/sheets_dialog_callbacks.c b/app/sheets_dialog_callbacks.c
index b21042ae..9cde9384 100644
--- a/app/sheets_dialog_callbacks.c
+++ b/app/sheets_dialog_callbacks.c
@@ -255,7 +255,7 @@ sheets_dialog_wrapbox_add_line_break(GtkWidget *wrapbox)
   SheetMod *sm;
   GtkWidget *button;
   GtkStyle *style;
-  GdkPixmap *pixmap, *mask;
+  GdkPixbuf *pixmap, *mask;
   GtkWidget *gtkpixmap;
 
   sm = g_object_get_data(G_OBJECT(wrapbox), "sheet_mod");
@@ -272,14 +272,9 @@ sheets_dialog_wrapbox_add_line_break(GtkWidget *wrapbox)
   gtk_container_set_border_width(GTK_CONTAINER(button), 0);
 
   style = gtk_widget_get_style(wrapbox);
-  pixmap =
-    gdk_pixmap_colormap_create_from_xpm_d(NULL,
-                                          gtk_widget_get_colormap(wrapbox),
-                                          &mask,
-                                          &style->bg[GTK_STATE_NORMAL],
-                                          line_break_xpm);
-
-  gtkpixmap = gtk_pixmap_new(pixmap, mask);
+  pixmap = gdk_pixbuf_new_from_xpm_data ((const gchar **) line_break_xpm);
+
+  gtkpixmap = gtk_image_new_from_pixbuf (pixmap);
   gtk_container_add(GTK_CONTAINER(button), gtkpixmap);
   gtk_widget_show(gtkpixmap);
 
@@ -319,7 +314,7 @@ sheets_dialog_create_object_button(SheetObjectMod *som, SheetMod *sm,
                                    GtkWidget *wrapbox)
 {
   GtkWidget *button;
-  GdkPixmap *pixmap, *mask;
+  GdkPixbuf *pixmap;
   GtkWidget *gtkpixmap;
 
   button = gtk_radio_button_new(radio_group);
@@ -328,8 +323,8 @@ sheets_dialog_create_object_button(SheetObjectMod *som, SheetMod *sm,
   gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button), FALSE);
   gtk_container_set_border_width(GTK_CONTAINER(button), 0);
 
-  create_object_pixmap(&som->sheet_object, wrapbox, &pixmap, &mask);
-  gtkpixmap = gtk_pixmap_new(pixmap, mask);
+  create_object_pixmap(&som->sheet_object, wrapbox, &pixmap);
+  gtkpixmap = gtk_image_new_from_pixbuf (pixmap);
   gtk_container_add(GTK_CONTAINER(button), gtkpixmap);
   gtk_widget_show(gtkpixmap);
 
@@ -946,8 +941,8 @@ on_sheets_shapeselection_dialog_button_ok_clicked
   GtkWidget *entry;
 
   filename =
-      gtk_file_selection_get_filename(
-          GTK_FILE_SELECTION(sheets_shapeselection_dialog));
+      gtk_file_chooser_get_filename(
+          GTK_FILE_CHOOSER(sheets_shapeselection_dialog));
 
   entry = lookup_widget(sheets_new_dialog, "combo_entry_from_file");
   /* Since this is a filename entry from the dialog, no utf is needed */


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