[gtkmm] Gtk::IconInfo: Add async methods.



commit 1525a1c42cd65cf41a2c2f19d8f928edb620f0af
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Apr 1 19:36:30 2013 +0200

    Gtk::IconInfo: Add async methods.
    
        * gtk/src/iconinfo.hg: Add load_icon_async(),
        load_symbolic_async(), load_symbolic_for_context().
        * tools/m4/convert_gtk.m4: Add a conversion for
        AsyncResult.

 ChangeLog               |   11 ++++-
 gtk/src/iconinfo.ccg    |  111 +++++++++++++++++++++++++++++++++++++++++++++++
 gtk/src/iconinfo.hg     |   31 +++++++++++++
 tools/m4/convert_gtk.m4 |    2 +
 4 files changed, 154 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0effa9a..789f350 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,15 @@
 2013-04-01  Murray Cumming  <murrayc murrayc com>
 
-       Gtk::Settings: Add two new setings.
+       Gtk::IconInfo: Add async methods.
+       
+       * gtk/src/iconinfo.hg: Add load_icon_async(),
+       load_symbolic_async(), load_symbolic_for_context().
+       * tools/m4/convert_gtk.m4: Add a conversion for 
+       AsyncResult.
+
+2013-04-01  Murray Cumming  <murrayc murrayc com>
+
+       Gtk::Settings: Add two new settings.
        
        * gtk/src/settings.hg: Wrap the new
        gtk-recent-files-enabled and gtk-primary-button-warps-slider
diff --git a/gtk/src/iconinfo.ccg b/gtk/src/iconinfo.ccg
index efad128..8648830 100644
--- a/gtk/src/iconinfo.ccg
+++ b/gtk/src/iconinfo.ccg
@@ -19,6 +19,7 @@
 
 #include <gtk/gtk.h>
 #include <gtkmm/icontheme.h>
+//TODO: Install and use this? #include <giomm/slot_async.h>
 
 namespace {
 
@@ -30,6 +31,25 @@ static GtkIconInfo* gtk_icon_info_ref(GtkIconInfo* icon_info)
   return icon_info;
 }
 
+//TODO: Install and use giomm's slot_async.h if we use this more often:
+static void
+SignalProxy_async_callback(GObject*, GAsyncResult* res, void* data)
+{
+  Gio::SlotAsyncReady* the_slot = static_cast<Gio::SlotAsyncReady*>(data);
+
+  try
+  {
+    Glib::RefPtr<Gio::AsyncResult> result = Glib::wrap(res, true /* take copy */);
+    (*the_slot)(result);
+  }
+  catch(...)
+  {
+    Glib::exception_handlers_invoke();
+  }
+
+  delete the_slot;
+}
+
 }
 
 namespace Gtk
@@ -98,4 +118,95 @@ Glib::RefPtr<Gdk::Pixbuf> IconInfo::load_symbolic(const Glib::RefPtr<Style>& sty
 }
 */
 
+void IconInfo::load_icon_async(const Gio::SlotAsyncReady& slot, const Glib::RefPtr<Gio::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.
+  Gio::SlotAsyncReady* slot_copy = new Gio::SlotAsyncReady(slot);
+
+  gtk_icon_info_load_icon_async(gobj(),
+    Glib::unwrap(cancellable),
+    &SignalProxy_async_callback,
+    slot_copy);
+}
+
+void IconInfo::load_icon_async(const Gio::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.
+  Gio::SlotAsyncReady* slot_copy = new Gio::SlotAsyncReady(slot);
+
+  gtk_icon_info_load_icon_async(gobj(),
+    0,
+    &SignalProxy_async_callback,
+    slot_copy);
+}
+
+
+void IconInfo::load_symbolic_async(const Gdk::RGBA& fg, const Gdk::RGBA& success_color, const Gdk::RGBA& 
warning_color, const Gdk::RGBA& error_color, const Gio::SlotAsyncReady& slot, const 
Glib::RefPtr<Gio::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.
+  Gio::SlotAsyncReady* slot_copy = new Gio::SlotAsyncReady(slot);
+
+  gtk_icon_info_load_symbolic_async(gobj(),
+    fg.gobj(),
+    success_color.gobj(),
+    warning_color.gobj(),
+    error_color.gobj(),
+    Glib::unwrap(cancellable),
+    &SignalProxy_async_callback,
+    slot_copy);
+}
+
+void IconInfo::load_symbolic_async(const Gdk::RGBA& fg, const Gdk::RGBA& success_color, const Gdk::RGBA& 
warning_color, const Gdk::RGBA& error_color, const Gio::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.
+  Gio::SlotAsyncReady* slot_copy = new Gio::SlotAsyncReady(slot);
+
+  gtk_icon_info_load_symbolic_async(gobj(),
+    fg.gobj(),
+    success_color.gobj(),
+    warning_color.gobj(),
+    error_color.gobj(),
+    0,
+    &SignalProxy_async_callback,
+    slot_copy);
+}
+
+
+void IconInfo::load_symbolic_for_context_async(const Glib::RefPtr<StyleContext>& context, const 
Gio::SlotAsyncReady& slot, const Glib::RefPtr<Gio::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.
+  Gio::SlotAsyncReady* slot_copy = new Gio::SlotAsyncReady(slot);
+
+  gtk_icon_info_load_symbolic_for_context_async(gobj(),
+    Glib::unwrap(context),
+    Glib::unwrap(cancellable),
+    &SignalProxy_async_callback,
+    slot_copy);
+}
+
+void IconInfo::load_symbolic_for_context_async(const Glib::RefPtr<StyleContext>& context, const 
Gio::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.
+  Gio::SlotAsyncReady* slot_copy = new Gio::SlotAsyncReady(slot);
+
+  gtk_icon_info_load_symbolic_for_context_async(gobj(),
+    Glib::unwrap(context),
+    0,
+    &SignalProxy_async_callback,
+    slot_copy);
+}
+
+
 } // namespace Gtk
