[dia/zbrown/test-build: 4/6] app: further drawing thunks




commit 746e083f517b2614f93c92e6c3456ecc26534b44
Author: Zander Brown <zbrown gnome org>
Date:   Fri Sep 24 04:29:14 2021 +0100

    app: further drawing thunks

 app/dia-page-layout.c | 37 ++++++++++++++++++++++++++++++-------
 app/gtkhwrapbox.c     |  3 +--
 app/gtkwrapbox.c      | 12 +-----------
 app/gtkwrapbox.h      |  2 +-
 app/ruler.c           | 14 ++++++++++----
 app/splash.c          | 47 +++++++++++++++++++++++++++++------------------
 6 files changed, 72 insertions(+), 43 deletions(-)
---
diff --git a/app/dia-page-layout.c b/app/dia-page-layout.c
index c58fa138a..9be8a61a7 100644
--- a/app/dia-page-layout.c
+++ b/app/dia-page-layout.c
@@ -83,7 +83,10 @@ dia_page_layout_class_init (DiaPageLayoutClass *klass)
 
 
 static void darea_size_allocate(DiaPageLayout *self, GtkAllocation *alloc);
-static int darea_expose_event(DiaPageLayout *self, GdkEventExpose *ev);
+static gboolean darea_draw (GtkWidget *self, cairo_t *ctx);
+#if !GTK_CHECK_VERSION (3, 0, 0)
+static gboolean darea_expose_event (GtkWidget *self, GdkEventExpose *ev);
+#endif
 static void paper_size_change(GtkWidget *widget, DiaPageLayout *self);
 static void orient_changed(DiaPageLayout *self);
 static void margin_changed(DiaPageLayout *self);
@@ -330,8 +333,11 @@ dia_page_layout_init (DiaPageLayout *self)
                             G_CALLBACK (darea_size_allocate),
                             G_OBJECT (self));
   g_signal_connect_swapped (G_OBJECT (self->darea),
-                            "expose_event",
-                            G_CALLBACK (darea_expose_event),
+#if GTK_CHECK_VERSION (3, 0, 0)
+                            "draw", G_CALLBACK (darea_draw),
+#else
+                            "expose-event", G_CALLBACK (darea_expose_event),
+#endif
                             G_OBJECT (self));
 
   self->block_changed = FALSE;
@@ -633,19 +639,18 @@ darea_size_allocate (DiaPageLayout *self, GtkAllocation *allocation)
 }
 
 
-static int
-darea_expose_event (DiaPageLayout *self, GdkEventExpose *event)
+static gboolean
+darea_draw (GtkWidget *widget, cairo_t *ctx)
 {
+  DiaPageLayout *self = DIA_PAGE_LAYOUT (widget);
   GdkWindow *window = gtk_widget_get_window (self->darea);
   double val;
   int num;
-  cairo_t *ctx;
   GtkAllocation alloc;
 
   if (!window)
     return FALSE;
 
-  ctx = gdk_cairo_create (window);
   cairo_set_line_cap (ctx, CAIRO_LINE_CAP_SQUARE);
   cairo_set_line_width (ctx, 1);
   cairo_set_antialias (ctx, CAIRO_ANTIALIAS_NONE);
@@ -738,6 +743,24 @@ darea_expose_event (DiaPageLayout *self, GdkEventExpose *event)
 }
 
 
+#if !GTK_CHECK_VERSION (3, 0, 0)
+static gboolean
+darea_expose_event (GtkWidget *widget, GdkEventExpose *event)
+{
+  cairo_t *ctx;
+  gboolean res;
+
+  ctx = gdk_cairo_create (GDK_DRAWABLE (gtk_widget_get_window (widget)));
+
+  res = darea_draw (widget, ctx);
+
+  cairo_destroy (ctx);
+
+  return res;
+}
+#endif
+
+
 /**
  * max_margin:
  * @size: page size
diff --git a/app/gtkhwrapbox.c b/app/gtkhwrapbox.c
index eccd8ee4d..72940c40b 100644
--- a/app/gtkhwrapbox.c
+++ b/app/gtkhwrapbox.c
@@ -22,9 +22,8 @@
 
 #include "config.h"
 
+#include <gtk/gtk.h>
 #include "gtkhwrapbox.h"
-#include <gtk/gtkversion.h>
-
 
 /* --- prototypes --- */
 static void    gtk_hwrap_box_class_init    (GtkHWrapBoxClass   *klass);
diff --git a/app/gtkwrapbox.c b/app/gtkwrapbox.c
index 53773db59..32b8650ff 100644
--- a/app/gtkwrapbox.c
+++ b/app/gtkwrapbox.c
@@ -23,7 +23,7 @@
 #include "config.h"
 
 #include "gtkwrapbox.h"
-#include <gtk/gtkversion.h>
+#include <gtk/gtk.h>
 
 
 /* --- properties --- */
@@ -73,8 +73,6 @@ static void gtk_wrap_box_get_child_property (GtkContainer    *container,
                                              GParamSpec      *pspec);
 static void gtk_wrap_box_map           (GtkWidget          *widget);
 static void gtk_wrap_box_unmap         (GtkWidget          *widget);
