[gtkmm] Gtk: Update for the latest gtk4 (Root::get_focus(), etc.)



commit f1c443ed822f1d2d8934e54a8c2d2575027a0398
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sun Mar 24 18:36:28 2019 +0100

    Gtk: Update for the latest gtk4 (Root::get_focus(), etc.)
    
    * gtk/src/eventcontrollerkey.hg: Add get_focus_origin/target(),
    property_is_focus(), property_contains_focus(). Update signal_focus_in/out().
    * gtk/src/eventcontrollermotion.hg: Add get_pointer_origin/target(),
    property_is_pointer_focus(), property_contains_pointer_focus().
    Update signal_enter(), signal_leave().
    * gtk/src/passwordentry.hg: set/get/property_show_peek_icon(),
    property_placeholder_text(), property_activates_default().
    * gtk/src/root.[ccg|hg]: Add set/unset/get_focus(), property_focus_widget().
    * gtk/src/widget.hg: Add get_focus_child(). Remove signal_focus().
    * gtk/src/window.hg: Remove signal_set_focus().

 gtk/src/eventcontrollerkey.hg    | 14 +++++++++++---
 gtk/src/eventcontrollermotion.hg | 17 ++++++++++++++---
 gtk/src/passwordentry.hg         |  7 +++++++
 gtk/src/root.ccg                 |  9 +++++++++
 gtk/src/root.hg                  | 19 +++++++++++++++++++
 gtk/src/widget.hg                | 11 +++--------
 gtk/src/window.hg                |  1 -
 7 files changed, 63 insertions(+), 15 deletions(-)
---
diff --git a/gtk/src/eventcontrollerkey.hg b/gtk/src/eventcontrollerkey.hg
index 855faf4e..73f3c1b1 100644
--- a/gtk/src/eventcontrollerkey.hg
+++ b/gtk/src/eventcontrollerkey.hg
@@ -15,6 +15,7 @@
  */
 
 #include <gtkmm/eventcontroller.h>
+#include <gdkmm/enums.h>
 #include <gdkmm/types.h>
 
 _DEFS(gtkmm,gtk)
