preview a broader range of sounds using "play", and (completely unrelated)

preview a broader range of sounds using "play", and (completely
	 unrelated) draw the icon stretch handles in anti-aliased mode.
This commit is contained in:
Andy Hertzfeld 2000-05-30 21:59:07 +00:00
parent 161115bb70
commit f665e65e4f
4 changed files with 132 additions and 8 deletions

View file

@ -1,3 +1,15 @@
2000-05-30 Andy Hertzfeld <andy@eazel.com>
* src/file-manager/fm-icon-view.c: (play_file),
(icon_container_preview_callback):
play it preview a much broader range of sounds using "play"
* libnautilus-extensions/nautilus-icon-canvas-item.c:
(draw_filled_rectangle_aa), (draw_stretch_handles_aa),
(nautilus_icon_canvas_item_render):
draw the stretch handles in anti-aliased mode. This isn't quite
finished yet, since there's a bug that makes the icon itself disappear
2000-05-30 Pavel Cisler <pavel@eazel.com>
* src/file-manager/dfos-xfer.h:

View file

@ -35,6 +35,7 @@
#include <libgnomeui/gnome-icon-text.h>
#include <libart_lgpl/art_rgb_affine.h>
#include <libart_lgpl/art_rgb_rgba_affine.h>
#include <libart_lgpl/art_svp_vpath.h>
#include "nautilus-icon-private.h"
#include "nautilus-string.h"
#include "nautilus-glib-extensions.h"
@ -800,6 +801,55 @@ draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
gdk_gc_unref (gc);
}
/* utility routine to use libart to draw a rectangle in the anti-aliased canvas */
static void
draw_filled_rectangle_aa (GnomeCanvasBuf *buf, int left, int top, int width, int height)
{
ArtVpath vpath[6];
ArtSVP *path;
vpath[0].code = ART_MOVETO;
vpath[0].x = left;
vpath[0].y = top;
vpath[1].code = ART_LINETO;
vpath[1].x = left;
vpath[1].y = top + height;
vpath[2].code = ART_LINETO;
vpath[2].x = left + width;
vpath[2].y = top + height;
vpath[3].code = ART_LINETO;
vpath[3].x = left + width;
vpath[3].y = top;
vpath[4].code = ART_LINETO;
vpath[4].x = left;
vpath[4].y = top;
vpath[5].code = ART_END;
vpath[5].x = 0;
vpath[5].y = 0;
path = art_svp_from_vpath(vpath);
gnome_canvas_render_svp(buf, path, 0x000000FF);
art_svp_free(path);
}
/* draw the stretch handles in the anti-aliased canvas */
static void
draw_stretch_handles_aa (NautilusIconCanvasItem *item, GnomeCanvasBuf *buf,
const ArtIRect *rect)
{
if (!item->details->show_stretch_handles) {
return;
}
draw_filled_rectangle_aa (buf, rect->x0, rect->y0, STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS);
draw_filled_rectangle_aa (buf, rect->x1 - STRETCH_HANDLE_THICKNESS, rect->y0, STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS);
draw_filled_rectangle_aa (buf, rect->x1 - STRETCH_HANDLE_THICKNESS, rect->y1 - STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS);
draw_filled_rectangle_aa (buf, rect->x0, rect->y1 - STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS);
}
static void
emblem_layout_reset (EmblemLayout *layout, NautilusIconCanvasItem *icon_item, const ArtIRect *icon_rect)
{
@ -1122,6 +1172,7 @@ nautilus_icon_canvas_item_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
i2c[3] = 1.0;
gnome_canvas_buf_ensure_buf (buf);
/* draw the icon */
if (gdk_pixbuf_get_has_alpha(temp_pixbuf))
art_rgb_rgba_affine (buf->buf,
@ -1155,9 +1206,10 @@ nautilus_icon_canvas_item_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
draw_pixbuf_aa (emblem_pixbuf, buf, i2c, emblem_rect.x0 - icon_rect.x0,
emblem_rect.y0 - icon_rect.y0);
}
/* draw the stretch handles */
draw_stretch_handles_aa (icon_item, buf, &icon_rect);
/* draw the text */
i2c[5] += icon_rect.y1 - icon_rect.y0;
x_delta = (icon_item->details->text_width - (icon_rect.x1 - icon_rect.x0)) / 2;

View file

@ -35,6 +35,7 @@
#include <libgnomeui/gnome-icon-text.h>
#include <libart_lgpl/art_rgb_affine.h>
#include <libart_lgpl/art_rgb_rgba_affine.h>
#include <libart_lgpl/art_svp_vpath.h>
#include "nautilus-icon-private.h"
#include "nautilus-string.h"
#include "nautilus-glib-extensions.h"
@ -800,6 +801,55 @@ draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
gdk_gc_unref (gc);
}
/* utility routine to use libart to draw a rectangle in the anti-aliased canvas */
static void
draw_filled_rectangle_aa (GnomeCanvasBuf *buf, int left, int top, int width, int height)
{
ArtVpath vpath[6];
ArtSVP *path;
vpath[0].code = ART_MOVETO;
vpath[0].x = left;
vpath[0].y = top;
vpath[1].code = ART_LINETO;
vpath[1].x = left;
vpath[1].y = top + height;
vpath[2].code = ART_LINETO;
vpath[2].x = left + width;
vpath[2].y = top + height;
vpath[3].code = ART_LINETO;
vpath[3].x = left + width;
vpath[3].y = top;
vpath[4].code = ART_LINETO;
vpath[4].x = left;
vpath[4].y = top;
vpath[5].code = ART_END;
vpath[5].x = 0;
vpath[5].y = 0;
path = art_svp_from_vpath(vpath);
gnome_canvas_render_svp(buf, path, 0x000000FF);
art_svp_free(path);
}
/* draw the stretch handles in the anti-aliased canvas */
static void
draw_stretch_handles_aa (NautilusIconCanvasItem *item, GnomeCanvasBuf *buf,
const ArtIRect *rect)
{
if (!item->details->show_stretch_handles) {
return;
}
draw_filled_rectangle_aa (buf, rect->x0, rect->y0, STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS);
draw_filled_rectangle_aa (buf, rect->x1 - STRETCH_HANDLE_THICKNESS, rect->y0, STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS);
draw_filled_rectangle_aa (buf, rect->x1 - STRETCH_HANDLE_THICKNESS, rect->y1 - STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS);
draw_filled_rectangle_aa (buf, rect->x0, rect->y1 - STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS, STRETCH_HANDLE_THICKNESS);
}
static void
emblem_layout_reset (EmblemLayout *layout, NautilusIconCanvasItem *icon_item, const ArtIRect *icon_rect)
{
@ -1122,6 +1172,7 @@ nautilus_icon_canvas_item_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
i2c[3] = 1.0;
gnome_canvas_buf_ensure_buf (buf);
/* draw the icon */
if (gdk_pixbuf_get_has_alpha(temp_pixbuf))
art_rgb_rgba_affine (buf->buf,
@ -1155,9 +1206,10 @@ nautilus_icon_canvas_item_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
draw_pixbuf_aa (emblem_pixbuf, buf, i2c, emblem_rect.x0 - icon_rect.x0,
emblem_rect.y0 - icon_rect.y0);
}
/* draw the stretch handles */
draw_stretch_handles_aa (icon_item, buf, &icon_rect);
/* draw the text */
i2c[5] += icon_rect.y1 - icon_rect.y0;
x_delta = (icon_item->details->text_width - (icon_rect.x1 - icon_rect.x0)) / 2;

View file

@ -1106,16 +1106,24 @@ icon_container_activate_callback (NautilusIconContainer *container,
static gint play_file(NautilusFile *file)
{
char * file_uri;
file_uri = nautilus_file_get_uri(file);
char *file_uri, *mime_type, *player;
file_uri = nautilus_file_get_uri(file);
mime_type = nautilus_file_get_mime_type(file);
if (!nautilus_strcmp(mime_type, "audio/x-mp3"))
player = "mpg123";
else
player = "play";
mp3_pid = fork ();
if (mp3_pid == (pid_t) 0) {
execlp ("mpg123", "mpg123", file_uri + 7, NULL);
execlp (player, player, file_uri + 7, NULL);
_exit (0);
}
g_free(file_uri);
g_free(mime_type);
timeout = -1;
return 0;
@ -1160,7 +1168,7 @@ icon_container_preview_callback (NautilusIconContainer *container,
/* preview files based on the mime_type. */
/* for now, we just handle mp3s, soon we'll do more general sounds, eventually, more general types */
if (!nautilus_strcmp(mime_type, "audio/x-mp3")) {
if (nautilus_str_has_prefix(mime_type, "audio/")) {
result = 1;
preview_sound(file, start_flag);
}