mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-29 10:37:39 +00:00
file chooser: Improve column sizing
Allow the name and location columns to be resized, but arrange for their sizing to be reset when the column layout changes (either by the location column appearing/disappearing, or by the time column changing between mtime and atime. This gives a decent compromise between good automatic sizing and user control.
This commit is contained in:
parent
ed1c349e0b
commit
22294a4a0d
@ -1611,10 +1611,9 @@ update_time_renderer_visible (GtkFileChooserWidget *impl)
|
||||
g_object_set (priv->list_time_renderer,
|
||||
"visible", priv->show_time,
|
||||
NULL);
|
||||
gtk_widget_queue_draw (priv->browse_files_tree_view);
|
||||
gtk_tree_view_column_queue_resize (priv->list_time_column);
|
||||
clear_model_cache (impl, MODEL_COL_DATE_TEXT);
|
||||
clear_model_cache (impl, MODEL_COL_TIME_TEXT);
|
||||
gtk_widget_queue_draw (priv->browse_files_tree_view);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3812,6 +3811,35 @@ set_busy_cursor (GtkFileChooserWidget *impl,
|
||||
g_object_unref (cursor);
|
||||
}
|
||||
|
||||
static void
|
||||
update_columns (GtkFileChooserWidget *impl,
|
||||
gboolean location_visible,
|
||||
const gchar *time_title)
|
||||
{
|
||||
GtkFileChooserWidgetPrivate *priv = impl->priv;
|
||||
gboolean need_resize = FALSE;
|
||||
|
||||
if (gtk_tree_view_column_get_visible (priv->list_location_column) != location_visible)
|
||||
{
|
||||
gtk_tree_view_column_set_visible (priv->list_location_column, location_visible);
|
||||
need_resize = TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (gtk_tree_view_column_get_title (priv->list_time_column), time_title) != 0)
|
||||
{
|
||||
gtk_tree_view_column_set_title (priv->list_time_column, time_title);
|
||||
need_resize = TRUE;
|
||||
}
|
||||
|
||||
if (need_resize)
|
||||
{
|
||||
/* This undoes user resizing of columns when the columns change. */
|
||||
gtk_tree_view_column_set_expand (priv->list_name_column, TRUE);
|
||||
gtk_tree_view_column_set_expand (priv->list_location_column, TRUE);
|
||||
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
||||
}
|
||||
}
|
||||
|
||||
/* Creates a sort model to wrap the file system model and sets it on the tree view */
|
||||
static void
|
||||
load_set_model (GtkFileChooserWidget *impl)
|
||||
@ -3825,9 +3853,7 @@ load_set_model (GtkFileChooserWidget *impl)
|
||||
profile_msg (" gtk_tree_view_set_model start", NULL);
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
||||
GTK_TREE_MODEL (priv->browse_files_model));
|
||||
gtk_tree_view_column_set_visible (priv->list_location_column, FALSE);
|
||||
gtk_tree_view_column_set_title (priv->list_time_column, _("Modified"));
|
||||
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
||||
update_columns (impl, FALSE, _("Modified"));
|
||||
file_list_set_sort_column_ids (impl);
|
||||
set_sort_column (impl);
|
||||
profile_msg (" gtk_tree_view_set_model end", NULL);
|
||||
@ -6691,9 +6717,7 @@ search_setup_model (GtkFileChooserWidget *impl)
|
||||
gtk_tree_view_column_set_sort_column_id (priv->list_size_column, -1);
|
||||
gtk_tree_view_column_set_sort_column_id (priv->list_location_column, -1);
|
||||
|
||||
gtk_tree_view_column_set_visible (priv->list_location_column, TRUE);
|
||||
gtk_tree_view_column_set_title (priv->list_time_column, _("Modified"));
|
||||
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
||||
update_columns (impl, TRUE, _("Modified"));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -6912,9 +6936,7 @@ recent_idle_cleanup (gpointer data)
|
||||
gtk_tree_view_column_set_sort_column_id (priv->list_size_column, -1);
|
||||
gtk_tree_view_column_set_sort_column_id (priv->list_location_column, -1);
|
||||
|
||||
gtk_tree_view_column_set_visible (priv->list_location_column, TRUE);
|
||||
gtk_tree_view_column_set_title (priv->list_time_column, _("Accessed"));
|
||||
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
||||
update_columns (impl, TRUE, _("Accessed"));
|
||||
|
||||
set_busy_cursor (impl, FALSE);
|
||||
|
||||
|
@ -172,8 +172,8 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_name_column">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Name</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="expand">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererPixbuf" id="list_pixbuf_renderer">
|
||||
@ -182,15 +182,32 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_name_renderer">
|
||||
<property name="width-chars">10</property>
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_size_column">
|
||||
<object class="GtkTreeViewColumn" id="list_location_column">
|
||||
<property name="title" translatable="yes">Location</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="expand">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_location_renderer">
|
||||
<property name="xalign">0</property>
|
||||
<property name="width-chars">10</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="xpad">6</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_size_column">
|
||||
<property name="title" translatable="yes">Size</property>
|
||||
<property name="sizing">fixed</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_size_renderer">
|
||||
<property name="xalign">0</property>
|
||||
@ -199,38 +216,17 @@
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_location_column">
|
||||
<property name="resizable">True</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="title" translatable="yes">Location</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_location_renderer">
|
||||
<property name="xalign">0</property>
|
||||
<property name="ellipsize">start</property>
|
||||
<property name="width-chars">15</property>
|
||||
<property name="max-width-chars">30</property>
|
||||
<property name="xpad">6</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_time_column">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Modified</property>
|
||||
<property name="sizing">fixed</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_date_renderer">
|
||||
<property name="xalign">1</property>
|
||||
<property name="xpad">6</property>
|
||||
</object>
|
||||
<cell-packing>
|
||||
<property name="expand">True</property>
|
||||
</cell-packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_time_renderer">
|
||||
<property name="xalign">1</property>
|
||||
<property name="xpad">6</property>
|
||||
</object>
|
||||
</child>
|
||||
|
Loading…
Reference in New Issue
Block a user