remove caching from the thumbnailer since all of the current users work
2007-06-06 Jens Granseuer <jensgr@gmx.net> * theme-thumbnail.c: (message_from_child), (generate_theme_thumbnail), (generate_theme_thumbnail_async), (theme_thumbnail_factory_init): * theme-thumbnail.h: remove caching from the thumbnailer since all of the current users work around it anyway, and resources aren't managed properly svn path=/trunk/; revision=7699
This commit is contained in:
parent
f7873f1304
commit
94e474bcd7
3 changed files with 15 additions and 56 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2007-06-06 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
|
* theme-thumbnail.c: (message_from_child),
|
||||||
|
(generate_theme_thumbnail), (generate_theme_thumbnail_async),
|
||||||
|
(theme_thumbnail_factory_init):
|
||||||
|
* theme-thumbnail.h: remove caching from the thumbnailer since
|
||||||
|
all of the current users work around it anyway, and resources
|
||||||
|
aren't managed properly
|
||||||
|
|
||||||
2007-06-06 Jens Granseuer <jensgr@gmx.net>
|
2007-06-06 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
* gnome-theme-info.c: (safe_strcmp), (get_data_from_hash_by_name),
|
* gnome-theme-info.c: (safe_strcmp), (get_data_from_hash_by_name),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <config.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <metacity-private/util.h>
|
#include <metacity-private/util.h>
|
||||||
|
@ -12,7 +13,6 @@
|
||||||
#undef N_
|
#undef N_
|
||||||
|
|
||||||
#include <libgnomeui/gnome-icon-theme.h>
|
#include <libgnomeui/gnome-icon-theme.h>
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "theme-thumbnail.h"
|
#include "theme-thumbnail.h"
|
||||||
#include "capplet-util.h"
|
#include "capplet-util.h"
|
||||||
|
@ -34,10 +34,8 @@ typedef struct
|
||||||
} ThemeThumbnailAsyncData;
|
} ThemeThumbnailAsyncData;
|
||||||
|
|
||||||
|
|
||||||
static GHashTable *theme_hash = NULL;
|
|
||||||
static ThemeThumbnailAsyncData async_data;
|
static ThemeThumbnailAsyncData async_data;
|
||||||
|
|
||||||
|
|
||||||
/* Protocol */
|
/* Protocol */
|
||||||
|
|
||||||
/* Our protocol is pretty simple. The parent process will write four strings
|
/* Our protocol is pretty simple. The parent process will write four strings
|
||||||
|
@ -480,9 +478,9 @@ message_from_child (GIOChannel *source,
|
||||||
memcpy (pixels + rowstride * i, async_data.data->data + 4 * ICON_SIZE_WIDTH * i, ICON_SIZE_WIDTH * 4);
|
memcpy (pixels + rowstride * i, async_data.data->data + 4 * ICON_SIZE_WIDTH * i, ICON_SIZE_WIDTH * 4);
|
||||||
|
|
||||||
scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, ICON_SIZE_WIDTH/2, ICON_SIZE_HEIGHT/2, GDK_INTERP_BILINEAR);
|
scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, ICON_SIZE_WIDTH/2, ICON_SIZE_HEIGHT/2, GDK_INTERP_BILINEAR);
|
||||||
g_hash_table_insert (theme_hash, g_strdup(async_data.meta_theme_name), scaled_pixbuf);
|
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
|
|
||||||
|
/* allbak function needs to unref the pixbuf */
|
||||||
(* async_data.func) (scaled_pixbuf, async_data.user_data);
|
(* async_data.func) (scaled_pixbuf, async_data.user_data);
|
||||||
if (async_data.destroy)
|
if (async_data.destroy)
|
||||||
(* async_data.destroy) (async_data.user_data);
|
(* async_data.destroy) (async_data.user_data);
|
||||||
|
@ -515,37 +513,15 @@ message_from_child (GIOChannel *source,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
theme_thumbnail_invalidate_cache (GnomeThemeMetaInfo *meta_theme_info)
|
|
||||||
{
|
|
||||||
gboolean success;
|
|
||||||
|
|
||||||
success = g_hash_table_remove (theme_hash, meta_theme_info->name);
|
|
||||||
printf ("Success is %d\n", success);
|
|
||||||
}
|
|
||||||
|
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
generate_theme_thumbnail (GnomeThemeMetaInfo *meta_theme_info,
|
generate_theme_thumbnail (GnomeThemeMetaInfo *meta_theme_info)
|
||||||
gboolean clear_cache)
|
|
||||||
{
|
{
|
||||||
GdkPixbuf *retval = NULL;
|
GdkPixbuf *retval = NULL;
|
||||||
GdkPixbuf *pixbuf = NULL;
|
GdkPixbuf *pixbuf;
|
||||||
gint i, rowstride;
|
gint i, rowstride;
|
||||||
char *pixels;
|
char *pixels;
|
||||||
|
|
||||||
if (async_data.set == TRUE)
|
if (async_data.set || !pipe_to_factory_fd[1] || !pipe_from_factory_fd[0])
|
||||||
return NULL;
|
|
||||||
|
|
||||||
pixbuf = g_hash_table_lookup (theme_hash, meta_theme_info->name);
|
|
||||||
if (pixbuf != NULL)
|
|
||||||
{
|
|
||||||
if (clear_cache)
|
|
||||||
g_hash_table_remove (theme_hash, meta_theme_info->name);
|
|
||||||
else
|
|
||||||
return pixbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pipe_to_factory_fd[1] || !pipe_from_factory_fd[0])
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, ICON_SIZE_WIDTH, ICON_SIZE_HEIGHT);
|
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, ICON_SIZE_WIDTH, ICON_SIZE_HEIGHT);
|
||||||
|
@ -594,36 +570,17 @@ generate_theme_thumbnail (GnomeThemeMetaInfo *meta_theme_info,
|
||||||
|
|
||||||
retval = gdk_pixbuf_scale_simple (pixbuf, ICON_SIZE_WIDTH/2, ICON_SIZE_HEIGHT/2, GDK_INTERP_BILINEAR);
|
retval = gdk_pixbuf_scale_simple (pixbuf, ICON_SIZE_WIDTH/2, ICON_SIZE_HEIGHT/2, GDK_INTERP_BILINEAR);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
|
|
||||||
g_hash_table_insert (theme_hash, g_strdup (meta_theme_info->name), retval);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
generate_theme_thumbnail_async (GnomeThemeMetaInfo *meta_theme_info,
|
generate_theme_thumbnail_async (GnomeThemeMetaInfo *meta_theme_info,
|
||||||
gboolean clear_cache,
|
|
||||||
ThemeThumbnailFunc func,
|
ThemeThumbnailFunc func,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify destroy)
|
GDestroyNotify destroy)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
|
||||||
|
|
||||||
g_return_if_fail (async_data.set == FALSE);
|
g_return_if_fail (async_data.set == FALSE);
|
||||||
|
|
||||||
pixbuf = g_hash_table_lookup (theme_hash, meta_theme_info->name);
|
|
||||||
if (pixbuf != NULL)
|
|
||||||
{
|
|
||||||
if (clear_cache)
|
|
||||||
g_hash_table_remove (theme_hash, meta_theme_info->name);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(* func) (pixbuf, user_data);
|
|
||||||
if (destroy)
|
|
||||||
(* destroy) (user_data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pipe_to_factory_fd[1] || !pipe_from_factory_fd[0])
|
if (!pipe_to_factory_fd[1] || !pipe_from_factory_fd[0])
|
||||||
{
|
{
|
||||||
(* func) (NULL, user_data);
|
(* func) (NULL, user_data);
|
||||||
|
@ -641,7 +598,6 @@ generate_theme_thumbnail_async (GnomeThemeMetaInfo *meta_theme_info,
|
||||||
async_data.watch_id = g_io_add_watch (async_data.channel, G_IO_IN | G_IO_HUP, message_from_child, NULL);
|
async_data.watch_id = g_io_add_watch (async_data.channel, G_IO_IN | G_IO_HUP, message_from_child, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async_data.set = TRUE;
|
async_data.set = TRUE;
|
||||||
async_data.meta_theme_name = g_strdup (meta_theme_info->name);
|
async_data.meta_theme_name = g_strdup (meta_theme_info->name);
|
||||||
async_data.func = func;
|
async_data.func = func;
|
||||||
|
@ -707,12 +663,9 @@ theme_thumbnail_factory_init (int argc, char *argv[])
|
||||||
async_data.set = FALSE;
|
async_data.set = FALSE;
|
||||||
async_data.meta_theme_name = NULL;
|
async_data.meta_theme_name = NULL;
|
||||||
async_data.data = g_byte_array_new ();
|
async_data.data = g_byte_array_new ();
|
||||||
|
|
||||||
theme_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Functions for specific types of themes */
|
/* Functions for specific types of themes */
|
||||||
|
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
|
|
|
@ -9,14 +9,11 @@ typedef void (* ThemeThumbnailFunc) (GdkPixbuf *pixbuf,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
|
|
||||||
GdkPixbuf *generate_theme_thumbnail (GnomeThemeMetaInfo *meta_theme_info,
|
GdkPixbuf *generate_theme_thumbnail (GnomeThemeMetaInfo *meta_theme_info);
|
||||||
gboolean clear_cache);
|
|
||||||
void generate_theme_thumbnail_async (GnomeThemeMetaInfo *meta_theme_info,
|
void generate_theme_thumbnail_async (GnomeThemeMetaInfo *meta_theme_info,
|
||||||
gboolean clear_cache,
|
|
||||||
ThemeThumbnailFunc func,
|
ThemeThumbnailFunc func,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GDestroyNotify destroy);
|
GDestroyNotify destroy);
|
||||||
void theme_thumbnail_invalidate_cache (GnomeThemeMetaInfo *meta_theme_info);
|
|
||||||
void theme_thumbnail_factory_init (int argc,
|
void theme_thumbnail_factory_init (int argc,
|
||||||
char *argv[]);
|
char *argv[]);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue