[gtk/wip/otte/listview] demo: Improve the file browser demo a bit



commit a5fa1a41c928034f689466b68ab041973a305823
Author: Benjamin Otte <otte redhat com>
Date:   Sat Oct 19 22:28:22 2019 +0200

    demo: Improve the file browser demo a bit

 demos/gtk-demo/demo.gresource.xml            |  1 +
 demos/gtk-demo/listview_filebrowser.c        |  9 ++++-----
 demos/gtk-demo/listview_filebrowser.ui       |  3 ++-
 demos/gtk-demo/listview_filebrowser_icons.ui | 27 +++++++++++++++++++++++++++
 4 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml
index 3829ddd61d..705be97709 100644
--- a/demos/gtk-demo/demo.gresource.xml
+++ b/demos/gtk-demo/demo.gresource.xml
@@ -121,6 +121,7 @@
   <gresource prefix="/listview_filebrowser">
     <file>listview_filebrowser.ui</file>
     <file>listview_filebrowser_list.ui</file>
+    <file>listview_filebrowser_icons.ui</file>
   </gresource>
   <gresource prefix="/listview_weather">
     <file compressed="true">listview_weather.txt</file>
diff --git a/demos/gtk-demo/listview_filebrowser.c b/demos/gtk-demo/listview_filebrowser.c
index fd0419e5f1..aa0e45bce6 100644
--- a/demos/gtk-demo/listview_filebrowser.c
+++ b/demos/gtk-demo/listview_filebrowser.c
@@ -1,8 +1,7 @@
-/* Icon View/Icon View Basics
+/* Lists/File browser
  *
- * The GtkIconView widget is used to display and manipulate icons.
- * It uses a GtkTreeModel for data storage, so the list store
- * example might be helpful.
+ * This demo shows off the different layouts that are quickly achievable
+ * with GtkGridView by implementing a file browser with different views.
  */
 
 #include <glib/gi18n.h>
@@ -59,7 +58,7 @@ do_listview_filebrowser (GtkWidget *do_widget)
       g_object_unref (file);
 
       /* grab focus in the view */
-      view = gtk_list_view_new_with_factory (gtk_builder_list_item_factory_new_from_resource 
("/listview_filebrowser/listview_filebrowser_list.ui"));
+      view = GTK_WIDGET (gtk_builder_get_object (builder, "view"));
       gtk_widget_grab_focus (view);
 
       g_object_unref (builder);
diff --git a/demos/gtk-demo/listview_filebrowser.ui b/demos/gtk-demo/listview_filebrowser.ui
index 27b4f8a0f9..67ac2f121b 100644
--- a/demos/gtk-demo/listview_filebrowser.ui
+++ b/demos/gtk-demo/listview_filebrowser.ui
@@ -43,9 +43,10 @@
         <child>
           <object class="GtkGridView" id="view">
             <property name="model">dirlist</property>
+            <property name="max-columns">15</property>
             <property name="factory">
               <object class="GtkBuilderListItemFactory">
-                <property name="resource">/listview_filebrowser/listview_filebrowser_list.ui</property>
+                <property name="resource">/listview_filebrowser/listview_filebrowser_icons.ui</property>
               </object>
             </property>
           </object>
diff --git a/demos/gtk-demo/listview_filebrowser_icons.ui b/demos/gtk-demo/listview_filebrowser_icons.ui
new file mode 100644
index 0000000000..c6464d6a6b
--- /dev/null
+++ b/demos/gtk-demo/listview_filebrowser_icons.ui
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GtkListItem">
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkImage">
+            <property name="icon-size">large</property>
+            <binding name="gicon">file-info(GtkListItem.item:GFileInfo, "standard::icon", 
object):GIcon</binding>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="wrap">1</property>
+            <property name="wrap-mode">word-char</property>
+            <property name="lines">2</property>
+            <property name="ellipsize">end</property>
+            <property name="width-chars">10</property>
+            <property name="max-width-chars">30</property>
+            <binding name="label">file-info(GtkListItem.item:GFileInfo, "standard::display-name", 
string)</binding>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>


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