[gnome-builder/wip/gtk4-port: 1032/1774] plugins/find-other-file: add is-directory property
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1032/1774] plugins/find-other-file: add is-directory property
- Date: Mon, 11 Jul 2022 22:31:32 +0000 (UTC)
commit 085d301a19d8ed26e2ad03123e5edcfe8cc86db8
Author: Christian Hergert <chergert redhat com>
Date: Mon May 16 16:17:28 2022 -0700
plugins/find-other-file: add is-directory property
This can be used to show additional widgetry for directories within the
popover rows.
src/plugins/find-other-file/gbp-found-file.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/find-other-file/gbp-found-file.c b/src/plugins/find-other-file/gbp-found-file.c
index 90650b43a..d3ae24da8 100644
--- a/src/plugins/find-other-file/gbp-found-file.c
+++ b/src/plugins/find-other-file/gbp-found-file.c
@@ -34,9 +34,10 @@ struct _GbpFoundFile
enum {
PROP_0,
- PROP_GICON,
PROP_DISPLAY_NAME,
PROP_FILE,
+ PROP_GICON,
+ PROP_IS_DIRECTORY,
N_PROPS
};
@@ -44,6 +45,16 @@ G_DEFINE_FINAL_TYPE (GbpFoundFile, gbp_found_file, G_TYPE_OBJECT)
static GParamSpec *properties [N_PROPS];
+static gboolean
+gbp_found_file_get_is_directory (GbpFoundFile *self)
+{
+ g_assert (GBP_IS_FOUND_FILE (self));
+
+ return self->info != NULL ?
+ g_file_info_get_file_type (self->info) == G_FILE_TYPE_DIRECTORY :
+ FALSE;
+}
+
static void
gbp_found_file_query_info_cb (GObject *object,
GAsyncResult *result,
@@ -61,6 +72,9 @@ gbp_found_file_query_info_cb (GObject *object,
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DISPLAY_NAME]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_GICON]);
+
+ if (gbp_found_file_get_is_directory (self))
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_IS_DIRECTORY]);
}
static void
@@ -75,7 +89,8 @@ gbp_found_file_constructed (GObject *object)
g_file_query_info_async (self->file,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME","
- G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON,
+ G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON","
+ G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_LOW,
NULL,
@@ -121,6 +136,10 @@ gbp_found_file_get_property (GObject *object,
g_value_set_object (value, g_file_info_get_attribute_object (self->info,
G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON));
break;
+ case PROP_IS_DIRECTORY:
+ g_value_set_boolean (value, gbp_found_file_get_is_directory (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -170,6 +189,11 @@ gbp_found_file_class_init (GbpFoundFileClass *klass)
G_TYPE_ICON,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ properties [PROP_IS_DIRECTORY] =
+ g_param_spec_boolean ("is-directory", NULL, NULL,
+ FALSE,
+ (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
g_object_class_install_properties (object_class, N_PROPS, properties);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]