[gtkmm] Glib::KeyFile is ref-counted



commit edcd8221563dbd786223c5238ad631e54b4708e3
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sat Feb 2 10:17:35 2019 +0100

    Glib::KeyFile is ref-counted
    
    * gtk/src/pagesetup.[ccg|hg]:
    * gtk/src/papersize.[ccg|hg]:
    * gtk/src/printsettings.[ccg|hg]: Store Glib::KeyFile in a Glib::RefPtr.

 gtk/src/pagesetup.ccg     | 12 ++++++------
 gtk/src/pagesetup.hg      | 14 ++++++--------
 gtk/src/papersize.ccg     |  8 ++++----
 gtk/src/papersize.hg      |  7 +++----
 gtk/src/printsettings.ccg | 12 ++++++------
 gtk/src/printsettings.hg  | 14 ++++++--------
 6 files changed, 31 insertions(+), 36 deletions(-)
---
diff --git a/gtk/src/pagesetup.ccg b/gtk/src/pagesetup.ccg
index a94d037d..f6fefe04 100644
--- a/gtk/src/pagesetup.ccg
+++ b/gtk/src/pagesetup.ccg
@@ -20,7 +20,7 @@
 namespace Gtk
 {
 
-Glib::RefPtr<PageSetup> PageSetup::create_from_key_file(const Glib::KeyFile& key_file)
+Glib::RefPtr<PageSetup> PageSetup::create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file)
 {
   auto result = PageSetup::create();
 
@@ -29,7 +29,7 @@ Glib::RefPtr<PageSetup> PageSetup::create_from_key_file(const Glib::KeyFile& key
   return result;
 }
 
-Glib::RefPtr<PageSetup> PageSetup::create_from_key_file(const Glib::KeyFile& key_file, const Glib::ustring& 
group_name)
+Glib::RefPtr<PageSetup> PageSetup::create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file, 
const Glib::ustring& group_name)
 {
   auto result = PageSetup::create();
 
@@ -47,15 +47,15 @@ Glib::RefPtr<PageSetup> PageSetup::create_from_file(const std::string& file_name
   return result;
 }
 
-void PageSetup::save_to_key_file(Glib::KeyFile& key_file) const
+void PageSetup::save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file) const
 {
-  gtk_page_setup_to_key_file(const_cast<GtkPageSetup*>(gobj()), (key_file).gobj(), nullptr);
+  gtk_page_setup_to_key_file(const_cast<GtkPageSetup*>(gobj()), Glib::unwrap(key_file), nullptr);
 }
 
-bool PageSetup::load_from_key_file(const Glib::KeyFile& key_file)
+bool PageSetup::load_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file)
 {
   GError* gerror = nullptr;
-  bool retvalue = gtk_page_setup_load_key_file(gobj(), const_cast<GKeyFile*>((key_file).gobj()), nullptr, 
&(gerror));
+  bool retvalue = gtk_page_setup_load_key_file(gobj(), const_cast<GKeyFile*>(Glib::unwrap(key_file)), 
nullptr, &(gerror));
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
 
diff --git a/gtk/src/pagesetup.hg b/gtk/src/pagesetup.hg
index 3da6d225..df42a833 100644
--- a/gtk/src/pagesetup.hg
+++ b/gtk/src/pagesetup.hg
@@ -60,7 +60,7 @@ public:
   *
   * @newin{2,14}
   */
-  static Glib::RefPtr<PageSetup> create_from_key_file(const Glib::KeyFile& key_file);
+  static Glib::RefPtr<PageSetup> create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file);
 
  /** Reads the page setup from the group @a group_name in the key file @a key_file.
   * Returns a new PageSetup object with the restored
@@ -74,7 +74,7 @@ public:
   *
   * @newin{2,14}
   */