diff --git a/gtk/src/iconinfo.hg b/gtk/src/iconinfo.hg
index 52aaedf..53a6e4a 100644
--- a/gtk/src/iconinfo.hg
+++ b/gtk/src/iconinfo.hg
@@ -22,6 +22,8 @@
 #include <gdkmm/pixbuf.h>
 #include <gdkmm/rgba.h>
 #include <gdkmm/types.h>
+#include <giomm/asyncresult.h>
+#include <giomm/cancellable.h>
 
 //#include <gtk/gtkicontheme.h>
 
@@ -67,10 +69,39 @@ public:
 
   _IGNORE(gtk_icon_info_load_symbolic_for_style) //deprecated
 
+  //TODO: Documentation.
+  void load_icon_async(const Gio::SlotAsyncReady& slot, const Glib::RefPtr<Gio::Cancellable>& cancellable);
+  void load_icon_async(const Gio::SlotAsyncReady& slot);
+  _IGNORE(gtk_icon_info_load_icon_async)
+
+ _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_icon_finish(const Glib::RefPtr<Gio::AsyncResult>& result), 
gtk_icon_info_load_icon_finish, errthrow)
+
+
+
   //TODO: Documentation:
   Glib::RefPtr<Gdk::Pixbuf> load_symbolic(const Glib::RefPtr<StyleContext>& style, bool& was_symbolic);
   _IGNORE(gtk_icon_info_load_symbolic_for_context)
 
+
+  //TODO: Documentation.
+  void load_symbolic_for_context_async(const Glib::RefPtr<StyleContext>& context, const Gio::SlotAsyncReady& 
slot, const Glib::RefPtr<Gio::Cancellable>& cancellable);
+  void load_symbolic_for_context_async(const Glib::RefPtr<StyleContext>& context, const Gio::SlotAsyncReady& 
slot);
+  _IGNORE(gtk_icon_info_load_symbolic_for_context_async)
+
+ _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_symbolic_for_context_finish(const 
Glib::RefPtr<Gio::AsyncResult>& result, bool& was_symbolic), gtk_icon_info_load_symbolic_for_context_finish, 
errthrow)
+
+
+  //TODO: In gtk_icon_info_load_symbolic_async(), each GdkRGBA* can be NULL, but we do not want that many 
method overloads.
+  //TODO: Documentation.
+  void load_symbolic_async(const Gdk::RGBA& fg, const Gdk::RGBA& success_color, const Gdk::RGBA& 
warning_color, const Gdk::RGBA& error_color, const Gio::SlotAsyncReady& slot, const 
Glib::RefPtr<Gio::Cancellable>& cancellable);
+  void load_symbolic_async(const Gdk::RGBA& fg, const Gdk::RGBA& success_color, const Gdk::RGBA& 
warning_color, const Gdk::RGBA& error_color, const Gio::SlotAsyncReady& slot);
+  _IGNORE(gtk_icon_info_load_symbolic_async)
+
+ _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_symbolic_finish(const Glib::RefPtr<Gio::AsyncResult>& result, 
bool& was_symbolic), gtk_icon_info_load_symbolic_finish, errthrow)
+
+
+
+
   _WRAP_METHOD(void set_raw_coordinates(bool raw_coordinates = true), gtk_icon_info_set_raw_coordinates)
   _WRAP_METHOD(bool get_embedded_rect(Gdk::Rectangle& rectangle) const, gtk_icon_info_get_embedded_rect)
 
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index 522215a..dbf503c 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -675,6 +675,8 @@ _CONVERSION(`Align',`float',`_gtkmm_align_float_from_enum($3)')
 #_CONVERSION(`const Glib::StringArrayHandle&',`const gchar**',`($3).data())')
 _CONVERSION(`const Glib::StringArrayHandle&',`const gchar**',`const_cast<const gchar**>(($3).data())')
 
+_CONVERSION(`const Glib::RefPtr<Gio::AsyncResult>&',`GAsyncResult*',__CONVERT_REFPTR_TO_P)
+
 _CONVERSION(`const Glib::RefPtr<const Gio::Icon>&',`GIcon*',__CONVERT_CONST_REFPTR_TO_P_SUN(Gio::Icon))
 _CONVERSION(`GIcon*',`Glib::RefPtr<Gio::Icon>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<Gio::Icon>&',`GIcon*',__CONVERT_CONST_REFPTR_TO_P_SUN(Gio::Icon))


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