[gtkmm/directorylist] Add Gtk::DirectoryList
- From: Andreas Persson <andreasp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/directorylist] Add Gtk::DirectoryList
- Date: Sun, 4 Oct 2020 09:06:16 +0000 (UTC)
commit 354c034d2c6ba6173317bce54a46d4a50da15ca6
Author: Andreas Persson <andreasp56 outlook com>
Date: Sun Oct 4 11:05:52 2020 +0200
Add Gtk::DirectoryList
.gitignore | 2 +
gtk/gtkmm.h | 1 +
gtk/gtkmm/meson.build | 1 +
gtk/src/directorylist.ccg | 17 ++++++
gtk/src/directorylist.hg | 91 +++++++++++++++++++++++++++++++
gtk/src/filelist.am | 1 +
gtk/src/gtk_docs_override.xml | 2 +
gtk/src/gtk_extra_objects.defs | 6 ++
gtk/src/gtk_signals.defs | 69 +++++++++++++++++++++++
tools/extra_defs_gen/generate_defs_gtk.cc | 1 +
10 files changed, 191 insertions(+)
---
diff --git a/.gitignore b/.gitignore
index 9e61c4a1..777f3e9f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -257,6 +257,8 @@ gtk/gtkmm/csssection.cc
gtk/gtkmm/csssection.h
gtk/gtkmm/dialog.cc
gtk/gtkmm/dialog.h
+gtk/gtkmm/directorylist.cc
+gtk/gtkmm/directorylist.h
gtk/gtkmm/dragicon.cc
gtk/gtkmm/dragicon.h
gtk/gtkmm/dragsource.cc
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index 8496ba92..57ea9922 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -136,6 +136,7 @@ extern const int gtkmm_micro_version;
#include <gtkmm/cssprovider.h>
#include <gtkmm/csssection.h>
#include <gtkmm/dialog.h>
+#include <gtkmm/directorylist.h>
#include <gtkmm/dragicon.h>
#include <gtkmm/dragsource.h>
#include <gtkmm/drawingarea.h>
diff --git a/gtk/gtkmm/meson.build b/gtk/gtkmm/meson.build
index 25a3feda..040df026 100644
--- a/gtk/gtkmm/meson.build
+++ b/gtk/gtkmm/meson.build
@@ -85,6 +85,7 @@ gtkmm_any_hg_ccg_basenames = [
'cssprovider',
'csssection',
'dialog',
+ 'directorylist',
'dragicon',
'dragsource',
'drawingarea',
diff --git a/gtk/src/directorylist.ccg b/gtk/src/directorylist.ccg
new file mode 100644
index 00000000..57b87fdc
--- /dev/null
+++ b/gtk/src/directorylist.ccg
@@ -0,0 +1,17 @@
+/* Copyright (C) 2020 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
diff --git a/gtk/src/directorylist.hg b/gtk/src/directorylist.hg
new file mode 100644
index 00000000..fa9181d8
--- /dev/null
+++ b/gtk/src/directorylist.hg
@@ -0,0 +1,91 @@
+/* Copyright (C) 2020 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+_CONFIGINCLUDE(gtkmmconfig.h)
+
+#include <giomm/listmodel.h>
+#include <giomm/file.h>
+#include <gtk/gtk.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gtk
+{
+
+/** A list model for directory listings.
+ *
+ * %Gtk::DirectoryList is a list model that wraps Gio::File::enumerate_children_async().
+ * It presents a Gio::ListModel and fills it asynchronously with the Gio::FileInfo%s
+ * returned from that function.
+ *
+ * Enumeration will start automatically when the property_file() property
+ * is set.
+ *
+ * While the %Gtk::DirectoryList is being filled, the property_loading()
+ * property will be set to <tt>true</tt>. You can listen to that property if you want
+ * to show information like a Gtk::Spinner or a "Loading..." text.
+ *
+ * If loading fails at any point, the property_error() property will be
+ * set to give more indication about the failure.
+ *
+ * The Gio::FileInfo%s returned from a %Gtk::DirectoryList have the "standard::file"
+ * attribute set to the Gio::File they refer to. This way you can get at the file
+ * that is referred to in the same way you would via Gio::File::enumerator_get_child().
+ * This means you do not need access to the %Gtk::DirectoryList but can access
+ * the Gio::File directly from the Gio::FileInfo when operating with a Gtk::ListView
+ * or similar.
+ *
+ * @see Gio::ListModel, Gio::File::enumerate_children()
+ * @newin{3,98}
+ */
+class GTKMM_API DirectoryList : public Glib::Object, public Gio::ListModel
+{
+ _CLASS_GOBJECT(DirectoryList, GtkDirectoryList, GTK_DIRECTORY_LIST, Glib::Object, GObject, , , GTKMM_API)
+ _IMPLEMENTS_INTERFACE(Gio::ListModel)
+ _STRUCT_NOT_HIDDEN
+
+protected:
+ _WRAP_CTOR(DirectoryList(const std::string& attributes, const Glib::RefPtr<Gio::File>& file = {}),
gtk_directory_list_new)
+
+public:
+ _WRAP_CREATE(const std::string& attributes, const Glib::RefPtr<Gio::File>& file = {})
+
+ _WRAP_METHOD(void set_file(const Glib::RefPtr<Gio::File>& file), gtk_directory_list_set_file)
+ _WRAP_METHOD(Glib::RefPtr<Gio::File> get_file(), gtk_directory_list_get_file)
+ _WRAP_METHOD(Glib::RefPtr<const Gio::File> get_file() const, gtk_directory_list_get_file, constversion)
+ _WRAP_METHOD(void set_attributes(const std::string& attributes), gtk_directory_list_set_attributes)
+ _WRAP_METHOD(std::string get_attributes() const, gtk_directory_list_get_attributes)
+ _WRAP_METHOD(void set_io_priority(int io_priority), gtk_directory_list_set_io_priority)
+ _WRAP_METHOD(int get_io_priority() const, gtk_directory_list_get_io_priority)
+
+ _WRAP_METHOD(bool is_loading() const, gtk_directory_list_is_loading)
+#m4 _CONVERSION(`const GError*',`Glib::Error',`Glib::Error(const_cast<GError*>($3), true)')
+ _WRAP_METHOD(Glib::Error get_error() const, gtk_directory_list_get_error)
+
+ _WRAP_METHOD(void set_monitored(bool monitored = true), gtk_directory_list_set_monitored)
+ _WRAP_METHOD(bool get_monitored() const, gtk_directory_list_get_monitored)
+
+ _WRAP_PROPERTY("attributes", std::string)
+ _WRAP_PROPERTY("error", Glib::Error)
+ _WRAP_PROPERTY("file", Glib::RefPtr<Gio::File>)
+ _WRAP_PROPERTY("io-priority", int)
+ _WRAP_PROPERTY("item-type", GType)
+ _WRAP_PROPERTY("loading", bool)
+ _WRAP_PROPERTY("monitored", bool)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 18d091f8..26dd78a9 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -70,6 +70,7 @@ gtkmm_files_any_hg = \
cssprovider.hg \
csssection.hg \
dialog.hg \
+ directorylist.hg \
dragicon.hg \
dragsource.hg \
drawingarea.hg \
diff --git a/gtk/src/gtk_docs_override.xml b/gtk/src/gtk_docs_override.xml
index e41a606c..5ec6b3f0 100644
--- a/gtk/src/gtk_docs_override.xml
+++ b/gtk/src/gtk_docs_override.xml
@@ -197,6 +197,8 @@
<substitute_enumerator_name from="GTK_CAN_FOCUS" to="GTK_CAN_FOCUS" />
<substitute_enumerator_name from="GTK_INVALID_LIST_POSITION" to="GTK_INVALID_LIST_POSITION" />
<substitute_enumerator_name from_prefix="GTK_STYLE_CLASS_" to_prefix="GTK_STYLE_CLASS_" />
+<substitute_enumerator_name from="G_PRIORITY_DEFAULT" to="Glib::PRIORITY_DEFAULT" />
+<substitute_enumerator_name from="G_PRIORITY_DEFAULT_IDLE" to="Glib::PRIORITY_DEFAULT_IDLE" />
<!-- This is the default substitution. Included here to avoid warnings from DocsParser.pm. -->
<substitute_enumerator_name from="PANGO_SCALE" to="Pango::SCALE" />
diff --git a/gtk/src/gtk_extra_objects.defs b/gtk/src/gtk_extra_objects.defs
index 05151ad2..72766769 100644
--- a/gtk/src/gtk_extra_objects.defs
+++ b/gtk/src/gtk_extra_objects.defs
@@ -132,6 +132,12 @@
(gtype-id "GTK_TYPE_CSS_SECTION")
)
+(define-object DirectoryList
+ (in-module "Gtk")
+ (c-name "GtkDirectoryList")
+ (gtype-id "GTK_TYPE_DIRECTORY_LIST")
+)
+
(define-object DragSource
(in-module "Gtk")
(c-name "GtkDragSource")
diff --git a/gtk/src/gtk_signals.defs b/gtk/src/gtk_signals.defs
index b1a0bc02..a1330117 100644
--- a/gtk/src/gtk_signals.defs
+++ b/gtk/src/gtk_signals.defs
@@ -2913,6 +2913,75 @@
(default-value "-1")
)
+;; From GtkDirectoryList
+
+(define-property attributes
+ (of-object "GtkDirectoryList")
+ (prop-type "GParamString")
+ (docs "Attributes to query")
+ (readable #t)
+ (writable #t)
+ (construct-only #f)
+ (default-value "")
+)
+
+(define-property error
+ (of-object "GtkDirectoryList")
+ (prop-type "GParamBoxed")
+ (docs "Error encountered while loading files")
+ (readable #t)
+ (writable #f)
+ (construct-only #f)
+)
+
+(define-property file
+ (of-object "GtkDirectoryList")
+ (prop-type "GParamObject")
+ (docs "The file to query")
+ (readable #t)
+ (writable #t)
+ (construct-only #f)
+)
+
+(define-property io-priority
+ (of-object "GtkDirectoryList")
+ (prop-type "GParamInt")
+ (docs "Priority used when loading")
+ (readable #t)
+ (writable #t)
+ (construct-only #f)
+ (default-value "0")
+)
+
+(define-property item-type
+ (of-object "GtkDirectoryList")
+ (prop-type "GParamGType")
+ (docs "The type of elements of this object")
+ (readable #t)
+ (writable #f)
+ (construct-only #f)
+)
+
+(define-property loading
+ (of-object "GtkDirectoryList")
+ (prop-type "GParamBoolean")
+ (docs "TRUE if files are being loaded")
+ (readable #t)
+ (writable #f)
+ (construct-only #f)
+ (default-value "FALSE")
+)
+
+(define-property monitored
+ (of-object "GtkDirectoryList")
+ (prop-type "GParamBoolean")
+ (docs "TRUE if the directory is monitored for changes")
+ (readable #t)
+ (writable #t)
+ (construct-only #f)
+ (default-value "TRUE")
+)
+
;; From GtkDragIcon
(define-property child
diff --git a/tools/extra_defs_gen/generate_defs_gtk.cc b/tools/extra_defs_gen/generate_defs_gtk.cc
index 94d90ce7..49b7bc54 100644
--- a/tools/extra_defs_gen/generate_defs_gtk.cc
+++ b/tools/extra_defs_gen/generate_defs_gtk.cc
@@ -91,6 +91,7 @@ int main(int /* argc */, char** /* argv */)
<< get_defs( GTK_TYPE_CELL_VIEW )
<< get_defs( GTK_TYPE_CSS_PROVIDER )
<< get_defs( GTK_TYPE_DIALOG )
+ << get_defs( GTK_TYPE_DIRECTORY_LIST )
<< get_defs( GTK_TYPE_DRAG_ICON )
<< get_defs( GTK_TYPE_DRAG_SOURCE )
<< get_defs( GTK_TYPE_DRAWING_AREA )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]