-  static Glib::RefPtr<PageSetup> create_from_key_file(const Glib::KeyFile& key_file, const Glib::ustring& 
group_name);
+  static Glib::RefPtr<PageSetup> create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file, 
const Glib::ustring& group_name);
   _IGNORE(gtk_page_setup_new_from_key_file)
 
  /** Reads the page setup from the file @a file_name. Returns a
@@ -94,8 +94,7 @@ public:
   //The from_ infix was added to these functions to make them clearer. GTK+ didn't want to change them.
   _WRAP_METHOD(bool load_from_file(const std::string& file_name), gtk_page_setup_load_file, errthrow)
 
-  #m4 _CONVERSION(`const Glib::KeyFile&', `GKeyFile*', __FCR2P)
-  _WRAP_METHOD(bool load_from_key_file(const Glib::KeyFile& key_file, const Glib::ustring& group_name), 
gtk_page_setup_load_key_file, errthrow)
+  _WRAP_METHOD(bool load_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file, const 
Glib::ustring& group_name), gtk_page_setup_load_key_file, errthrow)
 
  /** Reads the page setup from the "Page Setup" group in the key file @a key_file.
   *
@@ -106,7 +105,7 @@ public:
   *
   * @newin{2,14}
   */
-  bool load_from_key_file(const Glib::KeyFile& key_file);
+  bool load_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file);
 
   _WRAP_METHOD(PageOrientation get_orientation() const, gtk_page_setup_get_orientation)
   _WRAP_METHOD(void set_orientation(PageOrientation orientation), gtk_page_setup_set_orientation)
@@ -139,8 +138,7 @@ public:
   //The save_ prefix was added to these functions to make them clearer. GTK+ didn't want to change them.
   _WRAP_METHOD(bool save_to_file(const std::string& file_name) const, gtk_page_setup_to_file, errthrow)
 
-  #m4 _CONVERSION(`Glib::KeyFile&', `GKeyFile*', __FR2P)
-  _WRAP_METHOD(void save_to_key_file(Glib::KeyFile& key_file, const Glib::ustring& group_name) const, 
gtk_page_setup_to_key_file)
+  _WRAP_METHOD(void save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file, const Glib::ustring& 
group_name) const, gtk_page_setup_to_key_file)
 
   /** This function adds the page setup from @a setup to @a key_file,
    * in the group "Page Setup"
@@ -149,7 +147,7 @@ public:
    *
    * @param key_file The G::KeyFile to save the page setup to.
    */
-  void save_to_key_file(Glib::KeyFile& key_file) const;
+  void save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file) const;
 };
 
 } // namespace Gtk
diff --git a/gtk/src/papersize.ccg b/gtk/src/papersize.ccg
index f7dadd79..c6f38aff 100644
--- a/gtk/src/papersize.ccg
+++ b/gtk/src/papersize.ccg
@@ -57,10 +57,10 @@ PaperSize::PaperSize(const Glib::ustring& name, const Glib::ustring& display_nam
                                      GtkUnit(unit)))
 {}
 
-PaperSize::PaperSize(const Glib::KeyFile& key_file, const Glib::ustring& group_name)
+PaperSize::PaperSize(const Glib::RefPtr<const Glib::KeyFile>& key_file, const Glib::ustring& group_name)
 {
   GError* gerror = nullptr;
-  gobject_ = gtk_paper_size_new_from_key_file(const_cast<GKeyFile*>(key_file.gobj()),
+  gobject_ = gtk_paper_size_new_from_key_file(const_cast<GKeyFile*>(Glib::unwrap(key_file)),
     Glib::c_str_or_nullptr(group_name), &gerror);
 
   if (gerror)
@@ -78,9 +78,9 @@ PaperSize::operator bool() const
   return gobj();
 }
 
-void PaperSize::save_to_key_file(Glib::KeyFile& key_file)
+void PaperSize::save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file)
 {
-  gtk_paper_size_to_key_file( gobj(), (key_file).gobj(), nullptr);
+  gtk_paper_size_to_key_file( gobj(), Glib::unwrap(key_file), nullptr);
 }
 
 // static
