Commit 9b94323c authored by Darin Adler's avatar Darin Adler

Added icon stretching and did some cleanups.

	Stretched icons aren't yet persistent (the scale factor is not
	saved in metadata), but that's not much more work.

	* libnautilus/gnome-icon-container-private.h:
	* libnautilus/gnome-icon-container.h:
	* libnautilus/gnome-icon-container.c: (icon_new), (icon_position),
	(icon_set_position), (icon_get_size), (icon_set_size),
	(icon_toggle_selected), (icon_select), (icon_set_selected),
	(button_press_event), (gnome_icon_container_begin_stretch),
	(start_stretching), (gnome_icon_container_stretch),
	(continue_stretching), (gnome_icon_container_end_stretch),
	(end_stretching), (button_release_event), (motion_notify_event),
	(handle_icon_button_press), (gnome_icon_container_clear),
	(request_update_one), (update_icon), (get_first_selected_icon),
	(gnome_icon_container_show_stretch_handles),
	(gnome_icon_container_has_stretch_handles),
	(gnome_icon_container_is_stretched),
	(gnome_icon_container_unstretch), (compute_stretch),
	(nautilus_self_check_compute_stretch),
	(nautilus_self_check_gnome_icon_container):
	* libnautilus/nautilus-icons-view-icon-item.h:
	* libnautilus/nautilus-icons-view-icon-item.c:
	(nautilus_icons_view_icon_item_draw),
	(nautilus_icons_view_icon_item_point),
	(nautilus_icons_view_icon_item_set_show_stretch_handles),
	(nautilus_icons_view_icon_item_get_hit_stretch_handle):
	* libnautilus/nautilus-lib-self-check-functions.h:
	Added machinery for stretching icons.

	* src/file-manager/fm-directory-view.h:
	* src/file-manager/fm-directory-view.c:
	(append_item_context_menu_items),
	(fm_directory_view_real_append_item_context_menu_items),
	(fm_directory_view_initialize_class), (create_item_context_menu):
	Added machinery for views to have view-specific menu items for
	icons as well as for the window as a whole.

	* src/file-manager/fm-directory-view-icons.c:
	(fm_directory_view_icons_initialize_class),
	(fm_directory_view_icons_append_item_context_menu_items),
	(show_stretch_handles_cb), (unstretch_item_cb):
	Added menu items for stretching icons.

	* libnautilus/gnome-icon-container.c: (start_rubberbanding):
	Fixed bug that would result in two rubberband timeouts at
	once if you did rubberbanding quickly.

	* components/notes/.cvsignore: Andy's new component needs a
	.cvsignore file for its generated pieces.

	* libnautilus/nautilus-directory.c:
	(nautilus_directory_try_to_read_metafile),
	(nautilus_directory_read_metafile):
	Simplified logic in metafile-reading functions and fixed a bug
	where the vfs handle would be left open if certain categories
	of errors occurred.

	* libnautilus/nautilus-gtk-extensions.h:
	Added a missing gtk_marshal function.

	* libnautilus/nautilus-icon-factory.h:
	* libnautilus/nautilus-icon-factory.c:
	(nautilus_icon_size_for_zoom_level),
	(nautilus_get_icon_size_for_zoom_level),
	(nautilus_icon_factory_get_pixbuf_for_file),
	(nautilus_icon_factory_get_pixmap_and_mask_for_file):
	* src/nautilus-index-title.c: (nautilus_index_title_set_up_icon):
	* src/nautilus-zoom-control.c: (set_zoom_level):
	* src/file-manager/fm-directory-view-list.c:
	(fm_directory_view_list_bump_zoom_level), (install_icon):
	Made some API improvements for the icon factory. Added a missing
	get_ to the name nautilus_get_icon_size_for_zoom_level and added
	convenience functions for the most common uses of the factory.

	* libnautilus/ntl-content-view-frame.c:
	* libnautilus/ntl-meta-view-frame.c:
	* libnautilus/ntl-view-frame.c:
	Weaned all the files in libnautilus itself from using the
	libnautilus.h include file. They instead include the parts that
	they need. Also added some missing <config.h> includes.
