filechoosercell: Bind "item" and "selected" to cell
authorCorey Berla <corey@berla.me>
Wed, 19 Oct 2022 16:19:47 +0000 (09:19 -0700)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 21 Oct 2022 02:34:41 +0000 (22:34 -0400)
gtk/gtkfilechoosercell.c
gtk/ui/gtkfilechooserwidget.ui

index b10c2cf02e18b41d4f2b7ff18e1d86e12cd0553e..07d4dc7c9f7f7fd881bcafae716d79ae7e162799 100644 (file)
@@ -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);
 }
index bfd4a0e9db38564dfbd0706181aff9fc7ea28d55..5a1253996549b43bc577260213954974782d3230 100644 (file)
         <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">
         <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>
         <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>
         <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>
         <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>