diff --git a/gtk/src/papersize.hg b/gtk/src/papersize.hg
index 33bd694a..266bf854 100644
--- a/gtk/src/papersize.hg
+++ b/gtk/src/papersize.hg
@@ -72,7 +72,7 @@ public:
    *
    * @throws Gtk::PrintError, Glib::KeyFileError
    */
-  explicit PaperSize(const Glib::KeyFile& key_file, const Glib::ustring& group_name = {});
+  explicit PaperSize(const Glib::RefPtr<const Glib::KeyFile>& key_file, const Glib::ustring& group_name = 
{});
 
   _IGNORE(gtk_paper_size_copy, gtk_paper_size_free, gtk_paper_size_is_equal)
   bool equal(const PaperSize& other) const;
@@ -108,8 +108,7 @@ public:
 
   _WRAP_METHOD(static Glib::ustring get_default(), gtk_paper_size_get_default)
 
-  #m4 _CONVERSION(`Glib::KeyFile&', `GKeyFile*', __FR2P)
-  _WRAP_METHOD(void save_to_key_file(Glib::KeyFile& key_file, const Glib::ustring& group_name), 
gtk_paper_size_to_key_file)
+  _WRAP_METHOD(void save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file, const Glib::ustring& 
group_name), gtk_paper_size_to_key_file)
 
   /** This function adds the paper size to @a key_file in the first group.
    *
@@ -117,7 +116,7 @@ public:
    *
    * @param key_file The Glib::KeyFile to save the paper size to.
    */
-  void save_to_key_file(Glib::KeyFile& key_file);
+  void save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file);
 };
 
 /** @relates Gtk::PaperSize */
diff --git a/gtk/src/printsettings.ccg b/gtk/src/printsettings.ccg
index 65b37d2d..94f68ec3 100644
--- a/gtk/src/printsettings.ccg
+++ b/gtk/src/printsettings.ccg
@@ -73,7 +73,7 @@ const Glib::ustring PrintSettings::Keys::OUTPUT_URI = GTK_PRINT_SETTINGS_OUTPUT_
 const Glib::ustring PrintSettings::Keys::WIN32_DRIVER_VERSION = GTK_PRINT_SETTINGS_WIN32_DRIVER_VERSION;
 const Glib::ustring PrintSettings::Keys::WIN32_DRIVER_EXTRA = GTK_PRINT_SETTINGS_WIN32_DRIVER_EXTRA;
 
-Glib::RefPtr<PrintSettings> PrintSettings::create_from_key_file(const Glib::KeyFile& key_file)
+Glib::RefPtr<PrintSettings> PrintSettings::create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& 
key_file)
 {
   auto result = PrintSettings::create();
 
@@ -82,7 +82,7 @@ Glib::RefPtr<PrintSettings> PrintSettings::create_from_key_file(const Glib::KeyF
   return result;
 }
 
-Glib::RefPtr<PrintSettings> PrintSettings::create_from_key_file(const Glib::KeyFile& key_file, const 
Glib::ustring& group_name)
+Glib::RefPtr<PrintSettings> PrintSettings::create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& 
key_file, const Glib::ustring& group_name)
 {
   auto result = PrintSettings::create();
 
@@ -138,19 +138,19 @@ void PrintSettings::set_page_ranges(const std::vector<PageRange>& page_ranges)
     page_ranges.size());
 }
 
-bool PrintSettings::load_from_key_file(const Glib::KeyFile& key_file)
+bool PrintSettings::load_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file)
 {
   GError* gerror = nullptr;
-  bool retvalue = gtk_print_settings_load_key_file(gobj(), const_cast<GKeyFile*>((key_file).gobj()), 
nullptr, &(gerror));
+  bool retvalue = gtk_print_settings_load_key_file(gobj(), const_cast<GKeyFile*>(Glib::unwrap(key_file)), 
nullptr, &(gerror));
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
 
   return retvalue;
 }
 
