"Fossies" - the Fresh Open Source Software Archive

Member "glibmm-2.63.1/gio/giomm/application.cc" (20 Jun 2019, 56778 Bytes) of package /linux/misc/glibmm-2.63.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "application.cc" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.62.0_vs_2.63.1.

    1 // Generated by gmmproc 2.61.1 -- DO NOT MODIFY!
    2 
    3 
    4 #include <glibmm.h>
    5 
    6 #include <giomm/application.h>
    7 #include <giomm/private/application_p.h>
    8 
    9 
   10 /* Copyright (C) 2007 The gtkmm Development Team
   11  *
   12  * This library is free software; you can redistribute it and/or
   13  * modify it under the terms of the GNU Lesser General Public
   14  * License as published by the Free Software Foundation; either
   15  * version 2.1 of the License, or (at your option) any later version.
   16  *
   17  * This library is distributed in the hope that it will be useful,
   18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20  * Lesser General Public License for more details.
   21  *
   22  * You should have received a copy of the GNU Lesser General Public
   23  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
   24  */
   25 
   26 #include <gio/gio.h>
   27 #include <giomm/file.h>
   28 #include <giomm/actiongroup.h>
   29 #include <giomm/init.h>
   30 #include <cstring> // std::memset()
   31 #include <map>
   32 #include <mutex>
   33 #include <vector>
   34 
   35 using Flags = Gio::Application::Flags;
   36 
   37 namespace // anonymous
   38 {
   39 
   40 static void
   41 Application_signal_open_callback(
   42   GApplication* self, GFile** files, gint n_files, const gchar* hint, void* data)
   43 {
   44   using SlotType = sigc::slot<void(const Gio::Application::type_vec_files&, const Glib::ustring&)>;
   45 
   46   Gio::Application::type_vec_files vec_files(n_files);
   47   for (int i = 0; i < n_files; ++i)
   48   {
   49     vec_files[i] = Glib::wrap(files[i], true);
   50   }
   51 
   52   const auto hint_str = (hint ? hint : Glib::ustring());
   53 
   54   // Do not try to call a signal on a disassociated wrapper.
   55   if (Glib::ObjectBase::_get_current_wrapper((GObject*)self))
   56   {
   57     try
   58     {
   59       if (const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
   60       {
   61         (*static_cast<SlotType*>(slot))(vec_files, hint_str);
   62         return;
   63       }
   64     }
   65     catch (...)
   66     {
   67       Glib::exception_handlers_invoke();
   68     }
   69   }
   70 
   71   return;
   72 }
   73 
   74 static void
   75 Application_signal_open_notify_callback(
   76   GApplication* self, GFile** files, gint n_files, const gchar* hint, void* data)
   77 {
   78   using namespace Gio;
   79   using SlotType = sigc::slot<void(const Application::type_vec_files&, const Glib::ustring&)>;
   80 
   81   Application::type_vec_files vec_files(n_files);
   82   for (int i = 0; i < n_files; i++)
   83   {
   84     vec_files[i] = Glib::wrap(files[i], true);
   85   }
   86 
   87   const auto hint_str = (hint ? hint : Glib::ustring());
   88 
   89   // Do not try to call a signal on a disassociated wrapper.
   90   if (Glib::ObjectBase::_get_current_wrapper((GObject*)self))
   91   {
   92     try
   93     {
   94       if (const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
   95       {
   96         (*static_cast<SlotType*>(slot))(vec_files, hint_str);
   97         return;
   98       }
   99     }
  100     catch (...)
  101     {
  102       Glib::exception_handlers_invoke();
  103     }
  104   }
  105 
  106   return;
  107 }
  108 
  109 static const Glib::SignalProxyInfo Application_signal_open_info = { "open",
  110   (GCallback)&Application_signal_open_callback,
  111   (GCallback)&Application_signal_open_notify_callback };
  112 
  113 // The add_main_option_entry*() methods that take a slot parameter are handled
  114 // similarly to the corresponding Glib::OptionGroup::add_entry*() methods.
  115 // There is an important difference: In add_main_option_entry*() we can't pass
  116 // an Application pointer to the used GOptionGroup.
  117 // g_application_add_main_option_entries() creates a GOptionGroup with user_data == nullptr.
  118 // Therefore Application_option_arg_callback() is called with data == nullptr.
  119 // Application_option_arg_callback() does not know which Application instance
  120 // the command-line option belongs to. All Application instances (usually only one)
  121 // share a map, mapping the long command option name to an OptionArgCallbackData.
  122 class OptionArgCallbackData
  123 {
  124 public:
  125   explicit OptionArgCallbackData(const Gio::Application* application,
  126     const Glib::ustring& long_name, gchar short_name,
  127     const Glib::ustring& description, const Glib::ustring& arg_description,
  128     const Glib::OptionGroup::SlotOptionArgString& slot)
  129   :
  130     application_(application),
  131     long_name_(g_strdup(long_name.c_str())), // must not be nullptr
  132     short_name_(short_name),
  133     description_(g_strdup(Glib::c_str_or_nullptr(description))),
  134     arg_description_(g_strdup(Glib::c_str_or_nullptr(arg_description))),
  135     slot_string_(new Glib::OptionGroup::SlotOptionArgString(slot)),
  136     slot_filename_(nullptr)
  137   {
  138   }
  139 
  140   explicit OptionArgCallbackData(const Gio::Application* application,
  141     const Glib::ustring& long_name, gchar short_name,
  142     const Glib::ustring& description, const Glib::ustring& arg_description,
  143     const Glib::OptionGroup::SlotOptionArgFilename& slot)
  144   :
  145     application_(application),
  146     long_name_(g_strdup(long_name.c_str())), // must not be nullptr
  147     short_name_(short_name),
  148     description_(g_strdup(Glib::c_str_or_nullptr(description))),
  149     arg_description_(g_strdup(Glib::c_str_or_nullptr(arg_description))),
  150     slot_string_(nullptr),
  151     slot_filename_(new Glib::OptionGroup::SlotOptionArgFilename(slot))
  152   {
  153   }
  154 
  155   const Gio::Application* get_application() const { return application_; }
  156   const gchar* get_long_name() const { return long_name_; }
  157   gchar get_short_name() const { return short_name_; }
  158   const gchar* get_description() const { return description_; }
  159   const gchar* get_arg_description() const { return arg_description_; }
  160   bool is_filename_option() const { return slot_filename_ != nullptr; }
  161 
  162   const Glib::OptionGroup::SlotOptionArgString* get_slot_string() const { return slot_string_; }
  163 
  164   const Glib::OptionGroup::SlotOptionArgFilename* get_slot_filename() const
  165   {
  166     return slot_filename_;
  167   }
  168 
  169   ~OptionArgCallbackData()
  170   {
  171     g_free(long_name_);
  172     g_free(description_);
  173     g_free(arg_description_);
  174     delete slot_string_;
  175     delete slot_filename_;
  176     // Don't delete application_. It's not owned by this class.
  177   }
  178 
  179 private:
  180   const Gio::Application* application_;
  181   gchar* long_name_;
  182   gchar short_name_;
  183   gchar* description_;
  184   gchar* arg_description_;
  185   // One of these slot pointers is nullptr and the other one points to a slot.
  186   Glib::OptionGroup::SlotOptionArgString* slot_string_;
  187   Glib::OptionGroup::SlotOptionArgFilename* slot_filename_;
  188 
  189   // Not copyable
  190   OptionArgCallbackData(const OptionArgCallbackData&) = delete;
  191   OptionArgCallbackData& operator=(const OptionArgCallbackData&) = delete;
  192 
  193 }; // end class OptionArgCallbackData
  194 
  195 using OptionArgCallbackDataMap = std::map<Glib::ustring, OptionArgCallbackData*>;
  196 OptionArgCallbackDataMap option_arg_callback_data;
  197 
  198 // Gio::Application instances may be used in different threads.
  199 // Accesses to option_arg_callback_data must be thread-safe.
  200 std::mutex option_arg_callback_data_mutex;
  201 
  202 gboolean
  203 Application_option_arg_callback(
  204   const gchar* option_name, const gchar* value, gpointer /* data */, GError** error)
  205 {
  206   const Glib::ustring cpp_option_name(option_name);
  207 
  208   // option_name is either a single dash followed by a single letter (for a
  209   // short name) or two dashes followed by a long option name.
  210   std::unique_lock<std::mutex> lock(option_arg_callback_data_mutex);
  211   OptionArgCallbackDataMap::const_iterator iterFind = option_arg_callback_data.end();
  212   if (option_name[1] == '-')
  213   {
  214     // Long option name.
  215     const auto long_option_name = Glib::ustring(option_name + 2);
  216     iterFind = option_arg_callback_data.find(long_option_name);
  217   }
  218   else
  219   {
  220     // Short option name.
  221     const auto short_option_name = option_name[1];
  222     for (iterFind = option_arg_callback_data.begin(); iterFind != option_arg_callback_data.end();
  223          ++iterFind)
  224     {
  225       if (iterFind->second->get_short_name() == short_option_name)
  226         break;
  227     }
  228   }
  229 
  230   if (iterFind == option_arg_callback_data.end())
  231   {
  232     Glib::OptionError(Glib::OptionError::UNKNOWN_OPTION, "Application_option_arg_callback(): "
  233                                                          "Unknown option " +
  234                                                            cpp_option_name)
  235       .propagate(error);
  236     return false;
  237   }
  238 
  239   const bool has_value = (value != nullptr);
  240   const OptionArgCallbackData* const option_arg = iterFind->second;
  241   try
  242   {
  243     if (option_arg->is_filename_option())
  244     {
  245       const auto the_slot = option_arg->get_slot_filename();
  246       lock.unlock();
  247       const std::string cpp_value(value ? value : "");
  248       return (*the_slot)(cpp_option_name, cpp_value, has_value);
  249     }
  250     else
  251     {
  252       const auto the_slot = option_arg->get_slot_string();
  253       lock.unlock();
  254       const Glib::ustring cpp_value(value ? value : "");
  255       return (*the_slot)(cpp_option_name, cpp_value, has_value);
  256     }
  257   }
  258   catch (Glib::Error& err)
  259   {
  260     err.propagate(error);
  261   }
  262   catch (...)
  263   {
  264     Glib::exception_handlers_invoke();
  265   }
  266   return false;
  267 }
  268 
  269 } // anonymous namespace
  270 
  271 namespace Gio
  272 {
  273 
  274 const Glib::Class&
  275 Application::custom_class_init()
  276 {
  277   Glib::init();
  278   Gio::init();
  279   return application_class_.init();
  280 }
  281 
  282 Application::Application(const Glib::ustring& application_id, Flags flags)
  283 : // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  284   // GApplication complains about "" but allows nullptr, so we avoid passing "".
  285   Glib::ObjectBase(nullptr),
  286   Glib::Object(Glib::ConstructParams(custom_class_init(),
  287     "application_id", Glib::c_str_or_nullptr(application_id),
  288     "flags", static_cast<GApplicationFlags>(flags), nullptr))
  289 {
  290 }
  291 
  292 Application::~Application() noexcept
  293 {
  294   // Delete all OptionArgCallbackData instances that belong to this application.
  295   std::lock_guard<std::mutex> lock(option_arg_callback_data_mutex);
  296   OptionArgCallbackDataMap::iterator iter = option_arg_callback_data.begin();
  297   while (iter != option_arg_callback_data.end())
  298   {
  299     OptionArgCallbackDataMap::iterator saved_iter = iter;
  300     ++iter;
  301     if (saved_iter->second->get_application() == this)
  302     {
  303       delete saved_iter->second;
  304       option_arg_callback_data.erase(saved_iter);
  305     }
  306   }
  307 }
  308 
  309 // static
  310 void
  311 Application::unset_default()
  312 {
  313   g_application_set_default(nullptr);
  314 }
  315 
  316 void
  317 Application_Class::open_callback(GApplication* self, GFile** files, gint n_files, const gchar* hint)
  318 {
  319   const auto obj_base =
  320     static_cast<Glib::ObjectBase*>(Glib::ObjectBase::_get_current_wrapper((GObject*)self));
  321 
  322   // Non-gtkmmproc-generated custom classes implicitly call the default
  323   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  324   // generated classes can use this optimisation, which avoids the unnecessary
  325   // parameter conversions if there is no possibility of the virtual function
  326   // being overridden:
  327 
  328   if (obj_base && obj_base->is_derived_())
  329   {
  330     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
  331     if (obj) // This can be nullptr during destruction.
  332     {
  333       try // Trap C++ exceptions which would normally be lost because this is a C callback.
  334       {
  335         // Call the virtual member method, which derived classes might override.
  336         Application::type_vec_files vec_files(n_files);
  337         for (int i = 0; i < n_files; i++)
  338         {
  339           vec_files[i] = Glib::wrap(files[i], true);
  340         }
  341 
  342         const auto hint_str = (hint ? hint : Glib::ustring());
  343 
  344         obj->on_open(vec_files, hint_str);
  345         return;
  346       }
  347       catch (...)
  348       {
  349         Glib::exception_handlers_invoke();
  350       }
  351     }
  352   }
  353 
  354   const auto base = static_cast<BaseClassType*>(g_type_class_peek_parent(G_OBJECT_GET_CLASS(
  355     self)) // Get the parent class of the object class (The original underlying C class).
  356     );
  357 
  358   // Call the original underlying C function:
  359   if (base && base->open)
  360     (*base->open)(self, files, n_files, hint);
  361 }
  362 
  363 Glib::SignalProxy<void(const Application::type_vec_files&, const Glib::ustring&)>
  364 Application::signal_open()
  365 {
  366   return Glib::SignalProxy<void(const Application::type_vec_files&, const Glib::ustring&)>(
  367     this, &Application_signal_open_info);
  368 }
  369 
  370 void
  371 Gio::Application::on_open(const Application::type_vec_files& files, const Glib::ustring& hint)
  372 {
  373   const auto base = static_cast<BaseClassType*>(g_type_class_peek_parent(G_OBJECT_GET_CLASS(
  374     gobject_)) // Get the parent class of the object class (The original underlying C class).
  375     );
  376 
  377   if (base && base->open)
  378   {
  379     (*base->open)(gobj(),
  380       Glib::ArrayHandler<type_vec_files::value_type>::vector_to_array(files).data(), files.size(),
  381       hint.c_str());
  382   }
  383 }
  384 
  385 void
  386 Application::open(const type_vec_files& files, const Glib::ustring& hint)
  387 {
  388   g_application_open(gobj(),
  389     Glib::ArrayHandler<type_vec_files::value_type>::vector_to_array(files).data(), files.size(),
  390     hint.c_str());
  391 }
  392 
  393 void
  394 Application::open(const Glib::RefPtr<Gio::File>& file, const Glib::ustring& hint)
  395 {
  396   type_vec_files files(1);
  397   files[0] = file;
  398   open(files, hint);
  399 }
  400 
  401 void
  402 Application::add_main_option_entry(OptionType arg_type, const Glib::ustring& long_name,
  403   gchar short_name, const Glib::ustring& description, const Glib::ustring& arg_description,
  404   Glib::OptionEntry::Flags flags)
  405 {
  406   // g_application_add_main_option() saves copies of the strings.
  407   // No need to keep copies in Gio::Application.
  408   g_application_add_main_option(gobj(), long_name.c_str(), short_name,
  409     static_cast<GOptionFlags>(flags), static_cast<GOptionArg>(arg_type),
  410     description.c_str(), Glib::c_str_or_nullptr(arg_description));
  411 }
  412 
  413 void
  414 Application::add_main_option_entry(const Glib::OptionGroup::SlotOptionArgString& slot,
  415   const Glib::ustring& long_name, gchar short_name, const Glib::ustring& description,
  416   const Glib::ustring& arg_description, Glib::OptionEntry::Flags flags)
  417 {
  418   OptionArgCallbackData* callback_data = nullptr;
  419   {
  420     std::lock_guard<std::mutex> lock(option_arg_callback_data_mutex);
  421     OptionArgCallbackDataMap::iterator iterFind = option_arg_callback_data.find(long_name);
  422     if (iterFind != option_arg_callback_data.end())
  423       return; // Ignore duplicates
  424 
  425     callback_data = new OptionArgCallbackData(
  426       this, long_name, short_name, description, arg_description, slot);
  427     option_arg_callback_data[long_name] = callback_data;
  428   } // option_arg_callback_data_mutex.unlock()
  429 
  430   add_main_option_entry_private(callback_data->get_long_name(), short_name,
  431     callback_data->get_description(), callback_data->get_arg_description(),
  432     flags & ~Glib::OptionEntry::Flags::FILENAME);
  433 }
  434 
  435 void
  436 Application::add_main_option_entry_filename(const Glib::OptionGroup::SlotOptionArgFilename& slot,
  437   const Glib::ustring& long_name, gchar short_name, const Glib::ustring& description,
  438   const Glib::ustring& arg_description, Glib::OptionEntry::Flags flags)
  439 {
  440   OptionArgCallbackData* callback_data = nullptr;
  441   {
  442     std::lock_guard<std::mutex> lock(option_arg_callback_data_mutex);
  443     OptionArgCallbackDataMap::iterator iterFind = option_arg_callback_data.find(long_name);
  444     if (iterFind != option_arg_callback_data.end())
  445       return; // Ignore duplicates
  446 
  447     callback_data = new OptionArgCallbackData(
  448       this, long_name, short_name, description, arg_description, slot);
  449     option_arg_callback_data[long_name] = callback_data;
  450   } // option_arg_callback_data_mutex.unlock()
  451 
  452   add_main_option_entry_private(callback_data->get_long_name(), short_name,
  453     callback_data->get_description(), callback_data->get_arg_description(),
  454     flags | Glib::OptionEntry::Flags::FILENAME);
  455 }
  456 
  457 void
  458 Application::add_main_option_entry_private(const gchar* long_name,
  459   gchar short_name, const gchar* description,
  460   const gchar* arg_description, Glib::OptionEntry::Flags flags)
  461 {
  462   // g_application_add_main_option() can't be used for options with
  463   // a callback slot, because GOptionEntry.arg_data must be non-null.
  464 
  465   // Create a temporary array, just so we can give the correct thing to
  466   // g_application_add_main_option_entries():
  467   GOptionEntry array[2];
  468   std::memset(array, 0, 2 * sizeof(GOptionEntry)); // null-termination
  469 
  470   // g_application_add_main_option_entries() does not take its own copy
  471   // of the strings. We must keep them alive, and keep pointers to them,
  472   // so we can delete them when the Application instance is deleted.
  473   // This is handled in OptionArgCallbackData.
  474 
  475   // Fill in array[0].
  476   array[0].arg = G_OPTION_ARG_CALLBACK;
  477   array[0].long_name = long_name;
  478   array[0].short_name = short_name;
  479   array[0].description = description;
  480   array[0].arg_description = arg_description;
  481   array[0].flags = static_cast<int>(flags);
  482 
  483   // GoptionEntry.arg_data is a function pointer, cast to void*.
  484   // See Glib::OptionGroup::CppOptionEntry::allocate_c_arg() for a discussion
  485   // of this hack.
  486   union {
  487     void* dp;
  488     GOptionArgFunc fp;
  489   } u;
  490   u.fp = &Application_option_arg_callback;
  491   array[0].arg_data = u.dp;
  492 
  493   g_application_add_main_option_entries(gobj(), array);
  494 }
  495 
  496 void
  497 Application::unset_resource_base_path()
  498 {
  499   g_application_set_resource_base_path(gobj(), nullptr /* see the C docs. */);
  500 }
  501 
  502 } // namespace Gio
  503 
  504 namespace
  505 {
  506 
  507 
  508 static const Glib::SignalProxyInfo Application_signal_startup_info =
  509 {
  510   "startup",
  511   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  512   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
  513 };
  514 
  515 
  516 static const Glib::SignalProxyInfo Application_signal_shutdown_info =
  517 {
  518   "shutdown",
  519   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  520   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
  521 };
  522 
  523 
  524 static const Glib::SignalProxyInfo Application_signal_activate_info =
  525 {
  526   "activate",
  527   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  528   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
  529 };
  530 
  531 
  532 static gint Application_signal_command_line_callback(GApplication* self, GApplicationCommandLine* p0,void* data)
  533 {
  534   using namespace Gio;
  535   using SlotType = sigc::slot<int(const Glib::RefPtr<ApplicationCommandLine>&)>;
  536 
  537   auto obj = dynamic_cast<Application*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  538   // Do not try to call a signal on a disassociated wrapper.
  539   if(obj)
  540   {
  541     try
  542     {
  543       if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
  544         return (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
  545 );
  546     }
  547     catch(...)
  548     {
  549        Glib::exception_handlers_invoke();
  550     }
  551   }
  552 
  553   using RType = gint;
  554   return RType();
  555 }
  556 
  557 static gint Application_signal_command_line_notify_callback(GApplication* self, GApplicationCommandLine* p0, void* data)
  558 {
  559   using namespace Gio;
  560   using SlotType = sigc::slot<void(const Glib::RefPtr<ApplicationCommandLine>&)>;
  561 
  562   auto obj = dynamic_cast<Application*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  563   // Do not try to call a signal on a disassociated wrapper.
  564   if(obj)
  565   {
  566     try
  567     {
  568       if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
  569         (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
  570 );
  571     }
  572     catch(...)
  573     {
  574       Glib::exception_handlers_invoke();
  575     }
  576   }
  577 
  578   using RType = gint;
  579   return RType();
  580 }
  581 
  582 static const Glib::SignalProxyInfo Application_signal_command_line_info =
  583 {
  584   "command-line",
  585   (GCallback) &Application_signal_command_line_callback,
  586   (GCallback) &Application_signal_command_line_notify_callback
  587 };
  588 
  589 
  590 static gint Application_signal_handle_local_options_callback(GApplication* self, GVariantDict* p0,void* data)
  591 {
  592   using namespace Gio;
  593   using SlotType = sigc::slot<int(const Glib::RefPtr<Glib::VariantDict>&)>;
  594 
  595   auto obj = dynamic_cast<Application*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  596   // Do not try to call a signal on a disassociated wrapper.
  597   if(obj)
  598   {
  599     try
  600     {
  601       if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
  602         return (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
  603 );
  604     }
  605     catch(...)
  606     {
  607        Glib::exception_handlers_invoke();
  608     }
  609   }
  610 
  611   using RType = gint;
  612   return RType();
  613 }
  614 
  615 static gint Application_signal_handle_local_options_notify_callback(GApplication* self, GVariantDict* p0, void* data)
  616 {
  617   using namespace Gio;
  618   using SlotType = sigc::slot<void(const Glib::RefPtr<Glib::VariantDict>&)>;
  619 
  620   auto obj = dynamic_cast<Application*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  621   // Do not try to call a signal on a disassociated wrapper.
  622   if(obj)
  623   {
  624     try
  625     {
  626       if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
  627         (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true)
  628 );
  629     }
  630     catch(...)
  631     {
  632       Glib::exception_handlers_invoke();
  633     }
  634   }
  635 
  636   using RType = gint;
  637   return RType();
  638 }
  639 
  640 static const Glib::SignalProxyInfo Application_signal_handle_local_options_info =
  641 {
  642   "handle-local-options",
  643   (GCallback) &Application_signal_handle_local_options_callback,
  644   (GCallback) &Application_signal_handle_local_options_notify_callback
  645 };
  646 
  647 
  648 static gboolean Application_signal_name_lost_callback(GApplication* self, void* data)
  649 {
  650   using namespace Gio;
  651   using SlotType = sigc::slot<bool()>;
  652 
  653   auto obj = dynamic_cast<Application*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  654   // Do not try to call a signal on a disassociated wrapper.
  655   if(obj)
  656   {
  657     try
  658     {
  659       if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
  660         return static_cast<int>((*static_cast<SlotType*>(slot))());
  661     }
  662     catch(...)
  663     {
  664        Glib::exception_handlers_invoke();
  665     }
  666   }
  667 
  668   using RType = gboolean;
  669   return RType();
  670 }
  671 
  672 static gboolean Application_signal_name_lost_notify_callback(GApplication* self,  void* data)
  673 {
  674   using namespace Gio;
  675   using SlotType = sigc::slot<void()>;
  676 
  677   auto obj = dynamic_cast<Application*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  678   // Do not try to call a signal on a disassociated wrapper.
  679   if(obj)
  680   {
  681     try
  682     {
  683       if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
  684         (*static_cast<SlotType*>(slot))();
  685     }
  686     catch(...)
  687     {
  688       Glib::exception_handlers_invoke();
  689     }
  690   }
  691 
  692   using RType = gboolean;
  693   return RType();
  694 }
  695 
  696 static const Glib::SignalProxyInfo Application_signal_name_lost_info =
  697 {
  698   "name-lost",
  699   (GCallback) &Application_signal_name_lost_callback,
  700   (GCallback) &Application_signal_name_lost_notify_callback
  701 };
  702 
  703 
  704 } // anonymous namespace
  705 
  706 // static
  707 GType Glib::Value<Gio::Application::Flags>::value_type()
  708 {
  709   return g_application_flags_get_type();
  710 }
  711 
  712 
  713 namespace Glib
  714 {
  715 
  716 Glib::RefPtr<Gio::Application> wrap(GApplication* object, bool take_copy)
  717 {
  718   return Glib::make_refptr_for_instance<Gio::Application>( dynamic_cast<Gio::Application*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
  719   //We use dynamic_cast<> in case of multiple inheritance.
  720 }
  721 
  722 } /* namespace Glib */
  723 
  724 
  725 namespace Gio
  726 {
  727 
  728 
  729 /* The *_Class implementation: */
  730 
  731 const Glib::Class& Application_Class::init()
  732 {
  733   if(!gtype_) // create the GType if necessary
  734   {
  735     // Glib::Class has to know the class init function to clone custom types.
  736     class_init_func_ = &Application_Class::class_init_function;
  737 
  738     // This is actually just optimized away, apparently with no harm.
  739     // Make sure that the parent type has been created.
  740     //CppClassParent::CppObjectType::get_type();
  741 
  742     // Create the wrapper type, with the same class/instance size as the base type.
  743     register_derived_type(g_application_get_type());
  744 
  745     // Add derived versions of interfaces, if the C type implements any interfaces:
  746   ActionGroup::add_interface(get_type());
  747   ActionMap::add_interface(get_type());
  748 
  749   }
  750 
  751   return *this;
  752 }
  753 
  754 
  755 void Application_Class::class_init_function(void* g_class, void* class_data)
  756 {
  757   const auto klass = static_cast<BaseClassType*>(g_class);
  758   CppClassParent::class_init_function(klass, class_data);
  759 
  760   klass->local_command_line = &local_command_line_vfunc_callback;
  761   klass->before_emit = &before_emit_vfunc_callback;
  762   klass->after_emit = &after_emit_vfunc_callback;
  763   klass->quit_mainloop = &quit_mainloop_vfunc_callback;
  764   klass->run_mainloop = &run_mainloop_vfunc_callback;
  765   klass->dbus_register = &dbus_register_vfunc_callback;
  766   klass->dbus_unregister = &dbus_unregister_vfunc_callback;
  767 
  768   klass->startup = &startup_callback;
  769   klass->shutdown = &shutdown_callback;
  770   klass->activate = &activate_callback;
  771   klass->command_line = &command_line_callback;
  772   klass->handle_local_options = &handle_local_options_callback;
  773   klass->name_lost = &name_lost_callback;
  774   klass->open = &open_callback;
  775   }
  776 
  777 gboolean Application_Class::local_command_line_vfunc_callback(GApplication* self, gchar*** arguments, int* exit_status)
  778 {
  779   const auto obj_base = static_cast<Glib::ObjectBase*>(
  780       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
  781 
  782   // Non-gtkmmproc-generated custom classes implicitly call the default
  783   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  784   // generated classes can use this optimisation, which avoids the unnecessary
  785   // parameter conversions if there is no possibility of the virtual function
  786   // being overridden:
  787   if(obj_base && obj_base->is_derived_())
  788   {
  789     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
  790     if(obj) // This can be NULL during destruction.
  791     {
  792       try // Trap C++ exceptions which would normally be lost because this is a C callback.
  793       {
  794         // Call the virtual member method, which derived classes might override.
  795         return static_cast<int>(obj->local_command_line_vfunc(*(arguments)
  796 , *(exit_status)
  797 ));
  798       }
  799       catch(...)
  800       {
  801         Glib::exception_handlers_invoke();
  802       }
  803     }
  804   }
  805 
  806   BaseClassType *const base = static_cast<BaseClassType*>(
  807       g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  808   );
  809 
  810   // Call the original underlying C function:
  811   if(base && base->local_command_line)
  812     return (*base->local_command_line)(self, arguments, exit_status);
  813 
  814   using RType = gboolean;
  815   return RType();
  816 }
  817 void Application_Class::before_emit_vfunc_callback(GApplication* self, GVariant* platform_data)
  818 {
  819   const auto obj_base = static_cast<Glib::ObjectBase*>(
  820       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
  821 
  822   // Non-gtkmmproc-generated custom classes implicitly call the default
  823   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  824   // generated classes can use this optimisation, which avoids the unnecessary
  825   // parameter conversions if there is no possibility of the virtual function
  826   // being overridden:
  827   if(obj_base && obj_base->is_derived_())
  828   {
  829     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
  830     if(obj) // This can be NULL during destruction.
  831     {
  832       try // Trap C++ exceptions which would normally be lost because this is a C callback.
  833       {
  834         // Call the virtual member method, which derived classes might override.
  835         obj->before_emit_vfunc(Glib::wrap(platform_data,true)
  836 );
  837         return;
  838       }
  839       catch(...)
  840       {
  841         Glib::exception_handlers_invoke();
  842       }
  843     }
  844   }
  845 
  846   BaseClassType *const base = static_cast<BaseClassType*>(
  847       g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  848   );
  849 
  850   // Call the original underlying C function:
  851   if(base && base->before_emit)
  852     (*base->before_emit)(self, platform_data);
  853 }
  854 void Application_Class::after_emit_vfunc_callback(GApplication* self, GVariant* platform_data)
  855 {
  856   const auto obj_base = static_cast<Glib::ObjectBase*>(
  857       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
  858 
  859   // Non-gtkmmproc-generated custom classes implicitly call the default
  860   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  861   // generated classes can use this optimisation, which avoids the unnecessary
  862   // parameter conversions if there is no possibility of the virtual function
  863   // being overridden:
  864   if(obj_base && obj_base->is_derived_())
  865   {
  866     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
  867     if(obj) // This can be NULL during destruction.
  868     {
  869       try // Trap C++ exceptions which would normally be lost because this is a C callback.
  870       {
  871         // Call the virtual member method, which derived classes might override.
  872         obj->after_emit_vfunc(Glib::wrap(platform_data,true)
  873 );
  874         return;
  875       }
  876       catch(...)
  877       {
  878         Glib::exception_handlers_invoke();
  879       }
  880     }
  881   }
  882 
  883   BaseClassType *const base = static_cast<BaseClassType*>(
  884       g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  885   );
  886 
  887   // Call the original underlying C function:
  888   if(base && base->after_emit)
  889     (*base->after_emit)(self, platform_data);
  890 }
  891 void Application_Class::quit_mainloop_vfunc_callback(GApplication* self)
  892 {
  893   const auto obj_base = static_cast<Glib::ObjectBase*>(
  894       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
  895 
  896   // Non-gtkmmproc-generated custom classes implicitly call the default
  897   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  898   // generated classes can use this optimisation, which avoids the unnecessary
  899   // parameter conversions if there is no possibility of the virtual function
  900   // being overridden:
  901   if(obj_base && obj_base->is_derived_())
  902   {
  903     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
  904     if(obj) // This can be NULL during destruction.
  905     {
  906       try // Trap C++ exceptions which would normally be lost because this is a C callback.
  907       {
  908         // Call the virtual member method, which derived classes might override.
  909         obj->quit_mainloop_vfunc();
  910         return;
  911       }
  912       catch(...)
  913       {
  914         Glib::exception_handlers_invoke();
  915       }
  916     }
  917   }
  918 
  919   BaseClassType *const base = static_cast<BaseClassType*>(
  920       g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  921   );
  922 
  923   // Call the original underlying C function:
  924   if(base && base->quit_mainloop)
  925     (*base->quit_mainloop)(self);
  926 }
  927 void Application_Class::run_mainloop_vfunc_callback(GApplication* self)
  928 {
  929   const auto obj_base = static_cast<Glib::ObjectBase*>(
  930       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
  931 
  932   // Non-gtkmmproc-generated custom classes implicitly call the default
  933   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  934   // generated classes can use this optimisation, which avoids the unnecessary
  935   // parameter conversions if there is no possibility of the virtual function
  936   // being overridden:
  937   if(obj_base && obj_base->is_derived_())
  938   {
  939     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
  940     if(obj) // This can be NULL during destruction.
  941     {
  942       try // Trap C++ exceptions which would normally be lost because this is a C callback.
  943       {
  944         // Call the virtual member method, which derived classes might override.
  945         obj->run_mainloop_vfunc();
  946         return;
  947       }
  948       catch(...)
  949       {
  950         Glib::exception_handlers_invoke();
  951       }
  952     }
  953   }
  954 
  955   BaseClassType *const base = static_cast<BaseClassType*>(
  956       g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  957   );
  958 
  959   // Call the original underlying C function:
  960   if(base && base->run_mainloop)
  961     (*base->run_mainloop)(self);
  962 }
  963 gboolean Application_Class::dbus_register_vfunc_callback(GApplication* self, GDBusConnection* connection, const gchar* object_path, GError** error)
  964 {
  965   const auto obj_base = static_cast<Glib::ObjectBase*>(
  966       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
  967 
  968   // Non-gtkmmproc-generated custom classes implicitly call the default
  969   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  970   // generated classes can use this optimisation, which avoids the unnecessary
  971   // parameter conversions if there is no possibility of the virtual function
  972   // being overridden:
  973   if(obj_base && obj_base->is_derived_())
  974   {
  975     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
  976     if(obj) // This can be NULL during destruction.
  977     {
  978       try // Trap C++ exceptions which would normally be lost because this is a C callback.
  979       {
  980         // Call the virtual member method, which derived classes might override.
  981         return static_cast<int>(obj->dbus_register_vfunc(Glib::wrap(connection, true)
  982 , Glib::convert_const_gchar_ptr_to_ustring(object_path)
  983 ));
  984       }
  985       catch(Glib::Error& errormm)
  986       {
  987         errormm.propagate(error);
  988         using RType = gboolean;
  989         return RType();
  990       }
  991       catch(...)
  992       {
  993         Glib::exception_handlers_invoke();
  994       }
  995     }
  996   }
  997 
  998   BaseClassType *const base = static_cast<BaseClassType*>(
  999       g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 1000   );
 1001 
 1002   // Call the original underlying C function:
 1003   if(base && base->dbus_register)
 1004     return (*base->dbus_register)(self, connection, object_path, error);
 1005 
 1006   using RType = gboolean;
 1007   return RType();
 1008 }
 1009 void Application_Class::dbus_unregister_vfunc_callback(GApplication* self, GDBusConnection* connection, const gchar* object_path)
 1010 {
 1011   const auto obj_base = static_cast<Glib::ObjectBase*>(
 1012       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 1013 
 1014   // Non-gtkmmproc-generated custom classes implicitly call the default
 1015   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 1016   // generated classes can use this optimisation, which avoids the unnecessary
 1017   // parameter conversions if there is no possibility of the virtual function
 1018   // being overridden:
 1019   if(obj_base && obj_base->is_derived_())
 1020   {
 1021     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
 1022     if(obj) // This can be NULL during destruction.
 1023     {
 1024       try // Trap C++ exceptions which would normally be lost because this is a C callback.
 1025       {
 1026         // Call the virtual member method, which derived classes might override.
 1027         obj->dbus_unregister_vfunc(Glib::wrap(connection, true)
 1028 , Glib::convert_const_gchar_ptr_to_ustring(object_path)
 1029 );
 1030         return;
 1031       }
 1032       catch(...)
 1033       {
 1034         Glib::exception_handlers_invoke();
 1035       }
 1036     }
 1037   }
 1038 
 1039   BaseClassType *const base = static_cast<BaseClassType*>(
 1040       g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 1041   );
 1042 
 1043   // Call the original underlying C function:
 1044   if(base && base->dbus_unregister)
 1045     (*base->dbus_unregister)(self, connection, object_path);
 1046 }
 1047 
 1048 void Application_Class::startup_callback(GApplication* self)
 1049 {
 1050   const auto obj_base = static_cast<Glib::ObjectBase*>(
 1051       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 1052 
 1053   // Non-gtkmmproc-generated custom classes implicitly call the default
 1054   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 1055   // generated classes can use this optimisation, which avoids the unnecessary
 1056   // parameter conversions if there is no possibility of the virtual function
 1057   // being overridden:
 1058   if(obj_base && obj_base->is_derived_())
 1059   {
 1060     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
 1061     if(obj) // This can be NULL during destruction.
 1062     {
 1063       try // Trap C++ exceptions which would normally be lost because this is a C callback.
 1064       {
 1065         // Call the virtual member method, which derived classes might override.
 1066         obj->on_startup();
 1067         return;
 1068       }
 1069       catch(...)
 1070       {
 1071         Glib::exception_handlers_invoke();
 1072       }
 1073     }
 1074   }
 1075 
 1076   const auto base = static_cast<BaseClassType*>(
 1077         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 1078     );
 1079 
 1080   // Call the original underlying C function:
 1081   if(base && base->startup)
 1082     (*base->startup)(self);
 1083 }
 1084 void Application_Class::shutdown_callback(GApplication* self)
 1085 {
 1086   const auto obj_base = static_cast<Glib::ObjectBase*>(
 1087       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 1088 
 1089   // Non-gtkmmproc-generated custom classes implicitly call the default
 1090   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 1091   // generated classes can use this optimisation, which avoids the unnecessary
 1092   // parameter conversions if there is no possibility of the virtual function
 1093   // being overridden:
 1094   if(obj_base && obj_base->is_derived_())
 1095   {
 1096     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
 1097     if(obj) // This can be NULL during destruction.
 1098     {
 1099       try // Trap C++ exceptions which would normally be lost because this is a C callback.
 1100       {
 1101         // Call the virtual member method, which derived classes might override.
 1102         obj->on_shutdown();
 1103         return;
 1104       }
 1105       catch(...)
 1106       {
 1107         Glib::exception_handlers_invoke();
 1108       }
 1109     }
 1110   }
 1111 
 1112   const auto base = static_cast<BaseClassType*>(
 1113         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 1114     );
 1115 
 1116   // Call the original underlying C function:
 1117   if(base && base->shutdown)
 1118     (*base->shutdown)(self);
 1119 }
 1120 void Application_Class::activate_callback(GApplication* self)
 1121 {
 1122   const auto obj_base = static_cast<Glib::ObjectBase*>(
 1123       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 1124 
 1125   // Non-gtkmmproc-generated custom classes implicitly call the default
 1126   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 1127   // generated classes can use this optimisation, which avoids the unnecessary
 1128   // parameter conversions if there is no possibility of the virtual function
 1129   // being overridden:
 1130   if(obj_base && obj_base->is_derived_())
 1131   {
 1132     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
 1133     if(obj) // This can be NULL during destruction.
 1134     {
 1135       try // Trap C++ exceptions which would normally be lost because this is a C callback.
 1136       {
 1137         // Call the virtual member method, which derived classes might override.
 1138         obj->on_activate();
 1139         return;
 1140       }
 1141       catch(...)
 1142       {
 1143         Glib::exception_handlers_invoke();
 1144       }
 1145     }
 1146   }
 1147 
 1148   const auto base = static_cast<BaseClassType*>(
 1149         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 1150     );
 1151 
 1152   // Call the original underlying C function:
 1153   if(base && base->activate)
 1154     (*base->activate)(self);
 1155 }
 1156 gint Application_Class::command_line_callback(GApplication* self, GApplicationCommandLine* p0)
 1157 {
 1158   const auto obj_base = static_cast<Glib::ObjectBase*>(
 1159       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 1160 
 1161   // Non-gtkmmproc-generated custom classes implicitly call the default
 1162   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 1163   // generated classes can use this optimisation, which avoids the unnecessary
 1164   // parameter conversions if there is no possibility of the virtual function
 1165   // being overridden:
 1166   if(obj_base && obj_base->is_derived_())
 1167   {
 1168     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
 1169     if(obj) // This can be NULL during destruction.
 1170     {
 1171       try // Trap C++ exceptions which would normally be lost because this is a C callback.
 1172       {
 1173         // Call the virtual member method, which derived classes might override.
 1174         return obj->on_command_line(Glib::wrap(p0, true)
 1175 );
 1176       }
 1177       catch(...)
 1178       {
 1179         Glib::exception_handlers_invoke();
 1180       }
 1181     }
 1182   }
 1183 
 1184   const auto base = static_cast<BaseClassType*>(
 1185         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 1186     );
 1187 
 1188   // Call the original underlying C function:
 1189   if(base && base->command_line)
 1190     return (*base->command_line)(self, p0);
 1191 
 1192   using RType = gint;
 1193   return RType();
 1194 }
 1195 gint Application_Class::handle_local_options_callback(GApplication* self, GVariantDict* p0)
 1196 {
 1197   const auto obj_base = static_cast<Glib::ObjectBase*>(
 1198       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 1199 
 1200   // Non-gtkmmproc-generated custom classes implicitly call the default
 1201   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 1202   // generated classes can use this optimisation, which avoids the unnecessary
 1203   // parameter conversions if there is no possibility of the virtual function
 1204   // being overridden:
 1205   if(obj_base && obj_base->is_derived_())
 1206   {
 1207     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
 1208     if(obj) // This can be NULL during destruction.
 1209     {
 1210       try // Trap C++ exceptions which would normally be lost because this is a C callback.
 1211       {
 1212         // Call the virtual member method, which derived classes might override.
 1213         return obj->on_handle_local_options(Glib::wrap(p0, true)
 1214 );
 1215       }
 1216       catch(...)
 1217       {
 1218         Glib::exception_handlers_invoke();
 1219       }
 1220     }
 1221   }
 1222 
 1223   const auto base = static_cast<BaseClassType*>(
 1224         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 1225     );
 1226 
 1227   // Call the original underlying C function:
 1228   if(base && base->handle_local_options)
 1229     return (*base->handle_local_options)(self, p0);
 1230 
 1231   using RType = gint;
 1232   return RType();
 1233 }
 1234 gboolean Application_Class::name_lost_callback(GApplication* self)
 1235 {
 1236   const auto obj_base = static_cast<Glib::ObjectBase*>(
 1237       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 1238 
 1239   // Non-gtkmmproc-generated custom classes implicitly call the default
 1240   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 1241   // generated classes can use this optimisation, which avoids the unnecessary
 1242   // parameter conversions if there is no possibility of the virtual function
 1243   // being overridden:
 1244   if(obj_base && obj_base->is_derived_())
 1245   {
 1246     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
 1247     if(obj) // This can be NULL during destruction.
 1248     {
 1249       try // Trap C++ exceptions which would normally be lost because this is a C callback.
 1250       {
 1251         // Call the virtual member method, which derived classes might override.
 1252         return static_cast<int>(obj->on_name_lost());
 1253       }
 1254       catch(...)
 1255       {
 1256         Glib::exception_handlers_invoke();
 1257       }
 1258     }
 1259   }
 1260 
 1261   const auto base = static_cast<BaseClassType*>(
 1262         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 1263     );
 1264 
 1265   // Call the original underlying C function:
 1266   if(base && base->name_lost)
 1267     return (*base->name_lost)(self);
 1268 
 1269   using RType = gboolean;
 1270   return RType();
 1271 }
 1272 
 1273 
 1274 Glib::ObjectBase* Application_Class::wrap_new(GObject* object)
 1275 {
 1276   return new Application((GApplication*)object);
 1277 }
 1278 
 1279 
 1280 /* The implementation: */
 1281 
 1282 GApplication* Application::gobj_copy()
 1283 {
 1284   reference();
 1285   return gobj();
 1286 }
 1287 
 1288 Application::Application(const Glib::ConstructParams& construct_params)
 1289 :
 1290   Glib::Object(construct_params)
 1291 {
 1292 
 1293 }
 1294 
 1295 Application::Application(GApplication* castitem)
 1296 :
 1297   Glib::Object((GObject*)(castitem))
 1298 {}
 1299 
 1300 
 1301 Application::Application(Application&& src) noexcept
 1302 : Glib::Object(std::move(src))
 1303   , ActionGroup(std::move(src))
 1304   , ActionMap(std::move(src))
 1305 {}
 1306 
 1307 Application& Application::operator=(Application&& src) noexcept
 1308 {
 1309   Glib::Object::operator=(std::move(src));
 1310   ActionGroup::operator=(std::move(src));
 1311   ActionMap::operator=(std::move(src));
 1312   return *this;
 1313 }
 1314 
 1315 
 1316 Application::CppClassType Application::application_class_; // initialize static member
 1317 
 1318 GType Application::get_type()
 1319 {
 1320   return application_class_.init().get_type();
 1321 }
 1322 
 1323 
 1324 GType Application::get_base_type()
 1325 {
 1326   return g_application_get_type();
 1327 }
 1328 
 1329 
 1330 Glib::RefPtr<Application> Application::create(const Glib::ustring& application_id, Flags flags)
 1331 {
 1332   return Glib::make_refptr_for_instance<Application>( new Application(application_id, flags) );
 1333 }
 1334 
 1335 bool Application::id_is_valid(const Glib::ustring& application_id)
 1336 {
 1337   return g_application_id_is_valid(application_id.c_str());
 1338 }
 1339 
 1340 Glib::ustring Application::get_id() const
 1341 {
 1342   return Glib::convert_const_gchar_ptr_to_ustring(g_application_get_application_id(const_cast<GApplication*>(gobj())));
 1343 }
 1344 
 1345 void Application::set_id(const Glib::ustring& application_id)
 1346 {
 1347   g_application_set_application_id(gobj(), application_id.c_str());
 1348 }
 1349 
 1350 Glib::RefPtr<DBus::Connection> Application::get_dbus_connection()
 1351 {
 1352   auto retvalue = Glib::wrap(g_application_get_dbus_connection(gobj()));
 1353   if(retvalue)
 1354     retvalue->reference(); //The function does not do a ref for us.
 1355   return retvalue;
 1356 }
 1357 
 1358 Glib::RefPtr<const DBus::Connection> Application::get_dbus_connection() const
 1359 {
 1360   return const_cast<Application*>(this)->get_dbus_connection();
 1361 }
 1362 
 1363 Glib::ustring Application::get_dbus_object_path() const
 1364 {
 1365   return Glib::convert_const_gchar_ptr_to_ustring(g_application_get_dbus_object_path(const_cast<GApplication*>(gobj())));
 1366 }
 1367 
 1368 guint Application::get_inactivity_timeout() const
 1369 {
 1370   return g_application_get_inactivity_timeout(const_cast<GApplication*>(gobj()));
 1371 }
 1372 
 1373 void Application::set_inactivity_timeout(guint inactivity_timeout)
 1374 {
 1375   g_application_set_inactivity_timeout(gobj(), inactivity_timeout);
 1376 }
 1377 
 1378 Flags Application::get_flags() const
 1379 {
 1380   return static_cast<Flags>(g_application_get_flags(const_cast<GApplication*>(gobj())));
 1381 }
 1382 
 1383 void Application::set_flags(Flags flags)
 1384 {
 1385   g_application_set_flags(gobj(), static_cast<GApplicationFlags>(flags));
 1386 }
 1387 
 1388 std::string Application::get_resource_base_path() const
 1389 {
 1390   return Glib::convert_const_gchar_ptr_to_stdstring(g_application_get_resource_base_path(const_cast<GApplication*>(gobj())));
 1391 }
 1392 
 1393 void Application::set_resource_base_path(const std::string& resource_path)
 1394 {
 1395   g_application_set_resource_base_path(gobj(), resource_path.c_str());
 1396 }
 1397 
 1398 void Application::add_option_group(Glib::OptionGroup& group)
 1399 {
 1400   g_application_add_option_group(gobj(), (group).gobj_copy());
 1401 }
 1402 
 1403 void Application::set_option_context_parameter_string(const Glib::ustring& parameter_string)
 1404 {
 1405   g_application_set_option_context_parameter_string(gobj(), parameter_string.empty() ? nullptr : parameter_string.c_str());
 1406 }
 1407 
 1408 void Application::set_option_context_summary(const Glib::ustring& summary)
 1409 {
 1410   g_application_set_option_context_summary(gobj(), summary.empty() ? nullptr : summary.c_str());
 1411 }
 1412 
 1413 void Application::set_option_context_description(const Glib::ustring& description)
 1414 {
 1415   g_application_set_option_context_description(gobj(), description.empty() ? nullptr : description.c_str());
 1416 }
 1417 
 1418 bool Application::is_registered() const
 1419 {
 1420   return g_application_get_is_registered(const_cast<GApplication*>(gobj()));
 1421 }
 1422 
 1423 bool Application::is_remote() const
 1424 {
 1425   return g_application_get_is_remote(const_cast<GApplication*>(gobj()));
 1426 }
 1427 
 1428 bool Application::register_application(const Glib::RefPtr<Gio::Cancellable>& cancellable)
 1429 {
 1430   GError* gerror = nullptr;
 1431   auto retvalue = g_application_register(gobj(), const_cast<GCancellable*>(Glib::unwrap(cancellable)), &(gerror));
 1432   if(gerror)
 1433     ::Glib::Error::throw_exception(gerror);
 1434   return retvalue;
 1435 }
 1436 
 1437 bool Application::register_application()
 1438 {
 1439   GError* gerror = nullptr;
 1440   auto retvalue = g_application_register(gobj(), nullptr, &(gerror));
 1441   if(gerror)
 1442     ::Glib::Error::throw_exception(gerror);
 1443   return retvalue;
 1444 }
 1445 
 1446 void Application::hold()
 1447 {
 1448   g_application_hold(gobj());
 1449 }
 1450 
 1451 void Application::release()
 1452 {
 1453   g_application_release(gobj());
 1454 }
 1455 
 1456 void Application::activate()
 1457 {
 1458   g_application_activate(gobj());
 1459 }
 1460 
 1461 int Application::run(int argc, char** argv)
 1462 {
 1463   return g_application_run(gobj(), argc, argv);
 1464 }
 1465 
 1466 void Application::quit()
 1467 {
 1468   g_application_quit(gobj());
 1469 }
 1470 
 1471 void Application::set_default(const Glib::RefPtr<Application>& application)
 1472 {
 1473   g_application_set_default(const_cast<GApplication*>(Glib::unwrap(application)));
 1474 }
 1475 
 1476 Glib::RefPtr<Application> Application::get_default()
 1477 {
 1478 
 1479   auto retvalue = Glib::wrap(g_application_get_default());
 1480   if(retvalue)
 1481     retvalue->reference(); //The function does not do a ref for us
 1482   return retvalue;
 1483 }
 1484 
 1485 void Application::mark_busy()
 1486 {
 1487   g_application_mark_busy(gobj());
 1488 }
 1489 
 1490 void Application::unmark_busy()
 1491 {
 1492   g_application_unmark_busy(gobj());
 1493 }
 1494 
 1495 bool Application::get_is_busy() const
 1496 {
 1497   return g_application_get_is_busy(const_cast<GApplication*>(gobj()));
 1498 }
 1499 
 1500 void Application::send_notification(const Glib::ustring& id, const Glib::RefPtr<Notification>& notification)
 1501 {
 1502   g_application_send_notification(gobj(), id.empty() ? nullptr : id.c_str(), const_cast<GNotification*>(Glib::unwrap(notification)));
 1503 }
 1504 
 1505 void Application::send_notification(const Glib::RefPtr<Notification>& notification)
 1506 {
 1507   g_application_send_notification(gobj(), nullptr, const_cast<GNotification*>(Glib::unwrap(notification)));
 1508 }
 1509 
 1510 void Application::withdraw_notification(const Glib::ustring& id)
 1511 {
 1512   g_application_withdraw_notification(gobj(), id.c_str());
 1513 }
 1514 
 1515 
 1516 Glib::SignalProxy<void()> Application::signal_startup()
 1517 {
 1518   return Glib::SignalProxy<void() >(this, &Application_signal_startup_info);
 1519 }
 1520 
 1521 
 1522 Glib::SignalProxy<void()> Application::signal_shutdown()
 1523 {
 1524   return Glib::SignalProxy<void() >(this, &Application_signal_shutdown_info);
 1525 }
 1526 
 1527 
 1528 Glib::SignalProxy<void()> Application::signal_activate()
 1529 {
 1530   return Glib::SignalProxy<void() >(this, &Application_signal_activate_info);
 1531 }
 1532 
 1533 
 1534 Glib::SignalProxy<int(const Glib::RefPtr<ApplicationCommandLine>&)> Application::signal_command_line()
 1535 {
 1536   return Glib::SignalProxy<int(const Glib::RefPtr<ApplicationCommandLine>&) >(this, &Application_signal_command_line_info);
 1537 }
 1538 
 1539 
 1540 Glib::SignalProxy<int(const Glib::RefPtr<Glib::VariantDict>&)> Application::signal_handle_local_options()
 1541 {
 1542   return Glib::SignalProxy<int(const Glib::RefPtr<Glib::VariantDict>&) >(this, &Application_signal_handle_local_options_info);
 1543 }
 1544 
 1545 
 1546 Glib::SignalProxy<bool()> Application::signal_name_lost()
 1547 {
 1548   return Glib::SignalProxy<bool() >(this, &Application_signal_name_lost_info);
 1549 }
 1550 
 1551 
 1552 Glib::PropertyProxy< Glib::ustring > Application::property_application_id() 
 1553 {
 1554   return Glib::PropertyProxy< Glib::ustring >(this, "application-id");
 1555 }
 1556 
 1557 Glib::PropertyProxy_ReadOnly< Glib::ustring > Application::property_application_id() const
 1558 {
 1559   return Glib::PropertyProxy_ReadOnly< Glib::ustring >(this, "application-id");
 1560 }
 1561 
 1562 static_assert(Glib::Traits::ValueCompatibleWithWrapProperty<Flags>::value,
 1563   "Type Flags cannot be used in _WRAP_PROPERTY. "
 1564   "There is no suitable template specialization of Glib::Value<>.");
 1565 
 1566 Glib::PropertyProxy< Flags > Application::property_flags() 
 1567 {
 1568   return Glib::PropertyProxy< Flags >(this, "flags");
 1569 }
 1570 
 1571 Glib::PropertyProxy_ReadOnly< Flags > Application::property_flags() const
 1572 {
 1573   return Glib::PropertyProxy_ReadOnly< Flags >(this, "flags");
 1574 }
 1575 
 1576 Glib::PropertyProxy< guint > Application::property_inactivity_timeout() 
 1577 {
 1578   return Glib::PropertyProxy< guint >(this, "inactivity-timeout");
 1579 }
 1580 
 1581 Glib::PropertyProxy_ReadOnly< guint > Application::property_inactivity_timeout() const
 1582 {
 1583   return Glib::PropertyProxy_ReadOnly< guint >(this, "inactivity-timeout");
 1584 }
 1585 
 1586 Glib::PropertyProxy_ReadOnly< bool > Application::property_is_registered() const
 1587 {
 1588   return Glib::PropertyProxy_ReadOnly< bool >(this, "is-registered");
 1589 }
 1590 
 1591 Glib::PropertyProxy_ReadOnly< bool > Application::property_is_remote() const
 1592 {
 1593   return Glib::PropertyProxy_ReadOnly< bool >(this, "is-remote");
 1594 }
 1595 
 1596 Glib::PropertyProxy< std::string > Application::property_resource_base_path() 
 1597 {
 1598   return Glib::PropertyProxy< std::string >(this, "resource-base-path");
 1599 }
 1600 
 1601 Glib::PropertyProxy_ReadOnly< std::string > Application::property_resource_base_path() const
 1602 {
 1603   return Glib::PropertyProxy_ReadOnly< std::string >(this, "resource-base-path");
 1604 }
 1605 
 1606 Glib::PropertyProxy_ReadOnly< bool > Application::property_is_busy() const
 1607 {
 1608   return Glib::PropertyProxy_ReadOnly< bool >(this, "is-busy");
 1609 }
 1610 
 1611 
 1612 void Gio::Application::on_startup()
 1613 {
 1614   const auto base = static_cast<BaseClassType*>(
 1615       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1616   );
 1617 
 1618   if(base && base->startup)
 1619     (*base->startup)(gobj());
 1620 }
 1621 void Gio::Application::on_shutdown()
 1622 {
 1623   const auto base = static_cast<BaseClassType*>(
 1624       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1625   );
 1626 
 1627   if(base && base->shutdown)
 1628     (*base->shutdown)(gobj());
 1629 }
 1630 void Gio::Application::on_activate()
 1631 {
 1632   const auto base = static_cast<BaseClassType*>(
 1633       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1634   );
 1635 
 1636   if(base && base->activate)
 1637     (*base->activate)(gobj());
 1638 }
 1639 int Gio::Application::on_command_line(const Glib::RefPtr<ApplicationCommandLine>& command_line)
 1640 {
 1641   const auto base = static_cast<BaseClassType*>(
 1642       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1643   );
 1644 
 1645   if(base && base->command_line)
 1646     return (*base->command_line)(gobj(),const_cast<GApplicationCommandLine*>(Glib::unwrap(command_line)));
 1647 
 1648   using RType = int;
 1649   return RType();
 1650 }
 1651 int Gio::Application::on_handle_local_options(const Glib::RefPtr<Glib::VariantDict>& options)
 1652 {
 1653   const auto base = static_cast<BaseClassType*>(
 1654       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1655   );
 1656 
 1657   if(base && base->handle_local_options)
 1658     return (*base->handle_local_options)(gobj(),Glib::unwrap(options));
 1659 
 1660   using RType = int;
 1661   return RType();
 1662 }
 1663 bool Gio::Application::on_name_lost()
 1664 {
 1665   const auto base = static_cast<BaseClassType*>(
 1666       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1667   );
 1668 
 1669   if(base && base->name_lost)
 1670     return (*base->name_lost)(gobj());
 1671 
 1672   using RType = bool;
 1673   return RType();
 1674 }
 1675 
 1676 bool Gio::Application::local_command_line_vfunc(char**& arguments, int& exit_status) 
 1677 {
 1678   const auto base = static_cast<BaseClassType*>(
 1679       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1680   );
 1681 
 1682   if(base && base->local_command_line)
 1683   {
 1684     bool retval((*base->local_command_line)(gobj(),&(arguments),&(exit_status)));
 1685     return retval;
 1686   }
 1687 
 1688   using RType = bool;
 1689   return RType();
 1690 }
 1691 void Gio::Application::before_emit_vfunc(const Glib::VariantBase& platform_data) 
 1692 {
 1693   const auto base = static_cast<BaseClassType*>(
 1694       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1695   );
 1696 
 1697   if(base && base->before_emit)
 1698   {
 1699     (*base->before_emit)(gobj(),const_cast<GVariant*>((platform_data).gobj()));
 1700   }
 1701 }
 1702 void Gio::Application::after_emit_vfunc(const Glib::VariantBase& platform_data) 
 1703 {
 1704   const auto base = static_cast<BaseClassType*>(
 1705       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1706   );
 1707 
 1708   if(base && base->after_emit)
 1709   {
 1710     (*base->after_emit)(gobj(),const_cast<GVariant*>((platform_data).gobj()));
 1711   }
 1712 }
 1713 void Gio::Application::quit_mainloop_vfunc() 
 1714 {
 1715   const auto base = static_cast<BaseClassType*>(
 1716       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1717   );
 1718 
 1719   if(base && base->quit_mainloop)
 1720   {
 1721     (*base->quit_mainloop)(gobj());
 1722   }
 1723 }
 1724 void Gio::Application::run_mainloop_vfunc() 
 1725 {
 1726   const auto base = static_cast<BaseClassType*>(
 1727       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1728   );
 1729 
 1730   if(base && base->run_mainloop)
 1731   {
 1732     (*base->run_mainloop)(gobj());
 1733   }
 1734 }
 1735 bool Gio::Application::dbus_register_vfunc(const Glib::RefPtr<DBus::Connection>& connection, const Glib::ustring& object_path) 
 1736 {
 1737   const auto base = static_cast<BaseClassType*>(
 1738       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1739   );
 1740 
 1741   if(base && base->dbus_register)
 1742   {
 1743     GError* gerror = nullptr;
 1744     bool retval((*base->dbus_register)(gobj(),Glib::unwrap(connection),object_path.c_str(),&(gerror)));
 1745     if(gerror)
 1746       ::Glib::Error::throw_exception(gerror);
 1747     return retval;
 1748   }
 1749 
 1750   using RType = bool;
 1751   return RType();
 1752 }
 1753 void Gio::Application::dbus_unregister_vfunc(const Glib::RefPtr<DBus::Connection>& connection, const Glib::ustring& object_path) 
 1754 {
 1755   const auto base = static_cast<BaseClassType*>(
 1756       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 1757   );
 1758 
 1759   if(base && base->dbus_unregister)
 1760   {
 1761     (*base->dbus_unregister)(gobj(),Glib::unwrap(connection),object_path.c_str());
 1762   }
 1763 }
 1764 
 1765 
 1766 } // namespace Gio
 1767 
 1768