diff options
Diffstat (limited to 'libnautilus-private/nautilus-theme.c')
-rw-r--r-- | libnautilus-private/nautilus-theme.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/libnautilus-private/nautilus-theme.c b/libnautilus-private/nautilus-theme.c index 57fe71b28..e8d09616e 100644 --- a/libnautilus-private/nautilus-theme.c +++ b/libnautilus-private/nautilus-theme.c @@ -302,18 +302,18 @@ nautilus_theme_get_image_path (const char *image_name) GdkPixbuf * nautilus_theme_make_selector (const char *theme_name) { - char *pixbuf_file, *temp_str; + char *pixbuf_file, *theme_preview_name; char *user_directory, *directory_uri; GdkPixbuf *pixbuf; /* first, see if we can find an explicit preview */ if (!nautilus_strcmp (theme_name, "default")) { - temp_str = g_strdup ("theme_preview.png"); + theme_preview_name = g_strdup ("theme_preview.png"); } else { - temp_str = g_strdup_printf ("%s/%s", theme_name, "theme_preview.png"); + theme_preview_name = g_strdup_printf ("%s/%s", theme_name, "theme_preview.png"); } - pixbuf_file = nautilus_pixmap_file(temp_str); + pixbuf_file = nautilus_pixmap_file (theme_preview_name); if (pixbuf_file != NULL) { pixbuf = gdk_pixbuf_new_from_file (pixbuf_file); g_free (pixbuf_file); @@ -322,7 +322,7 @@ nautilus_theme_make_selector (const char *theme_name) /* try the user directory */ user_directory = nautilus_get_user_directory (); directory_uri = nautilus_make_path (user_directory, "themes"); - pixbuf_file = nautilus_make_path (directory_uri, temp_str); + pixbuf_file = nautilus_make_path (directory_uri, theme_preview_name); g_free (user_directory); g_free (directory_uri); @@ -331,43 +331,45 @@ nautilus_theme_make_selector (const char *theme_name) pixbuf = gdk_pixbuf_new_from_file (pixbuf_file); g_free (pixbuf_file); return pixbuf; + } else { + g_free (pixbuf_file); } } /* couldn't find a custom one, so try for a directory */ - g_free (temp_str); - temp_str = g_strdup_printf ("%s/%s", theme_name, "i-directory.png"); - pixbuf_file = nautilus_pixmap_file (temp_str); - g_free (temp_str); + g_free (theme_preview_name); + theme_preview_name = g_strdup_printf ("%s/%s", theme_name, "i-directory.png"); + pixbuf_file = nautilus_pixmap_file (theme_preview_name); + g_free (theme_preview_name); if (pixbuf_file == NULL) { - temp_str = g_strdup_printf ("%s/%s", theme_name, "i-directory.svg"); - pixbuf_file = nautilus_pixmap_file(temp_str); - g_free (temp_str); - if (pixbuf_file == NULL) { - temp_str = g_strdup_printf ("%s/%s", theme_name, "i-directory.png"); - pixbuf_file = nautilus_pixmap_file (temp_str); - g_free (temp_str); - } + theme_preview_name = g_strdup_printf ("%s/%s", theme_name, "i-directory.svg"); + pixbuf_file = nautilus_pixmap_file (theme_preview_name); + g_free (theme_preview_name); } - /* try the user directory if necessary */ if (pixbuf_file == NULL) { user_directory = nautilus_get_user_directory (); directory_uri = nautilus_make_path (user_directory, "themes"); - temp_str = g_strdup_printf ("%s/i-directory.png", theme_name); - pixbuf_file = nautilus_make_path (directory_uri, temp_str); - - g_free (user_directory); - g_free (directory_uri); - g_free (temp_str); + theme_preview_name = g_strdup_printf ("%s/i-directory.png", theme_name); + pixbuf_file = nautilus_make_path (directory_uri, theme_preview_name); + g_free (theme_preview_name); - if (g_file_exists (pixbuf_file)) { - pixbuf = gdk_pixbuf_new_from_file (pixbuf_file); + if (!g_file_exists (pixbuf_file)) { g_free (pixbuf_file); - return pixbuf; + theme_preview_name = g_strdup_printf ("%s/i-directory.svg", theme_name); + pixbuf_file = nautilus_make_path (directory_uri, theme_preview_name); + g_free (theme_preview_name); + + if (!g_file_exists (pixbuf_file)) { + g_free (pixbuf_file); + pixbuf_file = NULL; + } } + + g_free (user_directory); + g_free (directory_uri); } /* if we can't find anything, return NULL */ @@ -376,8 +378,9 @@ nautilus_theme_make_selector (const char *theme_name) } pixbuf = NULL; + /* load the icon that we found and return it */ - if (nautilus_istr_has_suffix(pixbuf_file, ".svg")) { + if (nautilus_istr_has_suffix (pixbuf_file, ".svg")) { FILE *f = fopen (pixbuf_file, "rb"); if (f != NULL) { pixbuf = rsvg_render_file (f, 1.0); |