[gtkmm] Gtk: Update for the latest gtk4 (remove Gtk::FileFilter::Info, etc.)



commit 93f9891a8d06c6cc06f141d098ca82b60bc3bafd
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sun Jul 12 12:00:36 2020 +0200

    Gtk: Update for the latest gtk4 (remove Gtk::FileFilter::Info, etc.)

 gtk/src/bitset.hg          |  5 ++++-
 gtk/src/filechooser.hg     | 31 ++++++++++-----------------
 gtk/src/filefilter.ccg     | 51 +--------------------------------------------
 gtk/src/filefilter.hg      | 52 ++--------------------------------------------
 gtk/src/multiselection.hg  |  1 +
 gtk/src/noselection.hg     |  1 +
 gtk/src/singleselection.hg |  1 +
 tools/m4/convert_gtk.m4    |  1 -
 8 files changed, 21 insertions(+), 122 deletions(-)
---
diff --git a/gtk/src/bitset.hg b/gtk/src/bitset.hg
index cdabc887..da0986c1 100644
--- a/gtk/src/bitset.hg
+++ b/gtk/src/bitset.hg
@@ -68,6 +68,9 @@ public:
 
   _WRAP_METHOD(bool contains(guint value) const, gtk_bitset_contains)
   _WRAP_METHOD(bool is_empty() const, gtk_bitset_is_empty)
+  _WRAP_METHOD(guint64 get_size() const, gtk_bitset_get_size)
+  _WRAP_METHOD(guint64 get_size(guint first, guint last) const, gtk_bitset_get_size_in_range)
+  _WRAP_METHOD(guint get_nth(guint nth) const, gtk_bitset_get_nth)
   _WRAP_METHOD(bool equals(const Glib::RefPtr<const Bitset>& other) const, gtk_bitset_equals)
   _WRAP_METHOD(guint get_minimum() const, gtk_bitset_get_minimum)
   _WRAP_METHOD(guint get_maximum() const, gtk_bitset_get_maximum)
@@ -90,7 +93,7 @@ public:
   _WRAP_METHOD(void difference(const Glib::RefPtr<const Bitset>& other), gtk_bitset_difference)
   _WRAP_METHOD(void shift_left(guint amount), gtk_bitset_shift_left)
   _WRAP_METHOD(void shift_right(guint amount), gtk_bitset_shift_right)
-  _WRAP_METHOD(void slice(guint position, guint removed, guint value), gtk_bitset_slice)
+  _WRAP_METHOD(void splice(guint position, guint removed, guint value), gtk_bitset_splice)
 };
 
 } // namespace Gtk
diff --git a/gtk/src/filechooser.hg b/gtk/src/filechooser.hg
index 19fd8735..0d1505cd 100644
--- a/gtk/src/filechooser.hg
+++ b/gtk/src/filechooser.hg
@@ -20,6 +20,7 @@
 #include <gtkmm/widget.h>
 #include <gtkmm/filefilter.h>
 #include <giomm/file.h>
+#include <giomm/listmodel.h>
 
 _DEFS(gtkmm,gtk)
 _PINCLUDE(glibmm/private/interface_p.h)
@@ -74,21 +75,17 @@ public:
   _WRAP_METHOD(void set_current_name(const Glib::ustring& name), gtk_file_chooser_set_current_name)
   _WRAP_METHOD(Glib::ustring get_current_name() const, gtk_file_chooser_get_current_name)
 
-  _WRAP_METHOD(void select_all(), gtk_file_chooser_select_all)
-  _WRAP_METHOD(void unselect_all(), gtk_file_chooser_unselect_all)
-
   _WRAP_METHOD(bool set_file(const Glib::RefPtr<const Gio::File>& file), gtk_file_chooser_set_file, errthrow)
 
