summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--gio/giomm.h6
-rw-r--r--gio/src/action.ccg25
-rw-r--r--gio/src/action.hg106
-rw-r--r--gio/src/actiongroup.ccg25
-rw-r--r--gio/src/actiongroup.hg100
-rw-r--r--gio/src/application.ccg214
-rw-r--r--gio/src/application.hg219
-rw-r--r--gio/src/applicationcommandline.ccg33
-rw-r--r--gio/src/applicationcommandline.hg76
-rw-r--r--gio/src/filelist.am6
-rw-r--r--gio/src/simpleaction.ccg23
-rw-r--r--gio/src/simpleaction.hg82
-rw-r--r--gio/src/simpleactiongroup.ccg24
-rw-r--r--gio/src/simpleactiongroup.hg54
15 files changed, 1012 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a3895616..77fdf9ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2011-10-09 José Alburquerque <jaalburqu@svn.gnome.org>
+
+ Re-add Application and related class so they can be finished.
+
+ * gio/giomm.h:
+ * gio/src/action.ccg:
+ * gio/src/action.hg:
+ * gio/src/actiongroup.ccg:
+ * gio/src/actiongroup.hg:
+ * gio/src/application.ccg:
+ * gio/src/application.hg:
+ * gio/src/applicationcommandline.ccg:
+ * gio/src/applicationcommandline.hg:
+ * gio/src/filelist.am:
+ * gio/src/simpleaction.ccg:
+ * gio/src/simpleaction.hg:
+ * gio/src/simpleactiongroup.ccg:
+ * gio/src/simpleactiongroup.hg:
+
2011-09-27 Krzesimir Nowak <qdlacz@gmail.com>
Fix h2def.py not parsing function starting with G_GNUC_* macros.
diff --git a/gio/giomm.h b/gio/giomm.h
index ca489371..8a6fb4a1 100644
--- a/gio/giomm.h
+++ b/gio/giomm.h
@@ -20,7 +20,11 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <giomm/action.h>
+#include <giomm/actiongroup.h>
#include <giomm/appinfo.h>
+#include <giomm/application.h>
+#include <giomm/applicationcommandline.h>
#include <giomm/asyncresult.h>
#include <giomm/bufferedinputstream.h>
#include <giomm/bufferedoutputstream.h>
@@ -82,6 +86,8 @@
#include <giomm/resolver.h>
#include <giomm/seekable.h>
#include <giomm/settings.h>
+#include <giomm/simpleaction.h>
+#include <giomm/simpleactiongroup.h>
#include <giomm/socket.h>
#include <giomm/socketaddress.h>
#include <giomm/socketaddressenumerator.h>
diff --git a/gio/src/action.ccg b/gio/src/action.ccg
new file mode 100644
index 00000000..c8c78857
--- /dev/null
+++ b/gio/src/action.ccg
@@ -0,0 +1,25 @@
+// -*- 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 <gio/gio.h>
+
+namespace Gio
+{
+
+} // namespace Gio
diff --git a/gio/src/action.hg b/gio/src/action.hg
new file mode 100644
index 00000000..3d92bfe2
--- /dev/null
+++ b/gio/src/action.hg
@@ -0,0 +1,106 @@
+// -*- 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)
+
+#m4 _CONVERSION(`Glib::ustring',`const gchar*',`$3.c_str()')
+ _WRAP_VFUNC(Glib::ustring get_name() const, "get_name")
+
+#m4 _CONVERSION(`Glib::VariantType',`const GVariantType*',`$3.gobj_copy()')
+ _WRAP_VFUNC(Glib::VariantType get_parameter_type() const, "get_parameter_type")
+ _WRAP_VFUNC(Glib::VariantType get_state_type() const, "get_state_type")
+
+#m4 _CONVERSION(`Glib::VariantBase',`GVariant*',`$3.gobj_copy()')
+
+ _WRAP_VFUNC(Glib::VariantBase get_state_hint() const, "get_state_hint")
+
+ _WRAP_VFUNC(bool get_enabled() const, "get_enabled")
+
+ _WRAP_VFUNC(Glib::VariantBase get_state() const, "get_state")
+
+#m4 _CONVERSION(`GVariant*',`const Glib::VariantBase&',`Glib::wrap($3, true)')
+ _WRAP_VFUNC(void change_state(const Glib::VariantBase& value), "change_state")
+ _WRAP_VFUNC(void activate(const Glib::VariantBase& parameter), "activate")
+};
+
+} // namespace Gio
diff --git a/gio/src/actiongroup.ccg b/gio/src/actiongroup.ccg
new file mode 100644
index 00000000..555a34bc
--- /dev/null
+++ b/gio/src/actiongroup.ccg
@@ -0,0 +1,25 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2010 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 <gio/gio.h>
+
+namespace Gio
+{
+
+} // namespace Gio
diff --git a/gio/src/actiongroup.hg b/gio/src/actiongroup.hg
new file mode 100644
index 00000000..c3853091
--- /dev/null
+++ b/gio/src/actiongroup.hg
@@ -0,0 +1,100 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2010 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>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/interface_p.h)
+_PINCLUDE(gio/gio.h)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+typedef struct _GActionGroupInterface GActionGroupInterface;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+namespace Gio
+{
+
+/** ActionGroup - a group of actions.
+ * ActionGroup represents a group of actions.
+ *
+ * Each action in the group has a unique name (which is a string). All method
+ * calls, except list_actions() take the name of an action as an argument.
+ *
+ * The GActionGroup API is meant to be the 'public' API to the action group.
+ * The calls here are exactly the interaction that 'external forces' (eg: UI,
+ * incoming D-Bus messages, etc.) are supposed to have with actions.
+ * 'Internal' APIs (ie: ones meant only to be accessed by the action group
+ * implementation) are found on subclasses. This is why you will find -- for
+ * example -- get_action_enabled() but not an equivalent @c set() call.
+ *
+ * Signals are emitted on the action group in response to state changes on
+ * individual actions.
+ */
+class ActionGroup : public Glib::Interface
+{
+ _CLASS_INTERFACE(ActionGroup, GActionGroup, G_ACTION_GROUP, GActionGroupInterface)
+
+public:
+ _WRAP_METHOD(bool has_action(const Glib::ustring& action_name) const, g_action_group_has_action)
+
+#m4 _CONVERSION(`gchar**',`std::vector<Glib::ustring>',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, Glib::OWNERSHIP_DEEP)')
+ _WRAP_METHOD(std::vector<Glib::ustring> list_actions() const, g_action_group_list_actions)
+
+ _WRAP_METHOD(bool get_action_enabled(const Glib::ustring& action_name) const, g_action_group_get_action_enabled)
+
+ _WRAP_METHOD(Glib::VariantType get_action_parameter_type(const Glib::ustring& action_name) const, g_action_group_get_action_parameter_type)
+ _WRAP_METHOD(Glib::VariantType get_action_state_type(const Glib::ustring& action_name) const, g_action_group_get_action_state_type)
+
+ _WRAP_METHOD(Glib::VariantContainerBase get_action_state_hint(const Glib::ustring& action_name) const, g_action_group_get_action_state_hint)
+ _WRAP_METHOD(Glib::VariantBase get_action_state(const Glib::ustring& action_name) const, g_action_group_get_action_state)
+
+ _WRAP_METHOD(void change_action_state(const Glib::ustring& action_name, const Glib::VariantBase& value), g_action_group_change_action_state)
+ _WRAP_METHOD(void activate_action(const Glib::ustring& action_name, const Glib::VariantBase& parameter), g_action_group_activate_action)
+ _WRAP_METHOD(void action_added(const Glib::ustring& action_name), g_action_group_action_added)
+ _WRAP_METHOD(void action_removed(const Glib::ustring& action_name), g_action_group_action_removed)
+ _WRAP_METHOD(void action_enabled_changed(const Glib::ustring& action_name, bool enabled), g_action_group_action_enabled_changed)
+ _WRAP_METHOD(void action_state_changed (const Glib::ustring& action_name, const Glib::VariantBase& state), g_action_group_action_state_changed)
+
+ _WRAP_SIGNAL(void action_added(const Glib::ustring& action_name), "action-added")
+ _WRAP_SIGNAL(void action_enabled_changed(const Glib::ustring& action_name, bool enabled), "action-enabled-changed")
+ _WRAP_SIGNAL(void action_removed(const Glib::ustring& action_name), "action-removed")
+
+#m4 _CONVERSION(`GVariant*', `const Glib::VariantBase&', `Glib::wrap($3, true)')
+ _WRAP_SIGNAL(void action_state_changed(const Glib::ustring& action_name, const Glib::VariantBase& value), "action-state-changed")
+
+ _WRAP_VFUNC(bool has_action(const Glib::ustring& name) const, "has_action")
+
+#m4 _CONVERSION(`std::vector<Glib::ustring>',`gchar**',`const_cast<gchar**>(Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data())')
+ _WRAP_VFUNC(std::vector<Glib::ustring> list_actions() const, "list_actions")
+
+ _WRAP_VFUNC(bool get_action_enabled(const Glib::ustring& name) const, "get_action_enabled")
+
+#m4 _CONVERSION(`Glib::VariantType',`const GVariantType*',`$3.gobj_copy()')
+ _WRAP_VFUNC(Glib::VariantType get_action_parameter_type(const Glib::ustring& name) const, "get_action_parameter_type")
+ _WRAP_VFUNC(Glib::VariantType get_action_state_type(const Glib::ustring& name) const, "get_action_state_type")
+
+#m4 _CONVERSION(`Glib::VariantBase',`GVariant*',`$3.gobj_copy()')
+ _WRAP_VFUNC(Glib::VariantBase get_action_state_hint(const Glib::ustring& name) const, "get_action_state_hint")
+ _WRAP_VFUNC(Glib::VariantBase get_action_state(const Glib::ustring& name) const, "get_action_state")
+
+ _WRAP_VFUNC(void change_action_state(const Glib::ustring& name, const Glib::VariantBase& value), "change_action_state")
+ _WRAP_VFUNC(void activate_action(const Glib::ustring& name, const Glib::VariantBase& parameter), "activate_action")
+};
+
+} // namespace Gio
diff --git a/gio/src/application.ccg b/gio/src/application.ccg
new file mode 100644
index 00000000..25b0a630
--- /dev/null
+++ b/gio/src/application.ccg
@@ -0,0 +1,214 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2007 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+#include <giomm/file.h>
+#include <giomm/actiongroup.h>
+#include <giomm/init.h>
+
+namespace
+{
+
+static void Application_signal_open_callback(GApplication* self, GFile** files,
+ gint n_files, const gchar* hint, void* data)
+{
+ typedef sigc::slot< void, const Gio::Application::type_vec_files&, const Glib::ustring& > SlotType;
+
+ Gio::Application::type_vec_files vec_files(n_files);
+ for(int i = 0; i < n_files; ++i)
+ {
+ vec_files[i] = Glib::wrap(files[i], true);
+ }
+
+ const Glib::ustring hint_str = (hint ? hint : Glib::ustring());
+
+ // Do not try to call a signal on a disassociated wrapper.
+ if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
+ {
+ try
+ {
+ if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data)) {
+ (*static_cast<SlotType*>(slot))(vec_files, hint_str);
+ return;
+ }
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ }
+
+ return;
+}
+
+static void Application_signal_open_notify_callback(GApplication* self, GFile** files,
+ gint n_files, const gchar *hint, void* data)
+{
+ using namespace Gio;
+ typedef sigc::slot< void, const Application::type_vec_files&, const Glib::ustring& > SlotType;
+
+ Application::type_vec_files vec_files(n_files);
+ for (int i = 0; i < n_files; i++)
+ {
+ vec_files[i] = Glib::wrap(files[i], true);
+ }
+
+ const Glib::ustring hint_str = (hint ? hint : Glib::ustring());
+
+ // Do not try to call a signal on a disassociated wrapper.
+ if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
+ {
+ try
+ {
+ if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
+ {
+ (*static_cast<SlotType*>(slot))(vec_files, hint_str);
+ return;
+ }
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ }
+
+ return;
+}
+
+static const Glib::SignalProxyInfo Application_signal_open_info =
+{
+ "open",
+ (GCallback) &Application_signal_open_callback,
+ (GCallback) &Application_signal_open_notify_callback
+};
+
+}
+
+namespace Gio
+{
+
+
+const Glib::Class& Application::custom_class_init()
+{
+ Glib::init();
+ Gio::init();
+ return application_class_.init();
+}
+
+
+Application::Application(const Glib::ustring& application_id, ApplicationFlags flags)
+:
+ // Mark this class as non-derived to allow C++ vfuncs to be skipped.
+ Glib::ObjectBase(0),
+ Glib::Object(Glib::ConstructParams(custom_class_init(), "application_id", application_id.c_str(), "flags", ((GApplicationFlags)(flags)), static_cast<char*>(0)))
+{
+
+}
+
+void Application_Class::open_callback(GApplication* self, GFile** files,
+ gint n_files, const gchar *hint)
+{
+ Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+ // Non-gtkmmproc-generated custom classes implicitly call the default
+ // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+ // generated classes can use this optimisation, which avoids the unnecessary
+ // parameter conversions if there is no possibility of the virtual function
+ // being overridden:
+
+ if(obj_base && obj_base->is_derived_())
+ {
+ CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+ if(obj) // This can be NULL during destruction.
+ {
+ try // Trap C++ exceptions which would normally be lost because this is a C callback.
+ {
+ // Call the virtual member method, which derived classes might override.
+ Application::type_vec_files vec_files(n_files);
+ for (int i = 0; i < n_files; i++) {
+ vec_files[i] = Glib::wrap(files[i], true);
+ }
+
+ const Glib::ustring hint_str = (hint ? hint : Glib::ustring());
+
+ obj->on_open(vec_files, hint_str);
+ return;
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ }
+ }
+
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ // Call the original underlying C function:
+ if(base && base->open)
+ (*base->open)(self, files, n_files, hint);
+}
+
+Glib::SignalProxy2< void, const Application::type_vec_files&, const Glib::ustring& > Application::signal_open()
+{
+ return Glib::SignalProxy2< void, const Application::type_vec_files&, const Glib::ustring& >(this, &Application_signal_open_info);
+}
+
+void Gio::Application::on_open(const Application::type_vec_files& files, const Glib::ustring& hint)
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ if(base && base->open) {
+ (*base->open)(gobj(),
+ Glib::ArrayHandler<type_vec_files::value_type>::vector_to_array(files).data(),
+ files.size(),
+ hint.c_str());
+ }
+}
+
+void Application::open(const type_vec_files& files, const Glib::ustring& hint)
+{
+ g_application_open(gobj(),
+ Glib::ArrayHandler<type_vec_files::value_type>::vector_to_array(files).data(),
+ files.size(),
+ hint.c_str());
+}
+
+void Application::open(const Glib::RefPtr<Gio::File>& file, const Glib::ustring& hint)
+{
+ type_vec_files files(1);
+ files[0] = file;
+ open(files, hint);
+}
+
+bool Application::register_application()
+{
+ GError* gerror = 0;
+ bool retvalue = g_application_register(gobj(), NULL, &(gerror));
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+
+ return retvalue;
+}
+
+} // namespace Gio
diff --git a/gio/src/application.hg b/gio/src/application.hg
new file mode 100644
index 00000000..571042ec
--- /dev/null
+++ b/gio/src/application.hg
@@ -0,0 +1,219 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2007 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <giomm/applicationcommandline.h>
+#include <giomm/file.h>
+#include <glibmm/object.h>
+#include <glibmm/variant.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+_WRAP_ENUM(ApplicationFlags, GApplicationFlags, NO_GTYPE)
+
+class ActionGroup;
+
+/** Application - Core application class.
+ * An Application is the foundation of an application, unique for a given
+ * application identifier. The Application class wraps some low-level
+ * platform-specific services and is intended to act as the foundation for
+ * higher-level application classes such as Gtk::Application or MxApplication.
+ * In general, you should not use this class outside of a higher level
+ * framework.
+ *
+ * One of the core features that Application provides is process uniqueness,
+ * in the context of a "session". The session concept is platform-dependent,
+ * but corresponds roughly to a graphical desktop login. When your application
+ * is launched again, its arguments are passed through platform communication
+ * to the already running program. The already running instance of the program
+ * is called the <i>primary instance</i>.
+ *
+ * Before using Application, you must choose an "application identifier". The
+ * expected form of an application identifier is very close to that of of a
+ * <a href="
+ * http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface">DBus
+ * bus name</a>. Examples include: "com.example.MyApp",
+ * "org.example.internal-apps.Calculator". For details on valid application
+ * identifiers, see id_is_valid().
+ *
+ * Application provides convenient life cycle management by maintaining a
+ * <i>use count</i> for the primary application instance. The use count can be
+ * changed using hold() and release(). If it drops to zero, the application
+ * exits.
+ *
+ * Application also implements the ActionGroup interface and lets you easily
+ * export actions by adding them with set_action_group(). When
+ * invoking an action by calling Gio::ActionGroup::activate_action() on the
+ * application, it is always invoked in the primary instance.
+ *
+ * There is a number of different entry points into an Application:
+ *
+ * - via 'Activate' (i.e. just starting the application)
+ * - via 'Open' (i.e. opening some files)
+ * - via activating an action
+ *
+ * The signal_startup() signal lets you handle the application initialization
+ * for all of these in a single place.
+ *
+ * See the C API docs for an example.
+ *
+ * @newin{2,28}
+ */
+class Application : public Glib::Object
+{
+ _CLASS_GOBJECT(Application, GApplication, G_APPLICATION, Glib::Object, GObject)
+
+protected:
+ explicit Application(const Glib::ustring& application_id, ApplicationFlags flags=APPLICATION_FLAGS_NONE);
+ _IGNORE(g_application_new)
+
+public:
+ _WRAP_CREATE(const Glib::ustring& application_id, ApplicationFlags flags=APPLICATION_FLAGS_NONE)
+
+ _WRAP_METHOD(static bool id_is_valid(const Glib::ustring& application_id), g_application_id_is_valid)
+
+ _WRAP_METHOD(Glib::ustring get_id() const, g_application_get_application_id)
+ _WRAP_METHOD(void set_id(const Glib::ustring& application_id), g_application_set_application_id)
+
+ _WRAP_METHOD(guint get_inactivity_timeout() const, g_application_get_inactivity_timeout)
+ _WRAP_METHOD(void set_inactivity_timeout(guint inactivity_timeout), g_application_set_inactivity_timeout)
+
+ _WRAP_METHOD(ApplicationFlags get_flags() const, g_application_get_flags)
+ _WRAP_METHOD(void set_flags(ApplicationFlags flags), g_application_set_flags)
+
+ _WRAP_METHOD(void set_action_group(const Glib::RefPtr<ActionGroup>& action_group), g_application_set_action_group)
+
+ _WRAP_METHOD(bool is_registered() const, g_application_get_is_registered)
+ _WRAP_METHOD(bool is_remote() const, g_application_get_is_remote)
+
+ //Renamed from register() because that is a C++ keyword.
+ _WRAP_METHOD(bool register_application(const Glib::RefPtr<Gio::Cancellable>& cancellable), g_application_register, errthrow)
+
+ /// Non-cancellable version of register_application().
+ bool register_application();
+
+ _WRAP_METHOD(void hold(), g_application_hold)
+ _WRAP_METHOD(void release(), g_application_release)
+ _WRAP_METHOD(void activate(), g_application_activate)
+
+ typedef std::vector< Glib::RefPtr<File> > type_vec_files;
+
+ /* Opens the given files.
+ *
+ * In essence, this results in the open signal being emitted
+ * in the primary instance.
+ *
+ * @a hint is simply passed through to the open signal. It is
+ * intended to be used by applications that have multiple modes for
+ * opening files (eg: "view" vs "edit", etc).
+ *
+ * The application must be registered before calling this mwethod
+ * and it must have the APPLICATION_HANDLES_OPEN flag set.
+ *
+ * @param files The files to open. This must be non-empty.
+ * @param hint A hint.
+ *
+ * @newin{2,28}
+ */
+ void open(const type_vec_files& files, const Glib::ustring& hint = Glib::ustring());
+ _IGNORE(g_application_open)
+
+ /* Opens the given file.
+ *
+ * In essence, this results in the open signal being emitted
+ * in the primary instance.
+ *
+ * @a hint is simply passed through to the open signal. It is
+ * intended to be used by applications that have multiple modes for
+ * opening files (eg: "view" vs "edit", etc).
+ *
+ * The application must be registered before calling this mwethod
+ * and it must have the APPLICATION_HANDLES_OPEN flag set.
+ *
+ * @param file The file to open. This must be non-empty.
+ * @param hint A hint.
+ *
+ * @newin{2,28}
+ */
+ void open(const Glib::RefPtr<Gio::File>& file, const Glib::ustring& hint = Glib::ustring());
+
+ _WRAP_METHOD(int run(int argc, char** argv), g_application_run)
+ //TODO: g_application_run_with_arguments)
+
+ _WRAP_PROPERTY("action-group", Glib::RefPtr<ActionGroup>)
+ _WRAP_PROPERTY("application-id", Glib::ustring)
+ _WRAP_PROPERTY("flags", ApplicationFlags)
+ _WRAP_PROPERTY("inactivity-timeout", guint)
+ _WRAP_PROPERTY("is-registered", bool)
+ _WRAP_PROPERTY("is-remote", bool)
+
+//#m4 _CONVERSION(`const gchar*', `const Glib::ustring&', `Glib::ustring($3)')
+//#m4 _CONVERSION(`GVariant*', `const Glib::VariantBase&', `Glib::wrap($3, true)')
+
+ _WRAP_SIGNAL(void startup(), "startup")
+ _WRAP_SIGNAL(void activate(), "activate")
+
+ //We wrap the open signal without _WRAP_SIGNAL(), because we need to change its parameters.
+ //See bug https://bugzilla.gnome.org/show_bug.cgi?id=637457
+ Glib::SignalProxy2< void, const type_vec_files&, const Glib::ustring& > signal_open();
+
+#m4 _CONVERSION(`GApplicationCommandLine*', `const Glib::RefPtr<ApplicationCommandLine>&',`Glib::wrap($3, true)')
+ _WRAP_SIGNAL(int command_line(const Glib::RefPtr<ApplicationCommandLine>& command_line), "command-line")
+
+protected:
+ virtual void on_open(const type_vec_files& files, const Glib::ustring& hint);
+
+#m4begin
+ _PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
+ klass->open = &open_callback;
+ _SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
+ static void open_callback(GApplication* self, GFile** files, gint n_files, const gchar* hint);
+ _POP()
+#m4end
+
+#m4 _CONVERSION(`char**&', `gchar***',`&($3)')
+#m4 _CONVERSION(`gchar***', `char**&',`*($3)')
+ _WRAP_VFUNC(bool local_command_line(char**& arguments, int& exit_status), local_command_line)
+
+/* TODO:
+ void (* before_emit) (GApplication *application,
+ GVariant *platform_data);
+ void (* after_emit) (GApplication *application,
+ GVariant *platform_data);
+ void (* add_platform_data) (GApplication *application,
+ GVariantBuilder *builder);
+ void (* quit_mainloop) (GApplication *application);
+ void (* run_mainloop) (GApplication *application);
+*/
+
+
+private:
+ /** This is just a way to call Glib::init() (which calls g_type_init()) before
+ * calling application_class_.init(), so that
+ * g_application_get_type() will always succeed.
+ * See https://bugzilla.gnome.org/show_bug.cgi?id=639925
+ */
+ const Glib::Class& custom_class_init();
+};
+
+
+} // namespace Gio
diff --git a/gio/src/applicationcommandline.ccg b/gio/src/applicationcommandline.ccg
new file mode 100644
index 00000000..4e41294e
--- /dev/null
+++ b/gio/src/applicationcommandline.ccg
@@ -0,0 +1,33 @@
+/* Copyright (C) 2010 Jonathon Jongsma <jonathon@quotidian.org>
+ *
+ * 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 <gio/gio.h>
+
+namespace Gio
+{
+
+void ApplicationCommandLine::print(const Glib::ustring& message)
+{
+ g_application_command_line_print(gobj(), "%s", message.c_str());
+}
+
+void ApplicationCommandLine::printerr(const Glib::ustring& message)
+{
+ g_application_command_line_printerr(gobj(), "%s", message.c_str());
+}
+
+} //namespace Gio
diff --git a/gio/src/applicationcommandline.hg b/gio/src/applicationcommandline.hg
new file mode 100644
index 00000000..d7e16b60
--- /dev/null
+++ b/gio/src/applicationcommandline.hg
@@ -0,0 +1,76 @@
+/* Copyright (C) 2010 Jonathon Jongsma <jonathon@quotidian.org>
+ *
+ * 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/object.h>
+#include <glibmm/variant.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+class ApplicationCommandLine : public Glib::Object
+{
+ _CLASS_GOBJECT(ApplicationCommandLine, GApplicationCommandLine, G_APPLICATION_COMMAND_LINE, Glib::Object, GObject)
+
+protected:
+ _CTOR_DEFAULT
+
+public:
+
+ _WRAP_METHOD(char** get_arguments(int& argc) const, g_application_command_line_get_arguments)
+
+ //We use std::string instead of ustring because the C documentation says that it may be non-UTF-8 data:
+ _WRAP_METHOD(std::string get_cwd() const, g_application_command_line_get_cwd)
+
+ //We use std::string instead of ustring because the C documentation says that it may be non-UTF-8 data:
+#m4 _CONVERSION(`const gchar*const*',`std::vector<std::string>',`Glib::ArrayHandler<std::string>::array_to_vector($3, Glib::OWNERSHIP_NONE)')
+ _WRAP_METHOD(std::vector<std::string> get_environ() const, g_application_command_line_get_environ)
+
+ //We use std::string instead of ustring because the C documentation says that it may be non-UTF-8 data:
+ _WRAP_METHOD(std::string getenv(const Glib::ustring& name) const, g_application_command_line_getenv)
+
+ _WRAP_METHOD(bool is_remote() const, g_application_command_line_get_is_remote)
+
+ //TODO: Return a specific Glib::Variant< std::pair<K, V> > type?
+ //_WRAP_METHOD(Variant<> get_platform_data() const, g_application_command_line_get_platform_data)
+
+ _WRAP_METHOD(void set_exit_status(int exit_status), g_application_command_line_set_exit_status)
+ _WRAP_METHOD(int get_exit_status() const, g_application_command_line_get_exit_status)
+
+ /** Formats a message and prints it using the stdout print handler in the invoking process.
+ * If this is a local invocation then this is exactly equivalent to g_print().
+ * If this is remote then this is equivalent to calling g_print() in the invoking process.
+ *
+ * @param message The text to print.
+ */
+ void print(const Glib::ustring& message);
+ _IGNORE(g_application_command_line_print)
+
+ /** Formats a message and prints it using the stderr print handler in the invoking process.
+ * If this is a local invocation then this is exactly equivalent to g_printerr().
+ * If this is remote then this is equivalent to calling g_printerr() in the invoking process.
+ *
+ * @param message The text to print.
+ */
+ void printerr(const Glib::ustring& message);
+ _IGNORE(g_application_command_line_printerr)
+};
+
+
+} // namespace Gio
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index 2a528b49..8e2ce3f5 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -13,7 +13,11 @@ giomm_files_defs = \
gio_docs_override.xml
giomm_files_any_hg = \
+ action.hg \
+ actiongroup.hg \
appinfo.hg \
+ application.hg \
+ applicationcommandline.hg \
asyncinitable.hg \
asyncresult.hg \
bufferedinputstream.hg \
@@ -75,6 +79,8 @@ giomm_files_any_hg = \
resolver.hg \
seekable.hg \
settings.hg \
+ simpleaction.hg \
+ simpleactiongroup.hg \
socket.hg \
socketaddress.hg \
socketaddressenumerator.hg \
diff --git a/gio/src/simpleaction.ccg b/gio/src/simpleaction.ccg
new file mode 100644
index 00000000..eaf0b625
--- /dev/null
+++ b/gio/src/simpleaction.ccg
@@ -0,0 +1,23 @@
+/* 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 <gio/gio.h>
+
+namespace Gio
+{
+
+}// namespace Gio
diff --git a/gio/src/simpleaction.hg b/gio/src/simpleaction.hg
new file mode 100644
index 00000000..cf1292e5
--- /dev/null
+++ b/gio/src/simpleaction.hg
@@ -0,0 +1,82 @@
+/* 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/object.h>
+#include <giomm/action.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+typedef struct _GSimpleAction GSimpleAction;
+typedef GObjectClass GSimpleActionClass;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+namespace Gio
+{
+
+/** SimpleAction - A simple Action implementation.
+ * A SimpleAction is the obvious simple implementation of the Action
+ * interface. This is the easiest way to create an action for purposes of
+ * adding it to a SimpleActionGroup.
+ *
+ * See also Gtk::Action.
+ *
+ * @newin{2,30}
+ */
+class SimpleAction : public Glib::Object, public Action
+{
+ _CLASS_GOBJECT(SimpleAction, GSimpleAction, G_SIMPLE_ACTION, Glib::Object, GObject)
+ _IMPLEMENTS_INTERFACE(Action)
+ _STRUCT_NOT_HIDDEN
+
+protected:
+#m4 _CONVERSION(`const Glib::VariantType&',`const GVariantType*',`$3.gobj()')
+
+ _WRAP_CTOR(SimpleAction(const Glib::ustring& name, const Glib::VariantType& parameter_type), g_simple_action_new)
+ _WRAP_CTOR(SimpleAction(const Glib::ustring& name, const Glib::VariantType& parameter_type, const Glib::VariantBase& sate), g_simple_action_new_stateful)
+
+public:
+ _WRAP_METHOD_DOCS_ONLY(g_simple_action_new)
+ _WRAP_CREATE(const Glib::ustring& name, const Glib::VariantType& parameter_type)
+
+ _WRAP_METHOD_DOCS_ONLY(g_simple_action_new_stateful)
+ _WRAP_CREATE(const Glib::ustring& name, const Glib::VariantType& parameter_type, const Glib::VariantBase& sate)
+
+ _WRAP_METHOD(void set_enabled(bool enabled), g_simple_action_set_enabled)
+ _WRAP_METHOD(void set_state(const Glib::VariantBase& value), g_simple_action_set_state)
+
+ /* These properties are already wrapped in the Action interface.
+ _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: Signals are not wrapped because GSimpleAction does not declare a
+ * standard _GSimpleActionClass structure.
+ * See bug #659783:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=659783
+#m4 _CONVERSION(`GVariant*',`const Glib::VariantBase&',`Glib::wrap($3, true)')
+
+ _WRAP_SIGNAL(void activate(const Glib::VariantBase& parameter), "activate")
+ _WRAP_SIGNAL(void change_state(const Glib::VariantBase& value), "change-state")
+*/
+};
+
+} // namespace Gio
diff --git a/gio/src/simpleactiongroup.ccg b/gio/src/simpleactiongroup.ccg
new file mode 100644
index 00000000..cd3e297a
--- /dev/null
+++ b/gio/src/simpleactiongroup.ccg
@@ -0,0 +1,24 @@
+/* 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 <gio/gio.h>
+#include <giomm/action.h>
+
+namespace Gio
+{
+
+}// namespace Gio
diff --git a/gio/src/simpleactiongroup.hg b/gio/src/simpleactiongroup.hg
new file mode 100644
index 00000000..e9596e35
--- /dev/null
+++ b/gio/src/simpleactiongroup.hg
@@ -0,0 +1,54 @@
+/* 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/object.h>
+#include <giomm/actiongroup.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+class Action;
+
+/** SimpleActionGroup - A simple ActionGroup implementation.
+ * SimpleActionGroup is a hash table filled with Action objects, implementing
+ * the ActionGroup interface.
+ *
+ * @newin{2,30}
+ */
+class SimpleActionGroup : public Glib::Object, public ActionGroup
+{
+ _CLASS_GOBJECT(SimpleActionGroup, GSimpleActionGroup, G_SIMPLE_ACTION_GROUP, Glib::Object, GObject)
+ _IMPLEMENTS_INTERFACE(ActionGroup)
+
+protected:
+ _CTOR_DEFAULT()
+
+public:
+ _WRAP_METHOD_DOCS_ONLY(g_simple_action_group_new)
+ _WRAP_CREATE()
+
+ _WRAP_METHOD(Glib::RefPtr<Action> lookup(const Glib::ustring& action_name), g_simple_action_group_lookup)
+ _WRAP_METHOD(void insert(const Glib::RefPtr<Action>& action), g_simple_action_group_insert)
+ _WRAP_METHOD(void remove(const Glib::ustring& action_name), g_simple_action_group_remove)
+
+ //TODO?: _WRAP_METHOD(void add_entries(const GActionEntry* entries, int n_entries, gpointer user_data), g_simple_action_group_add_entries)
+};
+
+} // namespace Gio