Commit a3976b68 authored by Federico Mena Quintero's avatar Federico Mena Quintero Committed by Federico Mena Quintero

Added a render_icon virtual method.

2003-11-19  Federico Mena Quintero  <federico@ximian.com>

	* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
	render_icon virtual method.

	* gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.

	* gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
	Implement as a stub for now.

	* gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
	gtk_file_system_render_icon().
	(list_icon_data_func): Likewise.
	(toolbar_create): Set the toolbar style to icons only.

	* gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
	Fix doc comments.
parent 80bb3538
2003-11-19 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
render_icon virtual method.
* gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
Implement as a stub for now.
* gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
gtk_file_system_render_icon().
(list_icon_data_func): Likewise.
(toolbar_create): Set the toolbar style to icons only.
* gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
Fix doc comments.
Wed Nov 19 02:18:37 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call
......
2003-11-19 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
render_icon virtual method.
* gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
Implement as a stub for now.
* gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
gtk_file_system_render_icon().
(list_icon_data_func): Likewise.
(toolbar_create): Set the toolbar style to icons only.
* gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
Fix doc comments.
Wed Nov 19 02:18:37 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call
......
2003-11-19 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
render_icon virtual method.
* gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
Implement as a stub for now.
* gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
gtk_file_system_render_icon().
(list_icon_data_func): Likewise.
(toolbar_create): Set the toolbar style to icons only.
* gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
Fix doc comments.
Wed Nov 19 02:18:37 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call
......
2003-11-19 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
render_icon virtual method.
* gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
Implement as a stub for now.
* gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
gtk_file_system_render_icon().
(list_icon_data_func): Likewise.
(toolbar_create): Set the toolbar style to icons only.
* gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
Fix doc comments.
Wed Nov 19 02:18:37 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call
......
2003-11-19 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
render_icon virtual method.
* gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
Implement as a stub for now.
* gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
gtk_file_system_render_icon().
(list_icon_data_func): Likewise.
(toolbar_create): Set the toolbar style to icons only.
* gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
Fix doc comments.
Wed Nov 19 02:18:37 2003 Matthias Clasen <maclas@gmx.de>
* gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call
......
......@@ -1532,7 +1532,7 @@ gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
/**
* gtk_file_chooser_add_shortcut_folder_uri:
* @chooser: a #GtkFileChooser
* @folder: URI of the folder to add
* @uri: URI of the folder to add
* @error: location to store error, or %NULL
*
* Adds a folder URI to be displayed with the shortcut folders in a file
......
......@@ -139,7 +139,8 @@ enum {
};
/* Standard icon size */
#define ICON_SIZE 36
/* FIXME: maybe this should correspond to the font size in the tree views... */
#define ICON_SIZE 20
static void gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class);
static void gtk_file_chooser_default_iface_init (GtkFileChooserIface *iface);
......@@ -434,7 +435,11 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, GError **err
return NULL;
parent_folder = gtk_file_system_get_folder (file_system, parent_path,
#if 0
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_ICON,
#else
GTK_FILE_INFO_DISPLAY_NAME,
#endif
error);
gtk_file_path_free (parent_path);
......@@ -471,15 +476,22 @@ shortcuts_insert_path (GtkFileChooserDefault *impl,
if (is_root)
info = gtk_file_system_get_root_info (impl->file_system,
path,
#if 0
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_ICON,
#else
GTK_FILE_INFO_DISPLAY_NAME,
#endif
error);
else
info = get_file_info (impl->file_system, path, error);
if (!info)
return FALSE;
#if 0
pixbuf = gtk_file_info_render_icon (info, impl->shortcuts_tree, ICON_SIZE);
#endif
/* FIXME: NULL GError */
pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl), ICON_SIZE, NULL);
gtk_tree_store_insert (impl->shortcuts_model, &iter, NULL, pos);
path_copy = gtk_file_path_copy (path);
......@@ -715,6 +727,8 @@ static GtkWidget *
toolbar_create (GtkFileChooserDefault *impl)
{
impl->toolbar = gtk_toolbar_new ();
gtk_toolbar_set_style (GTK_TOOLBAR (impl->toolbar), GTK_TOOLBAR_ICONS);
impl->up_button = toolbar_add_item (impl, GTK_STOCK_GO_UP, G_CALLBACK (toolbar_up_cb));
return impl->toolbar;
......@@ -1585,7 +1599,9 @@ set_list_model (GtkFileChooserDefault *impl)
impl->list_model = _gtk_file_system_model_new (impl->file_system,
impl->current_folder, 0,
#if 0
GTK_FILE_INFO_ICON |
#endif
GTK_FILE_INFO_DISPLAY_NAME |
GTK_FILE_INFO_IS_FOLDER |
GTK_FILE_INFO_SIZE |
......@@ -2395,6 +2411,25 @@ list_icon_data_func (GtkTreeViewColumn *tree_column,
gpointer data)
{
GtkFileChooserDefault *impl = data;
GtkTreeIter child_iter;
const GtkFilePath *path;
GdkPixbuf *pixbuf;
gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
&child_iter,
iter);
path = _gtk_file_system_model_get_path (impl->list_model, &child_iter);
/* FIXME: NULL GError */
pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl), ICON_SIZE, NULL);
g_object_set (cell,
"pixbuf", pixbuf,
NULL);
if (pixbuf)
g_object_unref (pixbuf);
#if 0
const GtkFileInfo *info = get_list_file_info (impl, iter);
if (info)
......@@ -2409,6 +2444,7 @@ list_icon_data_func (GtkTreeViewColumn *tree_column,
if (pixbuf)
g_object_unref (pixbuf);
}
#endif
}
/* Sets a cellrenderer's text, making it bold if the GtkFileInfo is a folder */
......
......@@ -31,7 +31,9 @@ struct _GtkFileInfo
gchar *display_name;
gchar *display_key;
gchar *mime_type;
#if 0
GtkFileIconType icon_type : 4;
#endif
guint is_folder : 1;
guint is_hidden : 1;
};
......@@ -245,6 +247,7 @@ gtk_file_info_set_size (GtkFileInfo *info,
info->size = size;
}
#if 0
void
gtk_file_info_set_icon_type (GtkFileInfo *info,
GtkFileIconType icon_type)
......@@ -406,6 +409,7 @@ gtk_file_info_render_icon (const GtkFileInfo *info,
return get_cached_icon (widget, "gnome-fs-regular", pixel_size);
}
#endif
/*****************************************
* GtkFileSystem *
......@@ -667,6 +671,21 @@ gtk_file_system_filename_to_path (GtkFileSystem *file_system,
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->filename_to_path (file_system, filename);
}
GdkPixbuf *
gtk_file_system_render_icon (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkWidget *widget,
gint pixel_size,
GError **error)
{
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (widget != NULL, NULL);
g_return_val_if_fail (pixel_size > 0, NULL);
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->render_icon (file_system, path, widget, pixel_size, error);
}
/**
* gtk_file_system_add_bookmark:
* @file_system: a #GtkFileSystem
......
......@@ -54,10 +54,13 @@ typedef enum {
GTK_FILE_INFO_MIME_TYPE = 1 << 3,
GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
GTK_FILE_INFO_SIZE = 1 << 5,
#if 0
GTK_FILE_INFO_ICON = 1 << 6,
#endif
GTK_FILE_INFO_ALL = (1 << 7) - 1
} GtkFileInfoType;
#if 0
/* Icon type, supplemented by MIME type
*/
typedef enum {
......@@ -70,6 +73,7 @@ typedef enum {
GTK_FILE_ICON_FIFO,
GTK_FILE_ICON_SOCKET
} GtkFileIconType;
#endif
/* GError enumeration for GtkFileSystem
*/
......@@ -117,12 +121,14 @@ void gtk_file_info_set_modification_time (GtkFileInfo *in
gint64 gtk_file_info_get_size (const GtkFileInfo *info);
void gtk_file_info_set_size (GtkFileInfo *info,
gint64 size);
#if 0
void gtk_file_info_set_icon_type (GtkFileInfo *info,
GtkFileIconType icon_type);
GtkFileIconType gtk_file_info_get_icon_type (const GtkFileInfo *info);
GdkPixbuf * gtk_file_info_render_icon (const GtkFileInfo *info,
GtkWidget *widget,
gint pixel_size);
#endif
/* The base GtkFileSystem interface
*/
......@@ -177,6 +183,14 @@ struct _GtkFileSystemIface
GtkFilePath *(*filename_to_path) (GtkFileSystem *file_system,
const gchar *path);
/* Icons */
GdkPixbuf * (*render_icon) (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkWidget *widget,
gint pixel_size,
GError **error);
/* Bookmarks */
gboolean (*add_bookmark) (GtkFileSystem *file_system,
......@@ -232,6 +246,12 @@ GtkFilePath *gtk_file_system_uri_to_path (GtkFileSystem *file_system,
GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
const gchar *filename);
GdkPixbuf *gtk_file_system_render_icon (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkWidget *widget,
gint pixel_size,
GError **error);
gboolean gtk_file_system_add_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error);
......
......@@ -114,6 +114,12 @@ static GtkFilePath *gtk_file_system_unix_uri_to_path (GtkFileSystem *fi
static GtkFilePath *gtk_file_system_unix_filename_to_path (GtkFileSystem *file_system,
const gchar *filename);
static GdkPixbuf *gtk_file_system_unix_render_icon (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkWidget *widget,
gint pixel_size,
GError **error);
static gboolean gtk_file_system_unix_add_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error);
......@@ -223,6 +229,7 @@ gtk_file_system_unix_iface_init (GtkFileSystemIface *iface)
iface->path_to_filename = gtk_file_system_unix_path_to_filename;
iface->uri_to_path = gtk_file_system_unix_uri_to_path;
iface->filename_to_path = gtk_file_system_unix_filename_to_path;
iface->render_icon = gtk_file_system_unix_render_icon;
iface->add_bookmark = gtk_file_system_unix_add_bookmark;
iface->remove_bookmark = gtk_file_system_unix_remove_bookmark;
iface->list_bookmarks = gtk_file_system_unix_list_bookmarks;
......@@ -545,6 +552,21 @@ gtk_file_system_unix_filename_to_path (GtkFileSystem *file_system,
return gtk_file_path_new_dup (filename);
}
static GdkPixbuf *
gtk_file_system_unix_render_icon (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkWidget *widget,
gint pixel_size,
GError **error)
{
/* FIXME: Implement this */
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_FAILED,
_("This file system does not support icons"));
return NULL;
}
static gboolean
gtk_file_system_unix_add_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
......@@ -726,7 +748,9 @@ filename_get_info (const gchar *filename,
GError **error)
{
GtkFileInfo *info;
#if 0
GtkFileIconType icon_type = GTK_FILE_ICON_REGULAR;
#endif
struct stat statbuf;
/* If stat fails, try to fall back to lstat to catch broken links
......@@ -784,6 +808,7 @@ filename_get_info (const gchar *filename,
gtk_file_info_set_is_folder (info, S_ISDIR (statbuf.st_mode));
}
#if 0
if (types & GTK_FILE_INFO_ICON)
{
if (S_ISBLK (statbuf.st_mode))
......@@ -804,16 +829,21 @@ filename_get_info (const gchar *filename,
if ((types & GTK_FILE_INFO_MIME_TYPE) ||
((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR))
#else
if (types & GTK_FILE_INFO_MIME_TYPE)
#endif
{
const char *mime_type = xdg_mime_get_mime_type_for_file (filename);
gtk_file_info_set_mime_type (info, mime_type);
#if 0
if ((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR &&
(statbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) &&
(strcmp (mime_type, XDG_MIME_TYPE_UNKNOWN) == 0 ||
strcmp (mime_type, "application/x-executable") == 0 ||
strcmp (mime_type, "application/x-shellscript") == 0))
gtk_file_info_set_icon_type (info, GTK_FILE_ICON_EXECUTABLE);
#endif
}
if (types & GTK_FILE_INFO_MODIFICATION_TIME)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment