glibmm r579 - in trunk: . gio/src



Author: jjongsma
Date: Mon Feb  4 19:17:13 2008
New Revision: 579
URL: http://svn.gnome.org/viewvc/glibmm?rev=579&view=rev

Log:
	* gio/src/file.hg: remove an obsolete TODO
	* gio/src/gio_vfuncs.defs: add LoadableIcon vfunc definitions
	* gio/src/loadableicon.ccg:
	* gio/src/loadableicon.hg: wrap some methods of LoadableIcon.  Some vfuncs
	need to be wrapped yet



Modified:
   trunk/ChangeLog
   trunk/gio/src/file.hg
   trunk/gio/src/gio_vfuncs.defs
   trunk/gio/src/loadableicon.ccg
   trunk/gio/src/loadableicon.hg

Modified: trunk/gio/src/file.hg
==============================================================================
--- trunk/gio/src/file.hg	(original)
+++ trunk/gio/src/file.hg	Mon Feb  4 19:17:13 2008
@@ -1151,7 +1151,6 @@
   bool set_attributes_finish(const Glib::RefPtr<AsyncResult>& result, const Glib::RefPtr<FileInfo>& info, std::auto_ptr<Glib::Error>& error);
 #endif // GLIBMM_EXCEPTIONS_ENABLED
 
-  //TODO: Add overloads without the cancellable:
   _WRAP_METHOD(bool set_attribute_string(const std::string& attribute, const std::string& value, FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable),
                g_file_set_attribute_string,
                errthrow)

Modified: trunk/gio/src/gio_vfuncs.defs
==============================================================================
--- trunk/gio/src/gio_vfuncs.defs	(original)
+++ trunk/gio/src/gio_vfuncs.defs	Mon Feb  4 19:17:13 2008
@@ -126,6 +126,40 @@
   (return-type "guint")
 )
 
