summaryrefslogtreecommitdiff
path: root/gio/src/action.hg
diff options
context:
space:
mode:
authorJosé Alburquerque <jaalburqu@svn.gnome.org>2011-09-20 17:36:17 -0400
committerJosé Alburquerque <jaalburqu@svn.gnome.org>2011-09-20 17:46:56 -0400
commit00491f06c3080f14536b6aa00251055c6c584c21 (patch)
tree48cba016a15f95e41c926861df07502cb82d4c06 /gio/src/action.hg
parenteea80f82e0cc7c2a8d8d2d34984d75bcfa83368d (diff)
downloadglibmm-00491f06c3080f14536b6aa00251055c6c584c21.tar.gz
giomm: Add Action class wrapping GAction.
* gio/src/action.{ccg,hg}: * gio/src/filelist.am: Add the new sources wrapping the methods and signals of GAction and include them in the list of files to be built. * tools/extra_defs_gen/generate_defs_gio.cc: Add G_TYPE_ACTION to the list of types for which signals and properties should be generated. * gio/src/gio_signals.defs: * gio/src/gio_methods.defs: Regenerate to get the new methods and properties being wrapped. * gio/src/gio_extra_objects.defs: Add Action to the list of extra objects so gmmproc's documentation generation does not produce warnings because of it. Also added DBusNodeInfo and Proxy. * tools/m4/convert_gio.m4: Alphabetized the conversion by groups pertaining to types. Removed the Variant return conversions which take copies. * glib/src/variant.hg: Moved the conversions here because they are specific to the methods in this class, specifically get_child() and get().
Diffstat (limited to 'gio/src/action.hg')
-rw-r--r--gio/src/action.hg89
1 files changed, 89 insertions, 0 deletions
diff --git a/gio/src/action.hg b/gio/src/action.hg
new file mode 100644
index 00000000..e8d9e4d2
--- /dev/null
+++ b/gio/src/action.hg
@@ -0,0 +1,89 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2011 The giomm 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/interface.h>
+#include <glibmm/varianttype.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/interface_p.h)
+_PINCLUDE(gio/gio.h)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+typedef struct _GActionInterface GActionInterface;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+namespace Gio
+{
+
+/** Action - An action.
+ * Action represents a single named action.
+ *
+ * The main interface to an action is that it can be activated with activate().
+ * This results in the signal_activate() signal being emitted. An activation
+ * has a Glib::VariantBase parameter (which may be <tt>0</tt>). The correct
+ * type for the parameter is determined by a static parameter type (which is
+ * given at construction time).
+ *
+ * An action may optionally have a state, in which case the state may be set
+ * with change_state(). This call takes a Glib::VariantBase. The correct type
+ * for the state is determined by a static state type (which is given at
+ * construction time).
+ *
+ * The state may have a hint associated with it, specifying its valid range.
+ *
+ * Action is merely the interface to the concept of an action, as described
+ * above. Various implementations of actions exist, including SimpleAction and
+ * Gtk::Action.
+ *
+ * In all cases, the implementing class is responsible for storing the name of
+ * the action, the parameter type, the enabled state, the optional state type
+ * and the state and emitting the appropriate signals when these change. The
+ * implementor responsible for filtering calls to activate() and change_state()
+ * for type safety and for the state being enabled.
+ *
+ * Probably the only useful thing to do with a Action is to put it inside of a
+ * SimpleActionGroup.
+ *
+ * @newin{2,30}
+ */
+class Action : public Glib::Interface
+{
+ _CLASS_INTERFACE(Action, GAction, G_ACTION, GActionInterface)
+
+public:
+ _WRAP_METHOD(Glib::ustring get_name() const, g_action_get_name)
+ _WRAP_METHOD(Glib::VariantType get_parameter_type() const, g_action_get_parameter_type)
+ _WRAP_METHOD(Glib::VariantType get_state_type() const, g_action_get_state_type)
+ _WRAP_METHOD(void get_state_hint() const, g_action_get_state_hint)
+ _WRAP_METHOD(bool get_enabled() const, g_action_get_enabled)
+ _WRAP_METHOD(void get_state() const, g_action_get_state)
+
+ _WRAP_METHOD(void change_state(const Glib::VariantBase& value), g_action_change_state)
+ _WRAP_METHOD(void activate(const Glib::VariantBase& parameter), g_action_activate)
+
+ _WRAP_PROPERTY("enabled", bool)
+ _WRAP_PROPERTY("name", Glib::ustring)
+ _WRAP_PROPERTY("parameter-type", Glib::VariantType)
+ _WRAP_PROPERTY("state", Glib::VariantBase)
+ _WRAP_PROPERTY("state-type", Glib::VariantType)
+
+//TODO: Wrap virtual functions.
+};
+
+} // namespace Gio