[nautilus/wip/coreyberla/app-picker-followups: 3/4] app-chooser: Add property filename




commit 2834b99e3539dbce5d659add8b28e4e6bb74e066
Author: Corey Berla <corey berla me>
Date:   Fri Aug 5 13:12:36 2022 -0700

    app-chooser: Add property filename
    
    We need this for the description within the app chooser.
    If we are working on multiple files, set to NULL.

 src/nautilus-app-chooser.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/src/nautilus-app-chooser.c b/src/nautilus-app-chooser.c
index 145d3ae3d..267cf06d6 100644
--- a/src/nautilus-app-chooser.c
+++ b/src/nautilus-app-chooser.c
@@ -17,6 +17,7 @@ struct _NautilusAppChooser
     GtkDialog parent_instance;
 
     gchar *content_type;
+    gchar *file_name;
     gboolean single_content_type;
 
     GtkWidget *app_chooser_widget_box;
@@ -34,6 +35,7 @@ enum
     PROP_0,
     PROP_CONTENT_TYPE,
     PROP_SINGLE_CONTENT_TYPE,
+    PROP_FILE_NAME,
     LAST_PROP
 };
 
@@ -118,6 +120,12 @@ nautilus_app_chooser_set_property (GObject      *object,
         }
         break;
 
+        case PROP_FILE_NAME:
+        {
+            self->file_name = g_value_dup_string (value);
+        }
+        break;
+
         default:
         {
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -202,6 +210,7 @@ nautilus_app_chooser_finalize (GObject *object)
     NautilusAppChooser *self = (NautilusAppChooser *) object;
 
     g_clear_pointer (&self->content_type, g_free);
+    g_clear_pointer (&self->file_name, g_free);
 
     G_OBJECT_CLASS (nautilus_app_chooser_parent_class)->finalize (object);
 }
@@ -229,6 +238,12 @@ nautilus_app_chooser_class_init (NautilusAppChooserClass *klass)
                                                           NULL,
                                                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
 
+    g_object_class_install_property (object_class,
+                                     PROP_FILE_NAME,
+                                     g_param_spec_string ("file-name", "", "",
+                                                          NULL,
+                                                          G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
     g_object_class_install_property (object_class,
                                      PROP_SINGLE_CONTENT_TYPE,
                                      g_param_spec_boolean ("single-content-type", "", "",
@@ -242,9 +257,12 @@ nautilus_app_chooser_new (GList     *files,
 {
     gboolean single_content_type = TRUE;
     g_autofree gchar *content_type = NULL;
+    g_autofree gchar *file_name = NULL;
 
     content_type = nautilus_file_get_mime_type (files->data);
 
+    file_name = files->next ? NULL : nautilus_file_get_display_name (files->data);
+
     for (GList *l = files; l != NULL; l = l->next)
     {
         g_autofree gchar *temp_mime_type = NULL;
@@ -260,6 +278,7 @@ nautilus_app_chooser_new (GList     *files,
                                                "transient-for", parent_window,
                                                "content-type", content_type,
                                                "use-header-bar", TRUE,
+                                               "file-name", file_name,
                                                "single-content-type", single_content_type,
                                                NULL));
 }


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