[gtkmm] Take some Gdk::Event& (and subclasses) parameters as const&



commit a0635753df201a867e364a30b5dbb2b5075cd4cf
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sat Oct 14 09:00:11 2017 +0200

    Take some Gdk::Event& (and subclasses) parameters as const&
    
    Bug 135978

 gdk/src/window.hg       |    2 +-
 gtk/src/cellarea.hg     |    4 ++--
 gtk/src/celleditable.hg |    6 +++---
 gtk/src/cellrenderer.hg |   10 +++++-----
 gtk/src/clipboard.hg    |    4 ++--
 gtk/src/widget.hg       |   11 ++++++-----
 tools/m4/convert_gdk.m4 |    2 ++
 7 files changed, 21 insertions(+), 18 deletions(-)
---
diff --git a/gdk/src/window.hg b/gdk/src/window.hg
index c33f352..4a4fae6 100644
--- a/gdk/src/window.hg
+++ b/gdk/src/window.hg
@@ -341,7 +341,7 @@ public:
 
   _WRAP_METHOD(void set_shadow_width(int left, int right, int top, int bottom), gdk_window_set_shadow_width)
 
-  _WRAP_METHOD(bool show_window_menu(Event& event), gdk_window_show_window_menu)
+  _WRAP_METHOD(bool show_window_menu(const Event& event), gdk_window_show_window_menu)
 
   /** Creates a new GLContext matching the framebuffer format to the visual of the
    * Window. The context is disconnected from any particular window or surface.
diff --git a/gtk/src/cellarea.hg b/gtk/src/cellarea.hg
index 8ff3c23..119a1ca 100644
--- a/gtk/src/cellarea.hg
+++ b/gtk/src/cellarea.hg
@@ -157,7 +157,7 @@ public:
   void foreach(const Glib::RefPtr<CellAreaContext>& context, Widget* widget, const Gdk::Rectangle& 
cell_area, const Gdk::Rectangle& background_area, const SlotForeachAlloc& slot);
   _IGNORE(gtk_cell_area_foreach_alloc)
 
-  _WRAP_METHOD(int event(const Glib::RefPtr<CellAreaContext>& context, Widget& widget, Gdk::Event& 
gdk_event, const Gdk::Rectangle& cell_area,  GtkCellRendererState  flags), gtk_cell_area_event)
+  _WRAP_METHOD(int event(const Glib::RefPtr<CellAreaContext>& context, Widget& widget, const Gdk::Event& 
gdk_event, const Gdk::Rectangle& cell_area, GtkCellRendererState flags), gtk_cell_area_event)
 
   _WRAP_METHOD(void snapshot(const Glib::RefPtr<CellAreaContext>& context, Widget& widget,
      Snapshot& snapshot, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area,
@@ -220,7 +220,7 @@ public:
   _WRAP_METHOD(CellEditable* get_edit_widget(), gtk_cell_area_get_edit_widget)
   _WRAP_METHOD(const CellEditable* get_edit_widget() const, gtk_cell_area_get_edit_widget, constversion)
 
-  _WRAP_METHOD(bool activate_cell(Widget& widget, CellRenderer& renderer, Gdk::Event& gdk_event, const 
Gdk::Rectangle& cell_area, CellRendererState flags), gtk_cell_area_activate_cell)
+  _WRAP_METHOD(bool activate_cell(Widget& widget, CellRenderer& renderer, const Gdk::Event& gdk_event, const 
Gdk::Rectangle& cell_area, CellRendererState flags), gtk_cell_area_activate_cell)
   _WRAP_METHOD(void stop_editing(bool canceled), gtk_cell_area_stop_editing)
 
   _WRAP_METHOD(void inner_cell_area(Widget& widget, const Gdk::Rectangle& cell_area, Gdk::Rectangle& 
inner_area), gtk_cell_area_inner_cell_area)
diff --git a/gtk/src/celleditable.hg b/gtk/src/celleditable.hg
index 211b708..70eec89 100644
--- a/gtk/src/celleditable.hg
+++ b/gtk/src/celleditable.hg
@@ -40,7 +40,7 @@ class CellEditable : public Glib::Interface
   _CLASS_INTERFACE(CellEditable,GtkCellEditable,GTK_CELL_EDITABLE,GtkCellEditableIface)
 
 public:
-  _WRAP_METHOD(void start_editing(Gdk::Event& event), gtk_cell_editable_start_editing)
+  _WRAP_METHOD(void start_editing(const Gdk::Event& event), gtk_cell_editable_start_editing)
   _WRAP_METHOD(void editing_done(), gtk_cell_editable_editing_done)
   _WRAP_METHOD(void remove_widget(), gtk_cell_editable_remove_widget)
 
@@ -50,8 +50,8 @@ public:
   _WRAP_PROPERTY("editing-canceled", bool)
 
 protected:
-#m4 _CONVERSION(`GdkEvent*',`Gdk::Event&',`Gdk::wrap_event($3)')
-  _WRAP_VFUNC(void start_editing(Gdk::Event& event), start_editing)
+#m4 _CONVERSION(`GdkEvent*',`const Gdk::Event&',`Gdk::wrap_event($3)')
+  _WRAP_VFUNC(void start_editing(const Gdk::Event& event), start_editing)
 };
 
 } // namespace Gtk
diff --git a/gtk/src/cellrenderer.hg b/gtk/src/cellrenderer.hg
index e0481ec..524ef05 100644
--- a/gtk/src/cellrenderer.hg
+++ b/gtk/src/cellrenderer.hg
@@ -74,7 +74,7 @@ public:
                   CellRendererState flags), gtk_cell_renderer_snapshot)
 
   _WRAP_METHOD(bool activate(
-                  Gdk::Event& event,
+                  const Gdk::Event& event,
                   Widget& widget,
                   const Glib::ustring& path,
                   const Gdk::Rectangle& background_area,
@@ -82,7 +82,7 @@ public:
                   CellRendererState flags), gtk_cell_renderer_activate)
 
   _WRAP_METHOD(CellEditable* start_editing(
-                  Gdk::Event& event, Widget& widget,
+                  const Gdk::Event& event, Widget& widget,
                   const Glib::ustring& path,
                   const Gdk::Rectangle& background_area,
                   const Gdk::Rectangle& cell_area,
@@ -153,9 +153,9 @@ protected:
                   const Gdk::Rectangle& cell_area,
                   CellRendererState flags), snapshot)
 
-#m4 _CONVERSION(`GdkEvent*',`Gdk::Event&',`Gdk::wrap_event($3)')
+#m4 _CONVERSION(`GdkEvent*',`const Gdk::Event&',`Gdk::wrap_event($3)')
   _WRAP_VFUNC(bool activate(
-                  Gdk::Event& event,
+                  const Gdk::Event& event,
                   Widget& widget,
                   const Glib::ustring& path,
                   const Gdk::Rectangle& background_area,
@@ -163,7 +163,7 @@ protected:
                   CellRendererState flags), activate)
 
   _WRAP_VFUNC(CellEditable* start_editing(
-                  Gdk::Event& event,
+                  const Gdk::Event& event,
                   Widget& widget,
                   const Glib::ustring& path,
                   const Gdk::Rectangle& background_area,
diff --git a/gtk/src/clipboard.hg b/gtk/src/clipboard.hg
index d7f94a3..dce708d 100644
--- a/gtk/src/clipboard.hg
+++ b/gtk/src/clipboard.hg
@@ -308,9 +308,9 @@ public:
   _WRAP_METHOD(void store(), gtk_clipboard_store)
   _WRAP_METHOD(GdkAtom get_selection() const, gtk_clipboard_get_selection)
 
-#m4 _CONVERSION(`GdkEventOwnerChange*',`Gdk::EventOwnerChange&',`Gdk::wrap_event($3)')
+#m4 _CONVERSION(`GdkEventOwnerChange*',`const Gdk::EventOwnerChange&',`Gdk::wrap_event($3)')
   // no_default_handler because GtkClipboardClass is private.
-  _WRAP_SIGNAL(void owner_change(Gdk::EventOwnerChange& event), "owner_change", no_default_handler)
+  _WRAP_SIGNAL(void owner_change(const Gdk::EventOwnerChange& event), "owner_change", no_default_handler)
 
 };
 
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index dd5ec52..20b92bb 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -147,9 +147,9 @@ public:
   //Probably not useful. Too C-specific: _WRAP_METHOD(bool can_activate_accel(guint signal_id) const, 
gtk_widget_can_activate_accel)
 
   _WRAP_METHOD(bool event(const Gdk::Event& gdk_event), gtk_widget_event)
-  // We use Gdk::EventFocus& rather than Gdk::Event&. See GTK+ bug 
https://bugzilla.gnome.org/show_bug.cgi?id=709544
-#m4 _CONVERSION(`Gdk::EventFocus&',`GdkEvent*',`($3).Event::gobj()')
-  _WRAP_METHOD(bool send_focus_change(Gdk::EventFocus& gdk_event), gtk_widget_send_focus_change)
+  // We use const Gdk::EventFocus& rather than Gdk::Event&. See GTK+ bug 
https://bugzilla.gnome.org/show_bug.cgi?id=709544
+#m4 _CONVERSION(`const Gdk::EventFocus&',`GdkEvent*',`const_cast<$2>(($3).Event::gobj())')
+  _WRAP_METHOD(bool send_focus_change(const Gdk::EventFocus& gdk_event), gtk_widget_send_focus_change)
   _WRAP_METHOD(bool activate(), gtk_widget_activate)
 
   // gtk_widget_reparent() has been removed, but we want to keep Gtk::Widget::reparent().
@@ -423,7 +423,7 @@ public:
   _WRAP_METHOD(void drag_source_add_image_targets(), gtk_drag_source_add_image_targets)
 
   _WRAP_METHOD(Glib::RefPtr<Gdk::DragContext> drag_begin(const Glib::RefPtr<TargetList>& targets,
-    Gdk::DragAction actions, int button, Gdk::Event& gdk_event, int x, int y), 
gtk_drag_begin_with_coordinates, refreturn)
+    Gdk::DragAction actions, int button, const Gdk::Event& gdk_event, int x, int y), 
gtk_drag_begin_with_coordinates, refreturn)
   _WRAP_METHOD(bool drag_check_threshold(int start_x, int start_y, int current_x, int current_y), 
gtk_drag_check_threshold)
 
   //These should be a method of Gdk::DragContext, but gdkmm can't depend on gtkmm.
@@ -562,7 +562,8 @@ public:
 #m4 _CONVERSION(`GdkEvent*',`Gdk::Event&',`Gdk::wrap_event($3)')
   _WRAP_SIGNAL(bool event(Gdk::Event& gdk_event), "event")
   // The event_after signal can't have a default handler because the wrapped C signal has no default handler.
-  _WRAP_SIGNAL(void event_after(Gdk::Event& gdk_event), "event_after", no_default_handler)
+#m4 _CONVERSION(`GdkEvent*',`const Gdk::Event&',`Gdk::wrap_event($3)')
+  _WRAP_SIGNAL(void event_after(const Gdk::Event& gdk_event), "event_after", no_default_handler)
 
 #m4 _CONVERSION(`GdkEventButton*',`Gdk::EventButton&',`Gdk::wrap_event($3)')
   /// Event triggered by user pressing button.
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index e9a3cef..8fd6264 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -241,6 +241,8 @@ _CONVERSION(`GdkEvent*',`Gdk::Event',`Glib::wrap($3)')
 _CONVERSION(`const GdkEvent*',`Gdk::Event',`Glib::wrap(const_cast<GdkEvent*>($3), true)')
 _CONVERSION(`Event&',`GdkEvent*',`($3).gobj()')
 _CONVERSION(`Gdk::Event&',`GdkEvent*',`($3).gobj()')
+_CONVERSION(`const Event&',`GdkEvent*',`const_cast<$2>(($3).gobj())')
+_CONVERSION(`const Gdk::Event&',`GdkEvent*',`const_cast<$2>(($3).gobj())')
 _CONVERSION(`const Event&',`const GdkEvent*',`($3).gobj()')
 _CONVERSION(`const Gdk::Event&',`const GdkEvent*',`($3).gobj()')
 _CONVERSION(`Gdk::EventButton&',`GdkEventButton*',`($3).gobj()')


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