forked from AuroraMiddleware/gtk
Make the list model read in directory information as well.
2003-09-09 Federico Mena Quintero <federico@ximian.com> * gtkfilechooserimpldefault.c (tree_selection_changed): Make the list model read in directory information as well. (set_cell_text_bold_if_folder): New utility function. Sets a cell's text, making it bold if the file info is a folder. (list_name_data_func): Use set_cell_text_bold_if_folder(). (list_mtime_data_func): Use set_cell_text_bold_if_folder(). (list_size_data_func): Don't set anything if the file info is a folder.
This commit is contained in:
parent
243256ad4e
commit
4b3e2d69a5
@ -1357,6 +1357,7 @@ tree_selection_changed (GtkTreeSelection *selection,
|
||||
file_path, 0,
|
||||
GTK_FILE_INFO_ICON |
|
||||
GTK_FILE_INFO_DISPLAY_NAME |
|
||||
GTK_FILE_INFO_IS_FOLDER |
|
||||
GTK_FILE_INFO_SIZE |
|
||||
GTK_FILE_INFO_MODIFICATION_TIME);
|
||||
#if 0
|
||||
@ -1510,6 +1511,30 @@ list_icon_data_func (GtkTreeViewColumn *tree_column,
|
||||
}
|
||||
}
|
||||
|
||||
/* Sets a cellrenderer's text, making it bold if the GtkFileInfo is a folder */
|
||||
static void
|
||||
set_cell_text_bold_if_folder (const GtkFileInfo *info, GtkCellRenderer *cell, const char *text)
|
||||
{
|
||||
if (gtk_file_info_get_is_folder (info))
|
||||
{
|
||||
char *escaped;
|
||||
char *markup;
|
||||
|
||||
escaped = g_markup_escape_text (text, -1);
|
||||
markup = g_strdup_printf ("<span weight=\"bold\">%s</span>", escaped);
|
||||
|
||||
g_object_set (cell, "markup", markup, NULL);
|
||||
|
||||
g_free (escaped);
|
||||
g_free (markup);
|
||||
}
|
||||
else
|
||||
g_object_set (cell,
|
||||
"text", text,
|
||||
"attributes", NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
list_name_data_func (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
@ -1520,12 +1545,10 @@ list_name_data_func (GtkTreeViewColumn *tree_column,
|
||||
GtkFileChooserImplDefault *impl = data;
|
||||
const GtkFileInfo *info = get_list_file_info (impl, iter);
|
||||
|
||||
if (info)
|
||||
{
|
||||
g_object_set (cell,
|
||||
"text", gtk_file_info_get_display_name (info),
|
||||
NULL);
|
||||
}
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
set_cell_text_bold_if_folder (info, cell, gtk_file_info_get_display_name (info));
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -1538,12 +1561,12 @@ list_size_data_func (GtkTreeViewColumn *tree_column,
|
||||
{
|
||||
GtkFileChooserImplDefault *impl = data;
|
||||
const GtkFileInfo *info = get_list_file_info (impl, iter);
|
||||
|
||||
if (info)
|
||||
{
|
||||
gint64 size = gtk_file_info_get_size (info);
|
||||
gchar *str;
|
||||
|
||||
if (!info || gtk_file_info_get_is_folder (info))
|
||||
return;
|
||||
|
||||
if (size < (gint64)1024)
|
||||
str = g_strdup_printf ("%d bytes", (gint)size);
|
||||
else if (size < (gint64)1024*1024)
|
||||
@ -1559,7 +1582,6 @@ list_size_data_func (GtkTreeViewColumn *tree_column,
|
||||
|
||||
g_free (str);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Tree column data callback for the file list; fetches the mtime of a file */
|
||||
@ -1630,7 +1652,7 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column,
|
||||
}
|
||||
}
|
||||
|
||||
g_object_set (cell, "text", buf, NULL);
|
||||
set_cell_text_bold_if_folder (info, cell, buf);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
Loading…
Reference in New Issue
Block a user