-  _WRAP_METHOD(bool select_file(const Glib::RefPtr<const Gio::File>& file), gtk_file_chooser_select_file, 
errthrow)
-  _WRAP_METHOD(void unselect_file(const Glib::RefPtr<const Gio::File>& file), gtk_file_chooser_unselect_file)
-
-#m4 _CONVERSION(`GSList*',`std::vector< Glib::RefPtr<Gio::File> >',`Glib::SListHandler< 
Glib::RefPtr<Gio::File> >::slist_to_vector($3, Glib::OWNERSHIP_DEEP)')
-  _WRAP_METHOD(std::vector< Glib::RefPtr<Gio::File> > get_files(), gtk_file_chooser_get_files)
+  //No refreturn is needed here, because the C function provides a reference:
+  _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_files(), gtk_file_chooser_get_files)
+  _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_files() const, gtk_file_chooser_get_files)
 
   _WRAP_METHOD(bool set_current_folder(const Glib::RefPtr<const Gio::File>& file), 
gtk_file_chooser_set_current_folder, errthrow)
 
   //No refreturn is needed here, because the C function provides a reference:
   _WRAP_METHOD(Glib::RefPtr<Gio::File> get_current_folder(), gtk_file_chooser_get_current_folder)
+  _WRAP_METHOD(Glib::RefPtr<const Gio::File> get_current_folder() const, 
gtk_file_chooser_get_current_folder, constversion)
 
   //No refreturn is needed here, because the C function provides a reference:
   _WRAP_METHOD(Glib::RefPtr<Gio::File> get_file(), gtk_file_chooser_get_file)
@@ -99,10 +96,8 @@ public:
   _WRAP_METHOD(void add_filter(const Glib::RefPtr<FileFilter>& filter), gtk_file_chooser_add_filter)
   _WRAP_METHOD(void remove_filter (const Glib::RefPtr<FileFilter>& filter), gtk_file_chooser_remove_filter)
 
-#m4 _CONVERSION(`GSList*',`std::vector< Glib::RefPtr<FileFilter> >',`Glib::SListHandler< 
Glib::RefPtr<FileFilter> >::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
-#m4 _CONVERSION(`GSList*',`std::vector< Glib::RefPtr<const FileFilter> >',`Glib::SListHandler< 
Glib::RefPtr<const FileFilter> >::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
-  _WRAP_METHOD(std::vector< Glib::RefPtr<FileFilter> > list_filters(), gtk_file_chooser_list_filters)
-  _WRAP_METHOD(std::vector< Glib::RefPtr<const FileFilter> > list_filters() const, 
gtk_file_chooser_list_filters)
+  //No refreturn is needed here, because the C function provides a reference:
+  _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_filters() const, gtk_file_chooser_get_filters)
 
 /* Current filter
  */
@@ -115,10 +110,8 @@ public:
   _WRAP_METHOD(bool add_shortcut_folder(const Glib::RefPtr<Gio::File>& folder), 
gtk_file_chooser_add_shortcut_folder, errthrow)
   _WRAP_METHOD(bool remove_shortcut_folder(const Glib::RefPtr<Gio::File>& folder), 
gtk_file_chooser_remove_shortcut_folder, errthrow)
 
-#m4 
_CONVERSION(`GSList*',`std::vector<Glib::RefPtr<Gio::File>>',`Glib::SListHandler<Glib::RefPtr<Gio::File>>::slist_to_vector($3,
 Glib::OWNERSHIP_DEEP)')
-#m4 _CONVERSION(`GSList*',`std::vector<Glib::RefPtr<const 
Gio::File>>',`Glib::SListHandler<Glib::RefPtr<const Gio::File>>::slist_to_vector($3, Glib::OWNERSHIP_DEEP)')
-  _WRAP_METHOD(std::vector<Glib::RefPtr<Gio::File>> list_shortcut_folders(), 
gtk_file_chooser_list_shortcut_folders)
-  _WRAP_METHOD(std::vector<Glib::RefPtr<const Gio::File>> list_shortcut_folders() const, 
gtk_file_chooser_list_shortcut_folders)
+  //No refreturn is needed here, because the C function provides a reference:
+  _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_shortcut_folders() const, 
gtk_file_chooser_get_shortcut_folders)
 
 #m4 _CONVERSION(`const std::vector<Glib::ustring>&',`const 
char**',`Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data ()')
   _WRAP_METHOD(void add_choice(const Glib::ustring& id, const Glib::ustring& label, const 
std::vector<Glib::ustring>& options, const std::vector<Glib::ustring>& option_labels), 
gtk_file_chooser_add_choice)
@@ -142,13 +135,11 @@ public:
   _WRAP_METHOD(void set_choice(const Glib::ustring& id, const Glib::ustring& option), 
gtk_file_chooser_set_choice)
   _WRAP_METHOD(Glib::ustring get_choice(const Glib::ustring& id) const, gtk_file_chooser_get_choice)
 
