Commit 5c02e4a9 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Update according to NautilusIconFactory API changes.

2003-03-06  Alexander Larsson  <alexl@redhat.com>

	* libnautilus-private/nautilus-bookmark.c:
	(nautilus_bookmark_get_pixbuf), (nautilus_bookmark_update_icon):
	* libnautilus-private/nautilus-emblem-utils.c:
	(nautilus_emblem_rename_emblem):
	* src/nautilus-sidebar-title.c: (update_emblems):
	* src/file-manager/fm-directory-view.c: (ready_to_load):
	Update according to NautilusIconFactory API changes.

	* libnautilus-private/nautilus-file.h:
	* libnautilus-private/nautilus-file.c:
	(nautilus_file_peek_top_left_text),
	(nautilus_file_get_top_left_text):
	Add needs_loading out parameter to nautilus_file_peek_top_left_text.

	* libnautilus-private/nautilus-icon-canvas-item.h:
	* libnautilus-private/nautilus-icon-canvas-item.c:
	(nautilus_icon_canvas_item_finalize),
	(nautilus_icon_canvas_item_set_embedded_text_rect),
	(nautilus_icon_canvas_item_set_embedded_text),
	(draw_embedded_text), (nautilus_icon_canvas_item_draw):
	Render embedded text on exposes.
	(nautilus_icon_canvas_item_get_image):
	Return a GdkPixmap + mask instead of pixbuf, so that
	we can do the text rendering on it.

	* libnautilus-private/nautilus-icon-private.h:
	* libnautilus-private/nautilus-icon-container.h:
	* libnautilus-private/nautilus-icon-container.c:
	(nautilus_icon_container_clear), (icon_destroy),
	(nautilus_icon_container_get_icon_images),
	(nautilus_icon_container_start_monitor_top_left),
	(nautilus_icon_container_stop_monitor_top_left),
	(nautilus_icon_container_update_icon):
	For icons that have an embedded text rect, request the
	top-left text, and set the text on the canvas item.

	* libnautilus-private/nautilus-icon-dnd.c:
	(nautilus_icon_dnd_begin_drag):
	nautilus_icon_canvas_item_get_image now returns a pixmap, handle this
	change.

	* libnautilus-private/nautilus-icon-factory.h:
	* libnautilus-private/nautilus-icon-factory.c: (cache_key_destroy),
	(nautilus_icon_factory_get_required_file_attributes),
	(get_icon_from_cache), (nautilus_icon_factory_get_pixbuf_for_icon),
	(cache_key_hash), (cache_key_equal),
	(nautilus_icon_factory_get_pixbuf_for_file),
	(nautilus_icon_factory_get_pixbuf_from_name),
	(nautilus_icon_factory_remove_from_cache):
	Remove all embedded text handling.
	(nautilus_icon_factory_get_basic_file_attributes):
	Remove, not needed anymore.
	(nautilus_icon_factory_get_icon_for_file):
	Pass in whether you want icons for text embedding or not.

	* src/file-manager/fm-icon-container.c:
	(fm_icon_container_get_icon_images),
	(fm_icon_container_start_monitor_top_left),
	(fm_icon_container_stop_monitor_top_left),
	(fm_icon_container_class_init):
	Update to new APIs. pass TRUE for embedd_text in get_icon_for_file.
	Implement start/stop top left monitoring.

	* src/file-manager/fm-icon-view.c:
	(list_covers),(fm_icon_view_clear):
	Clear the icon container before unreferencing the NautilusFiles.
	Otherwise the stop_monitor call uses the unref:ed file.
