summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-2000041410
-rw-r--r--components/services/startup/nautilus-service-startup-view.c32
-rw-r--r--libnautilus-extensions/nautilus-icon-factory.c74
-rw-r--r--libnautilus-private/nautilus-icon-factory.c74
-rw-r--r--libnautilus/nautilus-icon-factory.c74
5 files changed, 222 insertions, 42 deletions
diff --git a/ChangeLog-20000414 b/ChangeLog-20000414
index ae9c975be..94ee011a4 100644
--- a/ChangeLog-20000414
+++ b/ChangeLog-20000414
@@ -1,3 +1,13 @@
+2000-04-09 Andy Hertzfeld <andy@eazel.com>
+
+ * components/services/startup/nautilus-service-startup-view.c:
+ now it saves the account toke assigned by the service, and passes it back in the
+ header of subsequent requests
+ * libnautilus/nautilus-icon-factory.c:
+ fixed bug #293, thumbnails of thumbnails endlessly, by explicitly testing for thumbnails
+ of thumbnails as part of the criteria for making them
+ also, make a "snapshot" frame for thumbnails (task 295)
+
2000-04-09 John Sullivan <sullivan@eazel.com>
Finished task 307 (keyboard navigation in list view should
diff --git a/components/services/startup/nautilus-service-startup-view.c b/components/services/startup/nautilus-service-startup-view.c
index fb357a6b9..7e240729d 100644
--- a/components/services/startup/nautilus-service-startup-view.c
+++ b/components/services/startup/nautilus-service-startup-view.c
@@ -43,6 +43,7 @@
struct _NautilusServicesContentViewDetails {
gchar *uri;
+ gchar *auth_token;
NautilusContentViewFrame *view_frame;
GtkWidget *form;
@@ -108,7 +109,7 @@ entry_changed_cb (GtkWidget *entry, NautilusServicesContentView *view)
it will optionally work asynchronously. Return NULL if we get an error */
static ghttp_request *
-make_http_post_request(gchar *uri, gchar *post_body)
+make_http_post_request(gchar *uri, gchar *post_body, gchar *auth_token)
{
ghttp_request *request = NULL;
gchar *proxy = g_getenv("http_proxy");
@@ -133,6 +134,10 @@ make_http_post_request(gchar *uri, gchar *post_body)
ghttp_set_header(request, http_hdr_Host, SERVICE_DOMAIN_NAME);
/* FIXME: user agent version and OS should be substituted on the fly */
ghttp_set_header(request, http_hdr_User_Agent, "Nautilus/0.1 (Linux)");
+
+ if (auth_token)
+ ghttp_set_header(request, "Cookie", auth_token);
+
ghttp_set_header(request, http_hdr_Connection, "close");
ghttp_set_body(request, post_body, strlen(post_body));
@@ -220,8 +225,7 @@ gather_config_button_cb (GtkWidget *button, NautilusServicesContentView *view)
/* FIXME: need to url-encode the arguments here */
uri = g_strdup_printf("http://%s/set.pl", SERVICE_DOMAIN_NAME);
- /* FIXME: we need to pass in the token and make make_http_post_request pass it in the cookie */
- request = make_http_post_request(uri, config_string);
+ request = make_http_post_request(uri, config_string, view->details->auth_token);
response_str = ghttp_get_body(request);
g_free(uri);
ghttp_request_destroy(request);
@@ -279,11 +283,14 @@ register_button_cb (GtkWidget *button, NautilusServicesContentView *view)
body = g_strdup_printf("email=%s&pwd=%s", email, password);
uri = g_strdup_printf("http://%s/member/new.pl", SERVICE_DOMAIN_NAME);
- request = make_http_post_request(uri, body);
+ request = make_http_post_request(uri, body, view->details->auth_token);
response_str = ghttp_get_body(request);
/* handle the error response */
- if (response_str && (strstr(response_str, "<ERROR field=") == response_str)) {
+ if (request == NULL) {
+ show_feedback(view, "Sorry, but the service did not respond. Please try again later.");
+ }
+ else if (response_str && (strstr(response_str, "<ERROR field=") == response_str)) {
if (strstr(response_str, "email")) {
if (strstr(response_str, "taken"))
show_feedback(view, "That email address is already registered! Please change it and try again.");
@@ -313,6 +320,11 @@ register_button_cb (GtkWidget *button, NautilusServicesContentView *view)
xmlSetProp(service_node, "domain", SERVICE_DOMAIN_NAME);
xmlSetProp(service_node, "token", temp_str);
+ /* save the token in the view object for subsequent accesses */
+ if (view->details->auth_token)
+ g_free(view->details->auth_token);
+ view->details->auth_token = g_strdup(temp_str);
+
temp_filename = g_strdup_printf("%s/.nautilus/service.xml", g_get_home_dir());
xmlSaveFile(temp_filename, service_doc);
xmlFreeDoc(service_doc);
@@ -648,9 +660,7 @@ nautilus_service_startup_view_initialize (NautilusServicesContentView *view)
"notify_location_change",
GTK_SIGNAL_FUNC (service_main_notify_location_change_cb),
view);
-
- view->details->form = NULL;
-
+
background = nautilus_get_widget_background (GTK_WIDGET (view));
nautilus_background_set_color (background, SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR);
@@ -664,7 +674,11 @@ nautilus_service_startup_view_destroy (GtkObject *object)
view = NAUTILUS_SERVICE_STARTUP_VIEW (object);
- g_free (view->details->uri);
+ if (view->details->uri)
+ g_free (view->details->uri);
+ if (view->details->auth_token)
+ g_free(view->details->auth_token);
+
g_free (view->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
diff --git a/libnautilus-extensions/nautilus-icon-factory.c b/libnautilus-extensions/nautilus-icon-factory.c
index 11e8ebff6..46bfa6d1a 100644
--- a/libnautilus-extensions/nautilus-icon-factory.c
+++ b/libnautilus-extensions/nautilus-icon-factory.c
@@ -717,7 +717,7 @@ nautilus_scalable_icon_equal (gconstpointer a,
NautilusScalableIcon *
nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
{
- char *uri;
+ char *uri, *file_uri;
const char *name;
NautilusScalableIcon *scalable_icon;
@@ -727,20 +727,22 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
/* if there is a custom image in the metadata, use that. */
uri = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL);
+ file_uri = nautilus_file_get_uri(file);
/* if the file is an image, either use the image itself as the icon if it's small enough,
or use a thumbnail if one exists. If a thumbnail is required, but does not yet exist,
put an entry on the thumbnail queue so we eventually make one */
-
+
+ /* also, dont make thumbnails for images in the thumbnails directory */
if (uri == NULL && nautilus_str_has_prefix (nautilus_file_get_mime_type (file), "image/")) {
if (nautilus_file_get_size (file) < SELF_THUMBNAIL_SIZE_THRESHOLD) {
uri = nautilus_file_get_uri (file);
- } else {
+ } else if (strstr(file_uri, "/.thumbnails/") == NULL)
uri = nautilus_icon_factory_get_thumbnail_uri (file);
- }
}
/* Get the generic icon set for this file. */
+ g_free(file_uri);
name = nautilus_icon_factory_get_icon_name_for_file (file);
/* Create the icon or find it in the cache if it's already there. */
@@ -1542,6 +1544,41 @@ check_for_thumbnails (NautilusIconFactory *factory)
return FALSE;
}
+/* utility to draw the thumbnail frame. The frame is rectangular, so it doesn't need an alpha channel */
+
+static void
+draw_thumbnail_frame(GdkPixbuf *frame_pixbuf)
+{
+ gint index, width, height, depth, rowstride, fill_value;
+ guchar *pixels, *temp_pixels;
+
+ width = gdk_pixbuf_get_width (frame_pixbuf);
+ height = gdk_pixbuf_get_height (frame_pixbuf);
+ depth = gdk_pixbuf_get_bits_per_sample (frame_pixbuf);
+ pixels = gdk_pixbuf_get_pixels (frame_pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (frame_pixbuf);
+
+ /* loop through the pixbuf a scaleline at a time, drawing the frame */
+ for (index = 0; index < height; index++) {
+ /* special case the first and last line to make them dark */
+ fill_value = (index == 0 || index == height - 1) ? 0 : 239;
+ memset(pixels, fill_value, rowstride);
+
+ /* draw the frame at the edge for each scanline */
+ temp_pixels = pixels;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+
+ pixels += rowstride;
+
+ temp_pixels = pixels - 3;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ }
+}
+
/* make_thumbnails is invoked periodically as a timer task to launch a task to make thumbnails */
static int
@@ -1582,7 +1619,7 @@ nautilus_icon_factory_make_thumbnails (gpointer data)
full_size_image = gdk_pixbuf_new_from_file (info->thumbnail_uri + 7);
if (full_size_image != NULL) {
- GdkPixbuf *scaled_image;
+ GdkPixbuf *scaled_image, *framed_image;
int scaled_width, scaled_height;
int full_width = gdk_pixbuf_get_width (full_size_image);
int full_height = gdk_pixbuf_get_height (full_size_image);
@@ -1595,19 +1632,34 @@ nautilus_icon_factory_make_thumbnails (gpointer data)
scaled_width = full_width * 96 / full_height;
}
- scaled_image = gdk_pixbuf_scale_simple (full_size_image,
- scaled_width, scaled_height,
- ART_FILTER_BILINEAR);
-
+ /* scale the image, then release the large one */
+
+ scaled_image = gdk_pixbuf_scale_simple (full_size_image, scaled_width, scaled_height, ART_FILTER_BILINEAR);
gdk_pixbuf_unref (full_size_image);
- if (!save_pixbuf_to_file (scaled_image, factory->new_thumbnail_path + 7))
- g_warning ("error saving thumbnail %s", factory->new_thumbnail_path + 7);
+
+ /* make the frame to mount it in - don't use an alpha channel, since it's rectangular */
+ framed_image = gdk_pixbuf_new(ART_PIX_RGB, FALSE, 8, scaled_width + 12, scaled_height + 12);
+ draw_thumbnail_frame(framed_image);
+
+ /* copy the scaled image into it, then release it */
+ gdk_pixbuf_copy_area(scaled_image, 0, 0, scaled_width, scaled_height, framed_image, 6, 6);
gdk_pixbuf_unref (scaled_image);
+
+ if (!save_pixbuf_to_file (framed_image, factory->new_thumbnail_path + 7))
+ g_warning ("error saving thumbnail %s", factory->new_thumbnail_path + 7);
+ gdk_pixbuf_unref (framed_image);
}
else {
/* gdk-pixbuf couldn't load the image, so trying using ImageMagick */
char *temp_str = g_strdup_printf ("png:%s", factory->new_thumbnail_path + 7);
+ char *temp_file = g_strdup_printf("%s.tmp", factory->new_thumbnail_path + 7);
+
+ /* scale the image, then draw a border and frame */
execlp ("convert", "convert", "-geometry", "96x96", info->thumbnail_uri + 7, temp_str, NULL);
+ execlp ("convert", "convert", "-bordercolor", "white", "-border", "8x8", info->thumbnail_uri + 7, temp_file, NULL);
+ execlp ("convert", "convert", "-mattecolor", "gray", "-frame", "2x2", temp_file, info->thumbnail_uri + 7);
+ unlink(temp_file);
+ g_free(temp_file);
g_free (temp_str);
}
diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c
index 11e8ebff6..46bfa6d1a 100644
--- a/libnautilus-private/nautilus-icon-factory.c
+++ b/libnautilus-private/nautilus-icon-factory.c
@@ -717,7 +717,7 @@ nautilus_scalable_icon_equal (gconstpointer a,
NautilusScalableIcon *
nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
{
- char *uri;
+ char *uri, *file_uri;
const char *name;
NautilusScalableIcon *scalable_icon;
@@ -727,20 +727,22 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
/* if there is a custom image in the metadata, use that. */
uri = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL);
+ file_uri = nautilus_file_get_uri(file);
/* if the file is an image, either use the image itself as the icon if it's small enough,
or use a thumbnail if one exists. If a thumbnail is required, but does not yet exist,
put an entry on the thumbnail queue so we eventually make one */
-
+
+ /* also, dont make thumbnails for images in the thumbnails directory */
if (uri == NULL && nautilus_str_has_prefix (nautilus_file_get_mime_type (file), "image/")) {
if (nautilus_file_get_size (file) < SELF_THUMBNAIL_SIZE_THRESHOLD) {
uri = nautilus_file_get_uri (file);
- } else {
+ } else if (strstr(file_uri, "/.thumbnails/") == NULL)
uri = nautilus_icon_factory_get_thumbnail_uri (file);
- }
}
/* Get the generic icon set for this file. */
+ g_free(file_uri);
name = nautilus_icon_factory_get_icon_name_for_file (file);
/* Create the icon or find it in the cache if it's already there. */
@@ -1542,6 +1544,41 @@ check_for_thumbnails (NautilusIconFactory *factory)
return FALSE;
}
+/* utility to draw the thumbnail frame. The frame is rectangular, so it doesn't need an alpha channel */
+
+static void
+draw_thumbnail_frame(GdkPixbuf *frame_pixbuf)
+{
+ gint index, width, height, depth, rowstride, fill_value;
+ guchar *pixels, *temp_pixels;
+
+ width = gdk_pixbuf_get_width (frame_pixbuf);
+ height = gdk_pixbuf_get_height (frame_pixbuf);
+ depth = gdk_pixbuf_get_bits_per_sample (frame_pixbuf);
+ pixels = gdk_pixbuf_get_pixels (frame_pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (frame_pixbuf);
+
+ /* loop through the pixbuf a scaleline at a time, drawing the frame */
+ for (index = 0; index < height; index++) {
+ /* special case the first and last line to make them dark */
+ fill_value = (index == 0 || index == height - 1) ? 0 : 239;
+ memset(pixels, fill_value, rowstride);
+
+ /* draw the frame at the edge for each scanline */
+ temp_pixels = pixels;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+
+ pixels += rowstride;
+
+ temp_pixels = pixels - 3;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ }
+}
+
/* make_thumbnails is invoked periodically as a timer task to launch a task to make thumbnails */
static int
@@ -1582,7 +1619,7 @@ nautilus_icon_factory_make_thumbnails (gpointer data)
full_size_image = gdk_pixbuf_new_from_file (info->thumbnail_uri + 7);
if (full_size_image != NULL) {
- GdkPixbuf *scaled_image;
+ GdkPixbuf *scaled_image, *framed_image;
int scaled_width, scaled_height;
int full_width = gdk_pixbuf_get_width (full_size_image);
int full_height = gdk_pixbuf_get_height (full_size_image);
@@ -1595,19 +1632,34 @@ nautilus_icon_factory_make_thumbnails (gpointer data)
scaled_width = full_width * 96 / full_height;
}
- scaled_image = gdk_pixbuf_scale_simple (full_size_image,
- scaled_width, scaled_height,
- ART_FILTER_BILINEAR);
-
+ /* scale the image, then release the large one */
+
+ scaled_image = gdk_pixbuf_scale_simple (full_size_image, scaled_width, scaled_height, ART_FILTER_BILINEAR);
gdk_pixbuf_unref (full_size_image);
- if (!save_pixbuf_to_file (scaled_image, factory->new_thumbnail_path + 7))
- g_warning ("error saving thumbnail %s", factory->new_thumbnail_path + 7);
+
+ /* make the frame to mount it in - don't use an alpha channel, since it's rectangular */
+ framed_image = gdk_pixbuf_new(ART_PIX_RGB, FALSE, 8, scaled_width + 12, scaled_height + 12);
+ draw_thumbnail_frame(framed_image);
+
+ /* copy the scaled image into it, then release it */
+ gdk_pixbuf_copy_area(scaled_image, 0, 0, scaled_width, scaled_height, framed_image, 6, 6);
gdk_pixbuf_unref (scaled_image);
+
+ if (!save_pixbuf_to_file (framed_image, factory->new_thumbnail_path + 7))
+ g_warning ("error saving thumbnail %s", factory->new_thumbnail_path + 7);
+ gdk_pixbuf_unref (framed_image);
}
else {
/* gdk-pixbuf couldn't load the image, so trying using ImageMagick */
char *temp_str = g_strdup_printf ("png:%s", factory->new_thumbnail_path + 7);
+ char *temp_file = g_strdup_printf("%s.tmp", factory->new_thumbnail_path + 7);
+
+ /* scale the image, then draw a border and frame */
execlp ("convert", "convert", "-geometry", "96x96", info->thumbnail_uri + 7, temp_str, NULL);
+ execlp ("convert", "convert", "-bordercolor", "white", "-border", "8x8", info->thumbnail_uri + 7, temp_file, NULL);
+ execlp ("convert", "convert", "-mattecolor", "gray", "-frame", "2x2", temp_file, info->thumbnail_uri + 7);
+ unlink(temp_file);
+ g_free(temp_file);
g_free (temp_str);
}
diff --git a/libnautilus/nautilus-icon-factory.c b/libnautilus/nautilus-icon-factory.c
index 11e8ebff6..46bfa6d1a 100644
--- a/libnautilus/nautilus-icon-factory.c
+++ b/libnautilus/nautilus-icon-factory.c
@@ -717,7 +717,7 @@ nautilus_scalable_icon_equal (gconstpointer a,
NautilusScalableIcon *
nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
{
- char *uri;
+ char *uri, *file_uri;
const char *name;
NautilusScalableIcon *scalable_icon;
@@ -727,20 +727,22 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
/* if there is a custom image in the metadata, use that. */
uri = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL);
+ file_uri = nautilus_file_get_uri(file);
/* if the file is an image, either use the image itself as the icon if it's small enough,
or use a thumbnail if one exists. If a thumbnail is required, but does not yet exist,
put an entry on the thumbnail queue so we eventually make one */
-
+
+ /* also, dont make thumbnails for images in the thumbnails directory */
if (uri == NULL && nautilus_str_has_prefix (nautilus_file_get_mime_type (file), "image/")) {
if (nautilus_file_get_size (file) < SELF_THUMBNAIL_SIZE_THRESHOLD) {
uri = nautilus_file_get_uri (file);
- } else {
+ } else if (strstr(file_uri, "/.thumbnails/") == NULL)
uri = nautilus_icon_factory_get_thumbnail_uri (file);
- }
}
/* Get the generic icon set for this file. */
+ g_free(file_uri);
name = nautilus_icon_factory_get_icon_name_for_file (file);
/* Create the icon or find it in the cache if it's already there. */
@@ -1542,6 +1544,41 @@ check_for_thumbnails (NautilusIconFactory *factory)
return FALSE;
}
+/* utility to draw the thumbnail frame. The frame is rectangular, so it doesn't need an alpha channel */
+
+static void
+draw_thumbnail_frame(GdkPixbuf *frame_pixbuf)
+{
+ gint index, width, height, depth, rowstride, fill_value;
+ guchar *pixels, *temp_pixels;
+
+ width = gdk_pixbuf_get_width (frame_pixbuf);
+ height = gdk_pixbuf_get_height (frame_pixbuf);
+ depth = gdk_pixbuf_get_bits_per_sample (frame_pixbuf);
+ pixels = gdk_pixbuf_get_pixels (frame_pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (frame_pixbuf);
+
+ /* loop through the pixbuf a scaleline at a time, drawing the frame */
+ for (index = 0; index < height; index++) {
+ /* special case the first and last line to make them dark */
+ fill_value = (index == 0 || index == height - 1) ? 0 : 239;
+ memset(pixels, fill_value, rowstride);
+
+ /* draw the frame at the edge for each scanline */
+ temp_pixels = pixels;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+
+ pixels += rowstride;
+
+ temp_pixels = pixels - 3;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ *temp_pixels++ = 0;
+ }
+}
+
/* make_thumbnails is invoked periodically as a timer task to launch a task to make thumbnails */
static int
@@ -1582,7 +1619,7 @@ nautilus_icon_factory_make_thumbnails (gpointer data)
full_size_image = gdk_pixbuf_new_from_file (info->thumbnail_uri + 7);
if (full_size_image != NULL) {
- GdkPixbuf *scaled_image;
+ GdkPixbuf *scaled_image, *framed_image;
int scaled_width, scaled_height;
int full_width = gdk_pixbuf_get_width (full_size_image);
int full_height = gdk_pixbuf_get_height (full_size_image);
@@ -1595,19 +1632,34 @@ nautilus_icon_factory_make_thumbnails (gpointer data)
scaled_width = full_width * 96 / full_height;
}
- scaled_image = gdk_pixbuf_scale_simple (full_size_image,
- scaled_width, scaled_height,
- ART_FILTER_BILINEAR);
-
+ /* scale the image, then release the large one */
+
+ scaled_image = gdk_pixbuf_scale_simple (full_size_image, scaled_width, scaled_height, ART_FILTER_BILINEAR);
gdk_pixbuf_unref (full_size_image);
- if (!save_pixbuf_to_file (scaled_image, factory->new_thumbnail_path + 7))
- g_warning ("error saving thumbnail %s", factory->new_thumbnail_path + 7);
+
+ /* make the frame to mount it in - don't use an alpha channel, since it's rectangular */
+ framed_image = gdk_pixbuf_new(ART_PIX_RGB, FALSE, 8, scaled_width + 12, scaled_height + 12);
+ draw_thumbnail_frame(framed_image);
+
+ /* copy the scaled image into it, then release it */
+ gdk_pixbuf_copy_area(scaled_image, 0, 0, scaled_width, scaled_height, framed_image, 6, 6);
gdk_pixbuf_unref (scaled_image);
+
+ if (!save_pixbuf_to_file (framed_image, factory->new_thumbnail_path + 7))
+ g_warning ("error saving thumbnail %s", factory->new_thumbnail_path + 7);
+ gdk_pixbuf_unref (framed_image);
}
else {
/* gdk-pixbuf couldn't load the image, so trying using ImageMagick */
char *temp_str = g_strdup_printf ("png:%s", factory->new_thumbnail_path + 7);
+ char *temp_file = g_strdup_printf("%s.tmp", factory->new_thumbnail_path + 7);
+
+ /* scale the image, then draw a border and frame */
execlp ("convert", "convert", "-geometry", "96x96", info->thumbnail_uri + 7, temp_str, NULL);
+ execlp ("convert", "convert", "-bordercolor", "white", "-border", "8x8", info->thumbnail_uri + 7, temp_file, NULL);
+ execlp ("convert", "convert", "-mattecolor", "gray", "-frame", "2x2", temp_file, info->thumbnail_uri + 7);
+ unlink(temp_file);
+ g_free(temp_file);
g_free (temp_str);
}