[gtkmm] Update for the latest gtk+4 (remove WidgetCustomDraw)



commit 7e406e8bd852626d3b5403f3ce531889ce982a4c
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Apr 16 11:21:30 2018 +0200

    Update for the latest gtk+4 (remove WidgetCustomDraw)
    
    * demos/gtk-demo/example_drawingarea.cc: Update for changes in Gtk::Widget.
    * gdk/gdkmm/general.[cc|h]: Remove create_surface_from_pixbuf().
    * gdk/src/drawingcontext.hg: Remove get_surface(), is_valid() and
    get_drawing_context_from_cairo_context().
    * gdk/src/surface.hg: Remove create_similar_image_surface().
    * gtk/gtkmm/filelist.am: Remove widgetcustomdraw.
    * gtk/gtkmm/widgetcustomdraw.[cc|h]: Removed files.
    * gtk/src/snapshot.[ccg|hg]: Add clips_rect(const graphene_rect_t*).
    * gtk/src/widget.[ccg|hg]: Remove queue_draw_area(), queue_draw_region(),
    get_clip(), draw() and set_realized().
    Remove a parameter from size_allocate() and signal_size_allocate().
    * tools/m4/convert_gdk.m4: Remove a conversion to Cairo::ImageSurface.

 demos/gtk-demo/example_drawingarea.cc |    9 +--
 gdk/gdkmm/general.cc                  |    7 --
 gdk/gdkmm/general.h                   |   13 ---
 gdk/src/drawingcontext.hg             |    7 --
 gdk/src/surface.hg                    |    3 -
 gtk/gtkmm/filelist.am                 |    2 -
 gtk/gtkmm/widgetcustomdraw.cc         |  153 ---------------------------------
 gtk/gtkmm/widgetcustomdraw.h          |  118 -------------------------
 gtk/src/snapshot.ccg                  |   19 +++-
 gtk/src/snapshot.hg                   |    3 +-
 gtk/src/widget.ccg                    |    8 --
 gtk/src/widget.hg                     |   31 +------
 tools/m4/convert_gdk.m4               |    1 -
 13 files changed, 21 insertions(+), 353 deletions(-)
---
diff --git a/demos/gtk-demo/example_drawingarea.cc b/demos/gtk-demo/example_drawingarea.cc
index 05854f5..feb6122 100644
--- a/demos/gtk-demo/example_drawingarea.cc
+++ b/demos/gtk-demo/example_drawingarea.cc
@@ -27,8 +27,7 @@ protected:
   void on_drawingarea_scribble_draw(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height);
 
   //signal handlers:
-  void on_drawingarea_scribble_size_allocate(const Gtk::Allocation& allocation,
-    int baseline, Gtk::Allocation& out_clip);
+  void on_drawingarea_scribble_size_allocate(const Gtk::Allocation& allocation, int baseline);
   void on_drawingarea_scribble_drag_begin(double start_x, double start_y);
   void on_drawingarea_scribble_drag_update(double offset_x, double offset_y);
   void on_drawingarea_scribble_drag_end(double offset_x, double offset_y);
@@ -178,8 +177,7 @@ void Example_DrawingArea::scribble_create_surface()
 }
 
 void Example_DrawingArea::on_drawingarea_scribble_size_allocate(
-  const Gtk::Allocation& /* allocation */, int /* baseline */,
-  Gtk::Allocation& /* out_clip */)
+  const Gtk::Allocation& /* allocation */, int /* baseline */)
 {
   scribble_create_surface();
 }
@@ -216,6 +214,5 @@ void Example_DrawingArea::scribble_draw_brush(double x, double y)
   Gdk::Cairo::add_rectangle_to_path(cr, update_rect);
   cr->fill();
 
-  m_DrawingArea_Scribble.queue_draw_area(update_rect.get_x(), update_rect.get_y(),
-    update_rect.get_width(), update_rect.get_height());
+  m_DrawingArea_Scribble.queue_draw();
 }
diff --git a/gdk/gdkmm/general.cc b/gdk/gdkmm/general.cc
index 99bddb5..8fee020 100644
--- a/gdk/gdkmm/general.cc
+++ b/gdk/gdkmm/general.cc
@@ -62,13 +62,6 @@ bool get_clip_rectangle(const ::Cairo::RefPtr< ::Cairo::Context >& context)
   return Gdk::Cairo::wrap(gdk_cairo_region_create_from_surface(surface->cobj()), true);
 }
 