-  _WRAP_SIGNAL(void current_folder_changed(), "current_folder_changed", no_default_handler)
-  _WRAP_SIGNAL(void selection_changed(), "selection_changed", no_default_handler)
-  _WRAP_SIGNAL(void file_activated(), "file_activated", no_default_handler)
-
   _WRAP_PROPERTY("action", Action)
   _WRAP_PROPERTY("filter", Glib::RefPtr<FileFilter>)
   _WRAP_PROPERTY("select-multiple", bool)
+  _WRAP_PROPERTY("filters", Glib::RefPtr<Gio::ListModel>)
+  _WRAP_PROPERTY("shortcut-folders", Glib::RefPtr<Gio::ListModel>)
   _WRAP_PROPERTY("create-folders", bool)
 };
 
diff --git a/gtk/src/filefilter.ccg b/gtk/src/filefilter.ccg
index 46db223d..31a889a9 100644
--- a/gtk/src/filefilter.ccg
+++ b/gtk/src/filefilter.ccg
@@ -15,53 +15,4 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <gtk/gtk.h> //For gtk_file_filter_flags_get_type().
-
-using Flags = Gtk::FileFilter::Flags;
-
-static gboolean SignalProxy_Custom_gtk_callback(const GtkFileFilterInfo* filter_info, gpointer data)
-{
-  auto the_slot = static_cast<Gtk::FileFilter::SlotCustom*>(data);
-
-  try
-  {
-    //Create a suitable C++ instance to pass to the C++ method:
-    Gtk::FileFilter::Info cppInfo;
-    cppInfo.contains = (Gtk::FileFilter::Flags)filter_info->contains;
-    cppInfo.filename = Glib::convert_const_gchar_ptr_to_ustring(filter_info->filename);
-    cppInfo.uri = Glib::convert_const_gchar_ptr_to_ustring(filter_info->uri);
-    cppInfo.display_name = Glib::convert_const_gchar_ptr_to_ustring(filter_info->display_name);
-    cppInfo.mime_type = Glib::convert_const_gchar_ptr_to_ustring(filter_info->mime_type);
-
-    return (*the_slot)(cppInfo);
-  }
-  catch(...)
-  {
-    Glib::exception_handlers_invoke();
-    return false; //arbitrary default;
-  }
-}
-
-static void SignalProxy_Custom_gtk_callback_destroy(void* data)
-{
-  delete static_cast<Gtk::FileFilter::SlotCustom*>(data);
-}
-
-
-namespace Gtk
-{
-
-void FileFilter::add_custom(Flags needed, const SlotCustom& slot)
-{
-  //Create a copy of the slot. A pointer to this will be passed through the callback's data parameter.
-  //It will be deleted when SignalProxy_Custom::gtk_callback_destroy() is called.
-  auto slot_copy = new SlotCustom(slot);
-
-  gtk_file_filter_add_custom(gobj(), (GtkFileFilterFlags)needed,
-                             &SignalProxy_Custom_gtk_callback,
-                             slot_copy,
-                             &SignalProxy_Custom_gtk_callback_destroy);
-}
-
-} // namespace Gtk
-
+#include <gtk/gtk.h>
diff --git a/gtk/src/filefilter.hg b/gtk/src/filefilter.hg
index e4426464..b9223c29 100644
--- a/gtk/src/filefilter.hg
+++ b/gtk/src/filefilter.hg
@@ -48,8 +48,6 @@ protected:
   _CTOR_DEFAULT
 
 public:
-  _WRAP_ENUM(Flags, GtkFileFilterFlags, decl_prefix GTKMM_API)
-
   _WRAP_CREATE()
 
   _WRAP_METHOD(void set_name(const Glib::ustring& name), gtk_file_filter_set_name)
@@ -59,54 +57,8 @@ public:
   _WRAP_METHOD(void add_pattern(const Glib::ustring& pattern), gtk_file_filter_add_pattern)
   _WRAP_METHOD(void add_pixbuf_formats(), gtk_file_filter_add_pixbuf_formats)
 
