[gtkmm] Gtk: Add PadController
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk: Add PadController
- Date: Sun, 3 Mar 2019 16:29:20 +0000 (UTC)
commit 6b882c9ffcdd399403b2be79fbf1a7128a885197
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Sun Mar 3 17:24:50 2019 +0100
Gtk: Add PadController
.gitignore | 2 +
gtk/gtkmm.h | 1 +
gtk/src/filelist.am | 1 +
gtk/src/gtk_signals.defs | 20 ++++++
gtk/src/padcontroller.ccg | 30 ++++++++
gtk/src/padcontroller.hg | 114 ++++++++++++++++++++++++++++++
tools/extra_defs_gen/generate_defs_gtk.cc | 1 +
tools/m4/convert_gtk.m4 | 1 +
8 files changed, 170 insertions(+)
---
diff --git a/.gitignore b/.gitignore
index 852e16a7..5f0b974a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -363,6 +363,8 @@ gtk/gtkmm/orientable.cc
gtk/gtkmm/orientable.h
gtk/gtkmm/overlay.cc
gtk/gtkmm/overlay.h
+gtk/gtkmm/padcontroller.cc
+gtk/gtkmm/padcontroller.h
gtk/gtkmm/pagesetup.cc
gtk/gtkmm/pagesetup.h
gtk/gtkmm/pagesetupunixdialog.cc
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index 1268c9fa..859679bd 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -198,6 +198,7 @@ extern const int gtkmm_micro_version;
#include <gtkmm/notebook.h>
#include <gtkmm/object.h>
#include <gtkmm/overlay.h>
+#include <gtkmm/padcontroller.h>
#include <gtkmm/paned.h>
#include <gtkmm/pagesetup.h>
#ifndef G_OS_WIN32
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index b0849caf..1fcd98d1 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -128,6 +128,7 @@ gtkmm_files_any_hg = \
notebookpage.hg \
orientable.hg \
overlay.hg \
+ padcontroller.hg \
pagesetup.hg \
paned.hg \
papersize.hg \
diff --git a/gtk/src/gtk_signals.defs b/gtk/src/gtk_signals.defs
index 55514544..ec96626a 100644
--- a/gtk/src/gtk_signals.defs
+++ b/gtk/src/gtk_signals.defs
@@ -6613,6 +6613,26 @@
)
)
+;; From GtkPadController
+
+(define-property action-group
+ (of-object "GtkPadController")
+ (prop-type "GParamObject")
+ (docs "Action group to launch actions from")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
+(define-property pad
+ (of-object "GtkPadController")
+ (prop-type "GParamObject")
+ (docs "Pad device to control")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
;; From GtkPaned
(define-signal cycle-child-focus
diff --git a/gtk/src/padcontroller.ccg b/gtk/src/padcontroller.ccg
new file mode 100644
index 00000000..ced9fd5e
--- /dev/null
+++ b/gtk/src/padcontroller.ccg
@@ -0,0 +1,30 @@
+/* Copyright (C) 2019 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+
+namespace Gtk
+{
+
+PadController::PadController(const Glib::RefPtr<Gio::ActionGroup>& action_group, const
Glib::RefPtr<Gdk::Device>& pad)
+:
+ // gtk_pad_controller_new() sets the propagation-phase property.
+ _CONSTRUCT("propagation-phase", GTK_PHASE_CAPTURE,
+ "action-group", Glib::unwrap(action_group), "pad", Glib::unwrap(pad))
+{
+}
+
+} // namespace Gtk
diff --git a/gtk/src/padcontroller.hg b/gtk/src/padcontroller.hg
new file mode 100644
index 00000000..9e24fc95
--- /dev/null
+++ b/gtk/src/padcontroller.hg
@@ -0,0 +1,114 @@
+/* Copyright (C) 2019 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <giomm/actiongroup.h>
+#include <gdkmm/device.h>
+#include <gtkmm/eventcontroller.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/eventcontroller_p.h)
+
+namespace Gtk
+{
+_WRAP_ENUM(PadActionType, GtkPadActionType)
+
+/** Event controller for drawing tablet pads.
+ *
+ * %Gtk::PadController is an event controller for the pads found in drawing
+ * tablets (The collection of buttons and tactile sensors often found around
+ * the stylus-sensitive area).
+ *
+ * These buttons and sensors have no implicit meaning, and by default they
+ * perform no action. This event controller is provided to map those to
+ * Gio::Action objects, thus letting the application give those a more semantic
+ * meaning.
+ *
+ * Buttons and sensors are not constrained to triggering a single action, some
+ * Gdk::InputSource::TABLET_PAD devices feature multiple "modes". All these input
+ * elements have one current mode, which may determine the final action
+ * being triggered. Pad devices often divide buttons and sensors into groups.
+ * All elements in a group share the same current mode, but different groups
+ * may have different modes. See Gdk::DevicePad::get_n_groups() and
+ * Gdk::DevicePad::get_group_n_modes().
+ *
+ * Each of the actions that a given button/strip/ring performs for a given
+ * mode is defined by a GtkPadActionEntry. It contains an action name that
+ * will be looked up in the given Gio::ActionGroup and activated whenever the
+ * specified input element and mode are triggered.
+ *
+ * A simple example of %Gtk::PadController usage, assigning button 1 in all
+ * modes and pad devices to an "invert-selection" action:
+ *
+ * @code
+ * auto action_group = Gio::SimpleActionGroup::create();
+ * auto action = action_group->add_action("pad-actions.invert-selection",
+ * sigc::ptr_fun(on_invert_selection_activated));
+ * auto pad_controller = Gtk::PadController::create(action_group);
+ * pad_controller->set_action(Gtk::PadActionType::BUTTON, 1, -1,
+ * "Invert selection", "pad-actions.invert-selection");
+ * @endcode
+ *
+ * The actions belonging to rings/strips will be activated with a parameter
+ * of type Glib::Variant<double> bearing the value of the given axis. It
+ * is required that those are made stateful and accepting this Glib::VariantType.
+ *
+ * @see Gtk::EventController, Gdk::DevicePad
+ * @newin{3,96}
+ *
+ * @ingroup Gestures
+ */
+class PadController : public EventController
+{
+ _CLASS_GOBJECT(PadController, GtkPadController, GTK_PAD_CONTROLLER, EventController, GtkEventController)
+
+protected:
+ explicit PadController(const Glib::RefPtr<Gio::ActionGroup>& action_group,
+ const Glib::RefPtr<Gdk::Device>& pad = {});
+ _IGNORE(gtk_pad_controller_new)
+
+public:
+ /** Creates a new %Gtk::PadController that will associate events from @a pad to actions.
+ *
+ * An empty %Glib::RefPtr pad may be provided so the controller manages all pad devices
+ * generically. It is discouraged to mix %Gtk::PadController objects with empty
+ * and non-empty @a pad argument on the same toplevel window, as execution order
+ * is not guaranteed.
+ *
+ * The %Gtk::PadController is created with no mapped actions. In order to map pad
+ * events to actions, use set_action_entries() or set_action().
+ *
+ * Be aware that pad events will only be delivered to Gtk::Windows, so adding a pad
+ * controller to any other type of widget will not have an effect.
+ *
+ * @param group Gio::ActionGroup to trigger actions from.
+ * @param pad A Gdk::InputSource::TABLET_PAD device, or an empty %Glib::RefPtr to handle all pads.
+ * @return A newly created %Gtk::PadController.
+ */
+ _WRAP_CREATE(const Glib::RefPtr<Gio::ActionGroup>& action_group,
+ const Glib::RefPtr<Gdk::Device>& pad = {})
+
+//TODO: Wrap GtkPadActionEntry. Glib::OptionEntry may give some hints.
+// _WRAP_METHOD(void set_action_entries(const std::vector<const PadActionEntry>& entries),
gtk_pad_controller_set_action_entries)
+ _WRAP_METHOD(void set_action(PadActionType type, int index, int mode,
+ const Glib::ustring& label, const Glib::ustring& action_name), gtk_pad_controller_set_action)
+
+ _WRAP_PROPERTY("action-group", Glib::RefPtr<Gio::ActionGroup>)
+ _WRAP_PROPERTY("pad", Glib::RefPtr<Gdk::Device>)
+
+ // There are no signals or vfuncs.
+};
+
+} // namespace Gtk
diff --git a/tools/extra_defs_gen/generate_defs_gtk.cc b/tools/extra_defs_gen/generate_defs_gtk.cc
index 9afabdc4..77ef21db 100644
--- a/tools/extra_defs_gen/generate_defs_gtk.cc
+++ b/tools/extra_defs_gen/generate_defs_gtk.cc
@@ -152,6 +152,7 @@ int main(int /* argc */, char** /* argv */)
<< get_defs( GTK_TYPE_NOTEBOOK_PAGE )
<< get_defs( GTK_TYPE_ORIENTABLE )
<< get_defs( GTK_TYPE_OVERLAY )
+ << get_defs( GTK_TYPE_PAD_CONTROLLER )
<< get_defs( GTK_TYPE_PANED )
<< get_defs( GTK_TYPE_PICTURE )
<< get_defs( GTK_TYPE_POPOVER )
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index c95bffff..161a3a3e 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -106,6 +106,7 @@ _CONV_INCLASS_ENUM(Gtk,RecentFilter,Flags)
_CONV_ENUM(Gtk,RecentManagerError)
_CONV_ENUM(Gtk,RecentSortType)
_CONV_ENUM(Gtk,Unit)
+_CONV_ENUM(Gtk,PadActionType)
_CONV_ENUM(Gtk,PageOrientation)
_CONV_ENUM(Gtk,PrintDuplex)
_CONV_ENUM(Gtk,PrintQuality)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]