-::Cairo::RefPtr< ::Cairo::Surface> create_surface_from_pixbuf(const Glib::RefPtr<const Gdk::Pixbuf>& pixbuf,
-  int scale, const Glib::RefPtr<Gdk::Surface>& for_surface)
-{
-  return Gdk::Cairo::wrap(gdk_cairo_surface_create_from_pixbuf(
-    pixbuf->gobj(), scale, for_surface ? for_surface->gobj() : nullptr), true);
-}
-
 void draw_from_gl(const ::Cairo::RefPtr< ::Cairo::Context >& context,
   const Glib::RefPtr<Gdk::Surface>& surface, int source, int source_type,
   int buffer_scale, int x, int y, int width, int height)
diff --git a/gdk/gdkmm/general.h b/gdk/gdkmm/general.h
index 91567af..72b7ae2 100644
--- a/gdk/gdkmm/general.h
+++ b/gdk/gdkmm/general.h
@@ -108,19 +108,6 @@ bool get_clip_rectangle(const ::Cairo::RefPtr< ::Cairo::Context >& context);
  */
 ::Cairo::RefPtr< ::Cairo::Region> create_region_from_surface(const ::Cairo::RefPtr< ::Cairo::Surface>& 
surface);
 
-/** Creates an image surface with the same contents as the pixbuf.
- *
- * @param pixbuf A Gdk::Pixbuf.
- * @param scale The scale of the new surface, or 0 to use same as @a for_surface.
- * @param for_surface The surface this will be drawn to, or an empty
- *        Glib::RefPtr<Gdk::Surface> if none.
- * @returns A new cairo surface.
- *
- * @newin{3,92}
- */
-::Cairo::RefPtr< ::Cairo::Surface> create_surface_from_pixbuf(const Glib::RefPtr<const Gdk::Pixbuf>& pixbuf,
-  int scale, const Glib::RefPtr<Gdk::Surface>& for_surface = {});
-
 /** This is the main way to draw GL content in gtkmm.
  * It takes a render buffer ID (@a source_type == GL_RENDERBUFFER) or a texture id
  * (@a source_type == GL_TEXTURE) and draws it onto @a context with an OVER operation,
diff --git a/gdk/src/drawingcontext.hg b/gdk/src/drawingcontext.hg
index 5b690fb..ccacde1 100644
--- a/gdk/src/drawingcontext.hg
+++ b/gdk/src/drawingcontext.hg
@@ -48,22 +48,15 @@ protected:
   _CTOR_DEFAULT()
 
 public:
-  _WRAP_METHOD(Glib::RefPtr<Surface> get_surface(), gdk_drawing_context_get_surface, refreturn)
-  _WRAP_METHOD(Glib::RefPtr<const Surface> get_surface() const, gdk_drawing_context_get_surface, refreturn, 
constversion)
-
   _WRAP_METHOD(Glib::RefPtr<DrawContext> get_paint_context(), gdk_drawing_context_get_paint_context, 
refreturn,)
   _WRAP_METHOD(Glib::RefPtr<const DrawContext> get_paint_context() const, 
gdk_drawing_context_get_paint_context, refreturn, constversion)
 
   // This is const because it returns a copy.
   _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Region> get_clip() const, gdk_drawing_context_get_clip)
 
-  _WRAP_METHOD(bool is_valid() const, gdk_drawing_context_is_valid)
-
   _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Context> get_cairo_context(), 
gdk_drawing_context_get_cairo_context, refreturn)
   _WRAP_METHOD(::Cairo::RefPtr<const ::Cairo::Context> get_cairo_context() const, 
gdk_drawing_context_get_cairo_context, refreturn, constversion)
 
-  _WRAP_METHOD(static Glib::RefPtr<DrawingContext> get_drawing_context_from_cairo_context(const 
::Cairo::RefPtr< ::Cairo::Context>& cr), gdk_cairo_get_drawing_context, refreturn)
-
   _WRAP_PROPERTY("surface", Glib::RefPtr<Surface>)
   _WRAP_PROPERTY("clip", ::Cairo::RefPtr< ::Cairo::Region>, newin "3,92")
   _WRAP_PROPERTY("paint-context", Glib::RefPtr<DrawContext>)
diff --git a/gdk/src/surface.hg b/gdk/src/surface.hg
index 7e6ef77..812287a 100644
--- a/gdk/src/surface.hg
+++ b/gdk/src/surface.hg
@@ -206,9 +206,6 @@ public:
   #m4 _CONVERSION(`::Cairo::Content',`cairo_content_t',`(cairo_content_t)($3)')
   _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Surface> create_similar_surface(::Cairo::Content content, int 
width,  int height), gdk_surface_create_similar_surface )
 
-  #m4 _CONVERSION(`::Cairo::Surface::Format',`cairo_format_t',`(cairo_format_t)($3)')
-  _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::ImageSurface> create_similar_image_surface(::Cairo::Surface::Format 
format, int width, int height, int scale), gdk_surface_create_similar_image_surface)
-
   _WRAP_METHOD(void beep(), gdk_surface_beep)
 
   _WRAP_METHOD(void iconify(), gdk_surface_iconify)
diff --git a/gtk/gtkmm/filelist.am b/gtk/gtkmm/filelist.am
index b9ed5fc..ba9ed56 100644
--- a/gtk/gtkmm/filelist.am
+++ b/gtk/gtkmm/filelist.am
@@ -16,7 +16,6 @@ gtkmm_files_extra_any_cc =            \
        selectiondata_private.cc        \
        treemodelcolumn.cc              \
        treeview_private.cc \
-       widgetcustomdraw.cc \
        widgetcustomsnapshot.cc
 
 gtkmm_files_extra_deprecated_cc =
@@ -35,7 +34,6 @@ gtkmm_files_extra_any_h =                     \
        selectiondata_private.h         \
        treemodelcolumn.h               \
        treeview_private.h              \
-       widgetcustomdraw.h \
        widgetcustomsnapshot.h \
        wrap_init.h
 
diff --git a/gtk/src/snapshot.ccg b/gtk/src/snapshot.ccg
index dd59241..05a4f9b 100644
--- a/gtk/src/snapshot.ccg
+++ b/gtk/src/snapshot.ccg
@@ -16,6 +16,19 @@
 
 #include <gtk/gtk.h>
 #include <gdkmm/cairoutils.h>
+#include <memory>
+
+namespace
+{
+std::unique_ptr<graphene_rect_t>
+gdk_rect_to_graphene_rect(const Gdk::Rectangle& gdk_rect)
+{
+  graphene_rect_t* graphene_rect = new graphene_rect_t;
+  graphene_rect_init(graphene_rect, gdk_rect.get_x(), gdk_rect.get_y(),
+    gdk_rect.get_width(), gdk_rect.get_height());
+  return std::unique_ptr<graphene_rect_t>(graphene_rect);
+}
+} // anonymous namespace
 
 namespace Gtk
 {
@@ -51,11 +64,7 @@ Cairo::RefPtr<Cairo::Context> Snapshot::append_cairo(
 Cairo::RefPtr<Cairo::Context> Snapshot::append_cairo(
   const Gdk::Rectangle& bounds, const Glib::ustring& name)
 {
-  graphene_rect_t rect;
-  graphene_rect_init(&rect, bounds.get_x(), bounds.get_y(),
-    bounds.get_width(), bounds.get_height());
-
-  return append_cairo(&rect, name);
+  return append_cairo(gdk_rect_to_graphene_rect(bounds).get(), name);
 }
 
 } //namespace Gtk
diff --git a/gtk/src/snapshot.hg b/gtk/src/snapshot.hg
index f161f3a..dbf0943 100644
--- a/gtk/src/snapshot.hg
+++ b/gtk/src/snapshot.hg
@@ -133,7 +133,8 @@ public:
   //TODO: Wrap gtk_snapshot_append_texture()?
   //TODO: Wrap gtk_snapshot_append_color()?
 
-#m4 _CONVERSION(`const Gdk::Rectangle&', `const cairo_rectangle_int_t*', `($3).gobj()')
+  _WRAP_METHOD(bool clips_rect(const graphene_rect_t* bounds) const, gtk_snapshot_clips_rect)
+#m4 _CONVERSION(`const Gdk::Rectangle&', `const graphene_rect_t*', `gdk_rect_to_graphene_rect($3).get()')
   _WRAP_METHOD(bool clips_rect(const Gdk::Rectangle& bounds) const, gtk_snapshot_clips_rect)
 
   _WRAP_METHOD(void render_backgrount(const Glib::RefPtr<StyleContext>& context,
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index 8a2fad5..147e3de 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -355,14 +355,6 @@ void Widget::set_surface(const Glib::RefPtr<Gdk::Surface>& surface)
     surface->reference(); // gtk_widget_set_surface does not add a ref.
 }
 
-Allocation Widget::get_clip() const
-{
-  Allocation allocation;
-  gtk_widget_get_clip(const_cast<GtkWidget*>(gobj()), allocation.gobj());
-  return allocation;
-}
-
-
 Allocation Widget::get_allocation() const
 {
   Allocation allocation;
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 820f57a..f140404 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -113,12 +113,10 @@ public:
 /* QUEUE DRAWS */
 
   _WRAP_METHOD(void queue_draw(), gtk_widget_queue_draw)
