From fc2e01d9a262c6ae48acabc3ff1605eb804acf1e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 16 May 2021 00:52:55 +0200 Subject: [PATCH] Make GtkPageSetup-related functions private These functions don't need to be members of wxGtkPrintNativeData as they don't use this object at all, so one shouldn't be required to call them. And rather than making them static, just make them private functions instead. No real changes, this is just a refactoring. --- include/wx/gtk/print.h | 4 ---- src/gtk/print.cpp | 17 +++++++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/wx/gtk/print.h b/include/wx/gtk/print.h index 9458ce7643..22b2b86f21 100644 --- a/include/wx/gtk/print.h +++ b/include/wx/gtk/print.h @@ -197,10 +197,6 @@ public: GtkPrintContext *GetPrintContext() { return m_context; } void SetPrintContext(GtkPrintContext *context) {m_context = context; } - - GtkPageSetup* GetPageSetupFromSettings(GtkPrintSettings* settings); - void SetPageSetupToSettings(GtkPrintSettings* settings, GtkPageSetup* page_setup); - private: // NB: m_config is created and owned by us, but the other objects are not // and their accessors don't change their ref count. diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index 3cc38f6bf0..751fb2afc5 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -583,8 +583,11 @@ void wxGtkPrintNativeData::SetPrintConfig( GtkPrintSettings * config ) } } +namespace +{ + // Extract page setup from settings. -GtkPageSetup* wxGtkPrintNativeData::GetPageSetupFromSettings(GtkPrintSettings* settings) +GtkPageSetup* GetPageSetupFromSettings(GtkPrintSettings* settings) { GtkPageSetup* page_setup = gtk_page_setup_new(); gtk_page_setup_set_orientation (page_setup, gtk_print_settings_get_orientation (settings)); @@ -600,12 +603,14 @@ GtkPageSetup* wxGtkPrintNativeData::GetPageSetupFromSettings(GtkPrintSettings* s } // Insert page setup into a given GtkPrintSettings. -void wxGtkPrintNativeData::SetPageSetupToSettings(GtkPrintSettings* settings, GtkPageSetup* page_setup) +void SetPageSetupToSettings(GtkPrintSettings* settings, GtkPageSetup* page_setup) { gtk_print_settings_set_orientation ( settings, gtk_page_setup_get_orientation (page_setup)); gtk_print_settings_set_paper_size ( settings, gtk_page_setup_get_paper_size (page_setup)); } +} // anonymous namespace + //---------------------------------------------------------------------------- // wxGtkPrintDialog //---------------------------------------------------------------------------- @@ -692,7 +697,7 @@ int wxGtkPrintDialog::ShowModal() // If the settings are OK, we restore it. if (settings != NULL) gtk_print_operation_set_print_settings (printOp, settings); - GtkPageSetup* pgSetup = native->GetPageSetupFromSettings(settings); + GtkPageSetup* pgSetup = GetPageSetupFromSettings(settings); gtk_print_operation_set_default_page_setup (printOp, pgSetup); g_object_unref(pgSetup); @@ -733,7 +738,7 @@ int wxGtkPrintDialog::ShowModal() g_object_get(printOp, "default-page-setup", &defPageSetup, NULL); if ( defPageSetup ) { - native->SetPageSetupToSettings(newSettings, defPageSetup); + SetPageSetupToSettings(newSettings, defPageSetup); g_object_unref(defPageSetup); } @@ -816,7 +821,7 @@ int wxGtkPageSetupDialog::ShowModal() GtkPrintSettings* nativeData = native->GetPrintConfig(); // We only need the pagesetup data which are part of the settings. - GtkPageSetup* oldPageSetup = native->GetPageSetupFromSettings(nativeData); + GtkPageSetup* oldPageSetup = GetPageSetupFromSettings(nativeData); // If the user used a custom paper format the last time he printed, we have to restore it too. wxPaperSize paperId = m_pageDialogData.GetPrintData().GetPaperId(); @@ -871,7 +876,7 @@ int wxGtkPageSetupDialog::ShowModal() wxGtkObject newPageSetup(gtk_page_setup_unix_dialog_get_page_setup( GTK_PAGE_SETUP_UNIX_DIALOG(dlg))); - native->SetPageSetupToSettings(nativeData, newPageSetup); + SetPageSetupToSettings(nativeData, newPageSetup); m_pageDialogData.GetPrintData().ConvertFromNative();