-void PrintSettings::save_to_key_file(Glib::KeyFile& key_file) const
+void PrintSettings::save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file) const
 {
-  gtk_print_settings_to_key_file(const_cast<GtkPrintSettings*>(gobj()), (key_file).gobj(), nullptr);
+  gtk_print_settings_to_key_file(const_cast<GtkPrintSettings*>(gobj()), Glib::unwrap(key_file), nullptr);
 }
 
 } // namespace Gtk
diff --git a/gtk/src/printsettings.hg b/gtk/src/printsettings.hg
index e9b51f2d..e1d4f82a 100644
--- a/gtk/src/printsettings.hg
+++ b/gtk/src/printsettings.hg
@@ -93,7 +93,7 @@ public:
   *
   * @newin{2,14}
   */
-  static Glib::RefPtr<PrintSettings> create_from_key_file(const Glib::KeyFile& key_file);
+  static Glib::RefPtr<PrintSettings> create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file);
 
  /** Reads the print settings from the group @a group_name in @a key_file.
   * Returns a new PrintSettings object with the restored settings,
@@ -108,7 +108,7 @@ public:
   *
   * @newin{2,14}
   */
-  static Glib::RefPtr<PrintSettings> create_from_key_file(const Glib::KeyFile& key_file, const 
Glib::ustring& group_name);
+  static Glib::RefPtr<PrintSettings> create_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file, 
const Glib::ustring& group_name);
   _IGNORE(gtk_print_settings_new_from_key_file)
 
  /** Reads the print settings from @a file_name. Returns a new PrintSettings
@@ -166,8 +166,7 @@ public:
   //The from_ infix was added to these functions to make them clearer. GTK+ didn't want to change them.
   _WRAP_METHOD(bool load_from_file(const std::string& file_name), gtk_print_settings_load_file, errthrow)
 
-  #m4 _CONVERSION(`const Glib::KeyFile&', `GKeyFile*', __FCR2P)
-  _WRAP_METHOD(bool load_from_key_file(const Glib::KeyFile& key_file, const Glib::ustring& group_name), 
gtk_print_settings_load_key_file, errthrow)
+  _WRAP_METHOD(bool load_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file, const 
Glib::ustring& group_name), gtk_print_settings_load_key_file, errthrow)
 
  /** Reads the print settings from the @a key_file.
   * See save_to_key_file().
@@ -179,14 +178,13 @@ public:
   *
   * @newin{2,14}
   */
-  bool load_from_key_file(const Glib::KeyFile& key_file);
+  bool load_from_key_file(const Glib::RefPtr<const Glib::KeyFile>& key_file);
 
 
   //The save_ prefix was added to these functions to make them clearer. GTK+ didn't want to change them.
   _WRAP_METHOD(bool save_to_file(const std::string& file_name) const, gtk_print_settings_to_file, errthrow)
 
-  #m4 _CONVERSION(`Glib::KeyFile&', `GKeyFile*', __FR2P)
-  _WRAP_METHOD(void save_to_key_file(Glib::KeyFile& key_file, const Glib::ustring& group_name) const, 
gtk_print_settings_to_key_file)
+  _WRAP_METHOD(void save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file, const Glib::ustring& 
group_name) const, gtk_print_settings_to_key_file)
 
   /** This function adds the print settings from @a settings to @a key_file,
    * in the "Print Settings" group.
@@ -195,7 +193,7 @@ public:
    *
    * @param key_file The Glib::KeyFile to save the print settings to.
    */
-  void save_to_key_file(Glib::KeyFile& key_file) const;
+  void save_to_key_file(const Glib::RefPtr<Glib::KeyFile>& key_file) const;
 
   //TODO: add a @see link?
   _WRAP_METHOD(bool has_key(const Glib::ustring& key) const, gtk_print_settings_has_key)


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