+; GLoadableIcon
+
+(define-vfunc load
+ (of-object "GLoadableIcon")
+ (return-type "GInputStream*")
+ (parameters
+  '("int" "size")
+  '("char**" "type")
+  '("GCancellable*" "cancellable")
+  '("GError**" "error")
+ )
+)
+
+(define-vfunc load_async
+ (of-object "GLoadableIcon")
+ (return-type "void")
+ (parameters
+  '("int" "size")
+  '("GCancellable*" "cancellable")
+  '("GAsyncReadyCallback" "callback")
+  '("gpointer" "user_data")
+ )
+)
+
+(define-vfunc load_finish
+ (of-object "GLoadableIcon")
+ (return-type "GInputStream*")
+ (parameters
+  '("GAsyncResult*" "res")
+  '("char**" "type")
+  '("GError**" "error")
+ )
+)
+
 ; GAppInfo
 
 (define-vfunc dup

Modified: trunk/gio/src/loadableicon.ccg
==============================================================================
--- trunk/gio/src/loadableicon.ccg	(original)
+++ trunk/gio/src/loadableicon.ccg	Mon Feb  4 19:17:13 2008
@@ -18,8 +18,101 @@
  */
 
 #include <gio/gio.h>
+#include "slot_async.h"
 
 namespace Gio {
 
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<InputStream>
+LoadableIcon::load(int size, Glib::ustring& type, const Glib::RefPtr<Cancellable>& cancellable)
+#else
+Glib::RefPtr<InputStream>
+LoadableIcon::load(int size, Glib::ustring& type, const Glib::RefPtr<Cancellable>& cancellable, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  char* c_type;
+  GError* gerror = 0;
+  Glib::RefPtr<InputStream> retval =
+      Glib::wrap(g_loadable_icon_load(gobj(),
+                 size,
+                 &c_type,
+                 cancellable->gobj(),
+                 &gerror));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  type = c_type;
+  g_free(c_type);
+  if(retval)
+    retval->reference(); //The function does not do a ref for us.
+  return retval;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<InputStream>
+LoadableIcon::load(int size, Glib::ustring& type)
+#else
+Glib::RefPtr<InputStream>
+LoadableIcon::load(int size, Glib::ustring& type, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  char* c_type;
+  GError* gerror = 0;
+  Glib::RefPtr<InputStream> retval =
+      Glib::wrap(g_loadable_icon_load(gobj(),
+                 size,
+                 &c_type,
+                 NULL,
+                 &gerror));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  type = c_type;
+  g_free(c_type);
+  if(retval)
+    retval->reference(); //The function does not do a ref for us.
+  return retval;
+}
+
+void
+LoadableIcon::load_async(int size, const SlotAsyncReady& slot, const
+                         Glib::RefPtr<Cancellable>& cancellable)
+{
+  // Create a copy of the slot.
+  // A pointer to it will be passed through the callback's data parameter
+  // and deleted in the callback.
+  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+  g_loadable_icon_load_async(gobj(),
+                             size,
+                             cancellable->gobj(),
+                             &SignalProxy_async_callback,
+                             slot_copy);
+}
+
+void
+LoadableIcon::load_async(int size, const SlotAsyncReady& slot)
+{
+  // Create a copy of the slot.
+  // A pointer to it will be passed through the callback's data parameter
+  // and deleted in the callback.
+  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+  g_loadable_icon_load_async(gobj(),
+                             size,
+                             NULL,
+                             &SignalProxy_async_callback,
+                             slot_copy);
+}
 
 } // namespace Gio

Modified: trunk/gio/src/loadableicon.hg
==============================================================================
--- trunk/gio/src/loadableicon.hg	(original)
+++ trunk/gio/src/loadableicon.hg	Mon Feb  4 19:17:13 2008
@@ -18,6 +18,8 @@
  */
 
 #include <glibmm/interface.h>
+#include <giomm/inputstream.h>
+#include <giomm/icon.h>
 
 _DEFS(giomm,gio)
 _PINCLUDE(glibmm/private/interface_p.h)
@@ -29,35 +31,62 @@
 namespace Gio
 {
 
-//TODO: Derive from Icon?
-
 /** Extends the Icon interface and adds the ability to load icons from streams.
  *
  * @newin2p16
  */
-class LoadableIcon : public Glib::Interface
+class LoadableIcon :
+    public Glib::Interface,
+    public Gio::Icon
 {
+  // TODO: this is an interface that extends another interface -- is there
+  // something else we need to do here, or is inheriting from the C++ class
+  // enough?
   _CLASS_INTERFACE(LoadableIcon, GLoadableIcon, G_LOADABLE_ICON, GLoadableIconIface)
 
 public:
-  //TODO:
-  /*
-  GInputStream *g_loadable_icon_load        (GLoadableIcon        *icon,
-					   int                   size,
-					   char                **type,
-					   GCancellable         *cancellable,
-					   GError              **error);
-  void          g_loadable_icon_load_async  (GLoadableIcon        *icon,
-					   int                   size,
-					   GCancellable         *cancellable,
-					   GAsyncReadyCallback   callback,
-					   gpointer              user_data);
-  GInputStream *g_loadable_icon_load_finish (GLoadableIcon        *icon,
-					   GAsyncResult         *res,
-					   char                **type,
-					   GError              **error);
-  */
-   
+/**
+ * Loads a loadable icon. For the asynchronous version of this function,
+ * see load_async().
+ *
+ * @param size an integer.
+ * @param type a location to store the type of the loaded icon
+ * @param cancellable a Cancellable object
+ *
+ * @return a InputStream to read the icon from.
+ **/
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  Glib::RefPtr<InputStream> load(int size, Glib::ustring& type, const Glib::RefPtr<Cancellable>& cancellable);
+#else
+  Glib::RefPtr<InputStream> load(int size, Glib::ustring& type, const Glib::RefPtr<Cancellable>& cancellable, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+  /** Non-cancellable version of load()
+   */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  Glib::RefPtr<InputStream> load(int size, Glib::ustring& type);
+#else
+  Glib::RefPtr<InputStream> load(int size, Glib::ustring& type, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+  //TODO: 'type' can be NULL as well, but I don't really want to add 2 more
+  //overloads -- one cancellable, and one not...
+
+  /**
+   * Loads an icon asynchronously. To finish this function, see load_finish().
+   * For the synchronous, blocking version of this function, see load().
+   *
+   * @param size an integer.
+   * @param cancellable a Cancellable object
+   * @param slot a function to call when the request is satisfied
+   **/
+  void load_async(int size, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable);
+  /** Non-cancellable version of load_async()
+   */
+  void load_async(int size, const SlotAsyncReady& slot);
+  //_WRAP_METHOD(Glib::RefPtr<InputStream> load_finish(const Glib::RefPtr<AsyncResult>& res, Glib::ustring& type), g_loadable_icon_load_finish, errthrow)
+
+protected:
+  //_WRAP_VFUNC(Glib::RefPtr<InputStream> load(int size, Glib::ustring& type, const Glib::RefPtr<Cancellable>& cancellable), "load")
+  // TODO: wrap async vfuncs
 };
 
 



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