parent d3d8e1d7
2000-02-15 Andu Hertzfeld <andy@eazel.com>
2000-02-16 Darin Adler <darin@eazel.com>
Added icon stretching and did some cleanups.
Stretched icons aren't yet persistent (the scale factor is not
saved in metadata), but that's not much more work.
* libnautilus/gnome-icon-container-private.h:
* libnautilus/gnome-icon-container.h:
* libnautilus/gnome-icon-container.c: (icon_new), (icon_position),
(icon_set_position), (icon_get_size), (icon_set_size),
(icon_toggle_selected), (icon_select), (icon_set_selected),
(button_press_event), (gnome_icon_container_begin_stretch),
(start_stretching), (gnome_icon_container_stretch),
(continue_stretching), (gnome_icon_container_end_stretch),
(end_stretching), (button_release_event), (motion_notify_event),
(handle_icon_button_press), (gnome_icon_container_clear),
(request_update_one), (update_icon), (get_first_selected_icon),
(gnome_icon_container_show_stretch_handles),
(gnome_icon_container_has_stretch_handles),
(gnome_icon_container_is_stretched),
(gnome_icon_container_unstretch), (compute_stretch),
(nautilus_self_check_compute_stretch),
(nautilus_self_check_gnome_icon_container):
* libnautilus/nautilus-icons-view-icon-item.h:
* libnautilus/nautilus-icons-view-icon-item.c:
(nautilus_icons_view_icon_item_draw),
(nautilus_icons_view_icon_item_point),
(nautilus_icons_view_icon_item_set_show_stretch_handles),
(nautilus_icons_view_icon_item_get_hit_stretch_handle):
* libnautilus/nautilus-lib-self-check-functions.h:
Added machinery for stretching icons.
* src/file-manager/fm-directory-view.h:
* src/file-manager/fm-directory-view.c:
(append_item_context_menu_items),
(fm_directory_view_real_append_item_context_menu_items),
(fm_directory_view_initialize_class), (create_item_context_menu):
Added machinery for views to have view-specific menu items for
icons as well as for the window as a whole.
* src/file-manager/fm-directory-view-icons.c:
(fm_directory_view_icons_initialize_class),
(fm_directory_view_icons_append_item_context_menu_items),
(show_stretch_handles_cb), (unstretch_item_cb):
Added menu items for stretching icons.
* libnautilus/gnome-icon-container.c: (start_rubberbanding):
Fixed bug that would result in two rubberband timeouts at
once if you did rubberbanding quickly.
* components/notes/.cvsignore: Andy's new component needs a
.cvsignore file for its generated pieces.
* libnautilus/nautilus-directory.c:
(nautilus_directory_try_to_read_metafile),
(nautilus_directory_read_metafile):
Simplified logic in metafile-reading functions and fixed a bug
where the vfs handle would be left open if certain categories
of errors occurred.
* libnautilus/nautilus-gtk-extensions.h:
Added a missing gtk_marshal function.
* libnautilus/nautilus-icon-factory.h:
* libnautilus/nautilus-icon-factory.c:
(nautilus_icon_size_for_zoom_level),
(nautilus_get_icon_size_for_zoom_level),
(nautilus_icon_factory_get_pixbuf_for_file),
(nautilus_icon_factory_get_pixmap_and_mask_for_file):
* src/nautilus-index-title.c: (nautilus_index_title_set_up_icon):
* src/nautilus-zoom-control.c: (set_zoom_level):
* src/file-manager/fm-directory-view-list.c:
(fm_directory_view_list_bump_zoom_level), (install_icon):
Made some API improvements for the icon factory. Added a missing
get_ to the name nautilus_get_icon_size_for_zoom_level and added
convenience functions for the most common uses of the factory.
* libnautilus/ntl-content-view-frame.c:
* libnautilus/ntl-meta-view-frame.c:
* libnautilus/ntl-view-frame.c:
Weaned all the files in libnautilus itself from using the
libnautilus.h include file. They instead include the parts that
they need. Also added some missing <config.h> includes.
2000-02-15 Andy Hertzfeld <andy@eazel.com>
* src/ntl-index-panel.c:
removed test code that created extra tabs on right-click
Removed test code that created extra tabs on right-click.
* src/ntl-index-title.c:
added logic to break the title into two lines so it can use a larger font,
Added logic to break the title into two lines so it can use a larger font,
if it can find an appropriate breaking point.
2000-02-15 Maciej Stachowiak <mjs@eazel.com>
......
.deps
.libs
Makefile
Makefile.in
ntl-notes
......@@ -36,11 +36,12 @@ typedef struct {
/* Canvas item for the icon. */
NautilusIconsViewIconItem *item;
/* X/Y coordinates and size. We could use the GnomeCanvasItem
* functions, but this is a lot faster
*/
/* X/Y coordinates. */
double x, y;
/* Scale factor (stretches icon). */
double scale;
/* Whether this item is selected for operation. */
gboolean is_selected : 1;
......@@ -99,6 +100,20 @@ typedef struct {
guint prev_x2, prev_y2;
} GnomeIconContainerRubberbandInfo;
typedef enum {
DRAG_ACTION_MOVE_OR_COPY,
DRAG_ACTION_STRETCH
} DragAction;
typedef struct {
/* Pointer position in canvas coordinates. */
int pointer_x, pointer_y;
/* Icon top, left, and size in canvas coordinates. */
int icon_x, icon_y;
guint icon_size;
} StretchState;
struct _GnomeIconContainerDetails {
NautilusIconsController *controller;
......@@ -123,6 +138,9 @@ struct _GnomeIconContainerDetails {
/* Current icon for keyboard navigation. */
GnomeIconContainerIcon *kbd_current;
/* Current icon with stretch handles, so we have only one. */
GnomeIconContainerIcon *stretch_icon;
/* Rubberbanding status. */
GnomeIconContainerRubberbandInfo rubberband_info;
......@@ -132,20 +150,16 @@ struct _GnomeIconContainerDetails {
*/
guint kbd_icon_visibility_timer_id;
/* the time the mouse button went down in milliseconds */
/* Remembered information about the start of the current event. */
guint32 button_down_time;
/* Position of the pointer during the last click. */
int drag_x, drag_y;
/* Button currently pressed, possibly for dragging. */
/* Drag state. Valid only if drag_button is non-zero. */
guint drag_button;
/* Icon on which the click happened. */
GnomeIconContainerIcon *drag_icon;
/* Whether we are actually performing a dragging action. */
gboolean doing_drag;
int drag_x, drag_y;
DragAction drag_action;
gboolean drag_started;
StretchState stretch_start;
/* Idle ID. */
guint idle_id;
......
......@@ -66,6 +66,7 @@ struct _GnomeIconContainerClass {
};
guint gnome_icon_container_get_type (void);
GtkWidget *gnome_icon_container_new (NautilusIconsController *controller);
......@@ -75,8 +76,8 @@ void gnome_icon_container_enable_linger_selection (GnomeIconContainer
void gnome_icon_container_clear (GnomeIconContainer *view);
void gnome_icon_container_add (GnomeIconContainer *view,
NautilusControllerIcon *icon,
gint x,
gint y);
int x,
int y);
void gnome_icon_container_add_auto (GnomeIconContainer *view,
NautilusControllerIcon *icon);
......@@ -87,10 +88,17 @@ void gnome_icon_container_request_update_all (GnomeIconContainer *containe
GList * gnome_icon_container_get_selection (GnomeIconContainer *view);
gint gnome_icon_container_get_zoom_level (GnomeIconContainer *view);
void gnome_icon_container_set_zoom_level (GnomeIconContainer *view, gint new_zoom_level);
int gnome_icon_container_get_zoom_level (GnomeIconContainer *view);
void gnome_icon_container_set_zoom_level (GnomeIconContainer *view,
int new_zoom_level);
void gnome_icon_container_unselect_all (GnomeIconContainer *view);
void gnome_icon_container_select_all (GnomeIconContainer *view);
/* The following all work on the selected icon. */
gboolean gnome_icon_container_has_stretch_handles (GnomeIconContainer *container);
gboolean gnome_icon_container_is_stretched (GnomeIconContainer *container);
void gnome_icon_container_show_stretch_handles (GnomeIconContainer *container);
void gnome_icon_container_unstretch (GnomeIconContainer *container);
#endif
......@@ -294,30 +294,34 @@ nautilus_directory_try_to_read_metafile (NautilusDirectory *directory, GnomeVFSU
GNOME_VFS_FILE_INFO_DEFAULT,
NULL);
if (result == GNOME_VFS_OK) {
/* Check for the case where the info doesn't give the file size. */
if ((metafile_info.flags & GNOME_VFS_FILE_INFO_FIELDS_SIZE) == 0)
result = GNOME_VFS_ERROR_GENERIC;
}
if (result == GNOME_VFS_OK) {
/* Check for a size that won't fit into a size_t. */
if(metafile_info.flags & GNOME_VFS_FILE_INFO_FIELDS_SIZE) {
size = metafile_info.size;
if (size != metafile_info.size)
result = GNOME_VFS_ERROR_TOOBIG;
} else
size = 0;
size = metafile_info.size;
if (size != metafile_info.size)
result = GNOME_VFS_ERROR_TOOBIG;
}
metafile_handle = NULL;
if (result == GNOME_VFS_OK) {
result = gnome_vfs_open_uri (&metafile_handle,
metafile_uri,
GNOME_VFS_OPEN_READ);
}
if (result == GNOME_VFS_OK && size) {
if (result == GNOME_VFS_OK) {
buffer = g_malloc (size);
result = gnome_vfs_read (metafile_handle, buffer, size, &actual_size);
directory->details->metafile_tree = xmlParseMemory (buffer, actual_size);
g_free (buffer);
} else
directory->details->metafile_tree = NULL;
}
if (result == GNOME_VFS_OK)
if (metafile_handle != NULL)
gnome_vfs_close (metafile_handle);
return result;
......@@ -339,12 +343,6 @@ nautilus_directory_read_metafile (NautilusDirectory *directory)
directory->details->use_alternate_metafile = TRUE;
else
result = nautilus_directory_try_to_read_metafile (directory, directory->details->metafile_uri);
/* Check for errors. Later this must be reported to the user, not spit out as a warning. */
if (result != GNOME_VFS_OK
&& result != GNOME_VFS_ERROR_NOTFOUND
&& result != GNOME_VFS_ERROR_NOTADIRECTORY)
g_warning ("nautilus_directory_read_metafile failed to read metafile - we should report this to the user");
}
static void
......
......@@ -25,11 +25,15 @@
*/
#ifndef NAUTILUS_GTK_EXTENSIONS_H
#define NAUTILUS_GTK_EXTENSIONS_H 1
#define NAUTILUS_GTK_EXTENSIONS_H
#include <gtk/gtkmenu.h>
#include <gtk/gtkwindow.h>
#define gtk_marshal_NONE__BOXED_BOXED gtk_marshal_NONE__POINTER_POINTER
#define NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT 2
guint nautilus_gtk_signal_connect_free_data (GtkObject *object,
const gchar *name,
GtkSignalFunc func,
......@@ -40,10 +44,8 @@ void nautilus_gtk_window_present (GtkWindow
GtkSelectionData *nautilus_gtk_selection_data_copy_deep (const GtkSelectionData *selection_data);
void nautilus_gtk_selection_data_free_deep (GtkSelectionData *selection_data);
#define NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT 2
void nautilus_pop_up_context_menu (GtkMenu *menu,
gint16 offset_x,
gint16 offset_y);
gint16 offset_x,
gint16 offset_y);
#endif /* NAUTILUS_GTK_EXTENSIONS_H */
......@@ -746,7 +746,7 @@ nautilus_icon_factory_scale (GdkPixbuf *standard_sized_image,
* NAUTILUS_ICON_SIZE_LARGEST, inclusive.
*/
guint
nautilus_icon_size_for_zoom_level (NautilusZoomLevel zoom_level)
nautilus_get_icon_size_for_zoom_level (NautilusZoomLevel zoom_level)
{
switch (zoom_level) {
case NAUTILUS_ZOOM_LEVEL_SMALLEST:
......@@ -768,3 +768,36 @@ nautilus_icon_size_for_zoom_level (NautilusZoomLevel zoom_level)
return NAUTILUS_ICON_SIZE_STANDARD;
}
}
/* Convenience cover for nautilus_icon_factory_get_icon_for_file
* and nautilus_icon_factory_get_pixbuf_for_icon.
*/
GdkPixbuf *
nautilus_icon_factory_get_pixbuf_for_file (NautilusFile *file,
guint size_in_pixels)
{
NautilusScalableIcon *icon;
GdkPixbuf *pixbuf;
icon = nautilus_icon_factory_get_icon_for_file (file);
pixbuf = nautilus_icon_factory_get_pixbuf_for_icon (icon, size_in_pixels);
nautilus_scalable_icon_unref (icon);
return pixbuf;
}
/* Convenience cover for nautilus_icon_factory_get_icon_for_file,
* nautilus_icon_factory_get_pixbuf_for_icon,
* and gdk_pixbuf_render_pixmap_and_mask.
*/
void
nautilus_icon_factory_get_pixmap_and_mask_for_file (NautilusFile *file,
guint size_in_pixels,
GdkPixmap **pixmap,
GdkBitmap **mask)
{
GdkPixbuf *pixbuf;
pixbuf = nautilus_icon_factory_get_pixbuf_for_file (file, size_in_pixels);
gdk_pixbuf_render_pixmap_and_mask (pixbuf, pixmap, mask, 128);
gdk_pixbuf_unref (pixbuf);
}
......@@ -70,32 +70,52 @@ typedef enum {
typedef struct _NautilusScalableIcon NautilusScalableIcon;
/* Relationship between zoom levels and icons sizes. */
guint nautilus_icon_size_for_zoom_level (NautilusZoomLevel zoom_level);
guint nautilus_get_icon_size_for_zoom_level (NautilusZoomLevel zoom_level);
/* Switch themes. */
void nautilus_icon_factory_set_theme (const char *theme_name);
void nautilus_icon_factory_set_theme (const char *theme_name);
/* Choose the appropriate icon, but don't render it yet. */
NautilusScalableIcon *nautilus_icon_factory_get_icon_for_file (NautilusFile *file);
NautilusScalableIcon *nautilus_icon_factory_get_icon_by_name (const char *scalable_icon_name);
NautilusScalableIcon *nautilus_icon_factory_get_icon_for_file (NautilusFile *file);
NautilusScalableIcon *nautilus_icon_factory_get_icon_by_name (const char *icon_name);
/* Render an icon to a particular size.
* Ownership of a ref. count in this pixbuf comes with the deal.
*/
GdkPixbuf * nautilus_icon_factory_get_pixbuf_for_icon (NautilusScalableIcon *scalable_icon,
guint size_in_pixels);
GdkPixbuf * nautilus_icon_factory_get_pixbuf_for_icon (NautilusScalableIcon *scalable_icon,
guint size_in_pixels);
/* Convenience functions for the common case where you want to choose
* and render the icon into a pixbuf all at once.
*/
GdkPixbuf * nautilus_icon_factory_get_pixbuf_for_file (NautilusFile *file,
guint size_in_pixels);
GdkPixbuf * nautilus_icon_factory_get_pixbuf_by_name (const char *icon_name,
guint size_in_pixels);
/* Convenience functions for legacy interfaces that require a pixmap and
* bitmap. Maybe we can get rid of these one day.
*/
void nautilus_icon_factory_get_pixmap_and_mask_for_file (NautilusFile *file,
guint size_in_pixels,
GdkPixmap **pixmap,
GdkBitmap **mask);
void nautilus_icon_factory_get_pixmap_and_mask_by_name (NautilusFile *file,
guint size_in_pixels,
GdkPixmap **pixmap,
GdkBitmap **mask);
/* Manage a scalable icon.
* Since the factory always passes out references to the same scalable
* icon, you can compare two scalable icons to see if they are the same
* with ==.
*/
void nautilus_scalable_icon_ref (NautilusScalableIcon *scalable_icon);
void nautilus_scalable_icon_unref (NautilusScalableIcon *scalable_icon);
void nautilus_scalable_icon_ref (NautilusScalableIcon *scalable_icon);
void nautilus_scalable_icon_unref (NautilusScalableIcon *scalable_icon);
/* The name of a scalable icon is suitable for storage in metadata.
* This is a quick way to record the result of getting an icon by name.
*/
char * nautilus_scalable_icon_get_name (NautilusScalableIcon *scalable_icon);
char * nautilus_scalable_icon_get_name (NautilusScalableIcon *scalable_icon);
#endif /* NAUTILUS_ICON_FACTORY_H */
......@@ -36,6 +36,8 @@
#include "nautilus-string.h"
#include "gdk-extensions.h"
#define STRETCH_HANDLE_THICKNESS 6
/* Private part of the NautilusIconsViewIconItem structure */
struct _NautilusIconsViewIconItemDetails {
/* The image, text, font. */
......@@ -51,6 +53,7 @@ struct _NautilusIconsViewIconItemDetails {
guint is_highlighted_for_selection : 1;
guint is_highlighted_for_keyboard_selection: 1;
guint is_highlighted_for_drop : 1;
guint show_stretch_handles : 1;
};
......@@ -491,6 +494,7 @@ nautilus_icons_view_icon_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable
NautilusIconsViewIconItem *icon_item;
NautilusIconsViewIconItemDetails *details;
ArtIRect pixbuf_rect, drawable_rect, draw_rect;
GdkGC *gc;
icon_item = NAUTILUS_ICONS_VIEW_ICON_ITEM (item);
details = icon_item->details;
......@@ -516,6 +520,34 @@ nautilus_icons_view_icon_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable
GDK_PIXBUF_ALPHA_BILEVEL, 128, GDK_RGB_DITHER_MAX,
draw_rect.x0, draw_rect.y0);
}
/* Draw stretching handles. */
if (details->show_stretch_handles) {
gc = gdk_gc_new (drawable);
gdk_draw_rectangle (drawable, gc, TRUE,
pixbuf_rect.x0 - x,
pixbuf_rect.y0 - y,
STRETCH_HANDLE_THICKNESS,
STRETCH_HANDLE_THICKNESS);
gdk_draw_rectangle (drawable, gc, TRUE,
pixbuf_rect.x1 - x - STRETCH_HANDLE_THICKNESS,
pixbuf_rect.y0 - y,
STRETCH_HANDLE_THICKNESS,
STRETCH_HANDLE_THICKNESS);
gdk_draw_rectangle (drawable, gc, TRUE,
pixbuf_rect.x0 - x,
pixbuf_rect.y1 - y - STRETCH_HANDLE_THICKNESS,
STRETCH_HANDLE_THICKNESS,
STRETCH_HANDLE_THICKNESS);
gdk_draw_rectangle (drawable, gc, TRUE,
pixbuf_rect.x1 - x - STRETCH_HANDLE_THICKNESS,
pixbuf_rect.y1 - y - STRETCH_HANDLE_THICKNESS,
STRETCH_HANDLE_THICKNESS,
STRETCH_HANDLE_THICKNESS);
gdk_gc_unref (gc);
}
/* Draw the text. */
nautilus_icons_view_draw_text_box
......@@ -544,7 +576,9 @@ nautilus_icons_view_icon_item_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf
/* Point handler for the icon canvas item. */
/* FIXME: This currently only reports a hit if the pixbuf is hit. */
/* FIXME: This currently only reports a hit if the pixbuf or stretch handles are hit,
* and ignores hits on the text.
*/
static double
nautilus_icons_view_icon_item_point (GnomeCanvasItem *item, double x, double y, int cx, int cy,
GnomeCanvasItem **actual_item)
......@@ -564,9 +598,13 @@ nautilus_icons_view_icon_item_point (GnomeCanvasItem *item, double x, double y,
/* Check to see if it's within the item's rectangle at all. */
nautilus_icons_view_icon_item_get_icon_canvas_rectangle (icon_item, &rect);
if (cx <= rect.x0 || cx >= rect.x1 || cy <= rect.y0 || cy >= rect.y1)
if (cx < rect.x0 || cx >= rect.x1 || cy < rect.y0 || cy >= rect.y1)
return no_hit;
/* Check for hits in the stretch handles. */
if (nautilus_icons_view_icon_item_get_hit_stretch_handle (icon_item, cx, cy))
return 0.0;
/* Can't get this far without a pixbuf. */
g_assert (details->pixbuf != NULL);
if (details->pixbuf == NULL)
......@@ -724,3 +762,44 @@ nautilus_icons_view_icon_item_get_icon_window_rectangle (NautilusIconsViewIconIt
rect->x1 = rect->x0 + (pixbuf == NULL ? 0 : pixbuf->art_pixbuf->width);
rect->y1 = rect->y0 + (pixbuf == NULL ? 0 : pixbuf->art_pixbuf->height);
}
void
nautilus_icons_view_icon_item_set_show_stretch_handles (NautilusIconsViewIconItem *item,
gboolean show_stretch_handles)
{
g_return_if_fail (NAUTILUS_IS_ICONS_VIEW_ICON_ITEM (item));
g_return_if_fail (show_stretch_handles == FALSE || show_stretch_handles == TRUE);
if (!item->details->show_stretch_handles == !show_stretch_handles)
return;
item->details->show_stretch_handles = show_stretch_handles;
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (item));
}
/* Check if one of the stretch handles was hit. */
gboolean
nautilus_icons_view_icon_item_get_hit_stretch_handle (NautilusIconsViewIconItem *item,
int canvas_x, int canvas_y)
{
ArtIRect rect;
g_return_val_if_fail (NAUTILUS_IS_ICONS_VIEW_ICON_ITEM (item), FALSE);
/* Make sure there are handles to hit. */
if (!item->details->show_stretch_handles)
return FALSE;
/* Get both the point and the icon rectangle in canvas coordinates. */
nautilus_icons_view_icon_item_get_icon_canvas_rectangle (item, &rect);
/* Handle the case where it's not in the rectangle at all. */
if (canvas_x < rect.x0 || canvas_x >= rect.x1 || canvas_y < rect.y0 || canvas_y >= rect.y1)
return FALSE;
/* Check for hits in the stretch handles. */
return (canvas_x < rect.x0 + STRETCH_HANDLE_THICKNESS
|| canvas_x >= rect.x1 - STRETCH_HANDLE_THICKNESS)
&& (canvas_y < rect.y0 + STRETCH_HANDLE_THICKNESS
|| canvas_y >= rect.y1 - STRETCH_HANDLE_THICKNESS);
}
......@@ -55,11 +55,19 @@ struct _NautilusIconsViewIconItemClass {
GnomeCanvasItemClass parent_class;
};
GtkType nautilus_icons_view_icon_item_get_type (void);
void nautilus_icons_view_icon_item_get_icon_world_rectangle (NautilusIconsViewIconItem *item,
ArtDRect *world_rectangle);
void nautilus_icons_view_icon_item_get_icon_window_rectangle (NautilusIconsViewIconItem *item,
ArtIRect *window_rectangle);
GtkType nautilus_icons_view_icon_item_get_type (void);
void nautilus_icons_view_icon_item_get_icon_world_rectangle (NautilusIconsViewIconItem *item,
ArtDRect *world_rectangle);
void nautilus_icons_view_icon_item_get_icon_window_rectangle (NautilusIconsViewIconItem *item,
ArtIRect *window_rectangle);
void nautilus_icons_view_icon_item_set_show_stretch_handles (NautilusIconsViewIconItem *item,
gboolean show_stretch_handles);
gboolean nautilus_icons_view_icon_item_get_hit_stretch_handle (NautilusIconsViewIconItem *item,
int canvas_x,
int canvas_y);
END_GNOME_DECLS
......
......@@ -43,6 +43,7 @@ void nautilus_run_lib_self_checks (void);
macro (nautilus_self_check_directory) \
macro (nautilus_self_check_gdk_extensions) \
macro (nautilus_self_check_glib_extensions) \
macro (nautilus_self_check_gnome_icon_container) \
macro (nautilus_self_check_string) \
/* Add new self-check functions to the list above this line. */
......
......@@ -36,11 +36,12 @@ typedef struct {
/* Canvas item for the icon. */
NautilusIconsViewIconItem *item;
/* X/Y coordinates and size. We could use the GnomeCanvasItem
* functions, but this is a lot faster
*/
/* X/Y coordinates. */
double x, y;
/* Scale factor (stretches icon). */
double scale;
/* Whether this item is selected for operation. */
gboolean is_selected : 1;
......@@ -99,6 +100,20 @@ typedef struct {
guint prev_x2, prev_y2;
} GnomeIconContainerRubberbandInfo;
typedef enum {
DRAG_ACTION_MOVE_OR_COPY,
DRAG_ACTION_STRETCH
} DragAction;
typedef struct {
/* Pointer position in canvas coordinates. */
int pointer_x, pointer_y;
/* Icon top, left, and size in canvas coordinates. */
int icon_x, icon_y;
guint icon_size;
} StretchState;
struct _GnomeIconContainerDetails {
NautilusIconsController *controller;
......@@ -123,6 +138,9 @@ struct _GnomeIconContainerDetails {
/* Current icon for keyboard navigation. */
GnomeIconContainerIcon *kbd_current;
/* Current icon with stretch handles, so we have only one. */
GnomeIconContainerIcon *stretch_icon;
/* Rubberbanding status. */
GnomeIconContainerRubberbandInfo rubberband_info;
......@@ -132,20 +150,16 @@ struct _GnomeIconContainerDetails {
*/
guint kbd_icon_visibility_timer_id;
/* the time the mouse button went down in milliseconds */
/* Remembered information about the start of the current event. */
guint32 button_down_time;
/* Position of the pointer during the last click. */
int drag_x, drag_y;
/* Button currently pressed, possibly for dragging. */
/* Drag state. Valid only if drag_button is non-zero. */
guint drag_button;
/* Icon on which the click happened. */
GnomeIconContainerIcon *drag_icon;
/* Whether we are actually performing a dragging action. */
gboolean doing_drag;
int drag_x, drag_y;
DragAction drag_action;
gboolean drag_started;
StretchState stretch_start;
/* Idle ID. */
guint idle_id;
......
This diff is collapsed.
......@@ -66,6 +66,7 @@ struct _GnomeIconContainerClass {
};
guint gnome_icon_container_get_type (void);
GtkWidget *gnome_icon_container_new (NautilusIconsController *controller);
......@@ -75,8 +76,8 @@ void gnome_icon_container_enable_linger_selection (GnomeIconContainer
void gnome_icon_container_clear (GnomeIconContainer *view);
void gnome_icon_container_add (GnomeIconContainer *view,
NautilusControllerIcon *icon,
gint x,
gint y);
int x,
int y);
void gnome_icon_container_add_auto (GnomeIconContainer *view,
NautilusControllerIcon *icon);
......@@ -87,10 +88,17 @@ void gnome_icon_container_request_update_all (GnomeIconContainer *containe
GList * gnome_icon_container_get_selection (GnomeIconContainer *view);
gint gnome_icon_container_get_zoom_level (GnomeIconContainer *view);
void gnome_icon_container_set_zoom_level (GnomeIconContainer *view, gint new_zoom_level);
int gnome_icon_container_get_zoom_level (GnomeIconContainer *view);
void gnome_icon_container_set_zoom_level (GnomeIconContainer *view,
int new_zoom_level);
void gnome_icon_container_unselect_all (GnomeIconContainer *view);
void gnome_icon_container_select_all (GnomeIconContainer *view);
/* The following all work on the selected icon. */
gboolean gnome_icon_container_has_stretch_handles (GnomeIconContainer *container);
gboolean gnome_icon_container_is_stretched (GnomeIconContainer *container);
void gnome_icon_container_show_stretch_handles (GnomeIconContainer *container);
void gnome_icon_container_unstretch (GnomeIconContainer *container);
#endif
......@@ -294,30 +294,34 @@ nautilus_directory_try_to_read_metafile (NautilusDirectory *directory, GnomeVFSU
GNOME_VFS_FILE_INFO_DEFAULT,
NULL);
if (result == GNOME_VFS_OK) {
/* Check for the case where the info doesn't give the file size. */
if ((metafile_info.flags & GNOME_VFS_FILE_INFO_FIELDS_SIZE) == 0)
result = GNOME_VFS_ERROR_GENERIC;
}
if (result == GNOME_VFS_OK) {
/* Check for a size that won't fit into a size_t. */
if(metafile_info.flags & GNOME_VFS_FILE_INFO_FIELDS_SIZE) {
size = metafile_info.size;
if (size != metafile_info.size)
result = GNOME_VFS_ERROR_TOOBIG;
} else
size = 0;
size = metafile_info.size;
if (size != metafile_info.size)