[gtk/gbsneto/filechooser-column-view: 35/82] filechooserwidget: Replace 'list' page with column view
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gbsneto/filechooser-column-view: 35/82] filechooserwidget: Replace 'list' page with column view
- Date: Tue, 11 Oct 2022 22:04:05 +0000 (UTC)
commit 10a0dd2bf744c7d6b90d4a96a21e3e4c378698af
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Oct 7 17:48:26 2022 -0300
filechooserwidget: Replace 'list' page with column view
Replace the 'list' page of the main stack with another page, this
one containing a GtkColumnView. This, again, is the very minimal
code to achieve a column view - and validate the GListModel code
introduced in the previous commit - but there's a long way until
this column view covers the full range of features of the file
chooser.
The tree view still lives in an unused 'list2' page. From now on,
commits will "cannibalize" the treeview, each commit porting any
particular feature - be it a column, an event controller, etc -
to the column view, and dropping the corresponding feature from
the treeview.
gtk/gtkfilechooserwidget.c | 23 +++++++++++++++++++++++
gtk/ui/gtkfilechooserwidget.ui | 30 ++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 8b00a40e65..0260015da5 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -27,6 +27,7 @@
#include "deprecated/gtkcellrendererpixbuf.h"
#include "deprecated/gtkcellrenderertext.h"
#include "gtkdropdown.h"
+#include "gtkcolumnview.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkdragsource.h"
#include "gtkdroptarget.h"
@@ -43,6 +44,7 @@
#include "gtkmarshalers.h"
#include "gtkmessagedialog.h"
#include "gtkmountoperation.h"
+#include "gtkmultiselection.h"
#include "gtkpaned.h"
#include "gtkpathbarprivate.h"
#include "gtkplacessidebarprivate.h"
@@ -51,6 +53,7 @@
#include "gtkrecentmanager.h"
#include "gtksearchentryprivate.h"
#include "gtksettings.h"
+#include "gtksingleselection.h"
#include "gtksizegroup.h"
#include "gtksizerequest.h"
#include "gtkstack.h"
@@ -189,6 +192,7 @@ struct _GtkFileChooserWidget
GtkWidget *browse_files_stack;
GtkWidget *browse_files_swin;
GtkWidget *browse_files_tree_view;
+ GtkWidget *browse_files_column_view;
GtkWidget *remote_warning_bar;
GtkWidget *browse_files_popover;
@@ -209,6 +213,8 @@ struct _GtkFileChooserWidget
GtkFileSystemModel *browse_files_model;
char *browse_files_last_selected_name;
+ GtkSelectionModel *browse_files_selection_model;
+
GtkWidget *places_sidebar;
GtkWidget *places_view;
StartupMode startup_mode;
@@ -2612,6 +2618,14 @@ set_select_multiple (GtkFileChooserWidget *impl,
gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (impl->browse_files_tree_view), select_multiple);
+ g_clear_object (&impl->browse_files_selection_model);
+ impl->browse_files_selection_model = select_multiple
+ ? GTK_SELECTION_MODEL (gtk_multi_selection_new (G_LIST_MODEL (impl->browse_files_model)))
+ : GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (impl->browse_files_model)));
+
+ gtk_column_view_set_model (GTK_COLUMN_VIEW (impl->browse_files_column_view),
+ GTK_SELECTION_MODEL (impl->browse_files_selection_model));
+
impl->select_multiple = select_multiple;
g_object_notify (G_OBJECT (impl), "select-multiple");
}
@@ -4670,6 +4684,14 @@ set_list_model (GtkFileChooserWidget *impl,
_gtk_file_system_model_set_filter (impl->browse_files_model, impl->current_filter);
+ g_clear_object (&impl->browse_files_selection_model);
+ impl->browse_files_selection_model = impl->select_multiple
+ ? GTK_SELECTION_MODEL (gtk_multi_selection_new (G_LIST_MODEL (impl->browse_files_model)))
+ : GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (impl->browse_files_model)));
+
+ gtk_column_view_set_model (GTK_COLUMN_VIEW (impl->browse_files_column_view),
+ GTK_SELECTION_MODEL (impl->browse_files_selection_model));
+
return TRUE;
}
@@ -7689,6 +7711,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_bind_template_child (widget_class, GtkFileChooserWidget, browse_files_stack);
gtk_widget_class_bind_template_child (widget_class, GtkFileChooserWidget, places_sidebar);
gtk_widget_class_bind_template_child (widget_class, GtkFileChooserWidget, places_view);
+ gtk_widget_class_bind_template_child (widget_class, GtkFileChooserWidget, browse_files_column_view);
gtk_widget_class_bind_template_child (widget_class, GtkFileChooserWidget, browse_files_tree_view);
gtk_widget_class_bind_template_child (widget_class, GtkFileChooserWidget, browse_files_swin);
gtk_widget_class_bind_template_child (widget_class, GtkFileChooserWidget, browse_header_revealer);
diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui
index 22cd76a881..379bdbdae3 100644
--- a/gtk/ui/gtkfilechooserwidget.ui
+++ b/gtk/ui/gtkfilechooserwidget.ui
@@ -132,6 +132,36 @@
<child>
<object class="GtkStackPage">
<property name="name">list</property>
+ <property name="child">
+ <object class="GtkBox">
+ <property name="orientation">1</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="hscrollbar-policy">2</property>
+ <property name="vexpand">1</property>
+ <child>
+ <object class="GtkColumnView" id="browse_files_column_view">
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkActionBar" id="remote_warning_bar2">
+ <property name="visible">0</property>
+ <child type="center">
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">Remote location — only
searching the current folder</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">list2</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">1</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]