filechooser: add a Type column
Like GTK 3, it shows the kind of file (Image, Text, Archive...) so that formats of one kind sort together. TypeFormat=description or mime in gtkfilechooser.ini shows the description or MIME type instead.
This commit is contained in:
parent
3e735a77ef
commit
51b9e7bb06
5 changed files with 557 additions and 107 deletions
|
|
@ -204,10 +204,11 @@ typedef enum {
|
|||
"standard::is-hidden,standard::is-backup,standard::size," \
|
||||
"standard::fast-content-type,time::modified"
|
||||
enum {
|
||||
/* the first 3 must be these due to settings caching sort column */
|
||||
/* the first 4 must be these due to settings caching sort column */
|
||||
MODEL_COL_NAME,
|
||||
MODEL_COL_SIZE,
|
||||
MODEL_COL_MTIME,
|
||||
MODEL_COL_TYPE,
|
||||
MODEL_COL_FILE,
|
||||
MODEL_COL_NAME_COLLATED,
|
||||
MODEL_COL_IS_FOLDER,
|
||||
|
|
@ -226,6 +227,7 @@ enum {
|
|||
G_TYPE_STRING, /* MODEL_COL_NAME */ \
|
||||
G_TYPE_INT64, /* MODEL_COL_SIZE */ \
|
||||
G_TYPE_INT64, /* MODEL_COL_MTIME */ \
|
||||
G_TYPE_STRING, /* MODEL_COL_TYPE */ \
|
||||
G_TYPE_FILE, /* MODEL_COL_FILE */ \
|
||||
G_TYPE_STRING, /* MODEL_COL_NAME_COLLATED */ \
|
||||
G_TYPE_BOOLEAN, /* MODEL_COL_IS_FOLDER */ \
|
||||
|
|
@ -236,6 +238,75 @@ enum {
|
|||
G_TYPE_STRING, /* MODEL_COL_MTIME_TEXT */ \
|
||||
PANGO_TYPE_ELLIPSIZE_MODE /* MODEL_COL_ELLIPSIZE */
|
||||
|
||||
/* The kinds of files in the Type column, as Nautilus and GTK+ 3 have
|
||||
* them: by the generic icon of the shared MIME info; where GLib has none
|
||||
* (Windows and the Mac), by the MIME type ("x/" for all of x), by the
|
||||
* UTIs of the Mac a type conforms to, and on Windows by the extension
|
||||
* when the registry does not know it. The more special ones first. */
|
||||
static const struct
|
||||
{
|
||||
const gchar *icon_name;
|
||||
const gchar *mime_types;
|
||||
const gchar *utis;
|
||||
const gchar *extensions;
|
||||
const gchar *display_name;
|
||||
} file_type_categories[] = {
|
||||
{ "x-office-address-book", "text/vcard text/x-vcard text/directory",
|
||||
"public.vcard", "vcf", N_("Contacts") },
|
||||
{ "x-office-calendar", "text/calendar",
|
||||
"public.calendar-event com.apple.ical.ics", "ics", N_("Calendar") },
|
||||
{ "text-html", "text/html application/xhtml+xml",
|
||||
"public.html", "htm html xhtml", N_("Markup") },
|
||||
{ "x-office-document",
|
||||
"application/pdf application/msword application/rtf text/rtf "
|
||||
"application/vnd.oasis.opendocument.text "
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"com.adobe.pdf public.rtf com.microsoft.word.doc "
|
||||
"org.openxmlformats.wordprocessingml.document org.oasis-open.opendocument.text",
|
||||
"pdf doc docx odt rtf", N_("Document") },
|
||||
{ "x-office-spreadsheet",
|
||||
"text/csv application/vnd.ms-excel application/vnd.oasis.opendocument.spreadsheet "
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"public.comma-separated-values-text com.microsoft.excel.xls "
|
||||
"org.openxmlformats.spreadsheetml.sheet org.oasis-open.opendocument.spreadsheet",
|
||||
"csv xls xlsx ods", N_("Spreadsheet") },
|
||||
{ "x-office-presentation",
|
||||
"application/vnd.ms-powerpoint application/vnd.oasis.opendocument.presentation "
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
"com.microsoft.powerpoint.ppt org.openxmlformats.presentationml.presentation "
|
||||
"org.oasis-open.opendocument.presentation com.apple.keynote.key",
|
||||
"ppt pptx odp", N_("Presentation") },
|
||||
{ "text-x-script",
|
||||
"application/x-shellscript text/x-python text/x-perl application/javascript "
|
||||
"text/javascript application/x-bat",
|
||||
"public.script", "sh py pl js bat cmd ps1 vbs", N_("Program") },
|
||||
{ "application-x-executable",
|
||||
"application/x-msdownload application/x-ms-dos-executable application/x-executable "
|
||||
"application/x-msi",
|
||||
"public.executable com.apple.application", "exe com msi scr", N_("Program") },
|
||||
{ "package-x-generic",
|
||||
"application/zip application/x-zip-compressed application/x-7z-compressed "
|
||||
"application/x-rar-compressed application/vnd.rar application/gzip application/x-gzip "
|
||||
"application/x-tar application/x-gtar application/x-bzip2 application/x-xz "
|
||||
"application/x-compressed application/x-compress application/vnd.ms-cab-compressed "
|
||||
"application/java-archive application/zstd",
|
||||
"public.archive", "zip 7z rar gz tgz bz2 xz tar cab lzh lha zst jar", N_("Archive") },
|
||||
{ "font-x-generic",
|
||||
"font/ application/x-font-ttf application/x-font-otf application/font-woff "
|
||||
"application/vnd.ms-fontobject",
|
||||
"public.font", "ttf otf ttc fon woff woff2 pfb", N_("Font") },
|
||||
{ "image-x-generic", "image/", "public.image",
|
||||
"png jpg jpeg gif bmp tif tiff ico webp svg xcf psd pcx tga xpm heic avif", N_("Image") },
|
||||
{ "audio-x-generic", "audio/", "public.audio",
|
||||
"mp3 ogg oga opus flac wav wma m4a aac mid midi aif aiff ape", N_("Audio") },
|
||||
{ "video-x-generic", "video/", "public.movie",
|
||||
"avi mp4 m4v mkv webm mov wmv mpg mpeg flv ogv 3gp", N_("Video") },
|
||||
{ "text-x-generic", "text/", "public.text",
|
||||
"txt log ini cfg conf md nfo c h cc cpp hpp java css xml json yml yaml diff patch po tex",
|
||||
N_("Text") },
|
||||
{ "text-x-generic-template", NULL, NULL, NULL, N_("Text") },
|
||||
};
|
||||
|
||||
/* Identifiers for target types */
|
||||
enum {
|
||||
GTK_TREE_MODEL_ROW,
|
||||
|
|
@ -795,6 +866,7 @@ _gtk_file_chooser_default_init (GtkFileChooserDefault *impl)
|
|||
impl->select_multiple = FALSE;
|
||||
impl->show_hidden = FALSE;
|
||||
impl->show_size_column = TRUE;
|
||||
impl->show_type_column = TRUE;
|
||||
impl->show_thumbnails = TRUE;
|
||||
impl->thumbnail_max_size = 64;
|
||||
impl->list_view_icon_size = FALLBACK_LIST_VIEW_ICON_SIZE;
|
||||
|
|
@ -955,6 +1027,8 @@ gtk_file_chooser_default_finalize (GObject *object)
|
|||
g_object_unref (impl->rename_file);
|
||||
if (impl->tooltip_file)
|
||||
g_object_unref (impl->tooltip_file);
|
||||
if (impl->type_texts)
|
||||
g_hash_table_destroy (impl->type_texts);
|
||||
|
||||
G_OBJECT_CLASS (_gtk_file_chooser_default_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -5257,6 +5331,12 @@ popup_menu_detach_cb (GtkWidget *attach_widget,
|
|||
impl->browse_files_popup_menu_hidden_files_item = NULL;
|
||||
impl->browse_files_popup_menu_thumbnails_item = NULL;
|
||||
impl->browse_files_popup_menu_preview_item = NULL;
|
||||
impl->browse_files_popup_menu_size_column_item = NULL;
|
||||
impl->browse_files_popup_menu_type_column_item = NULL;
|
||||
impl->browse_files_popup_menu_sort_by_name_item = NULL;
|
||||
impl->browse_files_popup_menu_sort_by_size_item = NULL;
|
||||
impl->browse_files_popup_menu_sort_by_mtime_item = NULL;
|
||||
impl->browse_files_popup_menu_sort_by_type_item = NULL;
|
||||
}
|
||||
|
||||
/* "Visit File": a file found by searching, or a recent one, in its folder */
|
||||
|
|
@ -5583,85 +5663,46 @@ show_size_column_toggled_cb (GtkCheckMenuItem *item,
|
|||
impl->show_size_column);
|
||||
}
|
||||
|
||||
/* Callback used when "Sort by Name" menu item is toggled */
|
||||
/* Callback used when the "Show Type Column" menu item is toggled */
|
||||
static void
|
||||
sort_by_name_toggled_cb (GtkCheckMenuItem *item,
|
||||
GtkFileChooserDefault *impl)
|
||||
show_type_column_toggled_cb (GtkCheckMenuItem *item,
|
||||
GtkFileChooserDefault *impl)
|
||||
{
|
||||
GtkCheckMenuItem *size_item = GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_sort_by_size_item),
|
||||
*mtime_item = GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_sort_by_mtime_item);
|
||||
impl->show_type_column = gtk_check_menu_item_get_active (item);
|
||||
|
||||
// This could be avoided if we used GtkAction's
|
||||
if (!gtk_check_menu_item_get_active (item) &&
|
||||
!gtk_check_menu_item_get_active (size_item) &&
|
||||
!gtk_check_menu_item_get_active (mtime_item))
|
||||
{
|
||||
gtk_check_menu_item_set_active (item, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gtk_check_menu_item_get_active (item))
|
||||
{
|
||||
gtk_check_menu_item_set_active (size_item, FALSE);
|
||||
gtk_check_menu_item_set_active (mtime_item, FALSE);
|
||||
|
||||
impl->sort_column = MODEL_COL_NAME;
|
||||
set_sort_column (impl);
|
||||
}
|
||||
gtk_tree_view_column_set_visible (impl->list_type_column,
|
||||
impl->show_type_column);
|
||||
}
|
||||
|
||||
/* Callback used when "Sort by Size" menu item is toggled */
|
||||
/* The "Sort by" items of the icon view are radio items: the one toggled on
|
||||
* sorts by its column, the others go off; the last one stays on. */
|
||||
static void
|
||||
sort_by_size_toggled_cb (GtkCheckMenuItem *item,
|
||||
GtkFileChooserDefault *impl)
|
||||
sort_by_toggled_cb (GtkCheckMenuItem *item,
|
||||
GtkFileChooserDefault *impl)
|
||||
{
|
||||
GtkCheckMenuItem *name_item = GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_sort_by_name_item),
|
||||
*mtime_item = GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_sort_by_mtime_item);
|
||||
GtkWidget *items[4];
|
||||
gint i;
|
||||
|
||||
// This could be avoided if we used GtkAction's
|
||||
if (!gtk_check_menu_item_get_active (item) &&
|
||||
!gtk_check_menu_item_get_active (name_item) &&
|
||||
!gtk_check_menu_item_get_active (mtime_item))
|
||||
items[0] = impl->browse_files_popup_menu_sort_by_name_item;
|
||||
items[1] = impl->browse_files_popup_menu_sort_by_size_item;
|
||||
items[2] = impl->browse_files_popup_menu_sort_by_mtime_item;
|
||||
items[3] = impl->browse_files_popup_menu_sort_by_type_item;
|
||||
|
||||
if (!gtk_check_menu_item_get_active (item))
|
||||
{
|
||||
for (i = 0; i < G_N_ELEMENTS (items); i++)
|
||||
if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (items[i])))
|
||||
return;
|
||||
gtk_check_menu_item_set_active (item, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gtk_check_menu_item_get_active (item))
|
||||
{
|
||||
gtk_check_menu_item_set_active (name_item, FALSE);
|
||||
gtk_check_menu_item_set_active (mtime_item, FALSE);
|
||||
for (i = 0; i < G_N_ELEMENTS (items); i++)
|
||||
if (items[i] != GTK_WIDGET (item))
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (items[i]), FALSE);
|
||||
|
||||
impl->sort_column = MODEL_COL_SIZE;
|
||||
set_sort_column (impl);
|
||||
}
|
||||
}
|
||||
|
||||
/* Callback used when "Sort by Modification Date" menu item is toggled */
|
||||
static void
|
||||
sort_by_mtime_toggled_cb (GtkCheckMenuItem *item,
|
||||
GtkFileChooserDefault *impl)
|
||||
{
|
||||
GtkCheckMenuItem *name_item = GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_sort_by_name_item),
|
||||
*size_item = GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_sort_by_size_item);
|
||||
|
||||
// This could be avoided if we used GtkAction's
|
||||
if (!gtk_check_menu_item_get_active (item) &&
|
||||
!gtk_check_menu_item_get_active (name_item) &&
|
||||
!gtk_check_menu_item_get_active (size_item))
|
||||
{
|
||||
gtk_check_menu_item_set_active (item, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gtk_check_menu_item_get_active (item))
|
||||
{
|
||||
gtk_check_menu_item_set_active (name_item, FALSE);
|
||||
gtk_check_menu_item_set_active (size_item, FALSE);
|
||||
|
||||
impl->sort_column = MODEL_COL_MTIME;
|
||||
set_sort_column (impl);
|
||||
}
|
||||
impl->sort_column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "gtk-sort-column"));
|
||||
set_sort_column (impl);
|
||||
}
|
||||
|
||||
/* Callback used when "Ascending" menu item is toggled */
|
||||
|
|
@ -6007,6 +6048,13 @@ file_list_build_popup_menu (GtkFileChooserDefault *impl)
|
|||
G_CALLBACK (show_size_column_toggled_cb), impl);
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
||||
|
||||
item = gtk_check_menu_item_new_with_mnemonic (_("Show T_ype Column"));
|
||||
impl->browse_files_popup_menu_type_column_item = item;
|
||||
g_signal_connect (item, "toggled",
|
||||
G_CALLBACK (show_type_column_toggled_cb), impl);
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
||||
}
|
||||
else if (impl->view_mode == VIEW_MODE_ICON)
|
||||
{
|
||||
|
|
@ -6019,24 +6067,36 @@ file_list_build_popup_menu (GtkFileChooserDefault *impl)
|
|||
subitem = gtk_check_menu_item_new_with_mnemonic (_("Sort by _Name"));
|
||||
impl->browse_files_popup_menu_sort_by_name_item = subitem;
|
||||
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (subitem), TRUE);
|
||||
g_object_set_data (G_OBJECT (subitem), I_("gtk-sort-column"), GINT_TO_POINTER (MODEL_COL_NAME));
|
||||
g_signal_connect (subitem, "toggled",
|
||||
G_CALLBACK (sort_by_name_toggled_cb), impl);
|
||||
G_CALLBACK (sort_by_toggled_cb), impl);
|
||||
gtk_widget_show (subitem);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
|
||||
|
||||
subitem = gtk_check_menu_item_new_with_mnemonic (_("Sort by _Size"));
|
||||
impl->browse_files_popup_menu_sort_by_size_item = subitem;
|
||||
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (subitem), TRUE);
|
||||
g_object_set_data (G_OBJECT (subitem), I_("gtk-sort-column"), GINT_TO_POINTER (MODEL_COL_SIZE));
|
||||
g_signal_connect (subitem, "toggled",
|
||||
G_CALLBACK (sort_by_size_toggled_cb), impl);
|
||||
G_CALLBACK (sort_by_toggled_cb), impl);
|
||||
gtk_widget_show (subitem);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
|
||||
|
||||
subitem = gtk_check_menu_item_new_with_mnemonic (_("Sort by Modification _Date"));
|
||||
impl->browse_files_popup_menu_sort_by_mtime_item = subitem;
|
||||
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (subitem), TRUE);
|
||||
g_object_set_data (G_OBJECT (subitem), I_("gtk-sort-column"), GINT_TO_POINTER (MODEL_COL_MTIME));
|
||||
g_signal_connect (subitem, "toggled",
|
||||
G_CALLBACK (sort_by_mtime_toggled_cb), impl);
|
||||
G_CALLBACK (sort_by_toggled_cb), impl);
|
||||
gtk_widget_show (subitem);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
|
||||
|
||||
subitem = gtk_check_menu_item_new_with_mnemonic (_("Sort by _Type"));
|
||||
impl->browse_files_popup_menu_sort_by_type_item = subitem;
|
||||
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (subitem), TRUE);
|
||||
g_object_set_data (G_OBJECT (subitem), I_("gtk-sort-column"), GINT_TO_POINTER (MODEL_COL_TYPE));
|
||||
g_signal_connect (subitem, "toggled",
|
||||
G_CALLBACK (sort_by_toggled_cb), impl);
|
||||
gtk_widget_show (subitem);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
|
||||
|
||||
|
|
@ -6149,6 +6209,14 @@ file_list_update_popup_menu (GtkFileChooserDefault *impl)
|
|||
impl->show_size_column);
|
||||
g_signal_handlers_unblock_by_func (impl->browse_files_popup_menu_size_column_item,
|
||||
G_CALLBACK (show_size_column_toggled_cb), impl);
|
||||
|
||||
/* 'Show Type Column' */
|
||||
g_signal_handlers_block_by_func (impl->browse_files_popup_menu_type_column_item,
|
||||
G_CALLBACK (show_type_column_toggled_cb), impl);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_type_column_item),
|
||||
impl->show_type_column);
|
||||
g_signal_handlers_unblock_by_func (impl->browse_files_popup_menu_type_column_item,
|
||||
G_CALLBACK (show_type_column_toggled_cb), impl);
|
||||
}
|
||||
else if (impl->view_mode == VIEW_MODE_ICON)
|
||||
{
|
||||
|
|
@ -6158,26 +6226,23 @@ file_list_update_popup_menu (GtkFileChooserDefault *impl)
|
|||
if (impl->current_model == GTK_TREE_MODEL (impl->recent_model))
|
||||
gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (impl->current_model), &column, &order);
|
||||
|
||||
g_signal_handlers_block_by_func (impl->browse_files_popup_menu_sort_by_name_item,
|
||||
G_CALLBACK (sort_by_name_toggled_cb), impl);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_sort_by_name_item),
|
||||
column == MODEL_COL_NAME);
|
||||
g_signal_handlers_unblock_by_func (impl->browse_files_popup_menu_sort_by_name_item,
|
||||
G_CALLBACK (sort_by_name_toggled_cb), impl);
|
||||
{
|
||||
GtkWidget *items[4];
|
||||
gint i;
|
||||
|
||||
g_signal_handlers_block_by_func (impl->browse_files_popup_menu_sort_by_size_item,
|
||||
G_CALLBACK (sort_by_size_toggled_cb), impl);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_sort_by_size_item),
|
||||
column == MODEL_COL_SIZE);
|
||||
g_signal_handlers_unblock_by_func (impl->browse_files_popup_menu_sort_by_size_item,
|
||||
G_CALLBACK (sort_by_size_toggled_cb), impl);
|
||||
|
||||
g_signal_handlers_block_by_func (impl->browse_files_popup_menu_sort_by_mtime_item,
|
||||
G_CALLBACK (sort_by_mtime_toggled_cb), impl);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_sort_by_mtime_item),
|
||||
column == MODEL_COL_MTIME);
|
||||
g_signal_handlers_unblock_by_func (impl->browse_files_popup_menu_sort_by_mtime_item,
|
||||
G_CALLBACK (sort_by_mtime_toggled_cb), impl);
|
||||
items[0] = impl->browse_files_popup_menu_sort_by_name_item;
|
||||
items[1] = impl->browse_files_popup_menu_sort_by_size_item;
|
||||
items[2] = impl->browse_files_popup_menu_sort_by_mtime_item;
|
||||
items[3] = impl->browse_files_popup_menu_sort_by_type_item;
|
||||
for (i = 0; i < G_N_ELEMENTS (items); i++)
|
||||
{
|
||||
g_signal_handlers_block_by_func (items[i], G_CALLBACK (sort_by_toggled_cb), impl);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (items[i]),
|
||||
column == GPOINTER_TO_INT (g_object_get_data (G_OBJECT (items[i]),
|
||||
"gtk-sort-column")));
|
||||
g_signal_handlers_unblock_by_func (items[i], G_CALLBACK (sort_by_toggled_cb), impl);
|
||||
}
|
||||
}
|
||||
|
||||
g_signal_handlers_block_by_func (impl->browse_files_popup_menu_sort_ascending_item,
|
||||
G_CALLBACK (sort_ascending_toggled_cb), impl);
|
||||
|
|
@ -6498,6 +6563,7 @@ file_list_set_sort_column_ids (GtkFileChooserDefault *impl)
|
|||
gtk_tree_view_column_set_sort_column_id (impl->list_name_column, MODEL_COL_NAME);
|
||||
gtk_tree_view_column_set_sort_column_id (impl->list_mtime_column, MODEL_COL_MTIME);
|
||||
gtk_tree_view_column_set_sort_column_id (impl->list_size_column, MODEL_COL_SIZE);
|
||||
gtk_tree_view_column_set_sort_column_id (impl->list_type_column, MODEL_COL_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6905,6 +6971,18 @@ file_list_update_fixed_sizing (GtkFileChooserDefault *impl)
|
|||
file_list_set_fixed_column_width (tree_view, impl->list_mtime_column, texts);
|
||||
g_ptr_array_free (texts, TRUE);
|
||||
|
||||
/* Type column: the kinds of files; descriptions and MIME types are
|
||||
* longer and get the width of a long kind, the rest is ellipsized */
|
||||
texts = g_ptr_array_new_with_free_func (g_free);
|
||||
for (i = 0; i < G_N_ELEMENTS (file_type_categories); i++)
|
||||
g_ptr_array_add (texts, g_strdup (_(file_type_categories[i].display_name)));
|
||||
g_ptr_array_add (texts, g_strdup (_("Folder")));
|
||||
g_ptr_array_add (texts, g_strdup (_("Unknown")));
|
||||
if (impl->type_format != TYPE_FORMAT_CATEGORY)
|
||||
g_ptr_array_add (texts, g_strdup ("application/vnd.oasis.opendocument"));
|
||||
file_list_set_fixed_column_width (tree_view, impl->list_type_column, texts);
|
||||
g_ptr_array_free (texts, TRUE);
|
||||
|
||||
gtk_tree_view_column_set_sizing (impl->list_name_column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
if (gtk_tree_view_column_get_fixed_width (impl->list_name_column) <= 0)
|
||||
gtk_tree_view_column_set_fixed_width (impl->list_name_column, 200);
|
||||
|
|
@ -7023,6 +7101,19 @@ create_browse_files_tree_view (GtkFileChooserDefault *impl)
|
|||
gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_files_tree_view), column);
|
||||
impl->list_size_column = column;
|
||||
|
||||
/* Type column */
|
||||
|
||||
column = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_resizable (column, TRUE);
|
||||
gtk_tree_view_column_set_title (column, _("Type"));
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||
gtk_tree_view_column_pack_start (column, renderer, TRUE);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_files_tree_view), column);
|
||||
gtk_tree_view_column_set_visible (column, impl->show_type_column);
|
||||
impl->list_type_column = column;
|
||||
|
||||
/* Modification time column */
|
||||
|
||||
column = gtk_tree_view_column_new ();
|
||||
|
|
@ -7724,6 +7815,7 @@ view_mode_set (GtkFileChooserDefault *impl, ViewMode view_mode)
|
|||
impl->list_name_column = NULL;
|
||||
impl->list_mtime_column = NULL;
|
||||
impl->list_size_column = NULL;
|
||||
impl->list_type_column = NULL;
|
||||
gtk_widget_set_visible (impl->icon_view_scale_hbox, !impl->compact_view);
|
||||
}
|
||||
else if (view_mode == VIEW_MODE_LIST)
|
||||
|
|
@ -9590,7 +9682,8 @@ settings_load (GtkFileChooserDefault *impl)
|
|||
LocationMode location_mode;
|
||||
ViewMode view_mode;
|
||||
gboolean show_hidden;
|
||||
gboolean show_size_column, show_thumbnails, show_preview_panel;
|
||||
gboolean show_size_column, show_type_column, show_thumbnails, show_preview_panel;
|
||||
TypeFormat type_format;
|
||||
gint thumbnail_max_size, thumbnail_max_size_remote;
|
||||
gint sort_column, icon_view_scale;
|
||||
GtkSortType sort_order;
|
||||
|
|
@ -9603,6 +9696,8 @@ settings_load (GtkFileChooserDefault *impl)
|
|||
icon_view_scale = _gtk_file_chooser_settings_get_icon_view_scale (settings);
|
||||
show_hidden = _gtk_file_chooser_settings_get_show_hidden (settings);
|
||||
show_size_column = _gtk_file_chooser_settings_get_show_size_column (settings);
|
||||
show_type_column = _gtk_file_chooser_settings_get_show_type_column (settings);
|
||||
type_format = _gtk_file_chooser_settings_get_type_format (settings);
|
||||
show_thumbnails = _gtk_file_chooser_settings_get_show_thumbnails (settings);
|
||||
show_preview_panel = _gtk_file_chooser_settings_get_show_preview_panel (settings);
|
||||
thumbnail_max_size = _gtk_file_chooser_settings_get_thumbnail_max_size (settings, FALSE);
|
||||
|
|
@ -9658,6 +9753,17 @@ settings_load (GtkFileChooserDefault *impl)
|
|||
preview_panel_sync (impl);
|
||||
if (impl->list_size_column)
|
||||
gtk_tree_view_column_set_visible (impl->list_size_column, show_size_column);
|
||||
impl->show_type_column = show_type_column;
|
||||
if (impl->list_type_column)
|
||||
gtk_tree_view_column_set_visible (impl->list_type_column, show_type_column);
|
||||
if (impl->type_format != type_format)
|
||||
{
|
||||
impl->type_format = type_format;
|
||||
if (impl->type_texts)
|
||||
g_hash_table_remove_all (impl->type_texts);
|
||||
if (impl->browse_files_tree_view)
|
||||
file_list_update_fixed_sizing (impl);
|
||||
}
|
||||
|
||||
impl->sort_column = sort_column;
|
||||
impl->sort_order = sort_order;
|
||||
|
|
@ -9702,6 +9808,7 @@ settings_save (GtkFileChooserDefault *impl)
|
|||
_gtk_file_chooser_settings_set_icon_view_scale (settings, impl->icon_view_icon_size);
|
||||
_gtk_file_chooser_settings_set_show_hidden (settings, gtk_file_chooser_get_show_hidden (GTK_FILE_CHOOSER (impl)));
|
||||
_gtk_file_chooser_settings_set_show_size_column (settings, impl->show_size_column);
|
||||
_gtk_file_chooser_settings_set_show_type_column (settings, impl->show_type_column);
|
||||
_gtk_file_chooser_settings_set_show_thumbnails (settings, impl->show_thumbnails);
|
||||
_gtk_file_chooser_settings_set_show_preview_panel (settings, impl->show_preview_panel);
|
||||
_gtk_file_chooser_settings_set_thumbnail_max_size (settings, FALSE, impl->thumbnail_max_size);
|
||||
|
|
@ -9886,6 +9993,28 @@ mtime_sort_func (GtkTreeModel *model,
|
|||
}
|
||||
}
|
||||
|
||||
/* Sort callback for the type column: the same kinds together, by name
|
||||
* within each */
|
||||
static gint
|
||||
type_sort_func (GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data)
|
||||
{
|
||||
COMPARE_DIRECTORIES;
|
||||
else
|
||||
{
|
||||
gint result;
|
||||
|
||||
result = g_strcmp0 (g_value_get_string (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_TYPE)),
|
||||
g_value_get_string (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_TYPE)));
|
||||
if (result == 0)
|
||||
result = g_strcmp0 (g_value_get_string (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_NAME_COLLATED)),
|
||||
g_value_get_string (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_NAME_COLLATED)));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/* Callback used when the sort column changes. We cache the sort order for use
|
||||
* in name_sort_func().
|
||||
*/
|
||||
|
|
@ -10922,6 +11051,149 @@ file_icon_dim_if_hidden (GtkFileChooserDefault *impl,
|
|||
return pixbuf;
|
||||
}
|
||||
|
||||
/* What the Type column shows for a file, as in GTK+ 3 (and Nautilus):
|
||||
* by default the kind of file, from the generic icon of its type, so
|
||||
* that pictures or archives of all formats come together; the strings
|
||||
* are kept per type, as there are few types in a folder. */
|
||||
/* Whether @word is one of the words of @list (separated by spaces), or
|
||||
* with @prefixes begins with one of them that ends with a slash */
|
||||
static gboolean
|
||||
file_type_word_in (const gchar *list,
|
||||
const gchar *word,
|
||||
gboolean prefixes)
|
||||
{
|
||||
gsize length = strlen (word);
|
||||
|
||||
while (list && *list)
|
||||
{
|
||||
const gchar *end = strchr (list, ' ');
|
||||
gsize n = end ? (gsize) (end - list) : strlen (list);
|
||||
|
||||
if (g_ascii_strncasecmp (list, word, n) == 0 &&
|
||||
(n == length || (prefixes && n < length && list[n - 1] == '/')))
|
||||
return TRUE;
|
||||
list = end ? end + 1 : NULL;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
/* Whether the type of the Mac @content_type conforms to one of @utis */
|
||||
static gboolean
|
||||
file_type_conforms (const gchar *content_type,
|
||||
const gchar *utis)
|
||||
{
|
||||
gchar **list = g_strsplit (utis, " ", -1);
|
||||
gboolean result = FALSE;
|
||||
gint i;
|
||||
|
||||
for (i = 0; list[i] && !result; i++)
|
||||
result = g_content_type_is_a (content_type, list[i]);
|
||||
g_strfreev (list);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The kind of files of @content_type, untranslated, or NULL */
|
||||
static const gchar *
|
||||
file_type_category (const gchar *content_type)
|
||||
{
|
||||
const gchar *result = NULL;
|
||||
gchar *icon_name, *mime_type;
|
||||
gint i;
|
||||
|
||||
icon_name = g_content_type_get_generic_icon_name (content_type);
|
||||
for (i = 0; icon_name && !result && i < G_N_ELEMENTS (file_type_categories); i++)
|
||||
if (strcmp (file_type_categories[i].icon_name, icon_name) == 0)
|
||||
result = file_type_categories[i].display_name;
|
||||
g_free (icon_name);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
mime_type = g_content_type_get_mime_type (content_type);
|
||||
for (i = 0; mime_type && !result && i < G_N_ELEMENTS (file_type_categories); i++)
|
||||
if (file_type_word_in (file_type_categories[i].mime_types, mime_type, TRUE))
|
||||
result = file_type_categories[i].display_name;
|
||||
g_free (mime_type);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (content_type[0] == '.')
|
||||
{
|
||||
/* Windows: the extension is the type */
|
||||
for (i = 0; !result && i < G_N_ELEMENTS (file_type_categories); i++)
|
||||
if (file_type_word_in (file_type_categories[i].extensions, content_type + 1, FALSE))
|
||||
result = file_type_categories[i].display_name;
|
||||
}
|
||||
#ifndef G_OS_WIN32
|
||||
else if (strchr (content_type, '/') == NULL)
|
||||
{
|
||||
/* the Mac: UTIs */
|
||||
for (i = 0; !result && i < G_N_ELEMENTS (file_type_categories); i++)
|
||||
if (file_type_categories[i].utis &&
|
||||
file_type_conforms (content_type, file_type_categories[i].utis))
|
||||
result = file_type_categories[i].display_name;
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
file_type_text (GtkFileChooserDefault *impl,
|
||||
GFileInfo *info)
|
||||
{
|
||||
const gchar *content_type;
|
||||
gchar *text = NULL;
|
||||
|
||||
if (_gtk_file_info_consider_as_directory (info))
|
||||
return _("Folder");
|
||||
|
||||
content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
|
||||
if (content_type == NULL)
|
||||
content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
|
||||
if (content_type == NULL)
|
||||
return "";
|
||||
|
||||
if (impl->type_texts == NULL)
|
||||
impl->type_texts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
else
|
||||
{
|
||||
const gchar *known = g_hash_table_lookup (impl->type_texts, content_type);
|
||||
|
||||
if (known)
|
||||
return known;
|
||||
}
|
||||
|
||||
switch (impl->type_format)
|
||||
{
|
||||
case TYPE_FORMAT_MIME:
|
||||
text = g_content_type_get_mime_type (content_type);
|
||||
break;
|
||||
|
||||
case TYPE_FORMAT_DESCRIPTION:
|
||||
text = g_content_type_get_description (content_type);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
const gchar *category = file_type_category (content_type);
|
||||
|
||||
if (category)
|
||||
text = g_strdup (_(category));
|
||||
if (text == NULL)
|
||||
text = g_content_type_get_description (content_type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (text == NULL)
|
||||
text = g_strdup (_("Unknown"));
|
||||
|
||||
g_hash_table_insert (impl->type_texts, g_strdup (content_type), text);
|
||||
return text;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
file_system_model_set (GtkFileSystemModel *model,
|
||||
GFile *file,
|
||||
|
|
@ -11071,6 +11343,9 @@ file_system_model_set (GtkFileSystemModel *model,
|
|||
case MODEL_COL_ELLIPSIZE:
|
||||
g_value_set_enum (value, info ? PANGO_ELLIPSIZE_END : PANGO_ELLIPSIZE_NONE);
|
||||
break;
|
||||
case MODEL_COL_TYPE:
|
||||
g_value_set_string (value, info ? file_type_text (impl, info) : _("Folder"));
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
|
|
@ -11105,6 +11380,7 @@ set_list_model (GtkFileChooserDefault *impl,
|
|||
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), MODEL_COL_NAME, name_sort_func, impl, NULL);
|
||||
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), MODEL_COL_SIZE, size_sort_func, impl, NULL);
|
||||
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), MODEL_COL_MTIME, mtime_sort_func, impl, NULL);
|
||||
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), MODEL_COL_TYPE, type_sort_func, impl, NULL);
|
||||
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), NULL, NULL, NULL);
|
||||
/* Sort from the start: the model sorts files as it adds them, while
|
||||
* resorting rows that are already shown takes extra work. */
|
||||
|
|
@ -13434,6 +13710,10 @@ search_setup_model (GtkFileChooserDefault *impl)
|
|||
MODEL_COL_SIZE,
|
||||
size_sort_func,
|
||||
impl, NULL);
|
||||
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->search_model),
|
||||
MODEL_COL_TYPE,
|
||||
type_sort_func,
|
||||
impl, NULL);
|
||||
set_sort_column (impl);
|
||||
|
||||
/* EB: setting the model here will make the hits list update feel
|
||||
|
|
@ -13646,6 +13926,10 @@ recent_setup_model (GtkFileChooserDefault *impl)
|
|||
MODEL_COL_MTIME,
|
||||
mtime_sort_func,
|
||||
impl, NULL);
|
||||
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->recent_model),
|
||||
MODEL_COL_TYPE,
|
||||
type_sort_func,
|
||||
impl, NULL);
|
||||
set_sort_column (impl);
|
||||
}
|
||||
|
||||
|
|
@ -14469,26 +14753,29 @@ update_cell_renderer_attributes (GtkFileChooserDefault *impl)
|
|||
}
|
||||
g_list_free (list);
|
||||
|
||||
/* size */
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (impl->browse_files_tree_view), 1);
|
||||
list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
|
||||
renderer = list->data;
|
||||
gtk_tree_view_column_set_attributes (column, renderer,
|
||||
"text", MODEL_COL_SIZE_TEXT,
|
||||
NULL);
|
||||
/* size, type, mtime */
|
||||
{
|
||||
GtkTreeViewColumn *columns[3];
|
||||
gint texts[3], i;
|
||||
|
||||
gtk_tree_view_column_add_attribute (column, renderer, "sensitive", MODEL_COL_IS_SENSITIVE);
|
||||
g_list_free (list);
|
||||
columns[0] = impl->list_size_column;
|
||||
texts[0] = MODEL_COL_SIZE_TEXT;
|
||||
columns[1] = impl->list_type_column;
|
||||
texts[1] = MODEL_COL_TYPE;
|
||||
columns[2] = impl->list_mtime_column;
|
||||
texts[2] = MODEL_COL_MTIME_TEXT;
|
||||
|
||||
/* mtime */
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (impl->browse_files_tree_view), 2);
|
||||
list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
|
||||
renderer = list->data;
|
||||
gtk_tree_view_column_set_attributes (column, renderer,
|
||||
"text", MODEL_COL_MTIME_TEXT,
|
||||
NULL);
|
||||
gtk_tree_view_column_add_attribute (column, renderer, "sensitive", MODEL_COL_IS_SENSITIVE);
|
||||
g_list_free (list);
|
||||
for (i = 0; i < G_N_ELEMENTS (columns); i++)
|
||||
{
|
||||
list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (columns[i]));
|
||||
renderer = list->data;
|
||||
gtk_tree_view_column_set_attributes (columns[i], renderer,
|
||||
"text", texts[i],
|
||||
NULL);
|
||||
gtk_tree_view_column_add_attribute (columns[i], renderer, "sensitive", MODEL_COL_IS_SENSITIVE);
|
||||
g_list_free (list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
|
|
|||
|
|
@ -197,9 +197,11 @@ struct _GtkFileChooserDefault
|
|||
GtkWidget *browse_files_popup_menu_hidden_files_item;
|
||||
GtkWidget *browse_files_popup_menu_thumbnails_item;
|
||||
GtkWidget *browse_files_popup_menu_size_column_item;
|
||||
GtkWidget *browse_files_popup_menu_type_column_item;
|
||||
GtkWidget *browse_files_popup_menu_sort_by_name_item;
|
||||
GtkWidget *browse_files_popup_menu_sort_by_size_item;
|
||||
GtkWidget *browse_files_popup_menu_sort_by_mtime_item;
|
||||
GtkWidget *browse_files_popup_menu_sort_by_type_item;
|
||||
GtkWidget *browse_files_popup_menu_sort_ascending_item;
|
||||
GtkWidget *browse_files_popup_menu_sort_descending_item;
|
||||
GtkWidget *browse_new_folder_button;
|
||||
|
|
@ -326,6 +328,9 @@ struct _GtkFileChooserDefault
|
|||
GtkCellRenderer *list_icon_renderer;
|
||||
GtkTreeViewColumn *list_mtime_column;
|
||||
GtkTreeViewColumn *list_size_column;
|
||||
GtkTreeViewColumn *list_type_column;
|
||||
GHashTable *type_texts; /* content type -> what the Type column shows */
|
||||
gint type_format;
|
||||
|
||||
GSource *edited_idle;
|
||||
char *edited_new_text;
|
||||
|
|
@ -379,6 +384,7 @@ struct _GtkFileChooserDefault
|
|||
guint has_desktop : 1;
|
||||
guint has_search : 1;
|
||||
guint show_size_column : 1;
|
||||
guint show_type_column : 1;
|
||||
guint show_thumbnails : 1;
|
||||
guint compact_view : 1; /* the icon view with small icons beside the names */
|
||||
guint show_preview_panel : 1;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@
|
|||
#define ICON_VIEW_SCALE_KEY "IconViewScale"
|
||||
#define SHOW_HIDDEN_KEY "ShowHidden"
|
||||
#define SHOW_SIZE_COLUMN_KEY "ShowSizeColumn"
|
||||
#define SHOW_TYPE_COLUMN_KEY "ShowTypeColumn"
|
||||
#define TYPE_FORMAT_KEY "TypeFormat"
|
||||
#define SHOW_THUMBNAILS_KEY "ShowThumbnails"
|
||||
#define SHOW_PREVIEW_PANEL_KEY "ShowPreviewPanel"
|
||||
#define THUMBNAIL_MAX_SIZE_KEY "ThumbnailMaxSize"
|
||||
|
|
@ -58,6 +60,11 @@
|
|||
#define COLUMN_NAME_STRING "name"
|
||||
#define COLUMN_MTIME_STRING "modified"
|
||||
#define COLUMN_SIZE_STRING "size"
|
||||
#define COLUMN_TYPE_STRING "type"
|
||||
|
||||
#define TYPE_FORMAT_CATEGORY_STRING "category"
|
||||
#define TYPE_FORMAT_DESCRIPTION_STRING "description"
|
||||
#define TYPE_FORMAT_MIME_STRING "mime"
|
||||
#define SORT_ASCENDING_STRING "ascending"
|
||||
#define SORT_DESCENDING_STRING "descending"
|
||||
|
||||
|
|
@ -216,6 +223,32 @@ ensure_settings_read (GtkFileChooserSettings *settings)
|
|||
else
|
||||
settings->show_size_column = value != FALSE;
|
||||
|
||||
/* Show type column */
|
||||
|
||||
value = g_key_file_get_boolean (key_file, SETTINGS_GROUP,
|
||||
SHOW_TYPE_COLUMN_KEY, &error);
|
||||
if (error)
|
||||
warn_if_invalid_key_and_clear_error (SHOW_TYPE_COLUMN_KEY, &error);
|
||||
else
|
||||
settings->show_type_column = value != FALSE;
|
||||
|
||||
/* What the type column shows; only read, as GTK+ 3 has it in
|
||||
* dconf-editor only */
|
||||
{
|
||||
gchar *format = g_key_file_get_string (key_file, SETTINGS_GROUP,
|
||||
TYPE_FORMAT_KEY, NULL);
|
||||
|
||||
if (format == NULL)
|
||||
;
|
||||
else if (EQ (format, TYPE_FORMAT_DESCRIPTION_STRING))
|
||||
settings->type_format = TYPE_FORMAT_DESCRIPTION;
|
||||
else if (EQ (format, TYPE_FORMAT_MIME_STRING))
|
||||
settings->type_format = TYPE_FORMAT_MIME;
|
||||
else if (EQ (format, TYPE_FORMAT_CATEGORY_STRING))
|
||||
settings->type_format = TYPE_FORMAT_CATEGORY;
|
||||
g_free (format);
|
||||
}
|
||||
|
||||
/* Show thumbnails */
|
||||
|
||||
value = g_key_file_get_boolean (key_file, SETTINGS_GROUP,
|
||||
|
|
@ -253,6 +286,8 @@ ensure_settings_read (GtkFileChooserSettings *settings)
|
|||
settings->sort_column = FILE_LIST_COL_MTIME;
|
||||
else if (EQ (COLUMN_SIZE_STRING, sort_column))
|
||||
settings->sort_column = FILE_LIST_COL_SIZE;
|
||||
else if (EQ (COLUMN_TYPE_STRING, sort_column))
|
||||
settings->sort_column = FILE_LIST_COL_TYPE;
|
||||
else
|
||||
g_warning ("Unknown sort column name '%s' encountered in filechooser settings",
|
||||
sort_column);
|
||||
|
|
@ -319,6 +354,8 @@ _gtk_file_chooser_settings_init (GtkFileChooserSettings *settings)
|
|||
settings->sort_column = FILE_LIST_COL_NAME;
|
||||
settings->show_hidden = FALSE;
|
||||
settings->show_size_column = TRUE;
|
||||
settings->show_type_column = TRUE;
|
||||
settings->type_format = TYPE_FORMAT_CATEGORY;
|
||||
settings->show_thumbnails = TRUE;
|
||||
settings->thumbnail_max_size = 64;
|
||||
settings->thumbnail_max_size_remote = 0;
|
||||
|
|
@ -488,6 +525,27 @@ _gtk_file_chooser_settings_set_geometry (GtkFileChooserSettings *settings,
|
|||
settings->geometry_height = height;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_file_chooser_settings_get_show_type_column (GtkFileChooserSettings *settings)
|
||||
{
|
||||
ensure_settings_read (settings);
|
||||
return settings->show_type_column;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_file_chooser_settings_set_show_type_column (GtkFileChooserSettings *settings,
|
||||
gboolean show_column)
|
||||
{
|
||||
settings->show_type_column = show_column != FALSE;
|
||||
}
|
||||
|
||||
TypeFormat
|
||||
_gtk_file_chooser_settings_get_type_format (GtkFileChooserSettings *settings)
|
||||
{
|
||||
ensure_settings_read (settings);
|
||||
return settings->type_format;
|
||||
}
|
||||
|
||||
gint
|
||||
_gtk_file_chooser_settings_get_sort_column (GtkFileChooserSettings *settings)
|
||||
{
|
||||
|
|
@ -588,6 +646,10 @@ _gtk_file_chooser_settings_save (GtkFileChooserSettings *settings,
|
|||
sort_column = COLUMN_SIZE_STRING;
|
||||
break;
|
||||
|
||||
case FILE_LIST_COL_TYPE:
|
||||
sort_column = COLUMN_TYPE_STRING;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
sort_column = NULL;
|
||||
|
|
@ -638,6 +700,8 @@ _gtk_file_chooser_settings_save (GtkFileChooserSettings *settings,
|
|||
SHOW_HIDDEN_KEY, settings->show_hidden);
|
||||
g_key_file_set_boolean (key_file, SETTINGS_GROUP,
|
||||
SHOW_SIZE_COLUMN_KEY, settings->show_size_column);
|
||||
g_key_file_set_boolean (key_file, SETTINGS_GROUP,
|
||||
SHOW_TYPE_COLUMN_KEY, settings->show_type_column);
|
||||
g_key_file_set_boolean (key_file, SETTINGS_GROUP,
|
||||
SHOW_THUMBNAILS_KEY, settings->show_thumbnails);
|
||||
g_key_file_set_boolean (key_file, SETTINGS_GROUP,
|
||||
|
|
|
|||
|
|
@ -34,9 +34,18 @@ enum {
|
|||
FILE_LIST_COL_NAME,
|
||||
FILE_LIST_COL_SIZE,
|
||||
FILE_LIST_COL_MTIME,
|
||||
FILE_LIST_COL_TYPE,
|
||||
FILE_LIST_COL_NUM_COLUMNS
|
||||
};
|
||||
|
||||
/* What the Type column shows, as in GTK+ 3: a kind of file ("Image",
|
||||
* "Text"), the description of the type ("PNG image") or the MIME type */
|
||||
typedef enum {
|
||||
TYPE_FORMAT_CATEGORY,
|
||||
TYPE_FORMAT_DESCRIPTION,
|
||||
TYPE_FORMAT_MIME
|
||||
} TypeFormat;
|
||||
|
||||
typedef struct _GtkFileChooserSettings GtkFileChooserSettings;
|
||||
typedef struct _GtkFileChooserSettingsClass GtkFileChooserSettingsClass;
|
||||
|
||||
|
|
@ -51,6 +60,7 @@ struct _GtkFileChooserSettings
|
|||
gint sort_column, icon_view_scale;
|
||||
gint thumbnail_max_size, thumbnail_max_size_remote; /* MB */
|
||||
StartupMode startup_mode;
|
||||
TypeFormat type_format;
|
||||
|
||||
int geometry_x;
|
||||
int geometry_y;
|
||||
|
|
@ -60,6 +70,7 @@ struct _GtkFileChooserSettings
|
|||
guint settings_read : 1;
|
||||
guint show_hidden : 1;
|
||||
guint show_size_column : 1;
|
||||
guint show_type_column : 1;
|
||||
guint show_thumbnails : 1;
|
||||
guint show_preview_panel : 1;
|
||||
};
|
||||
|
|
@ -107,6 +118,12 @@ gboolean _gtk_file_chooser_settings_get_show_size_column (GtkFileChooserSettings
|
|||
void _gtk_file_chooser_settings_set_show_size_column (GtkFileChooserSettings *settings,
|
||||
gboolean show_column);
|
||||
|
||||
gboolean _gtk_file_chooser_settings_get_show_type_column (GtkFileChooserSettings *settings);
|
||||
void _gtk_file_chooser_settings_set_show_type_column (GtkFileChooserSettings *settings,
|
||||
gboolean show_column);
|
||||
|
||||
TypeFormat _gtk_file_chooser_settings_get_type_format (GtkFileChooserSettings *settings);
|
||||
|
||||
gint _gtk_file_chooser_settings_get_sort_column (GtkFileChooserSettings *settings);
|
||||
void _gtk_file_chooser_settings_set_sort_column (GtkFileChooserSettings *settings,
|
||||
gint sort_column);
|
||||
|
|
|
|||
76
po/de.po
76
po/de.po
|
|
@ -6218,3 +6218,79 @@ msgstr "_Alle weiteren Fehler überspringen"
|
|||
#: gtk/gtkfileoperation.c
|
||||
msgid "A folder can not be copied or moved into itself."
|
||||
msgstr "Ein Ordner kann nicht in sich selbst kopiert oder verschoben werden."
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Show T_ype Column"
|
||||
msgstr "Spalte »_Typ« anzeigen"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Type"
|
||||
msgstr "Typ"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Folder"
|
||||
msgstr "Ordner"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Program"
|
||||
msgstr "Programm"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Audio"
|
||||
msgstr "Klänge"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Image"
|
||||
msgstr "Bild"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Archive"
|
||||
msgstr "Archiv"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Markup"
|
||||
msgstr "Markup"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Text"
|
||||
msgstr "Text"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Video"
|
||||
msgstr "Video"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Contacts"
|
||||
msgstr "Kontakte"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Calendar"
|
||||
msgstr "Kalender"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Document"
|
||||
msgstr "Dokument"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Presentation"
|
||||
msgstr "Präsentation"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Spreadsheet"
|
||||
msgstr "Tabellenkalkulation"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Sort by _Type"
|
||||
msgstr "Nach _Typ sortieren"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Sort by _Name"
|
||||
msgstr "Nach _Name sortieren"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Sort by _Size"
|
||||
msgstr "Nach _Größe sortieren"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Sort by Modification _Date"
|
||||
msgstr "Nach Än_derungsdatum sortieren"
|
||||
|
|
|
|||
Loading…
Reference in a new issue