summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--libnautilus-extensions/nautilus-theme.c59
-rw-r--r--libnautilus-private/nautilus-theme.c59
-rw-r--r--src/nautilus-theme-selector.c9
4 files changed, 80 insertions, 61 deletions
diff --git a/ChangeLog b/ChangeLog
index 5fcac516b..bb9da6a2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2001-01-23 Andy Hertzfeld <andy@eazel.com>
+
+ * src/nautilus-theme-selector.c:
+ (nautilus_theme_selector_initialize), (remove_button_callback),
+ (exit_remove_mode):
+ fixed bug 5972, remove theme button uses aa text, by using
+ a gtk_label instead of a nautilus_label. Also, hide the
+ add button during remove mode so it's less confusing.
+
+ * libnautilus-extensions/nautilus-theme.c:
+ (nautilus_theme_make_selector):
+ fixed a crash when an installed theme lacked a preview icon,
+ cleaned up code and fixed a memory leak.
+
2001-01-23 Maciej Stachowiak <mjs@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>
diff --git a/libnautilus-extensions/nautilus-theme.c b/libnautilus-extensions/nautilus-theme.c
index 57fe71b28..e8d09616e 100644
--- a/libnautilus-extensions/nautilus-theme.c
+++ b/libnautilus-extensions/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);
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);
diff --git a/src/nautilus-theme-selector.c b/src/nautilus-theme-selector.c
index 9f6b51e5a..af3d42c27 100644
--- a/src/nautilus-theme-selector.c
+++ b/src/nautilus-theme-selector.c
@@ -288,7 +288,6 @@ nautilus_theme_selector_initialize (GtkObject *object)
gtk_widget_show(theme_selector->details->add_button);
theme_selector->details->add_button_label = gtk_label_new (_(" Add new theme "));
-
gtk_widget_show(theme_selector->details->add_button_label);
gtk_container_add (GTK_CONTAINER(theme_selector->details->add_button), theme_selector->details->add_button_label);
gtk_box_pack_end (GTK_BOX (bottom_box), theme_selector->details->add_button, FALSE, FALSE, 4);
@@ -297,10 +296,7 @@ nautilus_theme_selector_initialize (GtkObject *object)
/* now create the "remove" button */
theme_selector->details->remove_button = gtk_button_new();
-
- theme_selector->details->remove_button_label = nautilus_label_new (_(" Remove theme "));
- nautilus_label_make_larger (NAUTILUS_LABEL (theme_selector->details->remove_button_label), 2);
-
+ theme_selector->details->remove_button_label = gtk_label_new (_(" Remove theme "));
gtk_widget_show(theme_selector->details->remove_button_label);
gtk_container_add (GTK_CONTAINER(theme_selector->details->remove_button), theme_selector->details->remove_button_label);
gtk_box_pack_end (GTK_BOX (bottom_box),
@@ -519,6 +515,7 @@ remove_button_callback (GtkWidget *widget, NautilusThemeSelector *theme_selector
nautilus_label_set_text (NAUTILUS_LABEL (theme_selector->details->add_button_label),
_("Cancel Remove"));
+ gtk_widget_hide (theme_selector->details->add_button);
populate_list_with_themes (theme_selector);
}
@@ -579,6 +576,8 @@ exit_remove_mode (NautilusThemeSelector *theme_selector)
/* change the add button label back to it's normal state */
nautilus_label_set_text (NAUTILUS_LABEL (theme_selector->details->add_button_label), _("Add New Theme"));
+
+ gtk_widget_show (theme_selector->details->add_button);
populate_list_with_themes (theme_selector);
}