2 /* Copyright (C) 2006 The gtkmm Development Team
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include <gtk/gtkprinter.h>
21 // This Signal Proxy allows the C++ coder to specify a sigc::slot instead of a static function.
23 static gboolean SignalProxy_Custom_gtk_callback(GtkPrinter* gtk_printer, gpointer data)
25 const Gtk::SlotPrinterEnumerator* the_slot = static_cast<Gtk::SlotPrinterEnumerator*>(data);
27 #ifdef GLIBMM_EXCEPTIONS_ENABLED
30 #endif //GLIBMM_EXCEPTIONS_ENABLED
31 // Create a suitable C++ instance to pass to the C++ method;
32 Glib::RefPtr<Gtk::Printer> printer = Glib::wrap(gtk_printer);
34 return (*the_slot)(printer);
35 #ifdef GLIBMM_EXCEPTIONS_ENABLED
39 Glib::exception_handlers_invoke();
40 return false; // arbitrary default;
42 #endif //GLIBMM_EXCEPTIONS_ENABLED
45 static void SignalProxy_Custom_gtk_callback_destroy(void* data)
47 delete static_cast<Gtk::SlotPrinterEnumerator*>(data);
53 bool Printer::equal(const Glib::RefPtr<Printer>& other) const
55 return (static_cast<bool>(gtk_printer_compare(const_cast<GtkPrinter*>(this->gobj()),
56 const_cast<GtkPrinter*>(other->gobj()))));
59 void enumerate_printers(const SlotPrinterEnumerator& slot, bool wait)
61 // Create a copy of the slot. A pointer to this will be passed through the callback's data parameter.
62 // It will be deleted when SignalProxy_Custom_gtk_callback_destroy() is called.
63 SlotPrinterEnumerator* slot_copy = new SlotPrinterEnumerator(slot);
65 gtk_enumerate_printers(&SignalProxy_Custom_gtk_callback,
67 &SignalProxy_Custom_gtk_callback_destroy,
68 static_cast<int>(wait));