[goocanvasmm] Item: signals: Use the new Event classes from gtkmm 4.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goocanvasmm] Item: signals: Use the new Event classes from gtkmm 4.
- Date: Mon, 19 Jun 2017 12:43:27 +0000 (UTC)
commit 932c26776bdb9463b5d30394a54e06d4e75fe4a3
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Jun 19 14:43:06 2017 +0200
Item: signals: Use the new Event classes from gtkmm 4.
examples/demo/primitives.cc | 8 +++---
examples/demo/primitives.h | 8 +++---
examples/moving_shapes/window.cc | 18 ++++++++--------
examples/moving_shapes/window.h | 10 ++++----
examples/simple/examplewindow.cc | 2 +-
examples/simple/examplewindow.h | 2 +-
examples/table/examplewindow.cc | 2 +-
examples/table/examplewindow.h | 2 +-
examples/tablemodel/examplewindow.h | 2 +-
goocanvas/src/item.hg | 39 +++++++++++++++++++++++++---------
10 files changed, 55 insertions(+), 38 deletions(-)
---
diff --git a/examples/demo/primitives.cc b/examples/demo/primitives.cc
index 53769de..90d0e8d 100644
--- a/examples/demo/primitives.cc
+++ b/examples/demo/primitives.cc
@@ -60,26 +60,26 @@ Primitives::getWidget()
}
bool
-Primitives::_on_background_button_press(const Glib::RefPtr<Goocanvas::Item>& /* item */, GdkEventButton* /*
ev */)
+Primitives::_on_background_button_press(const Glib::RefPtr<Goocanvas::Item>& /* item */, Gdk::EventButton&
/* ev */)
{
return false;
}
bool
-Primitives::_on_button_press(const Glib::RefPtr<Goocanvas::Item>& /* item */, GdkEventButton* /* ev */)
+Primitives::_on_button_press(const Glib::RefPtr<Goocanvas::Item>& /* item */, Gdk::EventButton& /* ev */)
{
std::cerr << "Clicked!" << std::endl ;
return false;
}
bool
-Primitives::_on_button_release(const Glib::RefPtr<Goocanvas::Item>& /* item */, GdkEventButton* /* ev */)
+Primitives::_on_button_release(const Glib::RefPtr<Goocanvas::Item>& /* item */, Gdk::EventButton& /* ev */)
{
return false;
}
bool
-Primitives::_on_motion_notify(const Glib::RefPtr<Goocanvas::Item>& /* item */, GdkEventMotion* /* ev */)
+Primitives::_on_motion_notify(const Glib::RefPtr<Goocanvas::Item>& /* item */, Gdk::EventMotion& /* ev */)
{
return false;
}
diff --git a/examples/demo/primitives.h b/examples/demo/primitives.h
index 9270a01..f6112cb 100644
--- a/examples/demo/primitives.h
+++ b/examples/demo/primitives.h
@@ -39,10 +39,10 @@ public:
private:
- bool _on_background_button_press(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventButton* ev);
- bool _on_button_press(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventButton* ev);
- bool _on_button_release(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventButton* ev);
- bool _on_motion_notify(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventMotion* ev);
+ bool _on_background_button_press(const Glib::RefPtr<Goocanvas::Item>& item, Gdk::EventButton& ev);
+ bool _on_button_press(const Glib::RefPtr<Goocanvas::Item>& item, Gdk::EventButton& ev);
+ bool _on_button_release(const Glib::RefPtr<Goocanvas::Item>& item, Gdk::EventButton& ev);
+ bool _on_motion_notify(const Glib::RefPtr<Goocanvas::Item>& item, Gdk::EventMotion& ev);
void _setup_signals(const Glib::RefPtr<Goocanvas::Item>& item);
void _setup_heading(const Glib::ustring& heading, int pos);
diff --git a/examples/moving_shapes/window.cc b/examples/moving_shapes/window.cc
index 4a51b15..7ca86c0 100644
--- a/examples/moving_shapes/window.cc
+++ b/examples/moving_shapes/window.cc
@@ -83,21 +83,21 @@ Window::on_item_created(const Glib::RefPtr<Goocanvas::Item>& item, const Glib::R
}
bool
-Window::on_item_button_press_event(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventButton* event)
+Window::on_item_button_press_event(const Glib::RefPtr<Goocanvas::Item>& item, Gdk::EventButton& event)
{
- if(event->button == 1)
+ if(event.get_button() == 1)
{
_dragging = item ;
- _drag_x = (int) event->x ;
- _drag_y = (int) event->y ;
+ _drag_x = (int) event.get_x();
+ _drag_y = (int) event.get_y();
}
return false;
}
bool
-Window::on_item_button_release_event(const Glib::RefPtr<Goocanvas::Item>& /* item */, GdkEventButton* event)
+Window::on_item_button_release_event(const Glib::RefPtr<Goocanvas::Item>& /* item */, Gdk::EventButton&
event)
{
- if(event->button == 1)
+ if(event.get_button() == 1)
{
_dragging.reset();
}
@@ -105,12 +105,12 @@ Window::on_item_button_release_event(const Glib::RefPtr<Goocanvas::Item>& /* ite
}
bool
-Window::on_item_motion_notify_event(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventMotion* event)
+Window::on_item_motion_notify_event(const Glib::RefPtr<Goocanvas::Item>& item, Gdk::EventMotion& event)
{
if(item && _dragging && item == _dragging)
{
- auto new_x = event->x ;
- auto new_y = event->y ;
+ auto new_x = event.get_x();
+ auto new_y = event.get_y();
item->translate(new_x - _drag_x, new_y - _drag_y);
}
return false;
diff --git a/examples/moving_shapes/window.h b/examples/moving_shapes/window.h
index 679106c..0e11496 100644
--- a/examples/moving_shapes/window.h
+++ b/examples/moving_shapes/window.h
@@ -35,12 +35,12 @@ private:
int _drag_y ;
void on_item_created(const Glib::RefPtr<Goocanvas::Item>& item, const Glib::RefPtr<Goocanvas::ItemModel>&
model);
- bool on_item_button_press_event(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventButton* event);
- bool on_item_button_release_event(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventButton* event);
- bool on_item_motion_notify_event(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventMotion* event);
+ bool on_item_button_press_event(const Glib::RefPtr<Goocanvas::Item>& item, Gdk::EventButton& event);
+ bool on_item_button_release_event(const Glib::RefPtr<Goocanvas::Item>& item, Gdk::EventButton& event);
+ bool on_item_motion_notify_event(const Glib::RefPtr<Goocanvas::Item>& item, Gdk::EventMotion& event);
/*
- bool on_focus_in_event(const Glib::RefPtr<Goocanvas::Item>& view, GdkEventFocus* event);
- bool on_focus_out_event(const Glib::RefPtr<Goocanvas::Item>& view, GdkEventFocus* event);
+ bool on_focus_in_event(const Glib::RefPtr<Goocanvas::Item>& view, Gdk::EventFocus& event);
+ bool on_focus_out_event(const Glib::RefPtr<Goocanvas::Item>& view, Gdk::EventFocus& event);
*/
};
diff --git a/examples/simple/examplewindow.cc b/examples/simple/examplewindow.cc
index ea6d298..e2868fd 100644
--- a/examples/simple/examplewindow.cc
+++ b/examples/simple/examplewindow.cc
@@ -61,7 +61,7 @@ ExampleWindow::ExampleWindow()
}
bool
-ExampleWindow::on_rect_button_press(const Glib::RefPtr<Goocanvas::Item>& /* item */, GdkEventButton* /*
event */)
+ExampleWindow::on_rect_button_press(const Glib::RefPtr<Goocanvas::Item>& /* item */, Gdk::EventButton& /*
event */)
{
std::cout << "You clicked the rectangle." << std::endl ;
return true ;
diff --git a/examples/simple/examplewindow.h b/examples/simple/examplewindow.h
index 7cebda0..88fb5ab 100644
--- a/examples/simple/examplewindow.h
+++ b/examples/simple/examplewindow.h
@@ -31,7 +31,7 @@ protected:
Goocanvas::Canvas m_canvas;
Glib::RefPtr<Goocanvas::Rect> m_table;
- bool on_rect_button_press(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventButton* event);
+ bool on_rect_button_press(const Glib::RefPtr<Goocanvas::Item>& target, Gdk::EventButton& event);
};
#endif //_GOOCANVASMM_EXAMPLEWINDOW_H
diff --git a/examples/table/examplewindow.cc b/examples/table/examplewindow.cc
index db48bac..2af4517 100644
--- a/examples/table/examplewindow.cc
+++ b/examples/table/examplewindow.cc
@@ -65,7 +65,7 @@ void ExampleWindow::add_text_to_cell(const Glib::RefPtr<Goocanvas::Table>& table
}
bool
-ExampleWindow::on_rect_button_press(const Glib::RefPtr<Goocanvas::Item>& /* item */, GdkEventButton* /*
event */)
+ExampleWindow::on_rect_button_press(const Glib::RefPtr<Goocanvas::Item>& /* item */, Gdk::EventButton& /*
event */)
{
std::cout << "You clicked the rectangle!" << std::endl ;
return true ;
diff --git a/examples/table/examplewindow.h b/examples/table/examplewindow.h
index 67a7877..2e5dabf 100644
--- a/examples/table/examplewindow.h
+++ b/examples/table/examplewindow.h
@@ -30,7 +30,7 @@ protected:
void add_text_to_cell(const Glib::RefPtr<Goocanvas::Table>&, const Glib::ustring& text, guint row, guint
col);
- bool on_rect_button_press(const Glib::RefPtr<Goocanvas::Item>& target, GdkEventButton* event);
+ bool on_rect_button_press(const Glib::RefPtr<Goocanvas::Item>& target, Gdk::EventButton& event);
Goocanvas::Canvas m_canvas;
Glib::RefPtr<Goocanvas::Table> m_table;
diff --git a/examples/tablemodel/examplewindow.h b/examples/tablemodel/examplewindow.h
index 0f54def..0eca9fa 100644
--- a/examples/tablemodel/examplewindow.h
+++ b/examples/tablemodel/examplewindow.h
@@ -30,7 +30,7 @@ protected:
void add_text_to_cell(const Glib::RefPtr<Goocanvas::TableModel>&, const Glib::ustring& text, guint row,
guint col);
- //bool on_rect_button_press(const Glib::RefPtr<Goocanvas::ItemModel>& target, GdkEventButton* event);
+ //bool on_rect_button_press(const Glib::RefPtr<Goocanvas::ItemModel>& target, Gdk::EventButton& event);
Goocanvas::Canvas m_first_canvas;
Goocanvas::Canvas m_second_canvas;
diff --git a/goocanvas/src/item.hg b/goocanvas/src/item.hg
index 04ffdbd..f33b322 100644
--- a/goocanvas/src/item.hg
+++ b/goocanvas/src/item.hg
@@ -20,6 +20,7 @@
#include <goocanvasmm/enums.h>
#include <goocanvasmm/style.h>
#include <cairomm/cairomm.h>
+#include <gdkmm/events.h>
#include <glibmm/interface.h>
#include <goocanvasitem.h>
@@ -146,21 +147,37 @@ public:
//_WRAP_SIGNAL(void child_moved(int old_position, int new_position), "child_moved")
//_WRAP_SIGNAL(void child_removed(int child_num), "child_removed")
//_WRAP_SIGNAL(void changed(bool recompute_bounds), "changed")
+
#m4 _CONVERSION(`GooCanvasItem*',`const Glib::RefPtr<Item>&',`Glib::wrap($3, true)')
- _WRAP_SIGNAL(bool enter_notify_event(const Glib::RefPtr<Item>& target, GdkEventCrossing* event),
"enter_notify_event")
- _WRAP_SIGNAL(bool leave_notify_event(const Glib::RefPtr<Item>& target, GdkEventCrossing* event),
"leave_notify_event")
- _WRAP_SIGNAL(bool motion_notify_event(const Glib::RefPtr<Item>& target, GdkEventMotion* event),
"motion_notify_event")
- _WRAP_SIGNAL(bool button_press_event(const Glib::RefPtr<Item>& target, GdkEventButton* event),
"button_press_event")
- _WRAP_SIGNAL(bool button_release_event(const Glib::RefPtr<Item>& target, GdkEventButton* event),
"button_release_event")
- _WRAP_SIGNAL(bool focus_in_event(const Glib::RefPtr<Item>& target, GdkEventFocus* event), "focus_in_event")
- _WRAP_SIGNAL(bool focus_out_event(const Glib::RefPtr<Item>& target, GdkEventFocus* event),
"focus_out_event")
- _WRAP_SIGNAL(bool key_press_event(const Glib::RefPtr<Item>& target, GdkEventKey* event), "key_press_event")
- _WRAP_SIGNAL(bool key_release_event(const Glib::RefPtr<Item>& target, GdkEventKey* event),
"key_release_event")
- _WRAP_SIGNAL(bool grab_broken_event(const Glib::RefPtr<Item>& target, GdkEventGrabBroken* event),
"grab_broken_event")
+#m4 _CONVERSION(`GdkEventCrossing*',`Gdk::EventCrossing&',`Gdk::wrap_event($3)')
+#m4 _CONVERSION(`Gdk::EventCrossing&',`GdkEventCrossing*',`($3).gobj()')
+#m4 _CONVERSION(`GdkEventMotion*',`Gdk::EventMotion&',`Gdk::wrap_event($3)')
+#m4 _CONVERSION(`Gdk::EventMotion&',`GdkEventMotion*',`($3).gobj()')
+#m4 _CONVERSION(`GdkEventButton*',`Gdk::EventButton&',`Gdk::wrap_event($3)')
+#m4 _CONVERSION(`Gdk::EventButton&',`GdkEventButton*',`($3).gobj()')
+#m4 _CONVERSION(`GdkEventFocus*',`Gdk::EventFocus&',`Gdk::wrap_event($3)')
+#m4 _CONVERSION(`Gdk::EventFocus&',`GdkEventFocus*',`($3).gobj()')
+#m4 _CONVERSION(`GdkEventKey*',`Gdk::EventKey&',`Gdk::wrap_event($3)')
+#m4 _CONVERSION(`Gdk::EventKey&',`GdkEventKey*',`($3).gobj()')
+#m4 _CONVERSION(`GdkEventGrabBroken*',`Gdk::EventGrabBroken&',`Gdk::wrap_event($3)')
+#m4 _CONVERSION(`Gdk::EventGrabBroken&',`GdkEventGrabBroken*',`($3).gobj()')
+#m4 _CONVERSION(`GdkEventScroll*',`Gdk::EventScroll&',`Gdk::wrap_event($3)')
+#m4 _CONVERSION(`Gdk::EventScroll&',`GdkEventScroll*',`($3).gobj()')
+
+ _WRAP_SIGNAL(bool enter_notify_event(const Glib::RefPtr<Item>& target, Gdk::EventCrossing& event),
"enter_notify_event")
+ _WRAP_SIGNAL(bool leave_notify_event(const Glib::RefPtr<Item>& target, Gdk::EventCrossing& event),
"leave_notify_event")
+ _WRAP_SIGNAL(bool motion_notify_event(const Glib::RefPtr<Item>& target, Gdk::EventMotion& event),
"motion_notify_event")
+ _WRAP_SIGNAL(bool button_press_event(const Glib::RefPtr<Item>& target, Gdk::EventButton& event),
"button_press_event")
+ _WRAP_SIGNAL(bool button_release_event(const Glib::RefPtr<Item>& target, Gdk::EventButton& event),
"button_release_event")
+ _WRAP_SIGNAL(bool focus_in_event(const Glib::RefPtr<Item>& target, Gdk::EventFocus& event),
"focus_in_event")
+ _WRAP_SIGNAL(bool focus_out_event(const Glib::RefPtr<Item>& target, Gdk::EventFocus& event),
"focus_out_event")
+ _WRAP_SIGNAL(bool key_press_event(const Glib::RefPtr<Item>& target, Gdk::EventKey& event),
"key_press_event")
+ _WRAP_SIGNAL(bool key_release_event(const Glib::RefPtr<Item>& target, Gdk::EventKey& event),
"key_release_event")
+ _WRAP_SIGNAL(bool grab_broken_event(const Glib::RefPtr<Item>& target, Gdk::EventGrabBroken& event),
"grab_broken_event")
_WRAP_SIGNAL(void child_notify(GParamSpec* pspec), "child_notify")
_WRAP_SIGNAL(void animation_finished(bool stopped), "animation_finished")
- _WRAP_SIGNAL(bool scroll_event(const Glib::RefPtr<Item>& target, GdkEventScroll* event), "scroll_event")
+ _WRAP_SIGNAL(bool scroll_event(const Glib::RefPtr<Item>& target, Gdk::EventScroll& event), "scroll_event")
_WRAP_PROPERTY("parent", Glib::RefPtr<Item>)
_WRAP_PROPERTY("visibility", ItemVisibility)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]