[gtk/gbsneto/filechooser-column-view] filechoosercell: Bind "item" and "selected" to cell



commit 5969a64fb72a7efb2f5fc2a5998cc79e409a00c1
Author: Corey Berla <corey berla me>
Date:   Wed Oct 19 09:19:47 2022 -0700

    filechoosercell: Bind "item" and "selected" to cell

 gtk/gtkfilechoosercell.c       | 30 ++++++++++++++++++++++++++++++
 gtk/ui/gtkfilechooserwidget.ui | 30 ++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
---
diff --git a/gtk/gtkfilechoosercell.c b/gtk/gtkfilechoosercell.c
index b10c2cf02e..07d4dc7c9f 100644
--- a/gtk/gtkfilechoosercell.c
+++ b/gtk/gtkfilechoosercell.c
@@ -31,6 +31,8 @@ struct _GtkFileChooserCell
 {
   GtkWidget parent_instance;
 
+  GFileInfo *item;
+  gboolean selected;
   guint position;
 };
 
@@ -44,6 +46,8 @@ G_DEFINE_TYPE (GtkFileChooserCell, gtk_file_chooser_cell, GTK_TYPE_WIDGET)
 enum
 {
   PROP_POSITION = 1,
+  PROP_SELECTED,
+  PROP_ITEM,
 };
 
 static void
@@ -126,6 +130,14 @@ gtk_file_chooser_cell_set_property (GObject      *object,
       self->position = g_value_get_uint (value);
       break;
 
+    case PROP_SELECTED:
+      self->selected = g_value_get_boolean (value);
+      break;
+
+    case PROP_ITEM:
+      self->item = g_value_get_object (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -146,6 +158,14 @@ gtk_file_chooser_cell_get_property (GObject    *object,
       g_value_set_uint (value, self->position);
       break;
 
+    case PROP_SELECTED:
+      g_value_set_boolean (value, self->selected);
+      break;
+
+    case PROP_ITEM:
+      g_value_set_object (value, self->item);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -168,6 +188,16 @@ gtk_file_chooser_cell_class_init (GtkFileChooserCellClass *klass)
                                                       0, G_MAXUINT, 0,
                                                       GTK_PARAM_READWRITE));
 
+  g_object_class_install_property (object_class, PROP_SELECTED,
+                                   g_param_spec_boolean ("selected", NULL, NULL,
+                                                         FALSE,
+                                                         GTK_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class, PROP_ITEM,
+                                   g_param_spec_object ("item", NULL, NULL,
+                                                        G_TYPE_FILE_INFO,
+                                                        GTK_PARAM_READWRITE));
+
   gtk_widget_class_set_css_name (widget_class, I_("filelistcell"));
   gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
 }
diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui
index bfd4a0e9db..5a12539965 100644
--- a/gtk/ui/gtkfilechooserwidget.ui
+++ b/gtk/ui/gtkfilechooserwidget.ui
@@ -159,6 +159,12 @@
         <binding name="position">
           <lookup name="position">GtkListItem</lookup>
         </binding>
+        <binding name="item">
+          <lookup name="item">GtkListItem</lookup>
+        </binding>
+        <binding name="selected">
+          <lookup name="selected">GtkListItem</lookup>
+        </binding>
         <child>
           <object class="GtkBox">
             <binding name="tooltip-text">
@@ -216,6 +222,12 @@
         <binding name="position">
           <lookup name="position">GtkListItem</lookup>
         </binding>
+        <binding name="item">
+          <lookup name="item">GtkListItem</lookup>
+        </binding>
+        <binding name="selected">
+          <lookup name="selected">GtkListItem</lookup>
+        </binding>
         <child>
           <object class="GtkInscription">
             <property name="hexpand">1</property>
@@ -259,6 +271,12 @@
         <binding name="position">
           <lookup name="position">GtkListItem</lookup>
         </binding>
+        <binding name="item">
+          <lookup name="item">GtkListItem</lookup>
+        </binding>
+        <binding name="selected">
+          <lookup name="selected">GtkListItem</lookup>
+        </binding>
         <child>
           <object class="GtkLabel">
             <property name="hexpand">1</property>
@@ -300,6 +318,12 @@
         <binding name="position">
           <lookup name="position">GtkListItem</lookup>
         </binding>
+        <binding name="item">
+          <lookup name="item">GtkListItem</lookup>
+        </binding>
+        <binding name="selected">
+          <lookup name="selected">GtkListItem</lookup>
+        </binding>
         <child>
           <object class="GtkLabel">
             <property name="hexpand">1</property>
@@ -340,6 +364,12 @@
         <binding name="position">
           <lookup name="position">GtkListItem</lookup>
         </binding>
+        <binding name="item">
+          <lookup name="item">GtkListItem</lookup>
+        </binding>
+        <binding name="selected">
+          <lookup name="selected">GtkListItem</lookup>
+        </binding>
         <child>
           <object class="GtkBox">
             <property name="spacing">6</property>


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