-static gint gtk_wrap_box_expose        (GtkWidget          *widget,
-                                        GdkEventExpose     *event);
 static void gtk_wrap_box_add           (GtkContainer       *container,
                                         GtkWidget          *widget);
 static void gtk_wrap_box_remove        (GtkContainer       *container,
@@ -136,7 +134,6 @@ gtk_wrap_box_class_init (GtkWrapBoxClass *class)
 
   widget_class->map = gtk_wrap_box_map;
   widget_class->unmap = gtk_wrap_box_unmap;
-  widget_class->expose_event = gtk_wrap_box_expose;
 
   container_class->add = gtk_wrap_box_add;
   container_class->remove = gtk_wrap_box_remove;
@@ -833,13 +830,6 @@ gtk_wrap_box_unmap (GtkWidget *widget)
       gtk_widget_unmap (child->widget);
 }
 
-static gint
-gtk_wrap_box_expose (GtkWidget      *widget,
-                     GdkEventExpose *event)
-{
-  return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
-}
-
 static void
 gtk_wrap_box_add (GtkContainer *container,
                   GtkWidget    *widget)
diff --git a/app/gtkwrapbox.h b/app/gtkwrapbox.h
index e557b5da7..dc65444ed 100644
--- a/app/gtkwrapbox.h
+++ b/app/gtkwrapbox.h
@@ -24,7 +24,7 @@
 #define __GTK_WRAP_BOX_H__
 
 
-#include <gtk/gtkcontainer.h>
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
diff --git a/app/ruler.c b/app/ruler.c
index 764f52af5..3ee619ce0 100644
--- a/app/ruler.c
+++ b/app/ruler.c
@@ -143,6 +143,8 @@ dia_ruler_draw (GtkWidget *widget,
   return FALSE;
 }
 
+
+#if !GTK_CHECK_VERSION (3, 0, 0)
 /* Wrapper can go with Gtk+-3.0 */
 static gboolean
 dia_ruler_expose_event (GtkWidget      *widget,
@@ -159,6 +161,8 @@ dia_ruler_expose_event (GtkWidget      *widget,
     }
   return FALSE;
 }
+#endif
+
 
 static gboolean
 dia_ruler_motion_notify (GtkWidget      *widget,
@@ -180,8 +184,6 @@ dia_ruler_motion_notify (GtkWidget      *widget,
   width = alloc.width;
   height = alloc.height;
 
-  gdk_drawable_get_size (gtk_widget_get_window (widget), &width, &height);
-
   if (ruler->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       /* get old position in display coordinates */
@@ -218,16 +220,20 @@ dia_ruler_motion_notify (GtkWidget      *widget,
   return FALSE;
 }
 
+
 static void
 dia_ruler_class_init (DiaRulerClass *klass)
 {
-  GtkWidgetClass *widget_class  = GTK_WIDGET_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-#if !GTK_CHECK_VERSION(3,0,0)
+#if GTK_CHECK_VERSION (3, 0, 0)
+  widget_class->draw = dia_ruler_draw;
+#else
   widget_class->expose_event = dia_ruler_expose_event;
 #endif
 }
 
+
 static void
 dia_ruler_init (DiaRuler *rule)
 {
diff --git a/app/splash.c b/app/splash.c
index da84309da..8d6612cfd 100644
--- a/app/splash.c
+++ b/app/splash.c
@@ -1,30 +1,39 @@
-#include <config.h>
+#include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include "intl.h"
-#include "dia_dirs.h"
 #include "app_procs.h"
 #include "widgets.h"
 
-static GtkWidget* splash = NULL;
+static GtkWidget *splash = NULL;
+
+
+static gboolean
+splash_quit (gpointer data)
+{
+  gtk_main_quit ();
+
+  return G_SOURCE_REMOVE;
+}
+
 
 static void
-splash_expose (GtkWidget *widget, GdkEventExpose *event)
+splash_realize (GtkWidget *widget, GdkEventExpose *event)
 {
-  /* this gets called after the splash screen gets exposed ... */
-  gtk_main_quit();
+  /* this gets called after the splash screen gets realized ... */
+  g_idle_add (splash_quit, NULL);
 }
 
+
 void
-app_splash_init (const gchar* fname)
+app_splash_init (const char *fname)
 {
   GtkWidget *vbox;
-  GtkWidget* gpixmap;
+  GtkWidget *gpixmap;
   GtkWidget *label;
   GtkWidget *frame;
-  gchar str[256];
+  char str[256];
   gulong signal_id;
 
   splash = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -50,21 +59,23 @@ app_splash_init (const gchar* fname)
   label = gtk_label_new (str);
   gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 1);
 
-  gtk_widget_show_all (splash);
+  signal_id = g_signal_connect_after (G_OBJECT (splash),
+                                      "realize", G_CALLBACK (splash_realize),
+                                      NULL);
 
-  signal_id = g_signal_connect_after (G_OBJECT (splash), "expose-event",
-                                      G_CALLBACK (splash_expose), NULL);
+  gtk_widget_show_all (splash);
 
-  /* splash_expose gets us out of this */
+  /* splash_realize gets us out of this */
   gtk_main();
-  g_signal_handler_disconnect(G_OBJECT(splash), signal_id);
+
+  g_signal_handler_disconnect (G_OBJECT (splash), signal_id);
 }
 
+
 void
 app_splash_done (void)
 {
-  if (splash)
-  {
+  if (splash) {
     gtk_widget_destroy (splash);
     splash = NULL;
   }


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