File gtkmm-2.20-compat.patch of Package imagescan

diff --git a/gtkmm/action-dialog.cpp b/gtkmm/action-dialog.cpp
index ad4e381..ac4ea4f 100644
--- a/gtkmm/action-dialog.cpp
+++ b/gtkmm/action-dialog.cpp
@@ -22,6 +22,8 @@
 #include <config.h>
 #endif
 
+#define HAVE_GTK_SPINNER 0
+
 #include "action-dialog.hpp"
 
 #include <utsushi/exception.hpp>
@@ -35,7 +37,9 @@
 #include <gtkmm/label.h>
 #include <gtkmm/main.h>
 #include <gtkmm/messagedialog.h>
+#if HAVE_GTK_SPINNER
 #include <gtkmm/spinner.h>
+#endif
 #include <gtkmm/stock.h>
 #include <gtkmm/widget.h>
 
@@ -88,6 +92,17 @@ void set_properties (Gtk::Widget& w)
 namespace utsushi {
 namespace gtkmm {
 
+class message_dialog
+  : public Gtk::MessageDialog
+  , public dialog_mixin
+{
+public:
+  message_dialog (Gtk::Window& parent, const Glib::ustring& message,
+                  bool use_markup, Gtk::MessageType type)
+    : Gtk::MessageDialog (parent, message, use_markup, type)
+  {}
+};
+
 struct action_runner
 {
   action_runner (option::map::ptr p, std::string key)
@@ -139,8 +154,10 @@ action_dialog::action_dialog (option::map::ptr actions, Gtk::Widget *trigger,
 
       if (use_spinner)
         {
+#if HAVE_GTK_SPINNER
           b->set_image (*(Gtk::manage (new Gtk::Spinner)));
           b->get_image ()->hide ();
+#endif
         }
       b->signal_clicked ()
         .connect (sigc::bind< Gtk::Button *, std::string, std::string >
@@ -167,9 +184,11 @@ void
 action_dialog::on_action (Gtk::Button *button, std::string key,
                           std::string message)
 {
-  Gtk::MessageDialog dlg (*this, message, false, Gtk::MESSAGE_OTHER);
+  message_dialog dlg (*this, message, false, Gtk::MESSAGE_OTHER);
+#if HAVE_GTK_SPINNER
   Gtk::Spinner *spinner =
     static_cast< Gtk::Spinner * > (button->get_image ());
+#endif
 
   // window manager hints
   dlg.set_position (Gtk::WIN_POS_CENTER_ALWAYS);
@@ -188,6 +207,7 @@ action_dialog::on_action (Gtk::Button *button, std::string key,
   set_response_sensitive (Gtk::RESPONSE_OK, false);
   buttons_->foreach (sigc::bind (&::set_insensitive, button));
 
+#if HAVE_GTK_SPINNER
   if (spinner)
     {
       spinner->set_visible (true);
@@ -195,6 +215,7 @@ action_dialog::on_action (Gtk::Button *button, std::string key,
       spinner->start ();
     }
   else
+#endif
     {
       dlg.get_image ()->set_visible (false);
       // FIXME reserve icon area to avoid the message from moving
@@ -234,12 +255,14 @@ action_dialog::on_action (Gtk::Button *button, std::string key,
           msg = "unknown exception";
         }
 
+#if HAVE_GTK_SPINNER
       if (spinner)              // display a separate dialog
         {
           Gtk::MessageDialog dlg (*this, _(msg), false, Gtk::MESSAGE_ERROR);
           dlg.run ();
         }
       else                      // override info icon
+#endif
         {
           Gtk::Image *img = new Gtk::Image (Gtk::Stock::DIALOG_ERROR,
                                             Gtk::ICON_SIZE_DIALOG);
@@ -251,6 +274,7 @@ action_dialog::on_action (Gtk::Button *button, std::string key,
     {
       if (*ar.rc)               // something went wrong
         {
+#if HAVE_GTK_SPINNER
           if (spinner)          // display a separate dialog
             {
               Gtk::MessageDialog dlg (*this, ar.rc->message (), false,
@@ -258,6 +282,7 @@ action_dialog::on_action (Gtk::Button *button, std::string key,
               dlg.run ();
             }
           else                  // override info icon
+#endif
             {
               Gtk::Image *img = new Gtk::Image (Gtk::Stock::DIALOG_WARNING,
                                                 Gtk::ICON_SIZE_DIALOG);
@@ -277,6 +302,7 @@ action_dialog::on_action (Gtk::Button *button, std::string key,
       // BOOST_THROW_EXCEPTION (internal_error);
     }
 
+#if HAVE_GTK_SPINNER
   if (spinner)
     {
       spinner->stop ();
@@ -284,6 +310,7 @@ action_dialog::on_action (Gtk::Button *button, std::string key,
       spinner->hide ();
     }
   else
+#endif
     {
       dlg.get_image ()->set_visible (true);
       dlg.get_action_area ()->set_sensitive (true);
@@ -313,5 +340,56 @@ action_dialog::on_maintenance (void)
   if (trigger_) trigger_->set_sensitive (true);
 }
 
+// implementation details copied from gtk+
+
+typedef struct _ResponseData ResponseData;
+
+struct _ResponseData
+{
+  int response_id;
+};
+
+static ResponseData * get_response_data (GtkWidget *widget, gboolean create)
+{
+  ResponseData *ad = (ResponseData *) g_object_get_data (G_OBJECT (widget),
+							 "gtk-dialog-response-data");
+
+  if (ad == NULL) assert (!create);
+
+  return ad;
+}
+
+Gtk::Widget *
+dialog_mixin::get_widget_for_response (int response_id)
+{
+  GtkDialog *dialog = reinterpret_cast< Gtk::Dialog * > (this)->gobj ();
+
+  GList *children;
+  GList *tmp_list;
+
+  g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
+
+  children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
+
+  tmp_list = children;
+  while (tmp_list != NULL)
+    {
+      GtkWidget *widget = GTK_WIDGET (tmp_list->data);
+      ResponseData *rd = get_response_data (widget, FALSE);
+
+      if (rd && rd->response_id == response_id)
+	{
+	  g_list_free (children);
+	  return Glib::wrap (widget);
+	}
+
+      tmp_list = g_list_next (tmp_list);
+    }
+
+  g_list_free (children);
+
+  return NULL;
+}
+
 }       // namespace gtkmm
 }       // namespace utsushi
diff --git a/gtkmm/action-dialog.hpp b/gtkmm/action-dialog.hpp
index 0f67f14..1644546 100644
--- a/gtkmm/action-dialog.hpp
+++ b/gtkmm/action-dialog.hpp
@@ -29,8 +29,15 @@
 namespace utsushi {
 namespace gtkmm {
 
+class dialog_mixin
+{
+public:
+  Gtk::Widget *get_widget_for_response (int response_id);
+};
+
 class action_dialog
   : public Gtk::Dialog
+  , public dialog_mixin
 {
 public:
   action_dialog (option::map::ptr actions, Gtk::Widget *trigger,
openSUSE Build Service is sponsored by