-  /** Information available per file when implementing a custom filter rule via
-   * add_custom().
-   */
-  class Info
-  {
-  public:
-    /// Flags indicating which of the following fields are filled. See add_custom().
-    Flags contains;
-
-    /// The filename of the file being tested.
-    Glib::ustring filename;
-
-    /// The URI for the file being tested.
-    Glib::ustring uri;
-
-    /// The string that will be used to display the file in the Gtk::FileChooser.
-    Glib::ustring display_name;
-
-    /// The MIME type of the file.
-    Glib::ustring mime_type;
-  };
-
-  /** A slot provided to add_custom() that implements a custom filter rule. This
-   * will be called with the Info of each file that is available, and it must
-   * return a bool indicating whether or not that file should be displayed.
-   *
-   * For instance:
-   * @code
-   * bool on_custom(const Gtk::FileFilter::Info& filter_info);
-   * @endcode
-   */
-  typedef sigc::slot<bool(const Info&)> SlotCustom;
-
-  /**
-   * Adds a rule to a filter that allows files based on a SlotCustom function.
-   * The Flags passed in provide information about what sorts of
-   * information the filter function needs; this allows the toolkit to avoid
-   * retrieving expensive information when it isn’t needed by the custom filter.
-   *
-   * @param needed The Flags identifying info needed by the @a slot.
-   * @param slot A SlotCustom to call for each file to perform the filtering.
-   */
-  void add_custom(Flags needed, const SlotCustom& slot);
-  _IGNORE(gtk_file_filter_add_custom)
-
-  // These are meant for implementors of FileChooser, so we don’t wrap them.
-  _IGNORE(gtk_file_filter_filter)
-  _IGNORE(gtk_file_filter_get_needed)
+  // This is meant for implementors of FileChooser, so we don’t wrap them.
+  _IGNORE(gtk_file_filter_get_attributes)
 
   _WRAP_PROPERTY("name", Glib::ustring)
 };
diff --git a/gtk/src/multiselection.hg b/gtk/src/multiselection.hg
index a26fe17c..c5a9e3b5 100644
--- a/gtk/src/multiselection.hg
+++ b/gtk/src/multiselection.hg
@@ -50,6 +50,7 @@ public:
 
   _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_multi_selection_get_model, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_model() const, gtk_multi_selection_get_model, 
refreturn, constversion)
+  _WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_multi_selection_set_model)
 
   _WRAP_PROPERTY("model", Glib::RefPtr<Gio::ListModel>)
 
diff --git a/gtk/src/noselection.hg b/gtk/src/noselection.hg
index 63504d61..63bf8dc8 100644
--- a/gtk/src/noselection.hg
+++ b/gtk/src/noselection.hg
@@ -53,6 +53,7 @@ public:
 
   _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_no_selection_get_model, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_model() const, gtk_no_selection_get_model, refreturn, 
constversion)
+  _WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_no_selection_set_model)
 
   _WRAP_PROPERTY("model", Glib::RefPtr<Gio::ListModel>)
 
diff --git a/gtk/src/singleselection.hg b/gtk/src/singleselection.hg
index b70888e8..42dd0aff 100644
--- a/gtk/src/singleselection.hg
+++ b/gtk/src/singleselection.hg
@@ -51,6 +51,7 @@ public:
 
   _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_single_selection_get_model, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_model() const, gtk_single_selection_get_model, 
refreturn, constversion)
+  _WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_single_selection_set_model)
 
   _WRAP_METHOD(guint get_selected() const, gtk_single_selection_get_selected)
   _WRAP_METHOD(void set_selected(guint position), gtk_single_selection_set_selected)
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index 369f9d38..f82d5674 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -93,7 +93,6 @@ _CONV_ENUM(Gtk,UpdateType)
 _CONV_ENUM(Gtk,Visibility)
 _CONV_ENUM(Gtk,WrapMode)
 _CONV_INCLASS_ENUM(Gtk,FileChooser,Action)
-_CONV_INCLASS_ENUM(Gtk,FileFilter,Flags)
 _CONV_ENUM(Gtk,IconLookupFlags)
 _CONV_ENUM(Gtk,IconThemeError)
 _CONV_ENUM(Gtk,SensitivityType)


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