[nautilus/wip/antoniof/extension-properties: 2/3] properties-window: Add support for new extension API
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/extension-properties: 2/3] properties-window: Add support for new extension API
- Date: Sat, 6 Aug 2022 09:36:58 +0000 (UTC)
commit ea6f9360180c56a1fe7c0af6ce0a41fab0fe6e85
Author: António Fernandes <antoniof gnome org>
Date: Fri Aug 5 21:53:33 2022 +0100
properties-window: Add support for new extension API
src/nautilus-properties-window.c | 80 ++++++++++++++++++++++++++
src/resources/ui/nautilus-properties-window.ui | 8 +++
2 files changed, 88 insertions(+)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 878f5daaa..f99055254 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -46,6 +46,8 @@
#include "nautilus-metadata.h"
#include "nautilus-mime-actions.h"
#include "nautilus-module.h"
+#include "nautilus-properties-model.h"
+#include "nautilus-properties-item.h"
#include "nautilus-property-page.h"
#include "nautilus-signaller.h"
#include "nautilus-tag-manager.h"
@@ -133,6 +135,8 @@ struct _NautilusPropertiesWindow
GtkListBox *extension_list_box;
+ GtkWidget *extension_groups_box;
+
/* Permissions page */
GtkWidget *permissions_stack;
@@ -3614,6 +3618,78 @@ refresh_extension_pages (NautilusPropertiesWindow *self)
NULL);
}
+static GtkWidget *
+create_extension_group_row (NautilusPropertiesItem *item,
+ NautilusPropertiesWindow *self)
+{
+ GtkWidget *row = adw_action_row_new ();
+ GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
+ GtkWidget *name_label = gtk_label_new (nautilus_properties_item_get_name (item));
+ GtkWidget *value_label = gtk_label_new (nautilus_properties_item_get_value (item));
+
+ gtk_list_box_row_set_selectable (GTK_LIST_BOX_ROW (row), FALSE);
+ gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
+ adw_action_row_add_prefix (ADW_ACTION_ROW (row), box);
+
+ gtk_widget_set_valign (box, GTK_ALIGN_CENTER);
+ gtk_box_append (GTK_BOX (box), name_label);
+ gtk_box_append (GTK_BOX (box), value_label);
+
+ gtk_widget_add_css_class (name_label, "caption");
+ gtk_widget_add_css_class (name_label, "dim-label");
+ gtk_widget_set_halign (name_label, GTK_ALIGN_START);
+ gtk_label_set_ellipsize (GTK_LABEL (name_label), PANGO_ELLIPSIZE_END);
+
+ gtk_widget_set_halign (value_label, GTK_ALIGN_START);
+ gtk_label_set_ellipsize (GTK_LABEL (value_label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_selectable (GTK_LABEL (value_label), TRUE);
+
+ return row;
+}
+
+static void
+refresh_extension_groups (NautilusPropertiesWindow *self)
+{
+ GtkWidget *child;
+ g_autolist (NautilusPropertiesModel) all_groups = NULL;
+ g_autolist (GObject) providers =
+ nautilus_module_get_extensions_for_type (NAUTILUS_TYPE_PROPERTIES_MODEL_PROVIDER);
+
+ while ((child = gtk_widget_get_first_child (self->extension_groups_box)) != NULL)
+ {
+ gtk_widget_unparent (child);
+ }
+
+ for (GList *l = providers; l != NULL; l = l->next)
+ {
+ GList *groups = nautilus_properties_model_provider_get_groups (l->data, self->original_files);
+
+ all_groups = g_list_concat (all_groups, groups);
+ }
+
+ for (GList *l = all_groups; l != NULL; l = l->next)
+ {
+ GListModel *model = nautilus_properties_model_get_model (l->data);
+ GtkWidget *group = adw_preferences_group_new ();
+ GtkWidget *group_list_box = gtk_list_box_new ();
+
+ adw_preferences_group_set_title (ADW_PREFERENCES_GROUP (group),
+ nautilus_properties_model_get_name (l->data));
+ adw_preferences_group_add (ADW_PREFERENCES_GROUP (group), group_list_box);
+ g_object_bind_property (model, "n-items",
+ group, "visible",
+ G_BINDING_SYNC_CREATE);
+
+ gtk_widget_add_css_class (group_list_box, "boxed-list");
+ gtk_list_box_bind_model (GTK_LIST_BOX (group_list_box), model,
+ (GtkListBoxCreateWidgetFunc) create_extension_group_row,
+ self,
+ NULL);
+
+ gtk_box_append (GTK_BOX (self->extension_groups_box), group);
+ }
+}
+
static gboolean
should_show_permissions (NautilusPropertiesWindow *self)
{
@@ -3826,6 +3902,9 @@ create_properties_window (StartupData *startup_data)
/* Add available extension pages */
refresh_extension_pages (window);
+ /* Add available extension groups */
+ refresh_extension_groups (window);
+
/* Update from initial state */
properties_window_update (window, NULL);
@@ -4385,6 +4464,7 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow,
permissions_navigation_row);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_value_label);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, extension_list_box);
+ gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, extension_groups_box);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, free_space_value_label);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_stack);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, not_the_owner_label);
diff --git a/src/resources/ui/nautilus-properties-window.ui b/src/resources/ui/nautilus-properties-window.ui
index 8299c93d1..b1f642890 100644
--- a/src/resources/ui/nautilus-properties-window.ui
+++ b/src/resources/ui/nautilus-properties-window.ui
@@ -670,6 +670,14 @@
</style>
</object>
</child>
+ <child>
+ <object class="GtkBox" id="extension_groups_box">
+ <property name="orientation">vertical</property>
+ <property name="spacing" bind-source="basic_box"
+ bind-property="spacing"
+ bind-flags="sync-create"/>
+ </object>
+ </child>
</object>
</property>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]