parent 2c4a5da9
2003-03-06 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-bookmark.c:
(nautilus_bookmark_get_pixbuf), (nautilus_bookmark_update_icon):
* libnautilus-private/nautilus-emblem-utils.c:
(nautilus_emblem_rename_emblem):
* src/nautilus-sidebar-title.c: (update_emblems):
* src/file-manager/fm-directory-view.c: (ready_to_load):
Update according to NautilusIconFactory API changes.
* libnautilus-private/nautilus-file.h:
* libnautilus-private/nautilus-file.c:
(nautilus_file_peek_top_left_text),
(nautilus_file_get_top_left_text):
Add needs_loading out parameter to nautilus_file_peek_top_left_text.
* libnautilus-private/nautilus-icon-canvas-item.h:
* libnautilus-private/nautilus-icon-canvas-item.c:
(nautilus_icon_canvas_item_finalize),
(nautilus_icon_canvas_item_set_embedded_text_rect),
(nautilus_icon_canvas_item_set_embedded_text),
(draw_embedded_text), (nautilus_icon_canvas_item_draw):
Render embedded text on exposes.
(nautilus_icon_canvas_item_get_image):
Return a GdkPixmap + mask instead of pixbuf, so that
we can do the text rendering on it.
* libnautilus-private/nautilus-icon-private.h:
* libnautilus-private/nautilus-icon-container.h:
* libnautilus-private/nautilus-icon-container.c:
(nautilus_icon_container_clear), (icon_destroy),
(nautilus_icon_container_get_icon_images),
(nautilus_icon_container_start_monitor_top_left),
(nautilus_icon_container_stop_monitor_top_left),
(nautilus_icon_container_update_icon):
For icons that have an embedded text rect, request the
top-left text, and set the text on the canvas item.
* libnautilus-private/nautilus-icon-dnd.c:
(nautilus_icon_dnd_begin_drag):
nautilus_icon_canvas_item_get_image now returns a pixmap, handle this
change.
* libnautilus-private/nautilus-icon-factory.h:
* libnautilus-private/nautilus-icon-factory.c: (cache_key_destroy),
(nautilus_icon_factory_get_required_file_attributes),
(get_icon_from_cache), (nautilus_icon_factory_get_pixbuf_for_icon),
(cache_key_hash), (cache_key_equal),
(nautilus_icon_factory_get_pixbuf_for_file),
(nautilus_icon_factory_get_pixbuf_from_name),
(nautilus_icon_factory_remove_from_cache):
Remove all embedded text handling.
(nautilus_icon_factory_get_basic_file_attributes):
Remove, not needed anymore.
(nautilus_icon_factory_get_icon_for_file):
Pass in whether you want icons for text embedding or not.
* src/file-manager/fm-icon-container.c:
(fm_icon_container_get_icon_images),
(fm_icon_container_start_monitor_top_left),
(fm_icon_container_stop_monitor_top_left),
(fm_icon_container_class_init):
Update to new APIs. pass TRUE for embedd_text in get_icon_for_file.
Implement start/stop top left monitoring.
* src/file-manager/fm-icon-view.c:
(list_covers),(fm_icon_view_clear):
Clear the icon container before unreferencing the NautilusFiles.
Otherwise the stop_monitor call uses the unref:ed file.
2003-03-05 Alexander Larsson <alexl@redhat.com>
* src/nautilus-zoom-control.[ch]:
......
......@@ -216,8 +216,9 @@ nautilus_bookmark_get_pixbuf (NautilusBookmark *bookmark,
}
result = nautilus_icon_factory_get_pixbuf_for_icon
(icon, NULL, NULL,
icon_size, NULL, TRUE, NULL);
(icon, NULL,
icon_size, NULL, NULL,
TRUE, NULL);
g_free (icon);
......@@ -304,7 +305,7 @@ nautilus_bookmark_update_icon (NautilusBookmark *bookmark)
}
if (nautilus_icon_factory_is_icon_ready_for_file (bookmark->details->file)) {
new_icon = nautilus_icon_factory_get_icon_for_file (bookmark->details->file);
new_icon = nautilus_icon_factory_get_icon_for_file (bookmark->details->file, FALSE);
if (nautilus_bookmark_icon_is_different (bookmark, new_icon)) {
g_free (bookmark->details->icon);
bookmark->details->icon = new_icon;
......
......@@ -384,7 +384,7 @@ nautilus_emblem_rename_emblem (const char *keyword, const char *name)
fclose (file);
icon_name = nautilus_emblem_get_icon_name_from_keyword (keyword);
nautilus_icon_factory_remove_from_cache (icon_name, NULL, NULL,
nautilus_icon_factory_remove_from_cache (icon_name, NULL,
NAUTILUS_ICON_SIZE_STANDARD);
g_free (icon_name);
......
......@@ -4720,22 +4720,30 @@ nautilus_file_is_executable (NautilusFile *file)
*
**/
char *
nautilus_file_peek_top_left_text (NautilusFile *file)
nautilus_file_peek_top_left_text (NautilusFile *file, gboolean *needs_loading)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
if (!nautilus_file_should_get_top_left_text (file)) {
if (needs_loading) {
*needs_loading = FALSE;
}
return NULL;
}
if (needs_loading) {
*needs_loading = !file->details->top_left_text_is_up_to_date;
}
/* Show " ..." in the file until we read the contents in. */
if (!file->details->got_top_left_text) {
if (nautilus_file_contains_text (file)) {
return " ...";
}
return NULL;
}
/* Show what we read in. */
return file->details->top_left_text;
}
......@@ -4752,7 +4760,7 @@ nautilus_file_peek_top_left_text (NautilusFile *file)
char *
nautilus_file_get_top_left_text (NautilusFile *file)
{
return g_strdup (nautilus_file_peek_top_left_text (file));
return g_strdup (nautilus_file_peek_top_left_text (file, NULL));
}
......
......@@ -159,7 +159,8 @@ void nautilus_file_set_keywords (Nautilu
GList *keywords);
GList * nautilus_file_get_emblem_names (NautilusFile *file);
char * nautilus_file_get_top_left_text (NautilusFile *file);
char * nautilus_file_peek_top_left_text (NautilusFile *file);
char * nautilus_file_peek_top_left_text (NautilusFile *file,
gboolean *got_top_left_text);
gboolean nautilus_file_get_directory_item_mime_types (NautilusFile *file,
GList **mime_list);
......
......@@ -99,6 +99,9 @@ struct NautilusIconCanvasItemDetails {
PangoLayout *editable_text_layout;
PangoLayout *additional_text_layout;
GdkRectangle embedded_text_rect;
PangoLayout *embedded_text_layout;
/* Cached rectangle in canvas coordinates */
ArtIRect canvas_rect;
ArtIRect text_rect;
......@@ -181,6 +184,10 @@ static gboolean hit_test_stretch_handle (NautilusIconCanvasItem
static void clear_rounded_corners (GdkPixbuf *destination_pixbuf,
GdkPixbuf *corner_pixbuf,
int corner_size);
static void draw_embedded_text (NautilusIconCanvasItem *icon_item,
GdkDrawable *drawable,
int x,
int y);
static NautilusIconCanvasItemClass *parent_class = NULL;
......@@ -238,6 +245,11 @@ nautilus_icon_canvas_item_finalize (GObject *object)
if (details->additional_text_layout != NULL) {
g_object_unref (details->additional_text_layout);
}
if (details->embedded_text_layout != NULL) {
g_object_unref (details->embedded_text_layout);
}
g_free (details);
......@@ -391,16 +403,25 @@ nautilus_icon_canvas_item_get_property (GObject *object,
}
}
GdkPixbuf *
nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item)
GdkPixmap *
nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
GdkBitmap **mask)
{
NautilusIconCanvasItemDetails *details;
GdkPixmap *pixmap;
EelCanvas *canvas;
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), NULL);
details = item->details;
canvas = EEL_CANVAS_ITEM (item)->canvas;
gdk_pixbuf_render_pixmap_and_mask_for_colormap (item->details->pixbuf,
gtk_widget_get_colormap (GTK_WIDGET (canvas)),
&pixmap,
mask,
128);
draw_embedded_text (item, GDK_DRAWABLE (pixmap), 0,0);
return details->pixbuf;
return pixmap;
}
void
......@@ -475,6 +496,43 @@ nautilus_icon_canvas_item_set_attach_points (NautilusIconCanvasItem *item,
}
}
void
nautilus_icon_canvas_item_set_embedded_text_rect (NautilusIconCanvasItem *item,
const GdkRectangle *text_rect)
{
item->details->embedded_text_rect = *text_rect;
eel_canvas_item_request_update (EEL_CANVAS_ITEM (item));
}
void
nautilus_icon_canvas_item_set_embedded_text (NautilusIconCanvasItem *item,
const char *text)
{
PangoContext *context;
PangoFontDescription *desc;
if (item->details->embedded_text_layout == NULL && text != NULL) {
context = gtk_widget_get_pango_context (GTK_WIDGET (EEL_CANVAS_ITEM(item)->canvas));
item->details->embedded_text_layout = pango_layout_new (context);
desc = pango_font_description_from_string ("monospace 6");
pango_layout_set_font_description (item->details->embedded_text_layout, desc);
pango_font_description_free (desc);
}
if (item->details->embedded_text_layout != NULL) {
if (text != NULL) {
pango_layout_set_text (item->details->embedded_text_layout, text, -1);
} else {
pango_layout_set_text (item->details->embedded_text_layout, "", -1);
}
eel_canvas_item_request_update (EEL_CANVAS_ITEM (item));
}
}
/* Recomputes the bounding box of a icon canvas item.
* This is a generic implementation that could be used for any canvas item
* class, it has no assumptions about how the item is used.
......@@ -1202,6 +1260,37 @@ map_pixbuf (NautilusIconCanvasItem *icon_item)
return icon_item->details->rendered_pixbuf;
}
static void
draw_embedded_text (NautilusIconCanvasItem *icon_item,
GdkDrawable *drawable,
int x, int y)
{
GdkGC *gc;
GdkRectangle clip_rect;
if (icon_item->details->embedded_text_layout == NULL ||
icon_item->details->embedded_text_rect.width == 0 ||
icon_item->details->embedded_text_rect.height == 0) {
return;
}
gc = gdk_gc_new (drawable);
clip_rect.x = x + icon_item->details->embedded_text_rect.x;
clip_rect.y = y + icon_item->details->embedded_text_rect.y;
clip_rect.width = icon_item->details->embedded_text_rect.width;
clip_rect.height = icon_item->details->embedded_text_rect.height;
gdk_gc_set_clip_rectangle (gc, &clip_rect);
gdk_draw_layout (drawable, gc,
x + icon_item->details->embedded_text_rect.x,
y + icon_item->details->embedded_text_rect.y,
icon_item->details->embedded_text_layout);
g_object_unref (gc);
}
/* Draw the icon item for non-anti-aliased mode. */
static void
nautilus_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
......@@ -1229,6 +1318,8 @@ nautilus_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
draw_pixbuf (temp_pixbuf, drawable, icon_rect.x0, icon_rect.y0);
g_object_unref (temp_pixbuf);
draw_embedded_text (icon_item, drawable, icon_rect.x0, icon_rect.y0);
/* Draw the emblem pixbufs. */
emblem_layout_reset (&emblem_layout, icon_item, icon_rect);
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect)) {
......
......@@ -63,13 +63,18 @@ GType nautilus_icon_canvas_item_get_type (void);
/* attributes */
void nautilus_icon_canvas_item_set_image (NautilusIconCanvasItem *item,
GdkPixbuf *image);
GdkPixbuf * nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item);
GdkPixmap * nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
GdkBitmap **mask);
void nautilus_icon_canvas_item_set_emblems (NautilusIconCanvasItem *item,
GList *emblem_pixbufs);
void nautilus_icon_canvas_item_set_show_stretch_handles (NautilusIconCanvasItem *item,
gboolean show_stretch_handles);
void nautilus_icon_canvas_item_set_attach_points (NautilusIconCanvasItem *item,
NautilusEmblemAttachPoints *attach_points);
void nautilus_icon_canvas_item_set_embedded_text_rect (NautilusIconCanvasItem *item,
const GdkRectangle *text_rect);
void nautilus_icon_canvas_item_set_embedded_text (NautilusIconCanvasItem *item,
const char *text);
double nautilus_icon_canvas_item_get_max_text_width (NautilusIconCanvasItem *item);
const char *nautilus_icon_canvas_item_get_editable_text (NautilusIconCanvasItem *icon_item);
void nautilus_icon_canvas_item_set_renaming (NautilusIconCanvasItem *icon_item,
......
......@@ -111,6 +111,10 @@
#define DEFAULT_LIGHT_INFO_COLOR 0xAAAAFD
#define DEFAULT_DARK_INFO_COLOR 0x33337F
#define MINIMUM_EMBEDDED_TEXT_RECT_WIDTH 20
#define MINIMUM_EMBEDDED_TEXT_RECT_HEIGHT 20
enum {
NAUTILUS_TYPESELECT_FLUSH_DELAY = 1000000
/* After this time the current typeselect buffer will be
......@@ -131,31 +135,38 @@ typedef struct {
static GType nautilus_icon_container_accessible_get_type (void);
static void activate_selected_items (NautilusIconContainer *container);
static void nautilus_icon_container_theme_changed (gpointer user_data);
static void compute_stretch (StretchState *start,
StretchState *current);
static NautilusIcon *get_first_selected_icon (NautilusIconContainer *container);
static NautilusIcon *get_nth_selected_icon (NautilusIconContainer *container,
int index);
static gboolean has_multiple_selection (NautilusIconContainer *container);
static void icon_destroy (NautilusIconContainer *container,
NautilusIcon *icon);
static void end_renaming_mode (NautilusIconContainer *container,
gboolean commit);
static NautilusIcon *get_icon_being_renamed (NautilusIconContainer *container);
static void finish_adding_new_icons (NautilusIconContainer *container);
static void update_label_color (EelBackground *background,
NautilusIconContainer *icon_container);
static void icon_get_bounding_box (NautilusIcon *icon,
int *x1_return,
int *y1_return,
int *x2_return,
int *y2_return);
static gboolean is_renaming (NautilusIconContainer *container);
static gboolean is_renaming_pending (NautilusIconContainer *container);
static void process_pending_icon_to_rename (NautilusIconContainer *container);
static void setup_label_gcs (NautilusIconContainer *container);
static void activate_selected_items (NautilusIconContainer *container);
static void nautilus_icon_container_theme_changed (gpointer user_data);
static void compute_stretch (StretchState *start,
StretchState *current);
static NautilusIcon *get_first_selected_icon (NautilusIconContainer *container);
static NautilusIcon *get_nth_selected_icon (NautilusIconContainer *container,
int index);
static gboolean has_multiple_selection (NautilusIconContainer *container);
static void icon_destroy (NautilusIconContainer *container,
NautilusIcon *icon);
static void end_renaming_mode (NautilusIconContainer *container,
gboolean commit);
static NautilusIcon *get_icon_being_renamed (NautilusIconContainer *container);
static void finish_adding_new_icons (NautilusIconContainer *container);
static void update_label_color (EelBackground *background,
NautilusIconContainer *icon_container);
static void icon_get_bounding_box (NautilusIcon *icon,
int *x1_return,
int *y1_return,
int *x2_return,
int *y2_return);
static gboolean is_renaming (NautilusIconContainer *container);
static gboolean is_renaming_pending (NautilusIconContainer *container);
static void process_pending_icon_to_rename (NautilusIconContainer *container);
static void setup_label_gcs (NautilusIconContainer *container);
static void nautilus_icon_container_stop_monitor_top_left (NautilusIconContainer *container,
NautilusIconData *data,
gconstpointer client);
static void nautilus_icon_container_start_monitor_top_left (NautilusIconContainer *container,
NautilusIconData *data,
gconstpointer client);
static int click_policy_auto_value;
......@@ -3767,6 +3778,7 @@ void
nautilus_icon_container_clear (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
NautilusIcon *icon;
GList *p;
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
......@@ -3786,6 +3798,12 @@ nautilus_icon_container_clear (NautilusIconContainer *container)
details->drop_target = NULL;
for (p = details->icons; p != NULL; p = p->next) {
icon = p->data;
if (icon->is_monitored) {
nautilus_icon_container_stop_monitor_top_left (container,
icon->data,
icon);
}
icon_free (p->data);
}
g_list_free (details->icons);
......@@ -3879,6 +3897,11 @@ icon_destroy (NautilusIconContainer *container,
set_pending_icon_to_reveal (container, NULL);
}
if (icon->is_monitored) {
nautilus_icon_container_stop_monitor_top_left (container,
icon->data,
icon);
}
icon_free (icon);
if (was_selected) {
......@@ -3925,14 +3948,15 @@ static char *
nautilus_icon_container_get_icon_images (NautilusIconContainer *container,
NautilusIconData *data,
GList **emblem_icons,
char **embedded_text)
char **embedded_text,
gboolean *embedded_text_needs_loading)
{
NautilusIconContainerClass *klass;
klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container);
g_return_val_if_fail (klass->get_icon_images != NULL, NULL);
return klass->get_icon_images (container, data, emblem_icons, embedded_text);
return klass->get_icon_images (container, data, emblem_icons, embedded_text, embedded_text_needs_loading);
}
......@@ -3950,6 +3974,33 @@ nautilus_icon_container_get_icon_text (NautilusIconContainer *container,
klass->get_icon_text (container, data, editable_text, additional_text);
}
static void
nautilus_icon_container_start_monitor_top_left (NautilusIconContainer *container,
NautilusIconData *data,
gconstpointer client)
{
NautilusIconContainerClass *klass;
klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container);
g_return_if_fail (klass->start_monitor_top_left != NULL);
klass->start_monitor_top_left (container, data, client);
}
static void
nautilus_icon_container_stop_monitor_top_left (NautilusIconContainer *container,
NautilusIconData *data,
gconstpointer client)
{
NautilusIconContainerClass *klass;
klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container);
g_return_if_fail (klass->stop_monitor_top_left != NULL);
klass->stop_monitor_top_left (container, data, client);
}
void
nautilus_icon_container_update_icon (NautilusIconContainer *container,
NautilusIcon *icon)
......@@ -3965,6 +4016,8 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
GList *emblem_icon_names, *emblem_pixbufs, *p;
char *editable_text, *additional_text;
char *embedded_text;
GdkRectangle embedded_text_rect;
gboolean embedded_text_needs_loading;
if (icon == NULL) {
return;
......@@ -3978,7 +4031,7 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
icon_name = nautilus_icon_container_get_icon_images (
container, icon->data,
&emblem_icon_names,
&embedded_text);
&embedded_text, &embedded_text_needs_loading);
/* compute the maximum size based on the scale factor */
min_image_size = MINIMUM_IMAGE_SIZE * EEL_CANVAS (container)->pixels_per_unit;
......@@ -3993,13 +4046,20 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
(icon_name,
(icon == details->drop_target) ? "accept" : NULL,
embedded_text,
icon_size,
&attach_points,
&embedded_text_rect,
TRUE, NULL);
g_free (icon_name);
if (embedded_text_rect.width > MINIMUM_EMBEDDED_TEXT_RECT_WIDTH &&
embedded_text_rect.height > MINIMUM_EMBEDDED_TEXT_RECT_HEIGHT &&
embedded_text_needs_loading) {
icon->is_monitored = TRUE;
nautilus_icon_container_start_monitor_top_left (container, icon->data, icon);
}
/* in the rare case an image is too small, scale it up */
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
......@@ -4024,10 +4084,10 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
for (p = emblem_icon_names; p != NULL; p = p->next) {
emblem_pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
(p->data,
NULL,
NULL,
MIN (icon_size, MAXIMUM_EMBLEM_SIZE),
NULL,
NULL,
FALSE, NULL);
if (emblem_pixbuf != NULL) {
emblem_pixbufs = g_list_prepend
......@@ -4063,6 +4123,8 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
nautilus_icon_canvas_item_set_image (icon->item, pixbuf);
nautilus_icon_canvas_item_set_attach_points (icon->item, &attach_points);
nautilus_icon_canvas_item_set_emblems (icon->item, emblem_pixbufs);
nautilus_icon_canvas_item_set_embedded_text_rect (icon->item, &embedded_text_rect);
nautilus_icon_canvas_item_set_embedded_text (icon->item, embedded_text);
/* Let the pixbufs go. */
g_object_unref (pixbuf);
......
......@@ -108,7 +108,8 @@ typedef struct {
char * (* get_icon_images) (NautilusIconContainer *container,
NautilusIconData *data,
GList **emblem_icons,
char **embedded_text);
char **embedded_text,
gboolean *embedded_text_needs_loading);
void (* get_icon_text) (NautilusIconContainer *container,
NautilusIconData *data,
char **editable_text,
......@@ -119,6 +120,12 @@ typedef struct {
int (* compare_icons_by_name) (NautilusIconContainer *container,
NautilusIconData *icon_a,
NautilusIconData *icon_b);
void (* start_monitor_top_left) (NautilusIconContainer *container,
NautilusIconData *data,
gconstpointer client);
void (* stop_monitor_top_left) (NautilusIconContainer *container,
NautilusIconData *data,
gconstpointer client);
/* Queries on icons for subclass/client.
* These must be implemented => These are signals !
......
......@@ -1201,7 +1201,8 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
NautilusIconDndInfo *dnd_info;
EelCanvas *canvas;
GdkDragContext *context;
GdkPixbuf *pixbuf;
GdkPixmap *pixmap;
GdkBitmap *mask;
int x_offset, y_offset;
ArtDRect world_rect;
ArtIRect widget_rect;
......@@ -1220,7 +1221,7 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
dnd_info->drag_info.start_y = event->y - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas)));
/* create a pixmap and mask to drag with */
pixbuf = nautilus_icon_canvas_item_get_image (container->details->drag_icon->item);
pixmap = nautilus_icon_canvas_item_get_image (container->details->drag_icon->item, &mask);
/* we want to drag semi-transparent pixbufs, but X is too slow dealing with
stippled masks, so we had to remove the code; this comment is left as a memorial
......@@ -1245,7 +1246,10 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
if (context) {
/* set the icon for dragging */
gtk_drag_set_icon_pixbuf (context, pixbuf, x_offset, y_offset);
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (GTK_WIDGET (container)),
pixmap, mask,
x_offset, y_offset);
}
}
......
......@@ -84,16 +84,6 @@
*/
#define ICON_CACHE_SWEEP_TIMEOUT (10 * 1000)
/* Embedded text font size and text line settings */
/* FIXME; Hard coded font size */
#define EMBEDDED_TEXT_FONT_SIZE 9
#define EMBEDDED_TEXT_LINE_SPACING 1
#define EMBEDDED_TEXT_EMPTY_LINE_HEIGHT 4
#define MINIMUM_EMBEDDED_TEXT_RECT_WIDTH 20
#define MINIMUM_EMBEDDED_TEXT_RECT_HEIGHT 20
/* This circular doubly-linked list structure is used to keep a list
* of the most recently used items in the cache.
*/
......@@ -107,7 +97,6 @@ struct CircularList {
typedef struct {
char *name; /* Icon name or absolute filename */
char *modifier;
char *embedded_text;
guint nominal_size;
} CacheKey;
......@@ -186,11 +175,7 @@ static CacheIcon *cache_icon_new (GdkPixbuf
GnomeIconData *icon_data);
static CacheIcon *get_icon_from_cache (const char *icon,
const char *modifier,
const char *embedded_text,
guint nominal_size);
static GdkPixbuf *embed_text (GdkPixbuf *pixbuf_without_text,
GnomeIconData *icon_data,
const char *text);
static void nautilus_icon_factory_clear (void);
GNOME_CLASS_BOILERPLATE (NautilusIconFactory,
......@@ -391,7 +376,6 @@ static void
cache_key_destroy (CacheKey *key)
{
g_free (key->name);
g_free (key->embedded_text);
g_free (key);
}
......@@ -739,7 +723,7 @@ should_show_thumbnail (NautilusFile *file)
/* key routine to get the icon for a file */
char *
nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
nautilus_icon_factory_get_icon_for_file (NautilusFile *file, gboolean embedd_text)
{
char *custom_uri, *file_uri, *icon_name, *mime_type, *custom_icon;
NautilusIconFactory *factory;
......@@ -786,7 +770,7 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
}
lookup_flags = GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES;
if (nautilus_file_peek_top_left_text (file) != NULL) {
if (embedd_text) {
lookup_flags |= GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT;
}
icon_name = gnome_icon_lookup (factory->icon_theme,
......@@ -820,25 +804,6 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file)
return icon_name;
}
/**
* nautilus_icon_factory_get_basic_file_attributes
*
* Get the list of file attributes required to obtain a file's basic icon.
* This includes attributes needed to get a custom icon, but not those needed
* for text preview.
* Callers must free this list.
*/
GList *
nautilus_icon_factory_get_basic_file_attributes (void)
{
GList *attributes;
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON);
attributes = g_list_prepend (attributes,
NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE);
return attributes;
}
/**
* nautilus_icon_factory_get_required_file_attributes
*
......@@ -850,9 +815,9 @@ nautilus_icon_factory_get_required_file_attributes (void)
{
GList *attributes;
attributes = nautilus_icon_factory_get_basic_file_attributes ();
attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON);
attributes = g_list_prepend (attributes,
NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT);
NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE);
return attributes;
}
......@@ -879,28 +844,6 @@ nautilus_icon_factory_is_icon_ready_for_file (NautilusFile *file)
return result;
}
/**
* nautilus_icon_factory_is_basic_icon_ready_for_file
*
* Check whether a NautilusFile has enough information to report
* what its basic icon should be. This will account for custom icons
* but not text preview.
*
* @file: The NautilusFile in question.
*/
gboolean
nautilus_icon_factory_is_basic_icon_ready_for_file (NautilusFile *file)
{
GList *attributes;
gboolean result;
attributes = nautilus_icon_factory_get_basic_file_attributes ();