-  _WRAP_METHOD(void queue_draw_area(int x, int y, int width, int height), gtk_widget_queue_draw_area)
-  _WRAP_METHOD(void queue_draw_region(const Cairo::RefPtr<const Cairo::Region>& region), 
gtk_widget_queue_draw_region)
   _WRAP_METHOD(void queue_resize(), gtk_widget_queue_resize)
   _WRAP_METHOD(void queue_allocate(), gtk_widget_queue_allocate)
 
-  _WRAP_METHOD(void size_allocate(const Allocation& allocation, int baseline, Allocation& out_clip), 
gtk_widget_size_allocate)
+  _WRAP_METHOD(void size_allocate(const Allocation& allocation, int baseline), gtk_widget_size_allocate)
 
   _WRAP_METHOD(SizeRequestMode get_request_mode() const, gtk_widget_get_request_mode)
   _WRAP_METHOD(void measure(Orientation orientation, int for_size, int& minimum, int& natural,
@@ -252,19 +250,6 @@ public:
   _WRAP_METHOD(int get_width() const, gtk_widget_get_width)
   _WRAP_METHOD(int get_height() const, gtk_widget_get_height)
 
-  /** Retrieves the widget’s clip area.
-   *
-   * The clip area is the area in which all of the widget's drawing will
-   * happen. Other toolkits call it the bounding box.
-   *
-   * Historically, in GTK+ the clip area has been equal to the allocation
-   * retrieved via get_allocation().
-   *
-   * @newin{3,14}
-   */
-  Allocation get_clip() const;
-  _IGNORE(gtk_widget_get_clip)
-
   _WRAP_METHOD(Container* get_parent(), gtk_widget_get_parent)
   _WRAP_METHOD(const Container* get_parent() const, gtk_widget_get_parent, constversion)
 
@@ -610,7 +595,7 @@ public:
 #m4 _CONVERSION(`const GdkRectangle*',`const Allocation&',`Glib::wrap($3)')
 #m4 _CONVERSION(`Allocation&',`GdkRectangle*',`($3.gobj())')
 #m4 _CONVERSION(`GdkRectangle*',`Allocation&',`Glib::wrap($3)')
-  _WRAP_SIGNAL(void size_allocate(const Allocation& allocation, int baseline, Allocation& out_clip), 
"size_allocate")
+  _WRAP_SIGNAL(void size_allocate(const Allocation& allocation, int baseline), "size_allocate")
 
   _WRAP_SIGNAL(void state_flags_changed(Gtk::StateFlags previous_state_flags), "state-flags-changed")
 
@@ -642,14 +627,6 @@ dnl
   _POP()
 #m4end
 
-  // The draw signal must not be wrapped here. It would interfere with the way
-  // gtk+ selects either the snapshot vfunc or the draw signal for rendering widgets.
-  // Custom widgets that need the draw signal must use a custom rendering widget
-  // that wraps the draw signal.
-  // https://bugzilla.gnome.org/show_bug.cgi?id=774778
-  //_WRAP_SIGNAL(bool draw(const Cairo::RefPtr<Cairo::Context>& cr), "draw")
-  _IGNORE_SIGNAL(draw)
-
 #m4 _CONVERSION(`GdkEventKey*',`const Glib::RefPtr<Gdk::EventKey>&',`Glib::wrap($3, true)')
   /// Event triggered by a key press will widget has focus.
   _WRAP_SIGNAL(bool key_press_event(const Glib::RefPtr<Gdk::EventKey>& key_event), "key_press_event")
@@ -752,10 +729,6 @@ protected:
   _WRAP_METHOD(void realize(), gtk_widget_realize)
   _WRAP_METHOD(void unrealize(), gtk_widget_unrealize)
 
-  _WRAP_METHOD(void draw(const Cairo::RefPtr<Cairo::Context>& cr), gtk_widget_draw)
-
-  _WRAP_METHOD(void set_realized(bool realized = true), gtk_widget_set_realized)
-
   _WRAP_METHOD(void set_has_surface(bool has_surface = true), gtk_widget_set_has_surface)
 
   /** Sets a widget's surface. This function should only be used in a
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index ae090fd..e1715a4 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -111,7 +111,6 @@ _CONVERSION(`const ::Cairo::RefPtr<const ::Cairo::Region>&',`const cairo_region_
 _CONVERSION(`cairo_region_t*',`::Cairo::RefPtr< ::Cairo::Region>',`Gdk::Cairo::wrap($3)')
 _CONVERSION(`const ::Cairo::RefPtr< ::Cairo::Surface>&',`cairo_surface_t*',`(($3) ? ($3)->cobj() : nullptr)')
 _CONVERSION(`cairo_surface_t*',`::Cairo::RefPtr< ::Cairo::Surface>',`Gdk::Cairo::wrap($3)')
-_CONVERSION(`cairo_surface_t*',`::Cairo::RefPtr< ::Cairo::ImageSurface>',`Gdk::Cairo::wrap< 
::Cairo::ImageSurface>($3)')
 
 _CONVERSION(`const Glib::RefPtr<Cursor>&',`GdkCursor*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<const Cursor>&',`GdkCursor*',__CONVERT_CONST_REFPTR_TO_P)


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