@@ -22,6 +23,8 @@ _PINCLUDE(gtkmm/private/eventcontroller_p.h)
 
 namespace Gtk
 {
+class Widget;
+
 /** Event controller for key press and key release events.
  *
  * %Gtk::EventControllerKey is an event controller meant to handle
@@ -48,16 +51,21 @@ public:
 
   _WRAP_METHOD(bool forward(Widget& widget), gtk_event_controller_key_forward)
   _WRAP_METHOD(guint get_group() const, gtk_event_controller_key_get_group)
+  _WRAP_METHOD(Widget* get_focus_origin(), gtk_event_controller_key_get_focus_origin)
+  _WRAP_METHOD(const Widget* get_focus_origin() const, gtk_event_controller_key_get_focus_origin, 
constversion)
+  _WRAP_METHOD(Widget* get_focus_target(), gtk_event_controller_key_get_focus_target)
+  _WRAP_METHOD(const Widget* get_focus_target() const, gtk_event_controller_key_get_focus_target, 
constversion)
 
   // no_default_handler because GtkEventControllerKeyClass is private.
   _WRAP_SIGNAL(bool key_pressed(guint keyval, guint keycode, Gdk::ModifierType state), "key-pressed", 
no_default_handler)
   _WRAP_SIGNAL(void key_released(guint keyval, guint keycode, Gdk::ModifierType state), "key-released", 
no_default_handler)
   _WRAP_SIGNAL(bool modifiers(Gdk::ModifierType state), "modifiers", no_default_handler)
   _WRAP_SIGNAL(void im_update(), "im-update", no_default_handler)
-  _WRAP_SIGNAL(void focus_in(), "focus-in", no_default_handler)
-  _WRAP_SIGNAL(void focus_out(), "focus-out", no_default_handler)
+  _WRAP_SIGNAL(void focus_in(Gdk::CrossingMode mode, Gdk::NotifyType detail), "focus-in", no_default_handler)
+  _WRAP_SIGNAL(void focus_out(Gdk::CrossingMode mode, Gdk::NotifyType detail), "focus-out", 
no_default_handler)
 
-  // There are no properties or vfuncs.
+  _WRAP_PROPERTY("is-focus", bool)
+  _WRAP_PROPERTY("contains-focus", bool)
 };
 
 } // namespace Gtk
diff --git a/gtk/src/eventcontrollermotion.hg b/gtk/src/eventcontrollermotion.hg
index 09b7362b..b3d73f26 100644
--- a/gtk/src/eventcontrollermotion.hg
+++ b/gtk/src/eventcontrollermotion.hg
@@ -15,12 +15,15 @@
  */
 
 #include <gtkmm/eventcontroller.h>
+#include <gdkmm/enums.h>
 
 _DEFS(gtkmm,gtk)
 _PINCLUDE(gtkmm/private/eventcontroller_p.h)
 
 namespace Gtk
 {
+class Widget;
+
 /** Event controller for motion events.
  *
  * %Gtk::EventControllerMotion is an event controller meant for situations
@@ -40,12 +43,20 @@ protected:
 public:
   _WRAP_CREATE()
 
+  _WRAP_METHOD(Widget* get_pointer_origin(), gtk_event_controller_motion_get_pointer_origin)
+  _WRAP_METHOD(const Widget* get_pointer_origin() const, gtk_event_controller_motion_get_pointer_origin, 
constversion)
+  _WRAP_METHOD(Widget* get_pointer_target(), gtk_event_controller_motion_get_pointer_target)
+  _WRAP_METHOD(const Widget* get_pointer_target() const, gtk_event_controller_motion_get_pointer_target, 
constversion)
+
   // no_default_handler because GtkEventControllerMotionClass is private.
-  _WRAP_SIGNAL(void enter(double x, double y), "enter", no_default_handler)
-  _WRAP_SIGNAL(void leave(), "leave", no_default_handler)
+  _WRAP_SIGNAL(void enter(double x, double y, Gdk::CrossingMode mode, Gdk::NotifyType detail),
+    "enter", no_default_handler)
+  _WRAP_SIGNAL(void leave(Gdk::CrossingMode mode, Gdk::NotifyType detail),
+    "leave", no_default_handler)
   _WRAP_SIGNAL(void motion(double x, double y), "motion", no_default_handler)
 
-  // There are no properties or vfuncs.
+  _WRAP_PROPERTY("is-pointer-focus", bool)
+  _WRAP_PROPERTY("contains-pointer-focus", bool)
 };
 
 } // namespace Gtk
diff --git a/gtk/src/passwordentry.hg b/gtk/src/passwordentry.hg
index 8e8bb0e2..fd1c9cd2 100644
--- a/gtk/src/passwordentry.hg
+++ b/gtk/src/passwordentry.hg
@@ -42,6 +42,13 @@ class PasswordEntry : public Widget, public Editable
   _IMPLEMENTS_INTERFACE(Editable)
 public:
   _CTOR_DEFAULT
+
+  _WRAP_METHOD(void set_show_peek_icon(bool show_peek_icon = true), gtk_password_entry_set_show_peek_icon)
+  _WRAP_METHOD(bool get_show_peek_icon() const, gtk_password_entry_get_show_peek_icon)
+
+  _WRAP_PROPERTY("placeholder-text", Glib::ustring)
+  _WRAP_PROPERTY("activates-default", bool)
+  _WRAP_PROPERTY("show-peek-icon", bool)
 };
 
 } //namespace Gtk
diff --git a/gtk/src/root.ccg b/gtk/src/root.ccg
index d60302c9..1c70facf 100644
--- a/gtk/src/root.ccg
+++ b/gtk/src/root.ccg
@@ -18,3 +18,12 @@
 #include <gdkmm/display.h>
 #include <gdkmm/surface.h>
 #include <gtkmm/widget.h>
+
+namespace Gtk
+{
+void Root::unset_focus()
+{
+  gtk_root_set_focus(gobj(), nullptr);
+}
+
+} // namespace Gtk
diff --git a/gtk/src/root.hg b/gtk/src/root.hg
index 17e2a0d6..5d0ca9c9 100644
--- a/gtk/src/root.hg
+++ b/gtk/src/root.hg
@@ -57,6 +57,25 @@ public:
   _WRAP_METHOD(static Widget* get_for_surface(const Glib::RefPtr<const Gdk::Surface>& surface),
     gtk_root_get_for_surface)
 
+  /** If @a focus is not the current focus widget, and is focusable, sets
+   * it as the focus widget for the root.
+   *
+   * To set the focus to a particular widget in the root, it is usually
+   * more convenient to use Gtk::Widget::grab_focus() instead of this function.
+   *
+   * @param focus Widget to be the new focus widget.
+   */
+  _WRAP_METHOD(void set_focus(Widget& focus), gtk_root_set_focus)
+
+  /** Unsets the focus widget for the root.
+   */
+  void unset_focus();
+
+  _WRAP_METHOD(Widget* get_focus(), gtk_root_get_focus)
+  _WRAP_METHOD(const Widget* get_focus() const, gtk_root_get_focus, constversion)
+
+  _WRAP_PROPERTY("focus-widget", Widget*)
+
 protected:
 #m4 _CONVERSION(`Glib::RefPtr<Gdk::Display>', `GdkDisplay*', __CONVERT_REFPTR_TO_P)
   _WRAP_VFUNC(Glib::RefPtr<Gdk::Display> get_display(), "get_display", refreturn)
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 700dc5ef..12b81c95 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -149,9 +149,6 @@ 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 Glib::RefPtr<const Gdk::Event>& gdk_event), gtk_widget_event)
-  // We use const Gdk::EventFocus& rather than Gdk::Event&. See GTK+ bug 
https://bugzilla.gnome.org/show_bug.cgi?id=709544
-#m4 _CONVERSION(`const Glib::RefPtr<const 
Gdk::EventFocus>&',`GdkEvent*',`const_cast<$2>(reinterpret_cast<const $2>(Glib::unwrap($3)))')
-  _WRAP_METHOD(bool send_focus_change(const Glib::RefPtr<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().
@@ -637,10 +634,6 @@ public:
    */
   void insert_at_end(Widget& parent);
 
-  //TODO: gtk_widget_set_focus_child() is not documented. Wrap or _IGNORE?
-  // 2017-06-06: The gtk+ API is not stable yet. See https://bugzilla.gnome.org/show_bug.cgi?id=783445#c2
-  //_WRAP_METHOD(void set_focus_child(Widget& child), gtk_widget_set_focus_child)
-  //void unset_focus_child();
   _WRAP_METHOD(void snapshot_child(Widget& child, const Glib::RefPtr<Gtk::Snapshot>& snapshot), 
gtk_widget_snapshot_child)
 
   _WRAP_SIGNAL(void show(),"show")
@@ -677,7 +670,6 @@ public:
   _WRAP_SIGNAL(void child_notify(GParamSpec* pspec), "child_notify", detail_name child_property_name)
 
   _WRAP_SIGNAL(bool mnemonic_activate(bool group_cycling), "mnemonic_activate")
-  _WRAP_SIGNAL(bool focus(DirectionType direction), "focus")
 
 #m4begin
 dnl// Hook in special code to catch explicit uses of gtk_object_destroy() by
@@ -819,6 +811,9 @@ protected:
    * This function is only suitable for widget implementations.
    */
   void unset_focus_child();
+
+  _WRAP_METHOD(Widget* get_focus_child(), gtk_widget_get_focus_child)
+  _WRAP_METHOD(const Widget* get_focus_child() const, gtk_widget_get_focus_child, constversion)
 };
 
 } // namespace Gtk
diff --git a/gtk/src/window.hg b/gtk/src/window.hg
index 95ebaf9a..4216f28a 100644
--- a/gtk/src/window.hg
+++ b/gtk/src/window.hg
@@ -91,7 +91,6 @@ public:
   _WRAP_PROPERTY("attached-to", Widget*)
   _WRAP_PROPERTY("is-maximized", bool)
 
-  _WRAP_SIGNAL(void set_focus(Widget* focus), "set_focus")
   _WRAP_SIGNAL(void keys_changed(), "keys_changed")
   _WRAP_SIGNAL(bool close_request(), "close-request")
 


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