[glibmm] Add back Gio::Application and friends so we can try to finish them.



commit f5265c7bfe9571bc3c11b95ac8e2033a3a49777d
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Aug 3 08:57:32 2011 +0200

    Add back Gio::Application and friends so we can try to finish them.
    
    This reverts commit c446268b44f3595431ba6f535dc297557c6097e0.

 ChangeLog                          |    9 ++
 gio/giomm.h                        |    3 +
 gio/src/actiongroup.ccg            |   25 ++++
 gio/src/actiongroup.hg             |   85 ++++++++++++++
 gio/src/application.ccg            |  214 +++++++++++++++++++++++++++++++++++
 gio/src/application.hg             |  219 ++++++++++++++++++++++++++++++++++++
 gio/src/applicationcommandline.ccg |   33 ++++++
 gio/src/applicationcommandline.hg  |   76 +++++++++++++
 gio/src/filelist.am                |    3 +
 9 files changed, 667 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7921f84..017c076 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-08-03  Murray Cumming  <murrayc murrayc com>
+
+	Add back Gio::Application and friends so we can try to finish them.
+
+	* gio/src/actiongroup.[hg|ccg]:
+	* gio/src/application.[hg|ccg]:
+	* gio/src/applicationcommandline.[hg|ccg]:
+	See http://mail.gnome.org/archives/gtkmm-list/2011-March/msg00062.html
+	
 2.29.11:
 
 2011-07-19  Murray Cumming  <murrayc murrayc com>
diff --git a/gio/giomm.h b/gio/giomm.h
index ca48937..de8cc27 100644
--- a/gio/giomm.h
+++ b/gio/giomm.h
@@ -20,7 +20,10 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#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>
diff --git a/gio/src/actiongroup.ccg b/gio/src/actiongroup.ccg
new file mode 100644
index 0000000..555a34b
--- /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 0000000..8ff29e9
--- /dev/null
+++ b/gio/src/actiongroup.hg
@@ -0,0 +1,85 @@
+// -*- 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)
+
+/* TODO:
+  _WRAP_METHOD(const GVariantType* get_action_parameter_type(const Glib::ustring& action_name), g_action_group_get_action_parameter_type)
+  GVariantType* get_action_state_type(const Glib::ustring& action_name), g_action_group_get_action_state_type)
+  _WRAP_METHOD(GVariant* get_action_state_hint(const Glib::ustring& action_name), g_action_group_get_action_state_hint)
+  _WRAP_METHOD(GVariant* get_action_state(GActionGroup* action_group, const gchar* action_name), 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")
+
+//TODO: Wrap virtual functions.
+};
+
+} // namespace Gio
diff --git a/gio/src/application.ccg b/gio/src/application.ccg
new file mode 100644
index 0000000..25b0a63
--- /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 0000000..7559525
--- /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
+
+  //TODO: Change the parameter types when we know how they are really used.
+  //See https://bugzilla.gnome.org/show_bug.cgi?id=643478
+  _WRAP_VFUNC(bool local_command_line(gchar*** 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 0000000..4e41294
--- /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 0000000..d7e16b6
--- /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 b5db4ed..c93230f 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -13,7 +13,10 @@ giomm_files_defs =			\
 	gio_docs_override.xml
 
 giomm_files_any_hg =			\
+	actiongroup.hg			\
 	appinfo.hg			\
+	application.hg			\
+	applicationcommandline.hg			\
 	asyncinitable.hg		\
 	asyncresult.hg			\
 	bufferedinputstream.hg		\



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