summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2011-12-01 07:09:27 +0100
committerDavid Tardon <dtardon@redhat.com>2011-12-05 15:11:51 +0100
commit823d4a3944aab86a6da50a383b498fbec2157f4d (patch)
treef96229b45b3d5513b990cb338ce83bdb0ca8ce1a /vcl/unx
parent5628699db434d4a84b6dd883538066ea972c47f6 (diff)
check for printing support dynamically
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/gtk/app/gtkinst.cxx10
-rw-r--r--vcl/unx/gtk/gdi/gtkprintwrapper.cxx264
-rw-r--r--vcl/unx/gtk/gdi/salprn-gtk.cxx68
-rw-r--r--vcl/unx/gtk/inc/gtkprintwrapper.hxx141
4 files changed, 460 insertions, 23 deletions
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index e145c0167f66..f887323ca79c 100644
--- a/vcl/unx/gtk/app/gtkinst.cxx
+++ b/vcl/unx/gtk/app/gtkinst.cxx
@@ -52,6 +52,8 @@
#include <fcntl.h>
#include <unistd.h>
+#include "gtkprintwrapper.hxx"
+
GtkHookedYieldMutex::GtkHookedYieldMutex()
{
}
@@ -629,6 +631,14 @@ GenPspGraphics *GtkInstance::CreatePrintGraphics()
return new GenPspGraphics();
}
+boost::shared_ptr<vcl::unx::GtkPrintWrapper>
+GtkInstance::getPrintWrapper() const
+{
+ if (!m_pPrintWrapper)
+ m_pPrintWrapper.reset(new vcl::unx::GtkPrintWrapper);
+ return m_pPrintWrapper;
+}
+
#if GTK_CHECK_VERSION(3,0,0)
#include "../../../headless/svpinst.cxx"
#endif
diff --git a/vcl/unx/gtk/gdi/gtkprintwrapper.cxx b/vcl/unx/gtk/gdi/gtkprintwrapper.cxx
new file mode 100644
index 000000000000..f937bdd30f77
--- /dev/null
+++ b/vcl/unx/gtk/gdi/gtkprintwrapper.cxx
@@ -0,0 +1,264 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 David Tardon, Red Hat Inc. <dtardon@redhat.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <cassert>
+
+#include <rtl/ustring.hxx>
+
+#include "gtkprintwrapper.hxx"
+
+namespace vcl
+{
+namespace unx
+{
+
+GtkPrintWrapper::GtkPrintWrapper()
+ : m_page_setup_new(0)
+ , m_print_job_new(0)
+ , m_print_job_send(0)
+ , m_print_job_set_source_file(0)
+ , m_print_settings_get(0)
+ , m_print_settings_get_collate(0)
+ , m_print_settings_set_collate(0)
+ , m_print_settings_get_n_copies(0)
+ , m_print_settings_set_n_copies(0)
+ , m_print_settings_get_page_ranges(0)
+ , m_print_settings_set_print_pages(0)
+ , m_print_unix_dialog_new(0)
+ , m_print_unix_dialog_add_custom_tab(0)
+ , m_print_unix_dialog_get_selected_printer(0)
+ , m_print_unix_dialog_set_manual_capabilities(0)
+ , m_print_unix_dialog_get_settings(0)
+ , m_print_unix_dialog_set_settings(0)
+ , m_print_operation_set_support_selection(0)
+ , m_print_operation_set_has_selection(0)
+ , m_print_unix_dialog_set_support_selection(0)
+ , m_print_unix_dialog_set_has_selection(0)
+{
+ impl_load();
+}
+
+GtkPrintWrapper::~GtkPrintWrapper()
+{
+}
+
+void GtkPrintWrapper::impl_load()
+{
+ m_aModule.load(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("libgtk-x11-2.0.so.0")));
+ if (!m_aModule.is())
+ m_aModule.load(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("libgtk-x11-2.0.so")));
+ if (!m_aModule.is())
+ return;
+
+ m_page_setup_new = reinterpret_cast<page_setup_new_t>(m_aModule.getFunctionSymbol("gtk_page_setup_new"));
+ m_print_job_new = reinterpret_cast<print_job_new_t>(m_aModule.getFunctionSymbol("gtk_print_job_new"));
+ m_print_job_send = reinterpret_cast<print_job_send_t>(m_aModule.getFunctionSymbol("gtk_print_job_send"));
+ m_print_job_set_source_file = reinterpret_cast<print_job_set_source_file_t>(m_aModule.getFunctionSymbol("gtk_print_job_set_source_file"));
+ m_print_settings_get = reinterpret_cast<print_settings_get_t>(m_aModule.getFunctionSymbol("gtk_print_settings_get"));
+ m_print_settings_get_collate = reinterpret_cast<print_settings_get_collate_t>(m_aModule.getFunctionSymbol("gtk_print_settings_get_collate"));
+ m_print_settings_set_collate = reinterpret_cast<print_settings_set_collate_t>(m_aModule.getFunctionSymbol("gtk_print_settings_set_collate"));
+ m_print_settings_get_n_copies = reinterpret_cast<print_settings_get_n_copies_t>(m_aModule.getFunctionSymbol("gtk_print_settings_get_n_copies"));
+ m_print_settings_set_n_copies = reinterpret_cast<print_settings_set_n_copies_t>(m_aModule.getFunctionSymbol("gtk_print_settings_set_n_copies"));
+ m_print_settings_get_page_ranges = reinterpret_cast<print_settings_get_page_ranges_t>(m_aModule.getFunctionSymbol("gtk_print_settings_get_page_ranges"));
+ m_print_settings_set_print_pages = reinterpret_cast<print_settings_set_print_pages_t>(m_aModule.getFunctionSymbol("gtk_print_settings_set_print_pages"));
+ m_print_unix_dialog_new = reinterpret_cast<print_unix_dialog_new_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_new"));
+ m_print_unix_dialog_add_custom_tab = reinterpret_cast<print_unix_dialog_add_custom_tab_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_add_custom_tab"));
+ m_print_unix_dialog_get_selected_printer = reinterpret_cast<print_unix_dialog_get_selected_printer_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_get_selected_printer"));
+ m_print_unix_dialog_set_manual_capabilities = reinterpret_cast<print_unix_dialog_set_manual_capabilities_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_set_manual_capabilities"));
+ m_print_unix_dialog_get_settings = reinterpret_cast<print_unix_dialog_get_settings_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_get_settings"));
+ m_print_unix_dialog_set_settings = reinterpret_cast<print_unix_dialog_set_settings_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_set_settings"));
+ m_print_operation_set_support_selection = reinterpret_cast<print_operation_set_support_selection_t>(m_aModule.getFunctionSymbol("gtk_print_operation_set_support_selection"));
+ m_print_operation_set_has_selection = reinterpret_cast<print_operation_set_has_selection_t>(m_aModule.getFunctionSymbol("gtk_print_operation_set_has_selection"));
+ m_print_unix_dialog_set_support_selection = reinterpret_cast<print_unix_dialog_set_support_selection_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_set_support_selection"));
+ m_print_unix_dialog_set_has_selection = reinterpret_cast<print_unix_dialog_set_has_selection_t>(m_aModule.getFunctionSymbol("gtk_print_unix_dialog_set_has_selection"));
+}
+
+bool GtkPrintWrapper::supportsPrinting() const
+{
+ return
+ m_page_setup_new
+ && m_print_job_new
+ && m_print_job_send
+ && m_print_job_set_source_file
+ && m_print_settings_get
+ && m_print_settings_get_collate
+ && m_print_settings_set_collate
+ && m_print_settings_get_n_copies
+ && m_print_settings_set_n_copies
+ && m_print_settings_get_page_ranges
+ && m_print_settings_set_print_pages
+ && m_print_unix_dialog_new
+ && m_print_unix_dialog_add_custom_tab
+ && m_print_unix_dialog_get_selected_printer
+ && m_print_unix_dialog_set_manual_capabilities
+ && m_print_unix_dialog_get_settings
+ && m_print_unix_dialog_set_settings
+ ;
+}
+
+bool GtkPrintWrapper::supportsPrintSelection() const
+{
+ return
+ supportsPrinting()
+ && m_print_operation_set_support_selection
+ && m_print_operation_set_has_selection
+ && m_print_unix_dialog_set_support_selection
+ && m_print_unix_dialog_set_has_selection
+ ;
+}
+
+GtkPageSetup* GtkPrintWrapper::page_setup_new() const
+{
+ assert(m_page_setup_new);
+ return (*m_page_setup_new)();
+}
+
+GtkPrintJob* GtkPrintWrapper::print_job_new(const gchar* title, GtkPrinter* printer, GtkPrintSettings* settings, GtkPageSetup* page_setup) const
+{
+ assert(m_print_job_new);
+ return (*m_print_job_new)(title, printer, settings, page_setup);
+}
+
+void GtkPrintWrapper::print_job_send(GtkPrintJob* job, GtkPrintJobCompleteFunc callback, gpointer user_data, GDestroyNotify dnotify) const
+{
+ assert(m_print_job_send);
+ (*m_print_job_send)(job, callback, user_data, dnotify);
+}
+
+gboolean GtkPrintWrapper::print_job_set_source_file(GtkPrintJob* job, const gchar* filename, GError** error) const
+{
+ assert(m_print_job_set_source_file);
+ return (*m_print_job_set_source_file)(job, filename, error);
+}
+
+const gchar* GtkPrintWrapper::print_settings_get(GtkPrintSettings* settings, const gchar* key) const
+{
+ assert(m_print_settings_get);
+ return (*m_print_settings_get)(settings, key);
+}
+
+gboolean GtkPrintWrapper::print_settings_get_collate(GtkPrintSettings* settings) const
+{
+ assert(m_print_settings_get_collate);
+ return (*m_print_settings_get_collate)(settings);
+}
+
+void GtkPrintWrapper::print_settings_set_collate(GtkPrintSettings* settings, gboolean collate) const
+{
+ assert(m_print_settings_set_collate);
+ (*m_print_settings_set_collate)(settings, collate);
+}
+
+gint GtkPrintWrapper::print_settings_get_n_copies(GtkPrintSettings* settings) const
+{
+ assert(m_print_settings_get_n_copies);
+ return (*m_print_settings_get_n_copies)(settings);
+}
+
+void GtkPrintWrapper::print_settings_set_n_copies(GtkPrintSettings* settings, gint num_copies) const
+{
+ assert(m_print_settings_set_n_copies);
+ (*m_print_settings_set_n_copies)(settings, num_copies);
+}
+
+GtkPageRange* GtkPrintWrapper::print_settings_get_page_ranges(GtkPrintSettings* settings, gint* num_ranges) const
+{
+ assert(m_print_settings_get_page_ranges);
+ return (*m_print_settings_get_page_ranges)(settings, num_ranges);
+}
+
+void GtkPrintWrapper::print_settings_set_print_pages(GtkPrintSettings* settings, GtkPrintPages pages) const
+{
+ assert(m_print_settings_set_print_pages);
+ (*m_print_settings_set_print_pages)(settings, pages);
+}
+
+GtkWidget* GtkPrintWrapper::print_unix_dialog_new(const gchar* title, GtkWindow* parent) const
+{
+ assert(m_print_unix_dialog_new);
+ return (*m_print_unix_dialog_new)(title, parent);
+}
+
+void GtkPrintWrapper::print_unix_dialog_add_custom_tab(GtkPrintUnixDialog* dialog, GtkWidget* child, GtkWidget* tab_label) const
+{
+ assert(m_print_unix_dialog_add_custom_tab);
+ (*m_print_unix_dialog_add_custom_tab)(dialog, child, tab_label);
+}
+
+GtkPrinter* GtkPrintWrapper::print_unix_dialog_get_selected_printer(GtkPrintUnixDialog* dialog) const
+{
+ assert(m_print_unix_dialog_get_selected_printer);
+ return (*m_print_unix_dialog_get_selected_printer)(dialog);
+}
+
+void GtkPrintWrapper::print_unix_dialog_set_manual_capabilities(GtkPrintUnixDialog* dialog, GtkPrintCapabilities capabilities) const
+{
+ assert(m_print_unix_dialog_set_manual_capabilities);
+ (*m_print_unix_dialog_set_manual_capabilities)(dialog, capabilities);
+}
+
+GtkPrintSettings* GtkPrintWrapper::print_unix_dialog_get_settings(GtkPrintUnixDialog* dialog) const
+{
+ assert(m_print_unix_dialog_get_settings);
+ return (*m_print_unix_dialog_get_settings)(dialog);
+}
+
+void GtkPrintWrapper::print_unix_dialog_set_settings(GtkPrintUnixDialog* dialog, GtkPrintSettings* settings) const
+{
+ assert(m_print_unix_dialog_set_settings);
+ (*m_print_unix_dialog_set_settings)(dialog, settings);
+}
+
+void GtkPrintWrapper::print_operation_set_support_selection(GtkPrintOperation* op, gboolean support_selection) const
+{
+ assert(m_print_operation_set_support_selection);
+ (*m_print_operation_set_support_selection)(op, support_selection);
+}
+
+void GtkPrintWrapper::print_operation_set_has_selection(GtkPrintOperation* op, gboolean has_selection) const
+{
+ assert(m_print_operation_set_has_selection);
+ (*m_print_operation_set_has_selection)(op, has_selection);
+}
+
+void GtkPrintWrapper::print_unix_dialog_set_support_selection(GtkPrintUnixDialog* dialog, gboolean support_selection) const
+{
+ assert(m_print_unix_dialog_set_support_selection);
+ (*m_print_unix_dialog_set_support_selection)(dialog, support_selection);
+}
+
+void GtkPrintWrapper::print_unix_dialog_set_has_selection(GtkPrintUnixDialog* dialog, gboolean has_selection) const
+{
+ assert(m_print_unix_dialog_set_has_selection);
+ (*m_print_unix_dialog_set_has_selection)(dialog, has_selection);
+}
+
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/gdi/salprn-gtk.cxx b/vcl/unx/gtk/gdi/salprn-gtk.cxx
index 31238f503a94..fafe6e643cd9 100644
--- a/vcl/unx/gtk/gdi/salprn-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salprn-gtk.cxx
@@ -27,7 +27,11 @@
* instead of those above.
*/
+#include "gtkprintwrapper.hxx"
+
+#include "unx/gtk/gtkdata.hxx"
#include "unx/gtk/gtkframe.hxx"
+#include "unx/gtk/gtkinst.hxx"
#include "unx/gtk/gtkprn.hxx"
#include "vcl/configsettings.hxx"
@@ -71,6 +75,8 @@ namespace sheet = com::sun::star::sheet;
namespace io = com::sun::star::io;
namespace view = com::sun::star::view;
+using vcl::unx::GtkPrintWrapper;
+
using uno::UNO_QUERY;
class GtkPrintDialog
@@ -80,11 +86,11 @@ public:
bool run();
GtkPrinter* getPrinter() const
{
- return gtk_print_unix_dialog_get_selected_printer(GTK_PRINT_UNIX_DIALOG(m_pDialog));
+ return m_pWrapper->print_unix_dialog_get_selected_printer(GTK_PRINT_UNIX_DIALOG(m_pDialog));
}
GtkPrintSettings* getSettings() const
{
- return gtk_print_unix_dialog_get_settings(GTK_PRINT_UNIX_DIALOG(m_pDialog));
+ return m_pWrapper->print_unix_dialog_get_settings(GTK_PRINT_UNIX_DIALOG(m_pDialog));
}
void updateControllerPrintRange();
#if 0
@@ -125,6 +131,7 @@ private:
vcl::PrinterController& m_rController;
std::map<GtkWidget*, rtl::OUString> m_aControlToPropertyMap;
std::map<GtkWidget*, sal_Int32> m_aControlToNumValMap;
+ boost::shared_ptr<GtkPrintWrapper> m_pWrapper;
};
@@ -161,6 +168,17 @@ GtkSalPrinter_Impl::~GtkSalPrinter_Impl()
}
}
+namespace
+{
+
+GtkInstance const&
+lcl_getGtkSalInstance()
+{
+ // we _know_ this is GtkInstance
+ return *static_cast<GtkInstance*>(GetGtkSalData()->m_pInstance);
+}
+
+}
GtkSalPrinter::GtkSalPrinter(SalInfoPrinter* const i_pInfoPrinter)
: PspSalPrinter(i_pInfoPrinter)
@@ -273,7 +291,9 @@ GtkSalPrinter::EndJob()
if (!bRet || !m_pImpl || m_pImpl->m_sSpoolFile.isEmpty())
return bRet;
- GtkPageSetup* pPageSetup = gtk_page_setup_new();
+ boost::shared_ptr<GtkPrintWrapper> const pWrapper(lcl_getGtkSalInstance().getPrintWrapper());
+
+ GtkPageSetup* pPageSetup = pWrapper->page_setup_new();
#if 0
//todo
gtk_page_setup_set_orientation(pPageSetup,);
@@ -284,14 +304,14 @@ GtkSalPrinter::EndJob()
gtk_page_setup_set_right_margin(pPageSetup,);
#endif
- GtkPrintJob* const pJob = gtk_print_job_new(
+ GtkPrintJob* const pJob = pWrapper->print_job_new(
rtl::OUStringToOString(m_pImpl->m_sJobName, RTL_TEXTENCODING_UTF8).getStr(),
m_pImpl->m_pPrinter, m_pImpl->m_pSettings, pPageSetup);
GError* error = NULL;
- bRet = gtk_print_job_set_source_file(pJob, m_pImpl->m_sSpoolFile.getStr(), &error);
+ bRet = pWrapper->print_job_set_source_file(pJob, m_pImpl->m_sSpoolFile.getStr(), &error);
if (bRet)
- gtk_print_job_send(pJob, NULL, NULL, NULL);
+ pWrapper->print_job_send(pJob, NULL, NULL, NULL);
else
{
//To-Do, do something with this
@@ -371,7 +391,8 @@ lcl_extractHelpTextsOrIds(
}
GtkPrintDialog::GtkPrintDialog(vcl::PrinterController& io_rController)
- : m_rController(io_rController)
+ : m_rController(io_rController)
+ , m_pWrapper(lcl_getGtkSalInstance().getPrintWrapper())
{
impl_initDialog();
impl_initCustomTab();
@@ -384,7 +405,7 @@ void
GtkPrintDialog::impl_initDialog()
{
//To-Do, like fpicker, set UI language
- m_pDialog = gtk_print_unix_dialog_new(NULL, NULL);
+ m_pDialog = m_pWrapper->print_unix_dialog_new(NULL, NULL);
Window* const pTopWindow(Application::GetActiveTopWindow());
if (pTopWindow)
@@ -398,7 +419,7 @@ GtkPrintDialog::impl_initDialog()
}
}
- gtk_print_unix_dialog_set_manual_capabilities(GTK_PRINT_UNIX_DIALOG(m_pDialog),
+ m_pWrapper->print_unix_dialog_set_manual_capabilities(GTK_PRINT_UNIX_DIALOG(m_pDialog),
GtkPrintCapabilities(GTK_PRINT_CAPABILITY_COPIES | GTK_PRINT_CAPABILITY_COLLATE |
// GTK_PRINT_CAPABILITY_REVERSE|GTK_PRINT_CAPABILITY_GENERATE_PDF|GTK_PRINT_CAPABILITY_GENERATE_PS |
GTK_PRINT_CAPABILITY_REVERSE|GTK_PRINT_CAPABILITY_GENERATE_PS |
@@ -692,7 +713,7 @@ GtkPrintDialog::impl_initCustomTab()
for (CustomTabs_t::const_reverse_iterator aI = aCustomTabs.rbegin(); aI != aEnd; ++aI)
{
gtk_widget_show_all(aI->first);
- gtk_print_unix_dialog_add_custom_tab(GTK_PRINT_UNIX_DIALOG(m_pDialog), aI->first,
+ m_pWrapper->print_unix_dialog_add_custom_tab(GTK_PRINT_UNIX_DIALOG(m_pDialog), aI->first,
gtk_label_new(rtl::OUStringToOString(aI->second, RTL_TEXTENCODING_UTF8).getStr()));
}
#endif
@@ -713,12 +734,12 @@ GtkPrintDialog::impl_initPrintRange()
if (nSelectionType == 2)
{
GtkPrintUnixDialog* const pDialog(GTK_PRINT_UNIX_DIALOG(m_pDialog));
- gtk_print_unix_dialog_set_support_selection(pDialog, TRUE);
- gtk_print_unix_dialog_set_has_selection(pDialog, TRUE);
+ m_pWrapper->print_unix_dialog_set_support_selection(pDialog, TRUE);
+ m_pWrapper->print_unix_dialog_set_has_selection(pDialog, TRUE);
GtkPrintSettings* const pSettings(getSettings());
- gtk_print_settings_set_print_pages(pSettings, GTK_PRINT_PAGES_SELECTION);
- gtk_print_unix_dialog_set_settings(pDialog, pSettings);
+ m_pWrapper->print_settings_set_print_pages(pSettings, GTK_PRINT_PAGES_SELECTION);
+ m_pWrapper->print_unix_dialog_set_settings(pDialog, pSettings);
g_object_unref(G_OBJECT(pSettings));
}
}
@@ -970,7 +991,8 @@ void
GtkPrintDialog::updateControllerPrintRange()
{
GtkPrintSettings* const pSettings(getSettings());
- if (const gchar* const pStr = gtk_print_settings_get(pSettings, GTK_PRINT_SETTINGS_PRINT_PAGES))
+ // TODO: use get_print_pages
+ if (const gchar* const pStr = m_pWrapper->print_settings_get(pSettings, GTK_PRINT_SETTINGS_PRINT_PAGES))
{
beans::PropertyValue* pVal = m_rController.getValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintRange")));
if (!pVal)
@@ -995,7 +1017,7 @@ GtkPrintDialog::updateControllerPrintRange()
{
rtl::OUStringBuffer sBuf;
gint num_ranges;
- const GtkPageRange* const pRanges = gtk_print_settings_get_page_ranges(pSettings, &num_ranges);
+ const GtkPageRange* const pRanges = m_pWrapper->print_settings_get_page_ranges(pSettings, &num_ranges);
for (gint i = 0; i != num_ranges && pRanges; ++i)
{
sBuf.append(pRanges[i].start+1);
@@ -1037,25 +1059,25 @@ GtkPrintDialog::impl_readFromSettings()
bool bChanged(false);
- const gint nOldCopyCount(gtk_print_settings_get_n_copies(pSettings));
+ const gint nOldCopyCount(m_pWrapper->print_settings_get_n_copies(pSettings));
const sal_Int32 nCopyCount(aCopyCount.toInt32());
if (nCopyCount > 0 && nOldCopyCount != nCopyCount)
{
bChanged = true;
- gtk_print_settings_set_n_copies(pSettings, sal::static_int_cast<gint>(nCopyCount));
+ m_pWrapper->print_settings_set_n_copies(pSettings, sal::static_int_cast<gint>(nCopyCount));
}
- const gboolean bOldCollate(gtk_print_settings_get_collate(pSettings));
+ const gboolean bOldCollate(m_pWrapper->print_settings_get_collate(pSettings));
const bool bCollate(aCollate.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("true")));
if (bOldCollate != bCollate)
{
bChanged = true;
- gtk_print_settings_set_collate(pSettings, bCollate);
+ m_pWrapper->print_settings_set_collate(pSettings, bCollate);
}
// TODO: wth was this var. meant for?
(void) bChanged;
- gtk_print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(m_pDialog), pSettings);
+ m_pWrapper->print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(m_pDialog), pSettings);
g_object_unref(G_OBJECT(pSettings));
}
@@ -1070,10 +1092,10 @@ const
const rtl::OUString aPrintDialogStr(RTL_CONSTASCII_USTRINGPARAM("PrintDialog"));
pItem->setValue(aPrintDialogStr,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CopyCount")),
- rtl::OUString::valueOf(gtk_print_settings_get_n_copies(pSettings)));
+ rtl::OUString::valueOf(m_pWrapper->print_settings_get_n_copies(pSettings)));
pItem->setValue(aPrintDialogStr,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Collate")),
- gtk_print_settings_get_collate(pSettings)
+ m_pWrapper->print_settings_get_collate(pSettings)
? rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("true"))
: rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("false")))
;
diff --git a/vcl/unx/gtk/inc/gtkprintwrapper.hxx b/vcl/unx/gtk/inc/gtkprintwrapper.hxx
new file mode 100644
index 000000000000..e89fb4c4f8c5
--- /dev/null
+++ b/vcl/unx/gtk/inc/gtkprintwrapper.hxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 David Tardon, Red Hat Inc. <dtardon@redhat.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef UNX_GTK_INC_GTKPRINTWRAPPER_HXX_INCLUDED
+#define UNX_GTK_INC_GTKPRINTWRAPPER_HXX_INCLUDED
+
+#include <boost/noncopyable.hpp>
+
+#include <gtk/gtk.h>
+#include <gtk/gtkunixprint.h>
+
+#include <osl/module.hxx>
+
+namespace vcl
+{
+namespace unx
+{
+
+class GtkPrintWrapper : private boost::noncopyable
+{
+public:
+ GtkPrintWrapper();
+ ~GtkPrintWrapper();
+
+ bool supportsPrinting() const;
+ bool supportsPrintSelection() const;
+
+ // general printing support, since 2.10.0
+ GtkPageSetup* page_setup_new() const;
+
+ GtkPrintJob* print_job_new(const gchar* title, GtkPrinter* printer, GtkPrintSettings* settings, GtkPageSetup* page_setup) const;
+ void print_job_send(GtkPrintJob* job, GtkPrintJobCompleteFunc callback, gpointer user_data, GDestroyNotify dnotify) const;
+ gboolean print_job_set_source_file(GtkPrintJob* job, const gchar* filename, GError** error) const;
+
+ const gchar* print_settings_get(GtkPrintSettings* settings, const gchar* key) const;
+ gboolean print_settings_get_collate(GtkPrintSettings* settings) const;
+ void print_settings_set_collate(GtkPrintSettings* settings, gboolean collate) const;
+ gint print_settings_get_n_copies(GtkPrintSettings* settings) const;
+ void print_settings_set_n_copies(GtkPrintSettings* settings, gint num_copies) const;
+ GtkPageRange* print_settings_get_page_ranges(GtkPrintSettings* settings, gint* num_ranges) const;
+ void print_settings_set_print_pages(GtkPrintSettings* settings, GtkPrintPages pages) const;
+
+ GtkWidget* print_unix_dialog_new(const gchar* title, GtkWindow* parent) const;
+ void print_unix_dialog_add_custom_tab(GtkPrintUnixDialog* dialog, GtkWidget* child, GtkWidget* tab_label) const;
+ GtkPrinter* print_unix_dialog_get_selected_printer(GtkPrintUnixDialog* dialog) const;
+ void print_unix_dialog_set_manual_capabilities(GtkPrintUnixDialog* dialog, GtkPrintCapabilities capabilities) const;
+ GtkPrintSettings* print_unix_dialog_get_settings(GtkPrintUnixDialog* dialog) const;
+ void print_unix_dialog_set_settings(GtkPrintUnixDialog* dialog, GtkPrintSettings* settings) const;
+
+ // print selection support, since 2.17.4
+ void print_operation_set_support_selection(GtkPrintOperation* op, gboolean support_selection) const;
+ void print_operation_set_has_selection(GtkPrintOperation* op, gboolean has_selection) const;
+ void print_unix_dialog_set_support_selection(GtkPrintUnixDialog* dialog, gboolean support_selection) const;
+ void print_unix_dialog_set_has_selection(GtkPrintUnixDialog* dialog, gboolean has_selection) const;
+
+private:
+ void impl_load();
+
+private:
+ typedef GtkPageSetup* (* page_setup_new_t)();
+ typedef GtkPrintJob* (* print_job_new_t)(const gchar*, GtkPrinter*, GtkPrintSettings*, GtkPageSetup*);
+ typedef void (* print_job_send_t)(GtkPrintJob*, GtkPrintJobCompleteFunc, gpointer, GDestroyNotify);
+ typedef gboolean (* print_job_set_source_file_t)(GtkPrintJob*, const gchar*, GError**);
+ typedef const gchar* (* print_settings_get_t)(GtkPrintSettings*, const gchar*);
+ typedef gboolean (* print_settings_get_collate_t)(GtkPrintSettings*);
+ typedef void (* print_settings_set_collate_t)(GtkPrintSettings*, gboolean);
+ typedef gint (* print_settings_get_n_copies_t)(GtkPrintSettings*);
+ typedef void (* print_settings_set_n_copies_t)(GtkPrintSettings*, gint);
+ typedef GtkPageRange* (* print_settings_get_page_ranges_t)(GtkPrintSettings*, gint*);
+ typedef void (* print_settings_set_print_pages_t)(GtkPrintSettings*, GtkPrintPages);
+ typedef GtkWidget* (* print_unix_dialog_new_t)(const gchar*, GtkWindow*);
+ typedef void (* print_unix_dialog_add_custom_tab_t)(GtkPrintUnixDialog*, GtkWidget*, GtkWidget*);
+ typedef GtkPrinter* (* print_unix_dialog_get_selected_printer_t)(GtkPrintUnixDialog*);
+ typedef void (* print_unix_dialog_set_manual_capabilities_t)(GtkPrintUnixDialog*, GtkPrintCapabilities);
+ typedef GtkPrintSettings* (* print_unix_dialog_get_settings_t)(GtkPrintUnixDialog*);
+ typedef void (* print_unix_dialog_set_settings_t)(GtkPrintUnixDialog*, GtkPrintSettings*);
+ typedef void (* print_operation_set_support_selection_t)(GtkPrintOperation*, gboolean);
+ typedef void (* print_operation_set_has_selection_t)(GtkPrintOperation*, gboolean);
+ typedef void (* print_unix_dialog_set_support_selection_t)(GtkPrintUnixDialog*, gboolean);
+ typedef void (* print_unix_dialog_set_has_selection_t)(GtkPrintUnixDialog*, gboolean);
+
+private:
+ osl::Module m_aModule;
+
+ // general printing support, since 2.10.0
+ page_setup_new_t m_page_setup_new;
+ print_job_new_t m_print_job_new;
+ print_job_send_t m_print_job_send;
+ print_job_set_source_file_t m_print_job_set_source_file;
+ print_settings_get_t m_print_settings_get;
+ print_settings_get_collate_t m_print_settings_get_collate;
+ print_settings_set_collate_t m_print_settings_set_collate;
+ print_settings_get_n_copies_t m_print_settings_get_n_copies;
+ print_settings_set_n_copies_t m_print_settings_set_n_copies;
+ print_settings_get_page_ranges_t m_print_settings_get_page_ranges;
+ print_settings_set_print_pages_t m_print_settings_set_print_pages;
+ print_unix_dialog_new_t m_print_unix_dialog_new;
+ print_unix_dialog_add_custom_tab_t m_print_unix_dialog_add_custom_tab;
+ print_unix_dialog_get_selected_printer_t m_print_unix_dialog_get_selected_printer;
+ print_unix_dialog_set_manual_capabilities_t m_print_unix_dialog_set_manual_capabilities;
+ print_unix_dialog_get_settings_t m_print_unix_dialog_get_settings;
+ print_unix_dialog_set_settings_t m_print_unix_dialog_set_settings;
+
+ // print selection support, since 2.17.4
+ print_operation_set_support_selection_t m_print_operation_set_support_selection;
+ print_operation_set_has_selection_t m_print_operation_set_has_selection;
+ print_unix_dialog_set_support_selection_t m_print_unix_dialog_set_support_selection;
+ print_unix_dialog_set_has_selection_t m_print_unix_dialog_set_has_selection;
+};
+
+}
+}
+
+#endif // UNX_GTK_INC_GTKPRINTWRAPPER_HXX_INCLUDED
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */