forked from AuroraMiddleware/gtk
GktFileSystem: Support rendering symbolic icons
This commit is contained in:
parent
386e59683a
commit
d26a84889b
@ -713,6 +713,7 @@ get_surface_from_gicon (GIcon *icon,
|
|||||||
GdkScreen *screen;
|
GdkScreen *screen;
|
||||||
GtkIconTheme *icon_theme;
|
GtkIconTheme *icon_theme;
|
||||||
GtkIconInfo *icon_info;
|
GtkIconInfo *icon_info;
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
|
||||||
screen = gtk_widget_get_screen (GTK_WIDGET (widget));
|
screen = gtk_widget_get_screen (GTK_WIDGET (widget));
|
||||||
@ -727,11 +728,21 @@ get_surface_from_gicon (GIcon *icon,
|
|||||||
if (!icon_info)
|
if (!icon_info)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
surface = gtk_icon_info_load_surface (icon_info,
|
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info,
|
||||||
gtk_widget_get_window (widget), error);
|
gtk_widget_get_style_context (widget),
|
||||||
|
NULL,
|
||||||
|
error);
|
||||||
|
|
||||||
g_object_unref (icon_info);
|
g_object_unref (icon_info);
|
||||||
|
|
||||||
|
if (pixbuf == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf,
|
||||||
|
gtk_widget_get_scale_factor (widget),
|
||||||
|
gtk_widget_get_window (widget));
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -744,8 +755,6 @@ _gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
|
|||||||
GIcon *icon = NULL;
|
GIcon *icon = NULL;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
|
||||||
DEBUG ("volume_get_icon_name");
|
|
||||||
|
|
||||||
if (IS_ROOT_VOLUME (volume))
|
if (IS_ROOT_VOLUME (volume))
|
||||||
icon = g_themed_icon_new ("drive-harddisk");
|
icon = g_themed_icon_new ("drive-harddisk");
|
||||||
else if (G_IS_DRIVE (volume))
|
else if (G_IS_DRIVE (volume))
|
||||||
@ -765,6 +774,34 @@ _gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
|
|||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cairo_surface_t *
|
||||||
|
_gtk_file_system_volume_render_symbolic_icon (GtkFileSystemVolume *volume,
|
||||||
|
GtkWidget *widget,
|
||||||
|
gint icon_size,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GIcon *icon = NULL;
|
||||||
|
cairo_surface_t *surface;
|
||||||
|
|
||||||
|
if (IS_ROOT_VOLUME (volume))
|
||||||
|
icon = g_themed_icon_new ("drive-harddisk-symbolic");
|
||||||
|
else if (G_IS_DRIVE (volume))
|
||||||
|
icon = g_drive_get_symbolic_icon (G_DRIVE (volume));
|
||||||
|
else if (G_IS_VOLUME (volume))
|
||||||
|
icon = g_volume_get_symbolic_icon (G_VOLUME (volume));
|
||||||
|
else if (G_IS_MOUNT (volume))
|
||||||
|
icon = g_mount_get_symbolic_icon (G_MOUNT (volume));
|
||||||
|
|
||||||
|
if (!icon)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
surface = get_surface_from_gicon (icon, widget, icon_size, error);
|
||||||
|
|
||||||
|
g_object_unref (icon);
|
||||||
|
|
||||||
|
return surface;
|
||||||
|
}
|
||||||
|
|
||||||
GtkFileSystemVolume *
|
GtkFileSystemVolume *
|
||||||
_gtk_file_system_volume_ref (GtkFileSystemVolume *volume)
|
_gtk_file_system_volume_ref (GtkFileSystemVolume *volume)
|
||||||
{
|
{
|
||||||
@ -794,9 +831,10 @@ _gtk_file_system_volume_unref (GtkFileSystemVolume *volume)
|
|||||||
|
|
||||||
/* GFileInfo helper functions */
|
/* GFileInfo helper functions */
|
||||||
cairo_surface_t *
|
cairo_surface_t *
|
||||||
_gtk_file_info_render_icon (GFileInfo *info,
|
_gtk_file_info_render_icon_internal (GFileInfo *info,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
gint icon_size)
|
gint icon_size,
|
||||||
|
gboolean symbolic)
|
||||||
{
|
{
|
||||||
GIcon *icon;
|
GIcon *icon;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
@ -823,6 +861,9 @@ _gtk_file_info_render_icon (GFileInfo *info,
|
|||||||
|
|
||||||
if (!surface)
|
if (!surface)
|
||||||
{
|
{
|
||||||
|
if (symbolic)
|
||||||
|
icon = g_file_info_get_symbolic_icon (info);
|
||||||
|
else
|
||||||
icon = g_file_info_get_icon (info);
|
icon = g_file_info_get_icon (info);
|
||||||
|
|
||||||
if (icon)
|
if (icon)
|
||||||
@ -831,6 +872,9 @@ _gtk_file_info_render_icon (GFileInfo *info,
|
|||||||
if (!surface)
|
if (!surface)
|
||||||
{
|
{
|
||||||
/* Use general fallback for all files without icon */
|
/* Use general fallback for all files without icon */
|
||||||
|
if (symbolic)
|
||||||
|
icon = g_themed_icon_new ("text-x-generic-symbolic");
|
||||||
|
else
|
||||||
icon = g_themed_icon_new ("text-x-generic");
|
icon = g_themed_icon_new ("text-x-generic");
|
||||||
surface = get_surface_from_gicon (icon, widget, icon_size, NULL);
|
surface = get_surface_from_gicon (icon, widget, icon_size, NULL);
|
||||||
g_object_unref (icon);
|
g_object_unref (icon);
|
||||||
@ -840,6 +884,22 @@ _gtk_file_info_render_icon (GFileInfo *info,
|
|||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cairo_surface_t *
|
||||||
|
_gtk_file_info_render_icon (GFileInfo *info,
|
||||||
|
GtkWidget *widget,
|
||||||
|
gint icon_size)
|
||||||
|
{
|
||||||
|
return _gtk_file_info_render_icon_internal (info, widget, icon_size, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
cairo_surface_t *
|
||||||
|
_gtk_file_info_render_symbolic_icon (GFileInfo *info,
|
||||||
|
GtkWidget *widget,
|
||||||
|
gint icon_size)
|
||||||
|
{
|
||||||
|
return _gtk_file_info_render_icon_internal (info, widget, icon_size, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_gtk_file_info_consider_as_directory (GFileInfo *info)
|
_gtk_file_info_consider_as_directory (GFileInfo *info)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,10 @@ cairo_surface_t * _gtk_file_system_volume_render_icon (GtkFileSystemVol
|
|||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
gint icon_size,
|
gint icon_size,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
cairo_surface_t * _gtk_file_system_volume_render_symbolic_icon (GtkFileSystemVolume *volume,
|
||||||
|
GtkWidget *widget,
|
||||||
|
gint icon_size,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
GtkFileSystemVolume *_gtk_file_system_volume_ref (GtkFileSystemVolume *volume);
|
GtkFileSystemVolume *_gtk_file_system_volume_ref (GtkFileSystemVolume *volume);
|
||||||
void _gtk_file_system_volume_unref (GtkFileSystemVolume *volume);
|
void _gtk_file_system_volume_unref (GtkFileSystemVolume *volume);
|
||||||
@ -105,6 +109,9 @@ void _gtk_file_system_volume_unref (GtkFileSystemVol
|
|||||||
cairo_surface_t * _gtk_file_info_render_icon (GFileInfo *info,
|
cairo_surface_t * _gtk_file_info_render_icon (GFileInfo *info,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
gint icon_size);
|
gint icon_size);
|
||||||
|
cairo_surface_t * _gtk_file_info_render_symbolic_icon (GFileInfo *info,
|
||||||
|
GtkWidget *widget,
|
||||||
|
gint icon_size);
|
||||||
|
|
||||||
gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
|
gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user