glibmm r503 - in trunk: . gio/giomm gio/src tools/m4



Author: markoa
Date: Thu Jan 10 22:33:38 2008
New Revision: 503
URL: http://svn.gnome.org/viewvc/glibmm?rev=503&view=rev

Log:
2008-01-10  Marko Anastasov  <marko anastasov gmail com>

	* gio/src/appinfo.ccg:
	* gio/src/appinfo.hg: Wrapped AppInfo and AppLaunchContext, without
	the vfuncs.
	* tools/m4/convert_glib.m4: New conversions.
	The previous comment on build was not valid.


Modified:
   trunk/ChangeLog
   trunk/gio/giomm/   (props changed)
   trunk/gio/src/appinfo.ccg
   trunk/gio/src/appinfo.hg
   trunk/tools/m4/convert_glib.m4

Modified: trunk/gio/src/appinfo.ccg
==============================================================================
--- trunk/gio/src/appinfo.ccg	(original)
+++ trunk/gio/src/appinfo.ccg	Thu Jan 10 22:33:38 2008
@@ -18,3 +18,74 @@
  */
 
 #include <gio/gio.h>
+
+namespace Gio
+{
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<AppInfo>
+AppInfo::create_from_commandline(const std::string& commandline,
+                                 const std::string& application_name,
+                                 AppInfoCreateFlags flags)
+#else
+Glib::RefPtr<AppInfo>
+AppInfo::create_from_commandline(const std::string& commandline,
+                                 const std::string& application_name,
+                                 AppInfoCreateFlags flags,
+                                 std::auto_ptr<Glib::Error>& error)
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+{
+  GAppInfo* capp_info = 0;
+  GError* gerror = 0;
+
+  capp_info = g_app_info_create_from_commandline(commandline.c_str(),
+                                                 application_name.c_str(),
+                                                 static_cast<GAppInfoCreateFlags>(flags),
+                                                 &gerror);
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if (gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if (error)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return Glib::wrap(capp_info);
+}
+
+bool AppInfo::equal(const Glib::RefPtr<AppInfo>& other) const
+{
+  return static_cast<bool>(
+    g_app_info_equal(const_cast<GAppInfo*>(this->gobj()),
+                     const_cast<GAppInfo*>(other->gobj())));
+}
+
+Glib::ListHandle< Glib::RefPtr<AppInfo> > AppInfo::get_all()
+{
+  return Glib::ListHandle< Glib::RefPtr<AppInfo> >(g_app_info_get_all(), Glib::OWNERSHIP_SHALLOW);
+}
+
+Glib::ListHandle< Glib::RefPtr<AppInfo> > AppInfo::get_all_for_type(const std::string& content_type)
+{
+  return Glib::ListHandle< Glib::RefPtr<AppInfo> >(
+    g_app_info_get_all_for_type(content_type.c_str()), Glib::OWNERSHIP_SHALLOW);
+}
+
+Glib::RefPtr<AppInfo> AppInfo::get_default_for_type(const std::string& content_type,
+                                                    bool must_support_uris)
+{
+  GAppInfo* cinfo = 0;
+  cinfo = g_app_info_get_default_for_type(content_type.c_str(),
+                                          static_cast<gboolean>(must_support_uris));
+  return Glib::wrap(cinfo);
+}
+
+Glib::RefPtr<AppInfo> AppInfo::get_default_for_uri_scheme(const std::string& uri_scheme)
+{
+  GAppInfo* cinfo = 0;
+  cinfo = g_app_info_get_default_for_uri_scheme(uri_scheme.c_str());
+  return Glib::wrap(cinfo);
+}
+
+} // namespace Gio

Modified: trunk/gio/src/appinfo.hg
==============================================================================
--- trunk/gio/src/appinfo.hg	(original)
+++ trunk/gio/src/appinfo.hg	Thu Jan 10 22:33:38 2008
@@ -19,23 +19,123 @@
 
 #include <gio/gio.h>
 
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+#include <exception>
+#endif
 #include <string>
+
 #include <glibmm/interface.h>
-//#include <glibmm/object.h>
+#include <glibmm/object.h>
+#include <giomm/icon.h>
 
 _DEFS(giomm,gio)
 _PINCLUDE(glibmm/private/interface_p.h)
+_PINCLUDE(glibmm/private/object_p.h)
 
 namespace Gio
 {
 
+_WRAP_ENUM(AppInfoCreateFlags, GAppInfoCreateFlags, NO_GTYPE)
+
+class AppInfo;
+
+class AppLaunchContext : public Glib::Object
+{
+  _CLASS_GOBJECT(AppLaunchContext, GAppLaunchContext, G_APP_LAUNCH_CONTEXT, Glib::Object, GObject)
+
+protected:
+  _CTOR_DEFAULT()
+
+public:
+  _WRAP_CREATE()
+
+  _WRAP_METHOD(std::string get_display(const Glib::RefPtr<AppInfo>& info,
+                                       const Glib::ListHandle<std::string>& files),
+               g_app_launch_context_get_display)
+  _WRAP_METHOD(std::string get_startup_notify_id(const Glib::RefPtr<AppInfo>& info,
+                                                 const Glib::ListHandle<std::string>& files),
+               g_app_launch_context_get_startup_notify_id)
+  _WRAP_METHOD(void launch_failed(const std::string& startup_notify_id),
+               g_app_launch_context_launch_failed)
+};
+
 class AppInfo : public Glib::Interface
 {
   _CLASS_INTERFACE(AppInfo, GAppInfo, G_APP_INFO, GAppInfoIface)
 
 public:
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  static Glib::RefPtr<AppInfo> create_from_commandline(const std::string& commandline,
+                                                       const std::string& application_name,
+                                                       AppInfoCreateFlags flags);
+#else
+  static Glib::RefPtr<AppInfo> create_from_commandline(const std::string& commandline,
+                                                       const std::string& application_name,
+                                                       AppInfoCreateFlags flags,
+                                                       std::auto_ptr<Glib::Error>& error);
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+
+  _IGNORE(g_app_info_dup)
+  _IGNORE(g_app_info_equal)
+
+  // I declare this as virtual so that it is possible to override
+  // the method in possible derived classes. markoa
+  virtual bool equal(const Glib::RefPtr<AppInfo>& other) const;
+
   _WRAP_METHOD(std::string get_id() const, g_app_info_get_id)
   _WRAP_METHOD(std::string get_name() const, g_app_info_get_name)
+  _WRAP_METHOD(std::string get_description() const, g_app_info_get_description)
+  _WRAP_METHOD(std::string get_executable() const, g_app_info_get_executable)
+
+  _WRAP_METHOD(Glib::RefPtr<Icon> get_icon(), g_app_info_get_icon, refreturn)
+  _WRAP_METHOD(const Glib::RefPtr<const Icon> get_icon() const,
+               g_app_info_get_icon,
+               refreturn, constversion)
+
+  _WRAP_METHOD(bool launch(const Glib::ListHandle<std::string>& files,
+                           const Glib::RefPtr<AppLaunchContext>& launch_context),
+               g_app_info_launch,
+               errthrow)
+  _WRAP_METHOD(bool supports_uris() const, g_app_info_supports_uris)
+  _WRAP_METHOD(bool supports_files() const, g_app_info_supports_files)
+  _WRAP_METHOD(bool launch_uris(const Glib::ListHandle<std::string>& uris,
+                                GAppLaunchContext* launch_context),
+               g_app_info_launch_uris,
+               errthrow)
+  _WRAP_METHOD(bool should_show() const, g_app_info_should_show)
+
+  _WRAP_METHOD(bool set_as_default_for_type(const std::string& content_type),
+               g_app_info_set_as_default_for_type,
+               errthrow)
+  _WRAP_METHOD(bool set_as_default_for_extension(const std::string& extension),
+               g_app_info_set_as_default_for_extension,
+               errthrow)
+  _WRAP_METHOD(bool add_supports_type(const std::string& content_type),
+               g_app_info_add_supports_type,
+               errthrow)
+  _WRAP_METHOD(bool can_remove_supports_type() const, g_app_info_can_remove_supports_type)
+  _WRAP_METHOD(bool remove_supports_type(const std::string& content_type),
+               g_app_info_remove_supports_type,
+               errthrow)
+
+  static Glib::ListHandle< Glib::RefPtr<AppInfo> > get_all();
+
+  static Glib::ListHandle< Glib::RefPtr<AppInfo> > get_all_for_type(const std::string& content_type);
+
+  static Glib::RefPtr<AppInfo> get_default_for_type(const std::string& content_type,
+                                                    bool must_support_uris = true);
+
+  static Glib::RefPtr<AppInfo> get_default_for_uri_scheme(const std::string& uri_scheme);
+
+  //TODO: vfuncs?
 };
 
+/** @relates Gio::AppInfo */
+inline bool operator==(const Glib::RefPtr<AppInfo>& lhs, const Glib::RefPtr<AppInfo>& rhs)
+{ return lhs->equal(rhs); }
+
+/** @relates Gio::AppInfo */
+inline bool operator!=(const Glib::RefPtr<AppInfo>& lhs, const Glib::RefPtr<AppInfo>& rhs)
+{ return ! lhs->equal(rhs); }
+
 } // namespace Gio

Modified: trunk/tools/m4/convert_glib.m4
==============================================================================
--- trunk/tools/m4/convert_glib.m4	(original)
+++ trunk/tools/m4/convert_glib.m4	Thu Jan 10 22:33:38 2008
@@ -36,6 +36,7 @@
 _CONV_ENUM(G,FileQueryInfoFlags)
 _CONV_ENUM(G,FileType)
 _CONV_ENUM(G,OutputStreamSpliceFlags)
+_CONV_ENUM(G,AppInfoCreateFlags)
 
 _CONVERSION(`gunichar&',`gunichar*',`&($3)')
 _CONVERSION(`gsize&',`gsize*',`&($3)')
@@ -83,6 +84,12 @@
 _CONVERSION(`OptionGroup&',`GOptionGroup*',`($3).gobj()')
 #_CONVERSION(`GOptionGroup*',`OptionGroup',`Glib::wrap(($3), true /* take_copy */)')
 
+# AppInfo
+_CONVERSION(`GAppInfo*',`Glib::RefPtr<AppInfo>',`Glib::wrap($3)')
+_CONVERSION(`const Glib::ListHandle<std::string>&',`GList*',`$3.data()')
+_CONVERSION(`const Glib::RefPtr<AppLaunchContext>&',`GAppLaunchContext*',__CONVERT_REFPTR_TO_P)
+_CONVERSION(`const Glib::RefPtr<AppInfo>&',`GAppInfo*',__CONVERT_REFPTR_TO_P)
+
 # AsyncResult
 _CONVERSION(`Glib::RefPtr<Glib::Object>',`GObject*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<AsyncResult>&',`GAsyncResult*',__CONVERT_REFPTR_TO_P)



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