diff options
36 files changed, 5479 insertions, 5486 deletions
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index 6512a1c67..6c8c48b8e 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -61,6 +61,13 @@ libnautilus_private_la_LIBADD = \ libnautilus_private_la_SOURCES = \ nautilus-bookmark.c \ nautilus-bookmark.h \ + nautilus-canvas-container.c \ + nautilus-canvas-container.h \ + nautilus-canvas-dnd.c \ + nautilus-canvas-dnd.h \ + nautilus-canvas-item.c \ + nautilus-canvas-item.h \ + nautilus-canvas-private.h \ nautilus-clipboard-monitor.c \ nautilus-clipboard-monitor.h \ nautilus-clipboard.c \ @@ -118,13 +125,6 @@ libnautilus_private_la_SOURCES = \ nautilus-generated.h \ nautilus-global-preferences.c \ nautilus-global-preferences.h \ - nautilus-icon-canvas-item.c \ - nautilus-icon-canvas-item.h \ - nautilus-icon-container.c \ - nautilus-icon-container.h \ - nautilus-icon-dnd.c \ - nautilus-icon-dnd.h \ - nautilus-icon-private.h \ nautilus-icon-info.c \ nautilus-icon-info.h \ nautilus-icon-names.h \ diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-canvas-container.c index 606c13058..57918c3ba 100644 --- a/libnautilus-private/nautilus-icon-container.c +++ b/libnautilus-private/nautilus-canvas-container.c @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* nautilus-icon-container.c - Icon container widget. +/* nautilus-canvas-container.c - Canvas container widget. Copyright (C) 1999, 2000 Free Software Foundation Copyright (C) 2000, 2001 Eazel, Inc. @@ -27,10 +27,10 @@ #include <config.h> #include <math.h> -#include "nautilus-icon-container.h" +#include "nautilus-canvas-container.h" #include "nautilus-global-preferences.h" -#include "nautilus-icon-private.h" +#include "nautilus-canvas-private.h" #include "nautilus-lib-self-check-functions.h" #include "nautilus-selection-canvas-item.h" #include <atk/atkaction.h> @@ -47,7 +47,7 @@ #include <stdio.h> #include <string.h> -#define DEBUG_FLAG NAUTILUS_DEBUG_ICON_CONTAINER +#define DEBUG_FLAG NAUTILUS_DEBUG_CANVAS_CONTAINER #include "nautilus-debug.h" #define TAB_NAVIGATION_DISABLED @@ -121,8 +121,8 @@ #define SNAP_CEIL_HORIZONTAL(x) SNAP_HORIZONTAL (ceil, x) #define SNAP_CEIL_VERTICAL(y) SNAP_VERTICAL (ceil, y) -/* Copied from NautilusIconContainer */ -#define NAUTILUS_ICON_CONTAINER_SEARCH_DIALOG_TIMEOUT 5 +/* Copied from NautilusCanvasContainer */ +#define NAUTILUS_CANVAS_CONTAINER_SEARCH_DIALOG_TIMEOUT 5 /* Copied from NautilusFile */ #define UNDEFINED_TIME ((time_t) (-1)) @@ -136,84 +136,84 @@ enum { typedef struct { GList *selection; char *action_descriptions[LAST_ACTION]; -} NautilusIconContainerAccessiblePrivate; +} NautilusCanvasContainerAccessiblePrivate; static AtkObject * get_accessible (GtkWidget *widget); -static void preview_selected_items (NautilusIconContainer *container); -static void activate_selected_items (NautilusIconContainer *container); -static void activate_selected_items_alternate (NautilusIconContainer *container, - NautilusIcon *icon); +static void preview_selected_items (NautilusCanvasContainer *container); +static void activate_selected_items (NautilusCanvasContainer *container); +static void activate_selected_items_alternate (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon); 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 gboolean all_selected (NautilusIconContainer *container); -static gboolean has_selection (NautilusIconContainer *container); -static void icon_destroy (NautilusIconContainer *container, - NautilusIcon *icon); -static void end_renaming_mode (NautilusIconContainer *container, +static NautilusCanvasIcon *get_first_selected_icon (NautilusCanvasContainer *container); +static NautilusCanvasIcon *get_nth_selected_icon (NautilusCanvasContainer *container, + int index); +static gboolean has_multiple_selection (NautilusCanvasContainer *container); +static gboolean all_selected (NautilusCanvasContainer *container); +static gboolean has_selection (NautilusCanvasContainer *container); +static void icon_destroy (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon); +static void end_renaming_mode (NautilusCanvasContainer *container, gboolean commit); -static NautilusIcon *get_icon_being_renamed (NautilusIconContainer *container); -static void finish_adding_new_icons (NautilusIconContainer *container); -static inline void icon_get_bounding_box (NautilusIcon *icon, - int *x1_return, - int *y1_return, - int *x2_return, - int *y2_return, - NautilusIconCanvasItemBoundsUsage usage); -static gboolean is_renaming (NautilusIconContainer *container); -static gboolean is_renaming_pending (NautilusIconContainer *container); -static void process_pending_icon_to_rename (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, - gboolean large_text); +static NautilusCanvasIcon *get_icon_being_renamed (NautilusCanvasContainer *container); +static void finish_adding_new_icons (NautilusCanvasContainer *container); +static inline void icon_get_bounding_box (NautilusCanvasIcon *icon, + int *x1_return, + int *y1_return, + int *x2_return, + int *y2_return, + NautilusCanvasItemBoundsUsage usage); +static gboolean is_renaming (NautilusCanvasContainer *container); +static gboolean is_renaming_pending (NautilusCanvasContainer *container); +static void process_pending_icon_to_rename (NautilusCanvasContainer *container); +static void nautilus_canvas_container_stop_monitor_top_left (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + gconstpointer client); +static void nautilus_canvas_container_start_monitor_top_left (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + gconstpointer client, + gboolean large_text); static void handle_hadjustment_changed (GtkAdjustment *adjustment, - NautilusIconContainer *container); + NautilusCanvasContainer *container); static void handle_vadjustment_changed (GtkAdjustment *adjustment, - NautilusIconContainer *container); -static GList * nautilus_icon_container_get_selected_icons (NautilusIconContainer *container); -static void nautilus_icon_container_update_visible_icons (NautilusIconContainer *container); -static void reveal_icon (NautilusIconContainer *container, - NautilusIcon *icon); - -static void nautilus_icon_container_set_rtl_positions (NautilusIconContainer *container); -static double get_mirror_x_position (NautilusIconContainer *container, - NautilusIcon *icon, + NautilusCanvasContainer *container); +static GList * nautilus_canvas_container_get_selected_icons (NautilusCanvasContainer *container); +static void nautilus_canvas_container_update_visible_icons (NautilusCanvasContainer *container); +static void reveal_icon (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon); + +static void nautilus_canvas_container_set_rtl_positions (NautilusCanvasContainer *container); +static double get_mirror_x_position (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, double x); static void text_ellipsis_limit_changed_container_callback (gpointer callback_data); -static int compare_icons_horizontal (NautilusIconContainer *container, - NautilusIcon *icon_a, - NautilusIcon *icon_b); +static int compare_icons_horizontal (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon_a, + NautilusCanvasIcon *icon_b); -static int compare_icons_vertical (NautilusIconContainer *container, - NautilusIcon *icon_a, - NautilusIcon *icon_b); +static int compare_icons_vertical (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon_a, + NautilusCanvasIcon *icon_b); -static void store_layout_timestamps_now (NautilusIconContainer *container); +static void store_layout_timestamps_now (NautilusCanvasContainer *container); -static const char *nautilus_icon_container_accessible_action_names[] = { +static const char *nautilus_canvas_container_accessible_action_names[] = { "activate", "menu", NULL }; -static const char *nautilus_icon_container_accessible_action_descriptions[] = { +static const char *nautilus_canvas_container_accessible_action_descriptions[] = { "Activate selected items", "Popup context menu", NULL }; -G_DEFINE_TYPE (NautilusIconContainer, nautilus_icon_container, EEL_TYPE_CANVAS); +G_DEFINE_TYPE (NautilusCanvasContainer, nautilus_canvas_container, EEL_TYPE_CANVAS); -/* The NautilusIconContainer signals. */ +/* The NautilusCanvasContainer signals. */ enum { ACTIVATE, ACTIVATE_ALTERNATE, @@ -262,15 +262,15 @@ static guint signals[LAST_SIGNAL]; /* Functions dealing with NautilusIcons. */ static void -icon_free (NautilusIcon *icon) +icon_free (NautilusCanvasIcon *icon) { - /* Destroy this canvas item; the parent will unref it. */ + /* Destroy this icon item; the parent will unref it. */ eel_canvas_item_destroy (EEL_CANVAS_ITEM (icon->item)); g_free (icon); } static gboolean -icon_is_positioned (const NautilusIcon *icon) +icon_is_positioned (const NautilusCanvasIcon *icon) { return icon->x != ICON_UNPOSITIONED_VALUE && icon->y != ICON_UNPOSITIONED_VALUE; } @@ -278,10 +278,10 @@ icon_is_positioned (const NautilusIcon *icon) /* x, y are the top-left coordinates of the icon. */ static void -icon_set_position (NautilusIcon *icon, - double x, double y) +icon_set_position (NautilusCanvasIcon *icon, + double x, double y) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; double pixels_per_unit; int container_left, container_top, container_right, container_bottom; int x1, x2, y1, y2; @@ -295,25 +295,25 @@ icon_set_position (NautilusIcon *icon, return; } - container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (icon->item)->canvas); + container = NAUTILUS_CANVAS_CONTAINER (EEL_CANVAS_ITEM (icon->item)->canvas); if (icon == get_icon_being_renamed (container)) { end_renaming_mode (container, TRUE); } - if (nautilus_icon_container_get_is_fixed_size (container)) { + if (nautilus_canvas_container_get_is_fixed_size (container)) { /* FIXME: This should be: - container_x = GTK_WIDGET (container)->allocation.x; - container_y = GTK_WIDGET (container)->allocation.y; - container_width = GTK_WIDGET (container)->allocation.width; - container_height = GTK_WIDGET (container)->allocation.height; + container_x = GTK_WIDGET (container)->allocation.x; + container_y = GTK_WIDGET (container)->allocation.y; + container_width = GTK_WIDGET (container)->allocation.width; + container_height = GTK_WIDGET (container)->allocation.height; - But for some reason the widget allocation is sometimes not done - at startup, and the allocation is then only 45x60. which is - really bad. + But for some reason the widget allocation is sometimes not done + at startup, and the allocation is then only 45x60. which is + really bad. - For now, we have a cheesy workaround: + For now, we have a cheesy workaround: */ container_x = 0; container_y = 0; @@ -335,7 +335,7 @@ icon_set_position (NautilusIcon *icon, item_width = x2 - x1; item_height = y2 - y1; - icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + icon_bounds = nautilus_canvas_item_get_icon_rectangle (icon->item); /* determine icon rectangle relative to item rectangle */ height_above = icon_bounds.y0 - y1; @@ -358,21 +358,21 @@ icon_set_position (NautilusIcon *icon, } eel_canvas_item_move (EEL_CANVAS_ITEM (icon->item), - x - icon->x, - y - icon->y); + x - icon->x, + y - icon->y); icon->x = x; icon->y = y; } static void -icon_get_size (NautilusIconContainer *container, - NautilusIcon *icon, - guint *size) +icon_get_size (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, + guint *size) { if (size != NULL) { *size = MAX (nautilus_get_icon_size_for_zoom_level (container->details->zoom_level) - * icon->scale, NAUTILUS_ICON_SIZE_SMALLEST); + * icon->scale, NAUTILUS_ICON_SIZE_SMALLEST); } } @@ -382,11 +382,11 @@ icon_get_size (NautilusIconContainer *container, * separate from X and we will change this around. */ static void -icon_set_size (NautilusIconContainer *container, - NautilusIcon *icon, - guint icon_size, - gboolean snap, - gboolean update_position) +icon_set_size (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, + guint icon_size, + gboolean snap, + gboolean update_position) { guint old_size; double scale; @@ -399,42 +399,42 @@ icon_set_size (NautilusIconContainer *container, scale = (double) icon_size / nautilus_get_icon_size_for_zoom_level (container->details->zoom_level); - nautilus_icon_container_move_icon (container, icon, - icon->x, icon->y, - scale, FALSE, - snap, update_position); + nautilus_canvas_container_move_icon (container, icon, + icon->x, icon->y, + scale, FALSE, + snap, update_position); } static void -icon_raise (NautilusIcon *icon) +icon_raise (NautilusCanvasIcon *icon) { EelCanvasItem *item, *band; item = EEL_CANVAS_ITEM (icon->item); - band = NAUTILUS_ICON_CONTAINER (item->canvas)->details->rubberband_info.selection_rectangle; + band = NAUTILUS_CANVAS_CONTAINER (item->canvas)->details->rubberband_info.selection_rectangle; eel_canvas_item_send_behind (item, band); } static void -emit_stretch_started (NautilusIconContainer *container, NautilusIcon *icon) +emit_stretch_started (NautilusCanvasContainer *container, NautilusCanvasIcon *icon) { g_signal_emit (container, - signals[ICON_STRETCH_STARTED], 0, - icon->data); + signals[ICON_STRETCH_STARTED], 0, + icon->data); } static void -emit_stretch_ended (NautilusIconContainer *container, NautilusIcon *icon) +emit_stretch_ended (NautilusCanvasContainer *container, NautilusCanvasIcon *icon) { g_signal_emit (container, - signals[ICON_STRETCH_ENDED], 0, - icon->data); + signals[ICON_STRETCH_ENDED], 0, + icon->data); } static void -icon_toggle_selected (NautilusIconContainer *container, - NautilusIcon *icon) +icon_toggle_selected (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { end_renaming_mode (container, TRUE); @@ -448,14 +448,14 @@ icon_toggle_selected (NautilusIconContainer *container, */ if (icon == container->details->stretch_icon) { container->details->stretch_icon = NULL; - nautilus_icon_canvas_item_set_show_stretch_handles (icon->item, FALSE); + nautilus_canvas_item_set_show_stretch_handles (icon->item, FALSE); /* snap the icon if necessary */ if (container->details->keep_aligned) { - nautilus_icon_container_move_icon (container, - icon, - icon->x, icon->y, - icon->scale, - FALSE, TRUE, TRUE); + nautilus_canvas_container_move_icon (container, + icon, + icon->x, icon->y, + icon->scale, + FALSE, TRUE, TRUE); } emit_stretch_ended (container, icon); @@ -469,9 +469,9 @@ icon_toggle_selected (NautilusIconContainer *container, /* Select an icon. Return TRUE if selection has changed. */ static gboolean -icon_set_selected (NautilusIconContainer *container, - NautilusIcon *icon, - gboolean select) +icon_set_selected (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, + gboolean select) { g_assert (select == FALSE || select == TRUE); g_assert (icon->is_selected == FALSE || icon->is_selected == TRUE); @@ -486,10 +486,10 @@ icon_set_selected (NautilusIconContainer *container, } static inline void -icon_get_bounding_box (NautilusIcon *icon, +icon_get_bounding_box (NautilusCanvasIcon *icon, int *x1_return, int *y1_return, int *x2_return, int *y2_return, - NautilusIconCanvasItemBoundsUsage usage) + NautilusCanvasItemBoundsUsage usage) { double x1, y1, x2, y2; @@ -497,11 +497,11 @@ icon_get_bounding_box (NautilusIcon *icon, eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (icon->item), &x1, &y1, &x2, &y2); } else if (usage == BOUNDS_USAGE_FOR_LAYOUT) { - nautilus_icon_canvas_item_get_bounds_for_layout (icon->item, - &x1, &y1, &x2, &y2); + nautilus_canvas_item_get_bounds_for_layout (icon->item, + &x1, &y1, &x2, &y2); } else if (usage == BOUNDS_USAGE_FOR_ENTIRE_ITEM) { - nautilus_icon_canvas_item_get_bounds_for_entire_item (icon->item, - &x1, &y1, &x2, &y2); + nautilus_canvas_item_get_bounds_for_entire_item (icon->item, + &x1, &y1, &x2, &y2); } else { g_assert_not_reached (); } @@ -523,11 +523,11 @@ icon_get_bounding_box (NautilusIcon *icon, } } -/* Utility functions for NautilusIconContainer. */ +/* Utility functions for NautilusCanvasContainer. */ gboolean -nautilus_icon_container_scroll (NautilusIconContainer *container, - int delta_x, int delta_y) +nautilus_canvas_container_scroll (NautilusCanvasContainer *container, + int delta_x, int delta_y) { GtkAdjustment *hadj, *vadj; int old_h_value, old_v_value; @@ -551,26 +551,26 @@ nautilus_icon_container_scroll (NautilusIconContainer *container, } static void -pending_icon_to_reveal_destroy_callback (NautilusIconCanvasItem *item, - NautilusIconContainer *container) +pending_icon_to_reveal_destroy_callback (NautilusCanvasItem *item, + NautilusCanvasContainer *container) { - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); g_assert (container->details->pending_icon_to_reveal != NULL); g_assert (container->details->pending_icon_to_reveal->item == item); container->details->pending_icon_to_reveal = NULL; } -static NautilusIcon* -get_pending_icon_to_reveal (NautilusIconContainer *container) +static NautilusCanvasIcon * +get_pending_icon_to_reveal (NautilusCanvasContainer *container) { return container->details->pending_icon_to_reveal; } static void -set_pending_icon_to_reveal (NautilusIconContainer *container, NautilusIcon *icon) +set_pending_icon_to_reveal (NautilusCanvasContainer *container, NautilusCanvasIcon *icon) { - NautilusIcon *old_icon; + NautilusCanvasIcon *old_icon; old_icon = container->details->pending_icon_to_reveal; @@ -633,13 +633,13 @@ item_get_canvas_bounds (EelCanvasItem *item, } static void -icon_get_row_and_column_bounds (NautilusIconContainer *container, - NautilusIcon *icon, +icon_get_row_and_column_bounds (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, EelIRect *bounds, gboolean safety_pad) { GList *p; - NautilusIcon *one_icon; + NautilusCanvasIcon *one_icon; EelIRect one_bounds; item_get_canvas_bounds (EEL_CANVAS_ITEM (icon->item), bounds, safety_pad); @@ -668,8 +668,8 @@ icon_get_row_and_column_bounds (NautilusIconContainer *container, } static void -reveal_icon (NautilusIconContainer *container, - NautilusIcon *icon) +reveal_icon (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { GtkAllocation allocation; GtkAdjustment *hadj, *vadj; @@ -687,7 +687,7 @@ reveal_icon (NautilusIconContainer *container, hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)); vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)); - if (nautilus_icon_container_is_auto_layout (container)) { + if (nautilus_canvas_container_is_auto_layout (container)) { /* ensure that we reveal the entire row/column */ icon_get_row_and_column_bounds (container, icon, &bounds, TRUE); } else { @@ -709,9 +709,9 @@ reveal_icon (NautilusIconContainer *container, } static void -process_pending_icon_to_reveal (NautilusIconContainer *container) +process_pending_icon_to_reveal (NautilusCanvasContainer *container) { - NautilusIcon *pending_icon_to_reveal; + NautilusCanvasIcon *pending_icon_to_reveal; pending_icon_to_reveal = get_pending_icon_to_reveal (container); @@ -723,10 +723,10 @@ process_pending_icon_to_reveal (NautilusIconContainer *container) static gboolean keyboard_icon_reveal_timeout_callback (gpointer data) { - NautilusIconContainer *container; - NautilusIcon *icon; + NautilusCanvasContainer *container; + NautilusCanvasIcon *icon; - container = NAUTILUS_ICON_CONTAINER (data); + container = NAUTILUS_CANVAS_CONTAINER (data); icon = container->details->keyboard_icon_to_reveal; g_assert (icon != NULL); @@ -748,9 +748,9 @@ keyboard_icon_reveal_timeout_callback (gpointer data) } static void -unschedule_keyboard_icon_reveal (NautilusIconContainer *container) +unschedule_keyboard_icon_reveal (NautilusCanvasContainer *container) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; details = container->details; @@ -760,10 +760,10 @@ unschedule_keyboard_icon_reveal (NautilusIconContainer *container) } static void -schedule_keyboard_icon_reveal (NautilusIconContainer *container, - NautilusIcon *icon) +schedule_keyboard_icon_reveal (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; details = container->details; @@ -777,19 +777,19 @@ schedule_keyboard_icon_reveal (NautilusIconContainer *container, } static void -clear_keyboard_focus (NautilusIconContainer *container) +clear_keyboard_focus (NautilusCanvasContainer *container) { if (container->details->keyboard_focus != NULL) { eel_canvas_item_set (EEL_CANVAS_ITEM (container->details->keyboard_focus->item), - "highlighted_as_keyboard_focus", 0, - NULL); + "highlighted_as_keyboard_focus", 0, + NULL); } container->details->keyboard_focus = NULL; } static void inline -emit_atk_focus_tracker_notify (NautilusIcon *icon) +emit_atk_focus_tracker_notify (NautilusCanvasIcon *icon) { AtkObject *atk_object = atk_gobject_accessible_for_object (G_OBJECT (icon->item)); atk_focus_tracker_notify (atk_object); @@ -797,8 +797,8 @@ emit_atk_focus_tracker_notify (NautilusIcon *icon) /* Set @icon as the icon currently selected for keyboard operations. */ static void -set_keyboard_focus (NautilusIconContainer *container, - NautilusIcon *icon) +set_keyboard_focus (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { g_assert (icon != NULL); @@ -811,34 +811,34 @@ set_keyboard_focus (NautilusIconContainer *container, container->details->keyboard_focus = icon; eel_canvas_item_set (EEL_CANVAS_ITEM (container->details->keyboard_focus->item), - "highlighted_as_keyboard_focus", 1, - NULL); + "highlighted_as_keyboard_focus", 1, + NULL); emit_atk_focus_tracker_notify (icon); } static void -set_keyboard_rubberband_start (NautilusIconContainer *container, - NautilusIcon *icon) +set_keyboard_rubberband_start (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { container->details->keyboard_rubberband_start = icon; } static void -clear_keyboard_rubberband_start (NautilusIconContainer *container) +clear_keyboard_rubberband_start (NautilusCanvasContainer *container) { container->details->keyboard_rubberband_start = NULL; } /* carbon-copy of eel_canvas_group_bounds(), but - * for NautilusIconContainerItems it returns the + * for NautilusCanvasContainerItems it returns the * bounds for the “entire item”. */ static void get_icon_bounds_for_canvas_bounds (EelCanvasGroup *group, - double *x1, double *y1, - double *x2, double *y2, - NautilusIconCanvasItemBoundsUsage usage) + double *x1, double *y1, + double *x2, double *y2, + NautilusCanvasItemBoundsUsage usage) { EelCanvasItem *child; GList *list; @@ -855,21 +855,21 @@ get_icon_bounds_for_canvas_bounds (EelCanvasGroup *group, for (list = group->item_list; list; list = list->next) { child = list->data; - if (!NAUTILUS_IS_ICON_CANVAS_ITEM (child)) { + if (!NAUTILUS_IS_CANVAS_ITEM (child)) { continue; } if (child->flags & EEL_CANVAS_ITEM_VISIBLE) { set = TRUE; - if (!NAUTILUS_IS_ICON_CANVAS_ITEM (child) || + if (!NAUTILUS_IS_CANVAS_ITEM (child) || usage == BOUNDS_USAGE_FOR_DISPLAY) { eel_canvas_item_get_bounds (child, &minx, &miny, &maxx, &maxy); } else if (usage == BOUNDS_USAGE_FOR_LAYOUT) { - nautilus_icon_canvas_item_get_bounds_for_layout (NAUTILUS_ICON_CANVAS_ITEM (child), - &minx, &miny, &maxx, &maxy); + nautilus_canvas_item_get_bounds_for_layout (NAUTILUS_CANVAS_ITEM (child), + &minx, &miny, &maxx, &maxy); } else if (usage == BOUNDS_USAGE_FOR_ENTIRE_ITEM) { - nautilus_icon_canvas_item_get_bounds_for_entire_item (NAUTILUS_ICON_CANVAS_ITEM (child), - &minx, &miny, &maxx, &maxy); + nautilus_canvas_item_get_bounds_for_entire_item (NAUTILUS_CANVAS_ITEM (child), + &minx, &miny, &maxx, &maxy); } else { g_assert_not_reached (); } @@ -891,22 +891,22 @@ get_icon_bounds_for_canvas_bounds (EelCanvasGroup *group, for (; list; list = list->next) { child = list->data; - if (!NAUTILUS_IS_ICON_CANVAS_ITEM (child)) { + if (!NAUTILUS_IS_CANVAS_ITEM (child)) { continue; } if (!(child->flags & EEL_CANVAS_ITEM_VISIBLE)) continue; - if (!NAUTILUS_IS_ICON_CANVAS_ITEM (child) || + if (!NAUTILUS_IS_CANVAS_ITEM (child) || usage == BOUNDS_USAGE_FOR_DISPLAY) { eel_canvas_item_get_bounds (child, &tx1, &ty1, &tx2, &ty2); } else if (usage == BOUNDS_USAGE_FOR_LAYOUT) { - nautilus_icon_canvas_item_get_bounds_for_layout (NAUTILUS_ICON_CANVAS_ITEM (child), - &tx1, &ty1, &tx2, &ty2); + nautilus_canvas_item_get_bounds_for_layout (NAUTILUS_CANVAS_ITEM (child), + &tx1, &ty1, &tx2, &ty2); } else if (usage == BOUNDS_USAGE_FOR_ENTIRE_ITEM) { - nautilus_icon_canvas_item_get_bounds_for_entire_item (NAUTILUS_ICON_CANVAS_ITEM (child), - &tx1, &ty1, &tx2, &ty2); + nautilus_canvas_item_get_bounds_for_entire_item (NAUTILUS_CANVAS_ITEM (child), + &tx1, &ty1, &tx2, &ty2); } else { g_assert_not_reached (); } @@ -951,22 +951,22 @@ get_icon_bounds_for_canvas_bounds (EelCanvasGroup *group, } static void -get_all_icon_bounds (NautilusIconContainer *container, +get_all_icon_bounds (NautilusCanvasContainer *container, double *x1, double *y1, double *x2, double *y2, - NautilusIconCanvasItemBoundsUsage usage) + NautilusCanvasItemBoundsUsage usage) { /* FIXME bugzilla.gnome.org 42477: Do we have to do something about the rubberband * here? Any other non-icon items? */ get_icon_bounds_for_canvas_bounds (EEL_CANVAS_GROUP (EEL_CANVAS (container)->root), - x1, y1, x2, y2, usage); + x1, y1, x2, y2, usage); } /* Don't preserve visible white space the next time the scroll region * is recomputed when the container is not empty. */ void -nautilus_icon_container_reset_scroll_region (NautilusIconContainer *container) +nautilus_canvas_container_reset_scroll_region (NautilusCanvasContainer *container) { container->details->reset_scroll_region_trigger = TRUE; } @@ -1001,7 +1001,7 @@ canvas_set_scroll_region_include_visible_area (EelCanvas *canvas, } void -nautilus_icon_container_update_scroll_region (NautilusIconContainer *container) +nautilus_canvas_container_update_scroll_region (NautilusCanvasContainer *container) { double x1, y1, x2, y2; double pixels_per_unit; @@ -1012,7 +1012,7 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container) pixels_per_unit = EEL_CANVAS (container)->pixels_per_unit; - if (nautilus_icon_container_get_is_fixed_size (container)) { + if (nautilus_canvas_container_get_is_fixed_size (container)) { /* Set the scroll region to the size of the container allocation */ gtk_widget_get_allocation (GTK_WIDGET (container), &allocation); eel_canvas_set_scroll_region @@ -1020,26 +1020,26 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container) (double) - container->details->left_margin / pixels_per_unit, (double) - container->details->top_margin / pixels_per_unit, ((double) (allocation.width - 1) - - container->details->left_margin - - container->details->right_margin) + - container->details->left_margin + - container->details->right_margin) / pixels_per_unit, ((double) (allocation.height - 1) - - container->details->top_margin - - container->details->bottom_margin) + - container->details->top_margin + - container->details->bottom_margin) / pixels_per_unit); return; } reset_scroll_region = container->details->reset_scroll_region_trigger - || nautilus_icon_container_is_empty (container) - || nautilus_icon_container_is_auto_layout (container); + || nautilus_canvas_container_is_empty (container) + || nautilus_canvas_container_is_auto_layout (container); /* The trigger is only cleared when container is non-empty, so * callers can reliably reset the scroll region when an item * is added even if extraneous relayouts are called when the * window is still empty. */ - if (!nautilus_icon_container_is_empty (container)) { + if (!nautilus_canvas_container_is_empty (container)) { container->details->reset_scroll_region_trigger = FALSE; } @@ -1051,8 +1051,8 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container) * Vertical layout is used by the compact view so the end * depends on the RTL setting. */ - if (nautilus_icon_container_is_layout_vertical (container)) { - if (nautilus_icon_container_is_layout_rtl (container)) { + if (nautilus_canvas_container_is_layout_vertical (container)) { + if (nautilus_canvas_container_is_layout_rtl (container)) { x1 -= ICON_PAD_LEFT + CONTAINER_PAD_LEFT; } else { x2 += ICON_PAD_RIGHT + CONTAINER_PAD_RIGHT; @@ -1064,7 +1064,7 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container) /* Auto-layout assumes a 0, 0 scroll origin and at least allocation->width. * Then we lay out to the right or to the left, so * x can be < 0 and > allocation */ - if (nautilus_icon_container_is_auto_layout (container)) { + if (nautilus_canvas_container_is_auto_layout (container)) { gtk_widget_get_allocation (GTK_WIDGET (container), &allocation); x1 = MIN (x1, 0); x2 = MAX (x2, allocation.width / pixels_per_unit); @@ -1072,7 +1072,7 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container) } else { /* Otherwise we add the padding that is at the start of the layout */ - if (nautilus_icon_container_is_layout_rtl (container)) { + if (nautilus_canvas_container_is_layout_rtl (container)) { x2 += ICON_PAD_RIGHT + CONTAINER_PAD_RIGHT; } else { x1 -= ICON_PAD_LEFT + CONTAINER_PAD_LEFT; @@ -1111,39 +1111,39 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container) } static int -compare_icons (gconstpointer a, gconstpointer b, gpointer icon_container) +compare_icons (gconstpointer a, gconstpointer b, gpointer canvas_container) { - NautilusIconContainerClass *klass; - const NautilusIcon *icon_a, *icon_b; + NautilusCanvasContainerClass *klass; + const NautilusCanvasIcon *icon_a, *icon_b; icon_a = a; icon_b = b; - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (icon_container); + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (canvas_container); - return klass->compare_icons (icon_container, icon_a->data, icon_b->data); + return klass->compare_icons (canvas_container, icon_a->data, icon_b->data); } static void -sort_icons (NautilusIconContainer *container, - GList **icons) +sort_icons (NautilusCanvasContainer *container, + GList **icons) { - NautilusIconContainerClass *klass; + NautilusCanvasContainerClass *klass; - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container); + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (container); g_assert (klass->compare_icons != NULL); *icons = g_list_sort_with_data (*icons, compare_icons, container); } static void -resort (NautilusIconContainer *container) +resort (NautilusCanvasContainer *container) { sort_icons (container, &container->details->icons); } #if 0 static double -get_grid_width (NautilusIconContainer *container) +get_grid_width (NautilusCanvasContainer *container) { return STANDARD_ICON_GRID_WIDTH; } @@ -1156,7 +1156,7 @@ typedef struct { } IconPositions; static void -lay_down_one_line (NautilusIconContainer *container, +lay_down_one_line (NautilusCanvasContainer *container, GList *line_start, GList *line_end, double y, @@ -1165,13 +1165,13 @@ lay_down_one_line (NautilusIconContainer *container, gboolean whole_text) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; double x, y_offset; IconPositions *position; int i; gboolean is_rtl; - is_rtl = nautilus_icon_container_is_layout_rtl (container); + is_rtl = nautilus_canvas_container_is_layout_rtl (container); /* Lay out the icons along the baseline. */ x = ICON_PAD_LEFT; @@ -1186,7 +1186,7 @@ lay_down_one_line (NautilusIconContainer *container, (icon, is_rtl ? get_mirror_x_position (container, icon, x + position->x_offset) : x + position->x_offset, y + y_offset); - nautilus_icon_canvas_item_set_entire_text (icon->item, whole_text); + nautilus_canvas_item_set_entire_text (icon->item, whole_text); icon->saved_ltr_x = is_rtl ? get_mirror_x_position (container, icon, icon->x) : icon->x; @@ -1195,7 +1195,7 @@ lay_down_one_line (NautilusIconContainer *container, } static void -lay_down_one_column (NautilusIconContainer *container, +lay_down_one_column (NautilusCanvasContainer *container, GList *line_start, GList *line_end, double x, @@ -1204,13 +1204,13 @@ lay_down_one_column (NautilusIconContainer *container, GArray *positions) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; double y; IconPositions *position; int i; gboolean is_rtl; - is_rtl = nautilus_icon_container_is_layout_rtl (container); + is_rtl = nautilus_canvas_container_is_layout_rtl (container); /* Lay out the icons along the baseline. */ y = y_start; @@ -1232,12 +1232,12 @@ lay_down_one_column (NautilusIconContainer *container, } static void -lay_down_icons_horizontal (NautilusIconContainer *container, - GList *icons, - double start_y) +lay_down_icons_horizontal (NautilusCanvasContainer *container, + GList *icons, + double start_y) { GList *p, *line_start; - NautilusIcon *icon; + NautilusCanvasIcon *icon; double canvas_width, y; GArray *positions; IconPositions *position; @@ -1251,7 +1251,7 @@ lay_down_icons_horizontal (NautilusIconContainer *container, int i; GtkAllocation allocation; - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); if (icons == NULL) { return; @@ -1276,11 +1276,11 @@ lay_down_icons_horizontal (NautilusIconContainer *container, icon = p->data; /* Assume it's only one level hierarchy to avoid costly affine calculations */ - nautilus_icon_canvas_item_get_bounds_for_layout (icon->item, - &bounds.x0, &bounds.y0, - &bounds.x1, &bounds.y1); + nautilus_canvas_item_get_bounds_for_layout (icon->item, + &bounds.x0, &bounds.y0, + &bounds.x1, &bounds.y1); - icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + icon_bounds = nautilus_canvas_item_get_icon_rectangle (icon->item); icon_width = ceil ((bounds.x1 - bounds.x0)/grid_width) * grid_width; /* Calculate size above/below baseline */ @@ -1344,7 +1344,7 @@ get_max_icon_dimensions (GList *icon_start, double *max_text_height, double *max_bounds_height) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; EelDRect icon_bounds; EelDRect text_bounds; GList *p; @@ -1358,28 +1358,28 @@ get_max_icon_dimensions (GList *icon_start, for (p = icon_start; p != icon_end; p = p->next) { icon = p->data; - icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + icon_bounds = nautilus_canvas_item_get_icon_rectangle (icon->item); *max_icon_width = MAX (*max_icon_width, ceil (icon_bounds.x1 - icon_bounds.x0)); *max_icon_height = MAX (*max_icon_height, ceil (icon_bounds.y1 - icon_bounds.y0)); - text_bounds = nautilus_icon_canvas_item_get_text_rectangle (icon->item, TRUE); + text_bounds = nautilus_canvas_item_get_text_rectangle (icon->item, TRUE); *max_text_width = MAX (*max_text_width, ceil (text_bounds.x1 - text_bounds.x0)); *max_text_height = MAX (*max_text_height, ceil (text_bounds.y1 - text_bounds.y0)); - nautilus_icon_canvas_item_get_bounds_for_layout (icon->item, - NULL, &y1, - NULL, &y2); + nautilus_canvas_item_get_bounds_for_layout (icon->item, + NULL, &y1, + NULL, &y2); *max_bounds_height = MAX (*max_bounds_height, y2 - y1); } } static void -lay_down_icons_vertical (NautilusIconContainer *container, - GList *icons, - double start_y) +lay_down_icons_vertical (NautilusCanvasContainer *container, + GList *icons, + double start_y) { GList *p, *line_start; - NautilusIcon *icon; + NautilusCanvasIcon *icon; double x, canvas_height; GArray *positions; IconPositions *position; @@ -1402,7 +1402,7 @@ lay_down_icons_vertical (NautilusIconContainer *container, int height; int i; - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); if (icons == NULL) { return; @@ -1419,9 +1419,9 @@ lay_down_icons_vertical (NautilusIconContainer *container, max_bounds_height = 0.0; get_max_icon_dimensions (icons, NULL, - &max_icon_width, &max_icon_height, - &max_text_width, &max_text_height, - &max_bounds_height); + &max_icon_width, &max_icon_height, + &max_text_width, &max_text_height, + &max_bounds_height); max_width = max_icon_width + max_text_width; max_height = MAX (max_icon_height, max_text_height); @@ -1467,8 +1467,8 @@ lay_down_icons_vertical (NautilusIconContainer *container, max_width_in_column = 0; } - icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); - text_bounds = nautilus_icon_canvas_item_get_text_rectangle (icon->item, TRUE); + icon_bounds = nautilus_canvas_item_get_icon_rectangle (icon->item); + text_bounds = nautilus_canvas_item_get_text_rectangle (icon->item, TRUE); max_width_in_column = MAX (max_width_in_column, ceil (icon_bounds.x1 - icon_bounds.x0) + @@ -1501,8 +1501,8 @@ lay_down_icons_vertical (NautilusIconContainer *container, } static void -snap_position (NautilusIconContainer *container, - NautilusIcon *icon, +snap_position (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, int *x, int *y) { int center_x; @@ -1511,19 +1511,19 @@ snap_position (NautilusIconContainer *container, int icon_height; int total_width; int total_height; - EelDRect icon_position; + EelDRect canvas_position; GtkAllocation allocation; - icon_position = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); - icon_width = icon_position.x1 - icon_position.x0; - icon_height = icon_position.y1 - icon_position.y0; + canvas_position = nautilus_canvas_item_get_icon_rectangle (icon->item); + icon_width = canvas_position.x1 - canvas_position.x0; + icon_height = canvas_position.y1 - canvas_position.y0; gtk_widget_get_allocation (GTK_WIDGET (container), &allocation); total_width = CANVAS_WIDTH (container, allocation); total_height = CANVAS_HEIGHT (container, allocation); - if (nautilus_icon_container_is_layout_rtl (container)) - *x = get_mirror_x_position (container, icon, *x); + if (nautilus_canvas_container_is_layout_rtl (container)) + *x = get_mirror_x_position (container, icon, *x); if (*x + icon_width / 2 < DESKTOP_PAD_HORIZONTAL + SNAP_SIZE_X) { *x = DESKTOP_PAD_HORIZONTAL + SNAP_SIZE_X - icon_width / 2; @@ -1543,8 +1543,8 @@ snap_position (NautilusIconContainer *container, center_x = *x + icon_width / 2; *x = SNAP_NEAREST_HORIZONTAL (center_x) - (icon_width / 2); - if (nautilus_icon_container_is_layout_rtl (container)) { - *x = get_mirror_x_position (container, icon, *x); + if (nautilus_canvas_container_is_layout_rtl (container)) { + *x = get_mirror_x_position (container, icon, *x); } @@ -1557,19 +1557,19 @@ snap_position (NautilusIconContainer *container, static int compare_icons_by_position (gconstpointer a, gconstpointer b) { - NautilusIcon *icon_a, *icon_b; + NautilusCanvasIcon *icon_a, *icon_b; int x1, y1, x2, y2; int center_a; int center_b; - icon_a = (NautilusIcon*)a; - icon_b = (NautilusIcon*)b; + icon_a = (NautilusCanvasIcon *)a; + icon_b = (NautilusCanvasIcon *)b; icon_get_bounding_box (icon_a, &x1, &y1, &x2, &y2, - BOUNDS_USAGE_FOR_DISPLAY); + BOUNDS_USAGE_FOR_DISPLAY); center_a = x1 + (x2 - x1) / 2; icon_get_bounding_box (icon_b, &x1, &y1, &x2, &y2, - BOUNDS_USAGE_FOR_DISPLAY); + BOUNDS_USAGE_FOR_DISPLAY); center_b = x1 + (x2 - x1) / 2; return center_a == center_b ? @@ -1578,7 +1578,7 @@ compare_icons_by_position (gconstpointer a, gconstpointer b) } static PlacementGrid * -placement_grid_new (NautilusIconContainer *container, gboolean tight) +placement_grid_new (NautilusCanvasContainer *container, gboolean tight) { PlacementGrid *grid; int width, height; @@ -1688,25 +1688,25 @@ canvas_position_to_grid_position (PlacementGrid *grid, } static void -placement_grid_mark_icon (PlacementGrid *grid, NautilusIcon *icon) +placement_grid_mark_icon (PlacementGrid *grid, NautilusCanvasIcon *icon) { - EelIRect icon_pos; + EelIRect canvas_pos; EelIRect grid_pos; icon_get_bounding_box (icon, - &icon_pos.x0, &icon_pos.y0, - &icon_pos.x1, &icon_pos.y1, - BOUNDS_USAGE_FOR_LAYOUT); + &canvas_pos.x0, &canvas_pos.y0, + &canvas_pos.x1, &canvas_pos.y1, + BOUNDS_USAGE_FOR_LAYOUT); canvas_position_to_grid_position (grid, - icon_pos, + canvas_pos, &grid_pos); placement_grid_mark (grid, grid_pos); } static void -find_empty_location (NautilusIconContainer *container, +find_empty_location (NautilusCanvasContainer *container, PlacementGrid *grid, - NautilusIcon *icon, + NautilusCanvasIcon *icon, int start_x, int start_y, int *x, @@ -1727,19 +1727,19 @@ find_empty_location (NautilusIconContainer *container, canvas_height = CANVAS_HEIGHT(container, allocation); icon_get_bounding_box (icon, - &icon_position.x0, &icon_position.y0, - &icon_position.x1, &icon_position.y1, - BOUNDS_USAGE_FOR_LAYOUT); + &icon_position.x0, &icon_position.y0, + &icon_position.x1, &icon_position.y1, + BOUNDS_USAGE_FOR_LAYOUT); icon_width = icon_position.x1 - icon_position.x0; icon_height = icon_position.y1 - icon_position.y0; icon_get_bounding_box (icon, - NULL, &icon_position.y0, - NULL, &icon_position.y1, - BOUNDS_USAGE_FOR_ENTIRE_ITEM); + NULL, &icon_position.y0, + NULL, &icon_position.y1, + BOUNDS_USAGE_FOR_ENTIRE_ITEM); height_for_bound_check = icon_position.y1 - icon_position.y0; - pixbuf_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + pixbuf_rect = nautilus_canvas_item_get_icon_rectangle (icon->item); /* Start the icon on a grid location */ snap_position (container, icon, &start_x, &start_y); @@ -1787,7 +1787,7 @@ find_empty_location (NautilusIconContainer *container, } static void -align_icons (NautilusIconContainer *container) +align_icons (NautilusCanvasContainer *container) { GList *unplaced_icons; GList *l; @@ -1796,9 +1796,9 @@ align_icons (NautilusIconContainer *container) unplaced_icons = g_list_copy (container->details->icons); unplaced_icons = g_list_sort (unplaced_icons, - compare_icons_by_position); + compare_icons_by_position); - if (nautilus_icon_container_is_layout_rtl (container)) { + if (nautilus_canvas_container_is_layout_rtl (container)) { unplaced_icons = g_list_reverse (unplaced_icons); } @@ -1809,7 +1809,7 @@ align_icons (NautilusIconContainer *container) } for (l = unplaced_icons; l != NULL; l = l->next) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; int x, y; icon = l->data; @@ -1827,28 +1827,28 @@ align_icons (NautilusIconContainer *container) placement_grid_free (grid); - if (nautilus_icon_container_is_layout_rtl (container)) { - nautilus_icon_container_set_rtl_positions (container); + if (nautilus_canvas_container_is_layout_rtl (container)) { + nautilus_canvas_container_set_rtl_positions (container); } } static double -get_mirror_x_position (NautilusIconContainer *container, NautilusIcon *icon, double x) +get_mirror_x_position (NautilusCanvasContainer *container, NautilusCanvasIcon *icon, double x) { EelDRect icon_bounds; GtkAllocation allocation; gtk_widget_get_allocation (GTK_WIDGET (container), &allocation); - icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + icon_bounds = nautilus_canvas_item_get_icon_rectangle (icon->item); return CANVAS_WIDTH(container, allocation) - x - (icon_bounds.x1 - icon_bounds.x0); } static void -nautilus_icon_container_set_rtl_positions (NautilusIconContainer *container) +nautilus_canvas_container_set_rtl_positions (NautilusCanvasContainer *container) { GList *l; - NautilusIcon *icon; + NautilusCanvasIcon *icon; double x; if (!container->details->icons) { @@ -1863,11 +1863,11 @@ nautilus_icon_container_set_rtl_positions (NautilusIconContainer *container) } static void -lay_down_icons_vertical_desktop (NautilusIconContainer *container, GList *icons) +lay_down_icons_vertical_desktop (NautilusCanvasContainer *container, GList *icons) { GList *p, *placed_icons, *unplaced_icons; int total, new_length, placed; - NautilusIcon *icon; + NautilusCanvasIcon *icon; int height, max_width, column_width, icon_width, icon_height; int x, y, x1, x2, y1, y2; EelDRect icon_rect; @@ -1906,14 +1906,14 @@ lay_down_icons_vertical_desktop (NautilusIconContainer *container, GList *icons) if (grid) { for (p = placed_icons; p != NULL; p = p->next) { placement_grid_mark_icon - (grid, (NautilusIcon*)p->data); + (grid, (NautilusCanvasIcon *)p->data); } /* Place unplaced icons in the best locations */ for (p = unplaced_icons; p != NULL; p = p->next) { icon = p->data; - icon_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + icon_rect = nautilus_canvas_item_get_icon_rectangle (icon->item); /* Start the icon in the first column */ x = DESKTOP_PAD_HORIZONTAL + (SNAP_SIZE_X / 2) - ((icon_rect.x1 - icon_rect.x0) / 2); @@ -1956,7 +1956,7 @@ lay_down_icons_vertical_desktop (NautilusIconContainer *container, GList *icons) icon = p->data; icon_get_bounding_box (icon, &x1, &y1, &x2, &y2, - BOUNDS_USAGE_FOR_LAYOUT); + BOUNDS_USAGE_FOR_LAYOUT); icon_width = x2 - x1; icon_height = y2 - y1; @@ -1966,7 +1966,7 @@ lay_down_icons_vertical_desktop (NautilusIconContainer *container, GList *icons) if (should_snap) { /* Snap the baseline to a grid position */ - icon_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + icon_rect = nautilus_canvas_item_get_icon_rectangle (icon->item); baseline = y + (icon_rect.y1 - icon_rect.y0); baseline = SNAP_CEIL_VERTICAL (baseline); y = baseline - (icon_rect.y1 - icon_rect.y0); @@ -1998,14 +1998,14 @@ lay_down_icons_vertical_desktop (NautilusIconContainer *container, GList *icons) for (p = icons; p != NULL; p = p->next) { icon = p->data; icon_get_bounding_box (icon, &x1, &y1, &x2, &y2, - BOUNDS_USAGE_FOR_LAYOUT); + BOUNDS_USAGE_FOR_LAYOUT); icon_height = y2 - y1; icon_get_bounding_box (icon, NULL, &y1, NULL, &y2, - BOUNDS_USAGE_FOR_ENTIRE_ITEM); + BOUNDS_USAGE_FOR_ENTIRE_ITEM); icon_height_for_bound_check = y2 - y1; - icon_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + icon_rect = nautilus_canvas_item_get_icon_rectangle (icon->item); if (should_snap) { baseline = y + (icon_rect.y1 - icon_rect.y0); @@ -2022,8 +2022,8 @@ lay_down_icons_vertical_desktop (NautilusIconContainer *container, GList *icons) } icon_set_position (icon, - center_x - (icon_rect.x1 - icon_rect.x0) / 2, - y); + center_x - (icon_rect.x1 - icon_rect.x0) / 2, + y); icon->saved_ltr_x = icon->x; y += icon_height + DESKTOP_PAD_VERTICAL; @@ -2039,36 +2039,36 @@ lay_down_icons_vertical_desktop (NautilusIconContainer *container, GList *icons) * This should not be tied to the direction of layout. * It should be a separate switch. */ - nautilus_icon_container_freeze_icon_positions (container); + nautilus_canvas_container_freeze_icon_positions (container); } static void -lay_down_icons (NautilusIconContainer *container, GList *icons, double start_y) +lay_down_icons (NautilusCanvasContainer *container, GList *icons, double start_y) { switch (container->details->layout_mode) - { - case NAUTILUS_ICON_LAYOUT_L_R_T_B: - case NAUTILUS_ICON_LAYOUT_R_L_T_B: - lay_down_icons_horizontal (container, icons, start_y); - break; + { + case NAUTILUS_CANVAS_LAYOUT_L_R_T_B: + case NAUTILUS_CANVAS_LAYOUT_R_L_T_B: + lay_down_icons_horizontal (container, icons, start_y); + break; - case NAUTILUS_ICON_LAYOUT_T_B_L_R: - case NAUTILUS_ICON_LAYOUT_T_B_R_L: - if (nautilus_icon_container_get_is_desktop (container)) { - lay_down_icons_vertical_desktop (container, icons); - } else { - lay_down_icons_vertical (container, icons, start_y); - } - break; + case NAUTILUS_CANVAS_LAYOUT_T_B_L_R: + case NAUTILUS_CANVAS_LAYOUT_T_B_R_L: + if (nautilus_canvas_container_get_is_desktop (container)) { + lay_down_icons_vertical_desktop (container, icons); + } else { + lay_down_icons_vertical (container, icons, start_y); + } + break; - default: - g_assert_not_reached (); - } + default: + g_assert_not_reached (); + } } static void -redo_layout_internal (NautilusIconContainer *container) +redo_layout_internal (NautilusCanvasContainer *container) { finish_adding_new_icons (container); @@ -2086,23 +2086,23 @@ redo_layout_internal (NautilusIconContainer *container) lay_down_icons (container, container->details->icons, 0); } - if (nautilus_icon_container_is_layout_rtl (container)) { - nautilus_icon_container_set_rtl_positions (container); + if (nautilus_canvas_container_is_layout_rtl (container)) { + nautilus_canvas_container_set_rtl_positions (container); } - nautilus_icon_container_update_scroll_region (container); + nautilus_canvas_container_update_scroll_region (container); process_pending_icon_to_reveal (container); process_pending_icon_to_rename (container); - nautilus_icon_container_update_visible_icons (container); + nautilus_canvas_container_update_visible_icons (container); } static gboolean redo_layout_callback (gpointer callback_data) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (callback_data); + container = NAUTILUS_CANVAS_CONTAINER (callback_data); redo_layout_internal (container); container->details->idle_id = 0; @@ -2110,7 +2110,7 @@ redo_layout_callback (gpointer callback_data) } static void -unschedule_redo_layout (NautilusIconContainer *container) +unschedule_redo_layout (NautilusCanvasContainer *container) { if (container->details->idle_id != 0) { g_source_remove (container->details->idle_id); @@ -2119,7 +2119,7 @@ unschedule_redo_layout (NautilusIconContainer *container) } static void -schedule_redo_layout (NautilusIconContainer *container) +schedule_redo_layout (NautilusCanvasContainer *container) { if (container->details->idle_id == 0 && container->details->has_been_allocated) { @@ -2129,19 +2129,19 @@ schedule_redo_layout (NautilusIconContainer *container) } static void -redo_layout (NautilusIconContainer *container) +redo_layout (NautilusCanvasContainer *container) { unschedule_redo_layout (container); redo_layout_internal (container); } static void -reload_icon_positions (NautilusIconContainer *container) +reload_icon_positions (NautilusCanvasContainer *container) { GList *p, *no_position_icons; - NautilusIcon *icon; + NautilusCanvasIcon *icon; gboolean have_stored_position; - NautilusIconPosition position; + NautilusCanvasPosition position; EelDRect bounds; double bottom; EelCanvasItem *item; @@ -2159,18 +2159,18 @@ reload_icon_positions (NautilusIconContainer *container) have_stored_position = FALSE; g_signal_emit (container, - signals[GET_STORED_ICON_POSITION], 0, - icon->data, - &position, - &have_stored_position); + signals[GET_STORED_ICON_POSITION], 0, + icon->data, + &position, + &have_stored_position); if (have_stored_position) { icon_set_position (icon, position.x, position.y); item = EEL_CANVAS_ITEM (icon->item); - nautilus_icon_canvas_item_get_bounds_for_layout (icon->item, - &bounds.x0, - &bounds.y0, - &bounds.x1, - &bounds.y1); + nautilus_canvas_item_get_bounds_for_layout (icon->item, + &bounds.x0, + &bounds.y0, + &bounds.x1, + &bounds.y1); eel_canvas_item_i2w (item->parent, &bounds.x0, &bounds.y0); @@ -2201,42 +2201,42 @@ button_event_modifies_selection (GdkEventButton *event) /* invalidate the cached label sizes for all the icons */ static void -invalidate_label_sizes (NautilusIconContainer *container) +invalidate_label_sizes (NautilusCanvasContainer *container) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; for (p = container->details->icons; p != NULL; p = p->next) { icon = p->data; - nautilus_icon_canvas_item_invalidate_label_size (icon->item); + nautilus_canvas_item_invalidate_label_size (icon->item); } } /* invalidate the entire labels (i.e. their attributes) for all the icons */ static void -invalidate_labels (NautilusIconContainer *container) +invalidate_labels (NautilusCanvasContainer *container) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; for (p = container->details->icons; p != NULL; p = p->next) { icon = p->data; - nautilus_icon_canvas_item_invalidate_label (icon->item); + nautilus_canvas_item_invalidate_label (icon->item); } } static gboolean -select_range (NautilusIconContainer *container, - NautilusIcon *icon1, - NautilusIcon *icon2, +select_range (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon1, + NautilusCanvasIcon *icon2, gboolean unselect_outside_range) { gboolean selection_changed; GList *p; - NautilusIcon *icon; - NautilusIcon *unmatched_icon; + NautilusCanvasIcon *icon; + NautilusCanvasIcon *unmatched_icon; gboolean select; selection_changed = FALSE; @@ -2275,12 +2275,12 @@ select_range (NautilusIconContainer *container, static gboolean -select_one_unselect_others (NautilusIconContainer *container, - NautilusIcon *icon_to_select) +select_one_unselect_others (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon_to_select) { gboolean selection_changed; GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; selection_changed = FALSE; @@ -2299,23 +2299,23 @@ select_one_unselect_others (NautilusIconContainer *container, } static gboolean -unselect_all (NautilusIconContainer *container) +unselect_all (NautilusCanvasContainer *container) { return select_one_unselect_others (container, NULL); } void -nautilus_icon_container_move_icon (NautilusIconContainer *container, - NautilusIcon *icon, - int x, int y, - double scale, - gboolean raise, - gboolean snap, - gboolean update_position) -{ - NautilusIconContainerDetails *details; +nautilus_canvas_container_move_icon (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, + int x, int y, + double scale, + gboolean raise, + gboolean snap, + gboolean update_position) +{ + NautilusCanvasContainerDetails *details; gboolean emit_signal; - NautilusIconPosition position; + NautilusCanvasPosition position; details = container->details; @@ -2327,7 +2327,7 @@ nautilus_icon_container_move_icon (NautilusIconContainer *container, if (scale != icon->scale) { icon->scale = scale; - nautilus_icon_container_update_icon (container, icon); + nautilus_canvas_container_update_icon (container, icon); if (update_position) { redo_layout (container); emit_signal = TRUE; @@ -2344,7 +2344,7 @@ nautilus_icon_container_move_icon (NautilusIconContainer *container, emit_signal = update_position; } - icon->saved_ltr_x = nautilus_icon_container_is_layout_rtl (container) ? get_mirror_x_position (container, icon, icon->x) : icon->x; + icon->saved_ltr_x = nautilus_canvas_container_is_layout_rtl (container) ? get_mirror_x_position (container, icon, icon->x) : icon->x; } if (emit_signal) { @@ -2352,8 +2352,8 @@ nautilus_icon_container_move_icon (NautilusIconContainer *container, position.y = icon->y; position.scale = scale; g_signal_emit (container, - signals[ICON_POSITION_CHANGED], 0, - icon->data, &position); + signals[ICON_POSITION_CHANGED], 0, + icon->data, &position); } if (raise) { @@ -2371,13 +2371,13 @@ nautilus_icon_container_move_icon (NautilusIconContainer *container, /* Implementation of rubberband selection. */ static void -rubberband_select (NautilusIconContainer *container, +rubberband_select (NautilusCanvasContainer *container, const EelDRect *previous_rect, const EelDRect *current_rect) { GList *p; gboolean selection_changed, is_in, canvas_rect_calculated; - NautilusIcon *icon; + NautilusCanvasIcon *icon; EelIRect canvas_rect; EelCanvas *canvas; @@ -2405,7 +2405,7 @@ rubberband_select (NautilusIconContainer *container, canvas_rect_calculated = TRUE; } - is_in = nautilus_icon_canvas_item_hit_test_rectangle (icon->item, canvas_rect); + is_in = nautilus_canvas_item_hit_test_rectangle (icon->item, canvas_rect); selection_changed |= icon_set_selected (container, icon, @@ -2414,16 +2414,16 @@ rubberband_select (NautilusIconContainer *container, if (selection_changed) { g_signal_emit (container, - signals[SELECTION_CHANGED], 0); + signals[SELECTION_CHANGED], 0); } } static int rubberband_timeout_callback (gpointer data) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; GtkWidget *widget; - NautilusIconRubberbandInfo *band_info; + NautilusCanvasRubberbandInfo *band_info; int x, y; double x1, y1, x2, y2; double world_x, world_y; @@ -2435,7 +2435,7 @@ rubberband_timeout_callback (gpointer data) EelDRect selection_rect; widget = GTK_WIDGET (data); - container = NAUTILUS_ICON_CONTAINER (data); + container = NAUTILUS_CANVAS_CONTAINER (data); band_info = &container->details->rubberband_info; g_assert (band_info->timer_id != 0); @@ -2457,8 +2457,8 @@ rubberband_timeout_callback (gpointer data) gdk_window_get_device_position (gtk_widget_get_window (widget), gdk_device_manager_get_client_pointer ( - gdk_display_get_device_manager ( - gtk_widget_get_display (widget))), + gdk_display_get_device_manager ( + gtk_widget_get_display (widget))), &x, &y, NULL); if (x < RUBBERBAND_SCROLL_THRESHOLD) { @@ -2486,7 +2486,7 @@ rubberband_timeout_callback (gpointer data) return TRUE; } - nautilus_icon_container_scroll (container, x_scroll, y_scroll); + nautilus_canvas_container_scroll (container, x_scroll, y_scroll); /* Remember to convert from widget to scrolled window coords */ eel_canvas_window_to_world (EEL_CANVAS (container), @@ -2542,15 +2542,15 @@ rubberband_timeout_callback (gpointer data) } static void -start_rubberbanding (NautilusIconContainer *container, +start_rubberbanding (NautilusCanvasContainer *container, GdkEventButton *event) { AtkObject *accessible; - NautilusIconContainerDetails *details; - NautilusIconRubberbandInfo *band_info; + NautilusCanvasContainerDetails *details; + NautilusCanvasRubberbandInfo *band_info; GdkRGBA bg_color, border_color; GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; GtkStyleContext *context; details = container->details; @@ -2608,17 +2608,17 @@ start_rubberbanding (NautilusIconContainer *container, } eel_canvas_item_grab (band_info->selection_rectangle, - (GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_SCROLL_MASK), - NULL, event->time); + (GDK_POINTER_MOTION_MASK + | GDK_BUTTON_RELEASE_MASK + | GDK_SCROLL_MASK), + NULL, event->time); } static void -stop_rubberbanding (NautilusIconContainer *container, +stop_rubberbanding (NautilusCanvasContainer *container, guint32 time) { - NautilusIconRubberbandInfo *band_info; + NautilusCanvasRubberbandInfo *band_info; GList *icons; gboolean enable_animation; @@ -2644,32 +2644,32 @@ stop_rubberbanding (NautilusIconContainer *container, /* if only one item has been selected, use it as range * selection base (cf. handle_icon_button_press) */ - icons = nautilus_icon_container_get_selected_icons (container); + icons = nautilus_canvas_container_get_selected_icons (container); if (g_list_length (icons) == 1) { container->details->range_selection_base_icon = icons->data; } g_list_free (icons); g_signal_emit (container, - signals[BAND_SELECT_ENDED], 0); + signals[BAND_SELECT_ENDED], 0); } /* Keyboard navigation. */ -typedef gboolean (* IsBetterIconFunction) (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, - void *data); +typedef gboolean (* IsBetterCanvasFunction) (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, + void *data); -static NautilusIcon * -find_best_icon (NautilusIconContainer *container, - NautilusIcon *start_icon, - IsBetterIconFunction function, - void *data) +static NautilusCanvasIcon * +find_best_icon (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + IsBetterCanvasFunction function, + void *data) { GList *p; - NautilusIcon *best, *candidate; + NautilusCanvasIcon *best, *candidate; best = NULL; for (p = container->details->icons; p != NULL; p = p->next) { @@ -2684,14 +2684,14 @@ find_best_icon (NautilusIconContainer *container, return best; } -static NautilusIcon * -find_best_selected_icon (NautilusIconContainer *container, - NautilusIcon *start_icon, - IsBetterIconFunction function, - void *data) +static NautilusCanvasIcon * +find_best_selected_icon (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + IsBetterCanvasFunction function, + void *data) { GList *p; - NautilusIcon *best, *candidate; + NautilusCanvasIcon *best, *candidate; best = NULL; for (p = container->details->icons; p != NULL; p = p->next) { @@ -2707,20 +2707,20 @@ find_best_selected_icon (NautilusIconContainer *container, } static int -compare_icons_by_uri (NautilusIconContainer *container, - NautilusIcon *icon_a, - NautilusIcon *icon_b) +compare_icons_by_uri (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon_a, + NautilusCanvasIcon *icon_b) { char *uri_a, *uri_b; int result; - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); g_assert (icon_a != NULL); g_assert (icon_b != NULL); g_assert (icon_a != icon_b); - uri_a = nautilus_icon_container_get_icon_uri (container, icon_a); - uri_b = nautilus_icon_container_get_icon_uri (container, icon_b); + uri_a = nautilus_canvas_container_get_icon_uri (container, icon_a); + uri_b = nautilus_canvas_container_get_icon_uri (container, icon_b); result = strcmp (uri_a, uri_b); g_assert (result != 0); g_free (uri_a); @@ -2730,14 +2730,14 @@ compare_icons_by_uri (NautilusIconContainer *container, } static int -get_cmp_point_x (NautilusIconContainer *container, +get_cmp_point_x (NautilusCanvasContainer *container, EelDRect icon_rect) { return (icon_rect.x0 + icon_rect.x1) / 2; } static int -get_cmp_point_y (NautilusIconContainer *container, +get_cmp_point_y (NautilusCanvasContainer *container, EelDRect icon_rect) { return icon_rect.y1; @@ -2745,21 +2745,21 @@ get_cmp_point_y (NautilusIconContainer *container, static int -compare_icons_horizontal (NautilusIconContainer *container, - NautilusIcon *icon_a, - NautilusIcon *icon_b) +compare_icons_horizontal (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon_a, + NautilusCanvasIcon *icon_b) { EelDRect world_rect; int ax, bx; - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_a->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon_a->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), get_cmp_point_y (container, world_rect), &ax, NULL); - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_b->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon_b->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), @@ -2777,21 +2777,21 @@ compare_icons_horizontal (NautilusIconContainer *container, } static int -compare_icons_vertical (NautilusIconContainer *container, - NautilusIcon *icon_a, - NautilusIcon *icon_b) +compare_icons_vertical (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon_a, + NautilusCanvasIcon *icon_b) { EelDRect world_rect; int ay, by; - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_a->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon_a->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), get_cmp_point_y (container, world_rect), NULL, &ay); - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_b->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon_b->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), @@ -2809,21 +2809,21 @@ compare_icons_vertical (NautilusIconContainer *container, } static int -compare_icons_horizontal_first (NautilusIconContainer *container, - NautilusIcon *icon_a, - NautilusIcon *icon_b) +compare_icons_horizontal_first (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon_a, + NautilusCanvasIcon *icon_b) { EelDRect world_rect; int ax, ay, bx, by; - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_a->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon_a->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), get_cmp_point_y (container, world_rect), &ax, &ay); - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_b->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon_b->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), @@ -2847,21 +2847,21 @@ compare_icons_horizontal_first (NautilusIconContainer *container, } static int -compare_icons_vertical_first (NautilusIconContainer *container, - NautilusIcon *icon_a, - NautilusIcon *icon_b) +compare_icons_vertical_first (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon_a, + NautilusCanvasIcon *icon_b) { EelDRect world_rect; int ax, ay, bx, by; - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_a->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon_a->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), get_cmp_point_y (container, world_rect), &ax, &ay); - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_b->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon_b->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), @@ -2885,10 +2885,10 @@ compare_icons_vertical_first (NautilusIconContainer *container, } static gboolean -leftmost_in_top_row (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +leftmost_in_top_row (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { if (best_so_far == NULL) { @@ -2898,10 +2898,10 @@ leftmost_in_top_row (NautilusIconContainer *container, } static gboolean -rightmost_in_top_row (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +rightmost_in_top_row (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { if (best_so_far == NULL) { @@ -2912,10 +2912,10 @@ rightmost_in_top_row (NautilusIconContainer *container, } static gboolean -rightmost_in_bottom_row (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +rightmost_in_bottom_row (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { if (best_so_far == NULL) { @@ -2925,8 +2925,8 @@ rightmost_in_bottom_row (NautilusIconContainer *container, } static int -compare_with_start_row (NautilusIconContainer *container, - NautilusIcon *icon) +compare_with_start_row (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { EelCanvasItem *item; @@ -2942,8 +2942,8 @@ compare_with_start_row (NautilusIconContainer *container, } static int -compare_with_start_column (NautilusIconContainer *container, - NautilusIcon *icon) +compare_with_start_column (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { EelCanvasItem *item; @@ -2959,10 +2959,10 @@ compare_with_start_column (NautilusIconContainer *container, } static gboolean -same_row_right_side_leftmost (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +same_row_right_side_leftmost (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* Candidates not on the start row do not qualify. */ @@ -2973,16 +2973,16 @@ same_row_right_side_leftmost (NautilusIconContainer *container, /* Candidates that are farther right lose out. */ if (best_so_far != NULL) { if (compare_icons_horizontal_first (container, - best_so_far, - candidate) < 0) { + best_so_far, + candidate) < 0) { return FALSE; } } /* Candidate to the left of the start do not qualify. */ if (compare_icons_horizontal_first (container, - candidate, - start_icon) <= 0) { + candidate, + start_icon) <= 0) { return FALSE; } @@ -2990,10 +2990,10 @@ same_row_right_side_leftmost (NautilusIconContainer *container, } static gboolean -same_row_left_side_rightmost (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +same_row_left_side_rightmost (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* Candidates not on the start row do not qualify. */ @@ -3004,16 +3004,16 @@ same_row_left_side_rightmost (NautilusIconContainer *container, /* Candidates that are farther left lose out. */ if (best_so_far != NULL) { if (compare_icons_horizontal_first (container, - best_so_far, - candidate) > 0) { + best_so_far, + candidate) > 0) { return FALSE; } } /* Candidate to the right of the start do not qualify. */ if (compare_icons_horizontal_first (container, - candidate, - start_icon) >= 0) { + candidate, + start_icon) >= 0) { return FALSE; } @@ -3021,10 +3021,10 @@ same_row_left_side_rightmost (NautilusIconContainer *container, } static gboolean -next_row_leftmost (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +next_row_leftmost (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* sort out icons that are not below the current row */ @@ -3034,15 +3034,15 @@ next_row_leftmost (NautilusIconContainer *container, if (best_so_far != NULL) { if (compare_icons_vertical_first (container, - best_so_far, - candidate) > 0) { + best_so_far, + candidate) > 0) { /* candidate is above best choice, but below the current row */ return TRUE; } if (compare_icons_horizontal_first (container, - best_so_far, - candidate) > 0) { + best_so_far, + candidate) > 0) { return TRUE; } } @@ -3051,10 +3051,10 @@ next_row_leftmost (NautilusIconContainer *container, } static gboolean -next_row_rightmost (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +next_row_rightmost (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* sort out icons that are not below the current row */ @@ -3064,15 +3064,15 @@ next_row_rightmost (NautilusIconContainer *container, if (best_so_far != NULL) { if (compare_icons_vertical_first (container, - best_so_far, - candidate) > 0) { + best_so_far, + candidate) > 0) { /* candidate is above best choice, but below the current row */ return TRUE; } if (compare_icons_horizontal_first (container, - best_so_far, - candidate) < 0) { + best_so_far, + candidate) < 0) { return TRUE; } } @@ -3081,10 +3081,10 @@ next_row_rightmost (NautilusIconContainer *container, } static gboolean -next_column_bottommost (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +next_column_bottommost (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* sort out icons that are not on the right of the current column */ @@ -3094,15 +3094,15 @@ next_column_bottommost (NautilusIconContainer *container, if (best_so_far != NULL) { if (compare_icons_horizontal_first (container, - best_so_far, - candidate) > 0) { + best_so_far, + candidate) > 0) { /* candidate is above best choice, but below the current row */ return TRUE; } if (compare_icons_vertical_first (container, - best_so_far, - candidate) < 0) { + best_so_far, + candidate) < 0) { return TRUE; } } @@ -3111,10 +3111,10 @@ next_column_bottommost (NautilusIconContainer *container, } static gboolean -previous_row_rightmost (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +previous_row_rightmost (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* sort out icons that are not above the current row */ @@ -3124,15 +3124,15 @@ previous_row_rightmost (NautilusIconContainer *container, if (best_so_far != NULL) { if (compare_icons_vertical_first (container, - best_so_far, - candidate) < 0) { + best_so_far, + candidate) < 0) { /* candidate is below the best choice, but above the current row */ return TRUE; } if (compare_icons_horizontal_first (container, - best_so_far, - candidate) < 0) { + best_so_far, + candidate) < 0) { return TRUE; } } @@ -3141,10 +3141,10 @@ previous_row_rightmost (NautilusIconContainer *container, } static gboolean -same_column_above_lowest (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +same_column_above_lowest (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* Candidates not on the start column do not qualify. */ @@ -3155,16 +3155,16 @@ same_column_above_lowest (NautilusIconContainer *container, /* Candidates that are higher lose out. */ if (best_so_far != NULL) { if (compare_icons_vertical_first (container, - best_so_far, - candidate) > 0) { + best_so_far, + candidate) > 0) { return FALSE; } } /* Candidates below the start do not qualify. */ if (compare_icons_vertical_first (container, - candidate, - start_icon) >= 0) { + candidate, + start_icon) >= 0) { return FALSE; } @@ -3172,10 +3172,10 @@ same_column_above_lowest (NautilusIconContainer *container, } static gboolean -same_column_below_highest (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +same_column_below_highest (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* Candidates not on the start column do not qualify. */ @@ -3186,16 +3186,16 @@ same_column_below_highest (NautilusIconContainer *container, /* Candidates that are lower lose out. */ if (best_so_far != NULL) { if (compare_icons_vertical_first (container, - best_so_far, - candidate) < 0) { + best_so_far, + candidate) < 0) { return FALSE; } } /* Candidates above the start do not qualify. */ if (compare_icons_vertical_first (container, - candidate, - start_icon) <= 0) { + candidate, + start_icon) <= 0) { return FALSE; } @@ -3203,10 +3203,10 @@ same_column_below_highest (NautilusIconContainer *container, } static gboolean -previous_column_highest (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +previous_column_highest (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* sort out icons that are not before the current column */ @@ -3216,15 +3216,15 @@ previous_column_highest (NautilusIconContainer *container, if (best_so_far != NULL) { if (compare_icons_horizontal (container, - best_so_far, - candidate) < 0) { + best_so_far, + candidate) < 0) { /* candidate is right of the best choice, but left of the current column */ return TRUE; } if (compare_icons_vertical (container, - best_so_far, - candidate) > 0) { + best_so_far, + candidate) > 0) { return TRUE; } } @@ -3234,10 +3234,10 @@ previous_column_highest (NautilusIconContainer *container, static gboolean -next_column_highest (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +next_column_highest (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* sort out icons that are not after the current column */ @@ -3247,15 +3247,15 @@ next_column_highest (NautilusIconContainer *container, if (best_so_far != NULL) { if (compare_icons_horizontal_first (container, - best_so_far, - candidate) > 0) { + best_so_far, + candidate) > 0) { /* candidate is left of the best choice, but right of the current column */ return TRUE; } if (compare_icons_vertical_first (container, - best_so_far, - candidate) > 0) { + best_so_far, + candidate) > 0) { return TRUE; } } @@ -3264,10 +3264,10 @@ next_column_highest (NautilusIconContainer *container, } static gboolean -previous_column_lowest (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +previous_column_lowest (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { /* sort out icons that are not before the current column */ @@ -3277,15 +3277,15 @@ previous_column_lowest (NautilusIconContainer *container, if (best_so_far != NULL) { if (compare_icons_horizontal_first (container, - best_so_far, - candidate) < 0) { + best_so_far, + candidate) < 0) { /* candidate is right of the best choice, but left of the current column */ return TRUE; } if (compare_icons_vertical_first (container, - best_so_far, - candidate) < 0) { + best_so_far, + candidate) < 0) { return TRUE; } } @@ -3294,10 +3294,10 @@ previous_column_lowest (NautilusIconContainer *container, } static gboolean -last_column_lowest (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +last_column_lowest (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { if (best_so_far == NULL) { @@ -3307,10 +3307,10 @@ last_column_lowest (NautilusIconContainer *container, } static gboolean -closest_in_90_degrees (NautilusIconContainer *container, - NautilusIcon *start_icon, - NautilusIcon *best_so_far, - NautilusIcon *candidate, +closest_in_90_degrees (NautilusCanvasContainer *container, + NautilusCanvasIcon *start_icon, + NautilusCanvasIcon *best_so_far, + NautilusCanvasIcon *candidate, void *data) { EelDRect world_rect; @@ -3320,7 +3320,7 @@ closest_in_90_degrees (NautilusIconContainer *container, int *best_dist; - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (candidate->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (candidate->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), @@ -3377,8 +3377,8 @@ closest_in_90_degrees (NautilusIconContainer *container, } static EelDRect -get_rubberband (NautilusIcon *icon1, - NautilusIcon *icon2) +get_rubberband (NautilusCanvasIcon *icon1, + NautilusCanvasIcon *icon2) { EelDRect rect1; EelDRect rect2; @@ -3397,9 +3397,9 @@ get_rubberband (NautilusIcon *icon1, } static void -keyboard_move_to (NautilusIconContainer *container, - NautilusIcon *icon, - NautilusIcon *from, +keyboard_move_to (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, + NautilusCanvasIcon *from, GdkEventKey *event) { if (icon == NULL) { @@ -3436,7 +3436,7 @@ keyboard_move_to (NautilusIconContainer *container, (event->state & GDK_CONTROL_MASK) == 0 && (event->state & GDK_SHIFT_MASK) != 0) { /* Select range */ - NautilusIcon *start_icon; + NautilusCanvasIcon *start_icon; start_icon = container->details->range_selection_base_icon; if (start_icon == NULL || !start_icon->is_selected) { @@ -3458,61 +3458,61 @@ keyboard_move_to (NautilusIconContainer *container, container->details->range_selection_base_icon = icon; if (select_one_unselect_others (container, icon)) { g_signal_emit (container, - signals[SELECTION_CHANGED], 0); + signals[SELECTION_CHANGED], 0); } } schedule_keyboard_icon_reveal (container, icon); } static void -keyboard_home (NautilusIconContainer *container, +keyboard_home (NautilusCanvasContainer *container, GdkEventKey *event) { - NautilusIcon *from; - NautilusIcon *to; + NautilusCanvasIcon *from; + NautilusCanvasIcon *to; - /* Home selects the first icon. - * Control-Home sets the keyboard focus to the first icon. + /* Home selects the first canvas. + * Control-Home sets the keyboard focus to the first canvas. */ from = find_best_selected_icon (container, NULL, - rightmost_in_bottom_row, - NULL); + rightmost_in_bottom_row, + NULL); to = find_best_icon (container, NULL, leftmost_in_top_row, NULL); keyboard_move_to (container, to, from, event); } static void -keyboard_end (NautilusIconContainer *container, +keyboard_end (NautilusCanvasContainer *container, GdkEventKey *event) { - NautilusIcon *to; - NautilusIcon *from; + NautilusCanvasIcon *to; + NautilusCanvasIcon *from; - /* End selects the last icon. - * Control-End sets the keyboard focus to the last icon. + /* End selects the last canvas. + * Control-End sets the keyboard focus to the last canvas. */ from = find_best_selected_icon (container, NULL, - leftmost_in_top_row, - NULL); + leftmost_in_top_row, + NULL); to = find_best_icon (container, NULL, - nautilus_icon_container_is_layout_vertical (container) ? - last_column_lowest : - rightmost_in_bottom_row, - NULL); + nautilus_canvas_container_is_layout_vertical (container) ? + last_column_lowest : + rightmost_in_bottom_row, + NULL); keyboard_move_to (container, to, from, event); } static void -record_arrow_key_start (NautilusIconContainer *container, - NautilusIcon *icon, +record_arrow_key_start (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, GtkDirectionType direction) { EelDRect world_rect; - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon->item); eel_canvas_w2c (EEL_CANVAS (container), get_cmp_point_x (container, world_rect), @@ -3523,18 +3523,18 @@ record_arrow_key_start (NautilusIconContainer *container, } static void -keyboard_arrow_key (NautilusIconContainer *container, +keyboard_arrow_key (NautilusCanvasContainer *container, GdkEventKey *event, GtkDirectionType direction, - IsBetterIconFunction better_start, - IsBetterIconFunction empty_start, - IsBetterIconFunction better_destination, - IsBetterIconFunction better_destination_fallback, - IsBetterIconFunction better_destination_fallback_fallback, - IsBetterIconFunction better_destination_manual) -{ - NautilusIcon *from; - NautilusIcon *to; + IsBetterCanvasFunction better_start, + IsBetterCanvasFunction empty_start, + IsBetterCanvasFunction better_destination, + IsBetterCanvasFunction better_destination_fallback, + IsBetterCanvasFunction better_destination_fallback_fallback, + IsBetterCanvasFunction better_destination_manual) +{ + NautilusCanvasIcon *from; + NautilusCanvasIcon *to; int data; /* Chose the icon to start with. @@ -3624,25 +3624,25 @@ static gboolean is_rectangle_selection_event (GdkEventKey *event) { return (event->state & GDK_CONTROL_MASK) != 0 && - (event->state & GDK_SHIFT_MASK) != 0; + (event->state & GDK_SHIFT_MASK) != 0; } static void -keyboard_right (NautilusIconContainer *container, +keyboard_right (NautilusCanvasContainer *container, GdkEventKey *event) { - IsBetterIconFunction fallback; - IsBetterIconFunction next_column_fallback; + IsBetterCanvasFunction fallback; + IsBetterCanvasFunction next_column_fallback; fallback = NULL; if (container->details->auto_layout && - !nautilus_icon_container_is_layout_vertical (container) && + !nautilus_canvas_container_is_layout_vertical (container) && !is_rectangle_selection_event (event)) { fallback = next_row_leftmost; } next_column_fallback = NULL; - if (nautilus_icon_container_is_layout_vertical (container) && + if (nautilus_canvas_container_is_layout_vertical (container) && gtk_widget_get_direction (GTK_WIDGET (container)) != GTK_TEXT_DIR_RTL) { next_column_fallback = next_column_bottommost; } @@ -3654,7 +3654,7 @@ keyboard_right (NautilusIconContainer *container, event, GTK_DIR_RIGHT, rightmost_in_bottom_row, - nautilus_icon_container_is_layout_rtl (container) ? + nautilus_canvas_container_is_layout_rtl (container) ? rightmost_in_top_row : leftmost_in_top_row, same_row_right_side_leftmost, fallback, @@ -3663,21 +3663,21 @@ keyboard_right (NautilusIconContainer *container, } static void -keyboard_left (NautilusIconContainer *container, +keyboard_left (NautilusCanvasContainer *container, GdkEventKey *event) { - IsBetterIconFunction fallback; - IsBetterIconFunction previous_column_fallback; + IsBetterCanvasFunction fallback; + IsBetterCanvasFunction previous_column_fallback; fallback = NULL; if (container->details->auto_layout && - !nautilus_icon_container_is_layout_vertical (container) && + !nautilus_canvas_container_is_layout_vertical (container) && !is_rectangle_selection_event (event)) { fallback = previous_row_rightmost; } previous_column_fallback = NULL; - if (nautilus_icon_container_is_layout_vertical (container) && + if (nautilus_canvas_container_is_layout_vertical (container) && gtk_widget_get_direction (GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL) { previous_column_fallback = previous_column_lowest; } @@ -3689,7 +3689,7 @@ keyboard_left (NautilusIconContainer *container, event, GTK_DIR_LEFT, rightmost_in_bottom_row, - nautilus_icon_container_is_layout_rtl (container) ? + nautilus_canvas_container_is_layout_rtl (container) ? rightmost_in_top_row : leftmost_in_top_row, same_row_left_side_rightmost, fallback, @@ -3698,15 +3698,15 @@ keyboard_left (NautilusIconContainer *container, } static void -keyboard_down (NautilusIconContainer *container, +keyboard_down (NautilusCanvasContainer *container, GdkEventKey *event) { - IsBetterIconFunction fallback; - IsBetterIconFunction next_row_fallback; + IsBetterCanvasFunction fallback; + IsBetterCanvasFunction next_row_fallback; fallback = NULL; if (container->details->auto_layout && - nautilus_icon_container_is_layout_vertical (container) && + nautilus_canvas_container_is_layout_vertical (container) && !is_rectangle_selection_event (event)) { if (gtk_widget_get_direction (GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL) { fallback = previous_column_highest; @@ -3716,7 +3716,7 @@ keyboard_down (NautilusIconContainer *container, } next_row_fallback = NULL; - if (!nautilus_icon_container_is_layout_vertical (container)) { + if (!nautilus_canvas_container_is_layout_vertical (container)) { if (gtk_widget_get_direction (GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL) { next_row_fallback = next_row_leftmost; } else { @@ -3731,7 +3731,7 @@ keyboard_down (NautilusIconContainer *container, event, GTK_DIR_DOWN, rightmost_in_bottom_row, - nautilus_icon_container_is_layout_rtl (container) ? + nautilus_canvas_container_is_layout_rtl (container) ? rightmost_in_top_row : leftmost_in_top_row, same_column_below_highest, fallback, @@ -3740,14 +3740,14 @@ keyboard_down (NautilusIconContainer *container, } static void -keyboard_up (NautilusIconContainer *container, +keyboard_up (NautilusCanvasContainer *container, GdkEventKey *event) { - IsBetterIconFunction fallback; + IsBetterCanvasFunction fallback; fallback = NULL; if (container->details->auto_layout && - nautilus_icon_container_is_layout_vertical (container) && + nautilus_canvas_container_is_layout_vertical (container) && !is_rectangle_selection_event (event)) { if (gtk_widget_get_direction (GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL) { fallback = next_column_bottommost; @@ -3763,7 +3763,7 @@ keyboard_up (NautilusIconContainer *container, event, GTK_DIR_UP, rightmost_in_bottom_row, - nautilus_icon_container_is_layout_rtl (container) ? + nautilus_canvas_container_is_layout_rtl (container) ? rightmost_in_top_row : leftmost_in_top_row, same_column_above_lowest, fallback, @@ -3772,10 +3772,10 @@ keyboard_up (NautilusIconContainer *container, } static void -keyboard_space (NautilusIconContainer *container, +keyboard_space (NautilusCanvasContainer *container, GdkEventKey *event) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; if (!has_selection (container) && container->details->keyboard_focus != NULL) { @@ -3793,14 +3793,14 @@ keyboard_space (NautilusIconContainer *container, } } else { icon = find_best_selected_icon (container, - NULL, - leftmost_in_top_row, - NULL); + NULL, + leftmost_in_top_row, + NULL); if (icon == NULL) { icon = find_best_icon (container, - NULL, - leftmost_in_top_row, - NULL); + NULL, + leftmost_in_top_row, + NULL); } if (icon != NULL) { set_keyboard_focus (container, icon); @@ -3813,7 +3813,7 @@ keyboard_space (NautilusIconContainer *container, } } -/* look for the first icon that matches the longest part of a given +/* look for the first canvas that matches the longest part of a given * search pattern */ typedef struct { @@ -3823,11 +3823,11 @@ typedef struct { #ifndef TAB_NAVIGATION_DISABLED static void -select_previous_or_next_icon (NautilusIconContainer *container, - gboolean next, - GdkEventKey *event) +select_previous_or_next_icon (NautilusCanvasContainer *container, + gboolean next, + GdkEventKey *event) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; const GList *item; item = NULL; @@ -3841,7 +3841,7 @@ select_previous_or_next_icon (NautilusIconContainer *container, } if (icon != NULL) { - /* must have at least @icon in the list */ + /* must have at least @canvas in the list */ g_assert (container->details->icons != NULL); item = g_list_find (container->details->icons, icon); g_assert (item != NULL); @@ -3867,11 +3867,11 @@ select_previous_or_next_icon (NautilusIconContainer *container, static void destroy (GtkWidget *object) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (object); + container = NAUTILUS_CANVAS_CONTAINER (object); - nautilus_icon_container_clear (container); + nautilus_canvas_container_clear (container); if (container->details->rubberband_info.timer_id != 0) { g_source_remove (container->details->rubberband_info.timer_id); @@ -3903,15 +3903,15 @@ destroy (GtkWidget *object) container->details->size_allocation_count_id = 0; } - GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->destroy (object); + GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->destroy (object); } static void finalize (GObject *object) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; - details = NAUTILUS_ICON_CONTAINER (object)->details; + details = NAUTILUS_CANVAS_CONTAINER (object)->details; g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences, text_ellipsis_limit_changed_container_callback, @@ -3937,7 +3937,7 @@ finalize (GObject *object) g_free (details); - G_OBJECT_CLASS (nautilus_icon_container_parent_class)->finalize (object); + G_OBJECT_CLASS (nautilus_canvas_container_parent_class)->finalize (object); } /* GtkWidget methods. */ @@ -3945,9 +3945,9 @@ finalize (GObject *object) static gboolean clear_size_allocation_count (gpointer data) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (data); + container = NAUTILUS_CANVAS_CONTAINER (data); container->details->size_allocation_count_id = 0; container->details->size_allocation_count = 0; @@ -3959,11 +3959,11 @@ static void size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; gboolean need_layout_redone; GtkAllocation wid_allocation; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); need_layout_redone = !container->details->has_been_allocated; gtk_widget_get_allocation (widget, &wid_allocation); @@ -3998,7 +3998,7 @@ size_allocate (GtkWidget *widget, need_layout_redone = FALSE; } - GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->size_allocate (widget, allocation); + GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->size_allocate (widget, allocation); container->details->has_been_allocated = TRUE; @@ -4010,8 +4010,8 @@ size_allocate (GtkWidget *widget, static GtkSizeRequestMode get_request_mode (GtkWidget *widget) { - /* Don't trade size at all, since we get whatever we get anyway. */ - return GTK_SIZE_REQUEST_CONSTANT_SIZE; + /* Don't trade size at all, since we get whatever we get anyway. */ + return GTK_SIZE_REQUEST_CONSTANT_SIZE; } /* We need to implement these since the GtkScrolledWindow uses them @@ -4072,11 +4072,11 @@ static void realize (GtkWidget *widget) { GtkAdjustment *vadj, *hadj; - NautilusIconContainer *container; + NautilusCanvasContainer *container; - GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->realize (widget); + GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->realize (widget); - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); /* Ensure that the desktop window is native so the background set on it is drawn by X. */ @@ -4085,7 +4085,7 @@ realize (GtkWidget *widget) } /* Set up DnD. */ - nautilus_icon_dnd_init (container); + nautilus_canvas_dnd_init (container); hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget)); g_signal_connect (hadj, "value_changed", @@ -4100,33 +4100,33 @@ realize (GtkWidget *widget) static void unrealize (GtkWidget *widget) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); - nautilus_icon_dnd_fini (container); + nautilus_canvas_dnd_fini (container); - GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->unrealize (widget); + GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->unrealize (widget); } static void style_updated (GtkWidget *widget) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); container->details->use_drop_shadows = container->details->drop_shadows_requested; /* Don't chain up to parent, if this is a desktop container, * because that resets the background of the window. */ - if (!nautilus_icon_container_get_is_desktop (container)) { - GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->style_updated (widget); + if (!nautilus_canvas_container_get_is_desktop (container)) { + GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->style_updated (widget); } if (gtk_widget_get_realized (widget)) { invalidate_labels (container); - nautilus_icon_container_request_update_all (container); + nautilus_canvas_container_request_update_all (container); } } @@ -4134,12 +4134,12 @@ static gboolean button_press_event (GtkWidget *widget, GdkEventButton *event) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; gboolean selection_changed; gboolean return_value; gboolean clicked_on_icon; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); container->details->button_down_time = event->time; /* Forget about the old keyboard selection now that we've started mousing. */ @@ -4152,9 +4152,9 @@ button_press_event (GtkWidget *widget, } /* Invoke the canvas event handler and see if an item picks up the event. */ - clicked_on_icon = GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->button_press_event (widget, event); + clicked_on_icon = GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->button_press_event (widget, event); - /* Move focus to icon container, unless we're still renaming (to avoid exiting + /* Move focus to canvas container, unless we're still renaming (to avoid exiting * renaming mode) */ if (!gtk_widget_has_focus (widget) && !(is_renaming (container) || is_renaming_pending (container))) { @@ -4178,7 +4178,7 @@ button_press_event (GtkWidget *widget, selection_changed = unselect_all (container); if (selection_changed) { g_signal_emit (container, - signals[SELECTION_CHANGED], 0); + signals[SELECTION_CHANGED], 0); } } @@ -4220,10 +4220,10 @@ button_press_event (GtkWidget *widget, } static void -nautilus_icon_container_did_not_drag (NautilusIconContainer *container, - GdkEventButton *event) +nautilus_canvas_container_did_not_drag (NautilusCanvasContainer *container, + GdkEventButton *event) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; gboolean selection_changed; static gint64 last_click_time = 0; static gint click_count = 0; @@ -4296,7 +4296,7 @@ nautilus_icon_container_did_not_drag (NautilusIconContainer *container, } static gboolean -clicked_within_double_click_interval (NautilusIconContainer *container) +clicked_within_double_click_interval (NautilusCanvasContainer *container) { static gint64 last_click_time = 0; static gint click_count = 0; @@ -4327,17 +4327,17 @@ clicked_within_double_click_interval (NautilusIconContainer *container) } static void -clear_drag_state (NautilusIconContainer *container) +clear_drag_state (NautilusCanvasContainer *container) { container->details->drag_icon = NULL; container->details->drag_state = DRAG_STATE_INITIAL; } static gboolean -start_stretching (NautilusIconContainer *container) +start_stretching (NautilusCanvasContainer *container) { - NautilusIconContainerDetails *details; - NautilusIcon *icon; + NautilusCanvasContainerDetails *details; + NautilusCanvasIcon *icon; GtkWidget *toplevel; GtkCornerType corner; GdkCursor *cursor; @@ -4346,9 +4346,9 @@ start_stretching (NautilusIconContainer *container) icon = details->stretch_icon; /* Check if we hit the stretch handles. */ - if (!nautilus_icon_canvas_item_hit_test_stretch_handles (icon->item, - details->drag_x, details->drag_y, - &corner)) { + if (!nautilus_canvas_item_hit_test_stretch_handles (icon->item, + details->drag_x, details->drag_y, + &corner)) { return FALSE; } @@ -4372,22 +4372,22 @@ start_stretching (NautilusIconContainer *container) /* Set up the dragging. */ details->drag_state = DRAG_STATE_STRETCH; eel_canvas_w2c (EEL_CANVAS (container), - details->drag_x, - details->drag_y, - &details->stretch_start.pointer_x, - &details->stretch_start.pointer_y); + details->drag_x, + details->drag_y, + &details->stretch_start.pointer_x, + &details->stretch_start.pointer_y); eel_canvas_w2c (EEL_CANVAS (container), - icon->x, icon->y, - &details->stretch_start.icon_x, - &details->stretch_start.icon_y); + icon->x, icon->y, + &details->stretch_start.icon_x, + &details->stretch_start.icon_y); icon_get_size (container, icon, - &details->stretch_start.icon_size); + &details->stretch_start.icon_size); eel_canvas_item_grab (EEL_CANVAS_ITEM (icon->item), - (GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK), - cursor, - GDK_CURRENT_TIME); + (GDK_POINTER_MOTION_MASK + | GDK_BUTTON_RELEASE_MASK), + cursor, + GDK_CURRENT_TIME); if (cursor) g_object_unref (cursor); @@ -4401,10 +4401,10 @@ start_stretching (NautilusIconContainer *container) } static gboolean -update_stretch_at_idle (NautilusIconContainer *container) +update_stretch_at_idle (NautilusCanvasContainer *container) { - NautilusIconContainerDetails *details; - NautilusIcon *icon; + NautilusCanvasContainerDetails *details; + NautilusCanvasIcon *icon; double world_x, world_y; StretchState stretch_state; @@ -4417,15 +4417,15 @@ update_stretch_at_idle (NautilusIconContainer *container) } eel_canvas_w2c (EEL_CANVAS (container), - details->world_x, details->world_y, - &stretch_state.pointer_x, &stretch_state.pointer_y); + details->world_x, details->world_y, + &stretch_state.pointer_x, &stretch_state.pointer_y); compute_stretch (&details->stretch_start, &stretch_state); eel_canvas_c2w (EEL_CANVAS (container), - stretch_state.icon_x, stretch_state.icon_y, - &world_x, &world_y); + stretch_state.icon_x, stretch_state.icon_y, + &world_x, &world_y); icon_set_position (icon, world_x, world_y); icon_set_size (container, icon, stretch_state.icon_size, FALSE, FALSE); @@ -4436,11 +4436,11 @@ update_stretch_at_idle (NautilusIconContainer *container) } static void -continue_stretching (NautilusIconContainer *container, +continue_stretching (NautilusCanvasContainer *container, double world_x, double world_y) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); container->details->world_x = world_x; container->details->world_y = world_y; @@ -4451,10 +4451,10 @@ continue_stretching (NautilusIconContainer *container, } static gboolean -keyboard_stretching (NautilusIconContainer *container, +keyboard_stretching (NautilusCanvasContainer *container, GdkEventKey *event) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; guint size; icon = container->details->stretch_icon; @@ -4477,10 +4477,10 @@ keyboard_stretching (NautilusIconContainer *container, break; case GDK_KEY_0: case GDK_KEY_KP_0: - nautilus_icon_container_move_icon (container, icon, - icon->x, icon->y, - 1.0, - FALSE, TRUE, TRUE); + nautilus_canvas_container_move_icon (container, icon, + icon->x, icon->y, + 1.0, + FALSE, TRUE, TRUE); break; } @@ -4488,18 +4488,18 @@ keyboard_stretching (NautilusIconContainer *container, } static void -ungrab_stretch_icon (NautilusIconContainer *container) +ungrab_stretch_icon (NautilusCanvasContainer *container) { eel_canvas_item_ungrab (EEL_CANVAS_ITEM (container->details->stretch_icon->item), - GDK_CURRENT_TIME); + GDK_CURRENT_TIME); } static void -end_stretching (NautilusIconContainer *container, +end_stretching (NautilusCanvasContainer *container, double world_x, double world_y) { - NautilusIconPosition position; - NautilusIcon *icon; + NautilusCanvasPosition position; + NautilusCanvasIcon *icon; continue_stretching (container, world_x, world_y); ungrab_stretch_icon (container); @@ -4507,7 +4507,7 @@ end_stretching (NautilusIconContainer *container, /* now that we're done stretching, update the icon's position */ icon = container->details->drag_icon; - if (nautilus_icon_container_is_layout_rtl (container)) { + if (nautilus_canvas_container_is_layout_rtl (container)) { position.x = icon->saved_ltr_x = get_mirror_x_position (container, icon, icon->x); } else { position.x = icon->x; @@ -4515,17 +4515,17 @@ end_stretching (NautilusIconContainer *container, position.y = icon->y; position.scale = icon->scale; g_signal_emit (container, - signals[ICON_POSITION_CHANGED], 0, - icon->data, &position); + signals[ICON_POSITION_CHANGED], 0, + icon->data, &position); clear_drag_state (container); redo_layout (container); } static gboolean -undo_stretching (NautilusIconContainer *container) +undo_stretching (NautilusCanvasContainer *container) { - NautilusIcon *stretched_icon; + NautilusCanvasIcon *stretched_icon; stretched_icon = container->details->stretch_icon; @@ -4537,17 +4537,17 @@ undo_stretching (NautilusIconContainer *container) ungrab_stretch_icon (container); clear_drag_state (container); } - nautilus_icon_canvas_item_set_show_stretch_handles + nautilus_canvas_item_set_show_stretch_handles (stretched_icon->item, FALSE); icon_set_position (stretched_icon, - container->details->stretch_initial_x, - container->details->stretch_initial_y); + container->details->stretch_initial_x, + container->details->stretch_initial_y); icon_set_size (container, - stretched_icon, - container->details->stretch_initial_size, - TRUE, - TRUE); + stretched_icon, + container->details->stretch_initial_size, + TRUE, + TRUE); container->details->stretch_icon = NULL; emit_stretch_ended (container, stretched_icon); @@ -4560,11 +4560,11 @@ static gboolean button_release_event (GtkWidget *widget, GdkEventButton *event) { - NautilusIconContainer *container; - NautilusIconContainerDetails *details; + NautilusCanvasContainer *container; + NautilusCanvasContainerDetails *details; double world_x, world_y; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); details = container->details; if (event->button == RUBBERBAND_BUTTON && details->rubberband_info.active) { @@ -4578,10 +4578,10 @@ button_release_event (GtkWidget *widget, switch (details->drag_state) { case DRAG_STATE_MOVE_OR_COPY: if (!details->drag_started) { - nautilus_icon_container_did_not_drag (container, event); + nautilus_canvas_container_did_not_drag (container, event); } else { - nautilus_icon_dnd_end_drag (container); - DEBUG ("Ending drag from icon container"); + nautilus_canvas_dnd_end_drag (container); + DEBUG ("Ending drag from canvas container"); } break; case DRAG_STATE_STRETCH: @@ -4597,20 +4597,20 @@ button_release_event (GtkWidget *widget, return TRUE; } - return GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->button_release_event (widget, event); + return GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->button_release_event (widget, event); } static int motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { - NautilusIconContainer *container; - NautilusIconContainerDetails *details; + NautilusCanvasContainer *container; + NautilusCanvasContainerDetails *details; double world_x, world_y; int canvas_x, canvas_y; GdkDragAction actions; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); details = container->details; if (details->drag_button != 0) { @@ -4634,10 +4634,10 @@ motion_notify_event (GtkWidget *widget, end_renaming_mode (container, TRUE); eel_canvas_w2c (EEL_CANVAS (container), - details->drag_x, - details->drag_y, - &canvas_x, - &canvas_y); + details->drag_x, + details->drag_y, + &canvas_x, + &canvas_y); actions = GDK_ACTION_COPY | GDK_ACTION_LINK @@ -4647,13 +4647,13 @@ motion_notify_event (GtkWidget *widget, actions |= GDK_ACTION_MOVE; } - nautilus_icon_dnd_begin_drag (container, - actions, - details->drag_button, - event, - canvas_x, - canvas_y); - DEBUG ("Beginning drag from icon container"); + nautilus_canvas_dnd_begin_drag (container, + actions, + details->drag_button, + event, + canvas_x, + canvas_y); + DEBUG ("Beginning drag from canvas container"); } break; case DRAG_STATE_STRETCH: @@ -4666,26 +4666,26 @@ motion_notify_event (GtkWidget *widget, } } - return GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->motion_notify_event (widget, event); + return GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->motion_notify_event (widget, event); } static void -nautilus_icon_container_get_icon_text (NautilusIconContainer *container, - NautilusIconData *data, - char **editable_text, - char **additional_text, - gboolean include_invisible) +nautilus_canvas_container_get_icon_text (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + char **editable_text, + char **additional_text, + gboolean include_invisible) { - NautilusIconContainerClass *klass; + NautilusCanvasContainerClass *klass; - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container); + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (container); g_assert (klass->get_icon_text != NULL); klass->get_icon_text (container, data, editable_text, additional_text, include_invisible); } static gboolean -handle_popups (NautilusIconContainer *container, +handle_popups (NautilusCanvasContainer *container, GdkEventKey *event, const char *signal) { @@ -4703,10 +4703,10 @@ static int key_press_event (GtkWidget *widget, GdkEventKey *event) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; gboolean handled; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); handled = FALSE; if (is_renaming (container) || is_renaming_pending (container)) { @@ -4775,7 +4775,7 @@ key_press_event (GtkWidget *widget, case GDK_KEY_Tab: case GDK_KEY_ISO_Left_Tab: select_previous_or_next_icon (container, - (event->state & GDK_SHIFT_MASK) == 0, event); + (event->state & GDK_SHIFT_MASK) == 0, event); handled = TRUE; break; #endif @@ -4825,7 +4825,7 @@ key_press_event (GtkWidget *widget, } if (!handled) { - handled = GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->key_press_event (widget, event); + handled = GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->key_press_event (widget, event); } return handled; @@ -4834,9 +4834,9 @@ key_press_event (GtkWidget *widget, static gboolean popup_menu (GtkWidget *widget) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); if (has_selection (container)) { handle_popups (container, NULL, @@ -4850,7 +4850,7 @@ popup_menu (GtkWidget *widget) } static void -draw_canvas_background (EelCanvas *canvas, +draw_canvas_background (EelCanvas *icon, cairo_t *cr) { /* Don't chain up to the parent to avoid clearing and redrawing */ @@ -4860,9 +4860,9 @@ static void grab_notify_cb (GtkWidget *widget, gboolean was_grabbed) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); if (container->details->rubberband_info.active && !was_grabbed) { @@ -4879,28 +4879,28 @@ grab_notify_cb (GtkWidget *widget, static void text_ellipsis_limit_changed_container_callback (gpointer callback_data) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (callback_data); + container = NAUTILUS_CANVAS_CONTAINER (callback_data); invalidate_label_sizes (container); schedule_redo_layout (container); } static GObject* -nautilus_icon_container_constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) +nautilus_canvas_container_constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; GObject *object; - object = G_OBJECT_CLASS (nautilus_icon_container_parent_class)->constructor + object = G_OBJECT_CLASS (nautilus_canvas_container_parent_class)->constructor (type, n_construct_params, construct_params); - container = NAUTILUS_ICON_CONTAINER (object); - if (nautilus_icon_container_get_is_desktop (container)) { + container = NAUTILUS_CANVAS_CONTAINER (object); + if (nautilus_canvas_container_get_is_desktop (container)) { g_signal_connect_swapped (nautilus_desktop_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT, G_CALLBACK (text_ellipsis_limit_changed_container_callback), @@ -4918,12 +4918,12 @@ nautilus_icon_container_constructor (GType type, /* Initialization. */ static void -nautilus_icon_container_class_init (NautilusIconContainerClass *class) +nautilus_canvas_container_class_init (NautilusCanvasContainerClass *class) { GtkWidgetClass *widget_class; EelCanvasClass *canvas_class; - G_OBJECT_CLASS (class)->constructor = nautilus_icon_container_constructor; + G_OBJECT_CLASS (class)->constructor = nautilus_canvas_container_constructor; G_OBJECT_CLASS (class)->finalize = finalize; /* Signals. */ @@ -4932,7 +4932,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("selection_changed", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, selection_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, @@ -4941,7 +4941,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("button_press", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, button_press), NULL, NULL, g_cclosure_marshal_generic, @@ -4951,7 +4951,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("activate", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, activate), NULL, NULL, g_cclosure_marshal_VOID__POINTER, @@ -4961,7 +4961,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("activate_alternate", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, activate_alternate), NULL, NULL, g_cclosure_marshal_VOID__POINTER, @@ -4971,7 +4971,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("activate_previewer", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, activate_previewer), NULL, NULL, g_cclosure_marshal_generic, @@ -4981,7 +4981,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("context_click_selection", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, context_click_selection), NULL, NULL, g_cclosure_marshal_VOID__POINTER, @@ -4991,7 +4991,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("context_click_background", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, context_click_background), NULL, NULL, g_cclosure_marshal_VOID__POINTER, @@ -5001,7 +5001,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("middle_click", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, middle_click), NULL, NULL, g_cclosure_marshal_VOID__POINTER, @@ -5011,7 +5011,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("icon_position_changed", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, icon_position_changed), NULL, NULL, g_cclosure_marshal_generic, @@ -5022,7 +5022,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("icon_stretch_started", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, icon_stretch_started), NULL, NULL, g_cclosure_marshal_VOID__POINTER, @@ -5032,8 +5032,8 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("icon_stretch_ended", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, - icon_stretch_ended), + G_STRUCT_OFFSET (NautilusCanvasContainerClass, + icon_stretch_ended), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, @@ -5042,7 +5042,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("icon_rename_started", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, icon_rename_started), NULL, NULL, g_cclosure_marshal_VOID__POINTER, @@ -5052,7 +5052,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("icon_rename_ended", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, icon_rename_ended), NULL, NULL, g_cclosure_marshal_generic, @@ -5063,7 +5063,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("get_icon_uri", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, get_icon_uri), NULL, NULL, g_cclosure_marshal_generic, @@ -5073,7 +5073,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("get_icon_drop_target_uri", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, get_icon_drop_target_uri), NULL, NULL, g_cclosure_marshal_generic, @@ -5083,7 +5083,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("move_copy_items", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, move_copy_items), NULL, NULL, g_cclosure_marshal_generic, @@ -5098,7 +5098,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("handle_netscape_url", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, handle_netscape_url), NULL, NULL, g_cclosure_marshal_generic, @@ -5112,8 +5112,8 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("handle_uri_list", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, - handle_uri_list), + G_STRUCT_OFFSET (NautilusCanvasContainerClass, + handle_uri_list), NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 5, @@ -5126,7 +5126,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("handle_text", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, handle_text), NULL, NULL, g_cclosure_marshal_generic, @@ -5140,7 +5140,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("handle_raw", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, handle_raw), NULL, NULL, g_cclosure_marshal_generic, @@ -5156,7 +5156,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("get_container_uri", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, get_container_uri), NULL, NULL, g_cclosure_marshal_generic, @@ -5165,7 +5165,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("can_accept_item", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, can_accept_item), NULL, NULL, g_cclosure_marshal_generic, @@ -5176,7 +5176,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("get_stored_icon_position", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, get_stored_icon_position), NULL, NULL, g_cclosure_marshal_generic, @@ -5187,7 +5187,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("get_stored_layout_timestamp", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, get_stored_layout_timestamp), NULL, NULL, g_cclosure_marshal_generic, @@ -5198,7 +5198,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("store_layout_timestamp", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, store_layout_timestamp), NULL, NULL, g_cclosure_marshal_generic, @@ -5209,7 +5209,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("layout_changed", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, layout_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, @@ -5218,7 +5218,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("band_select_started", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, band_select_started), NULL, NULL, g_cclosure_marshal_VOID__VOID, @@ -5227,8 +5227,8 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("band_select_ended", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, - band_select_ended), + G_STRUCT_OFFSET (NautilusCanvasContainerClass, + band_select_ended), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); @@ -5236,7 +5236,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("icon_added", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, icon_added), NULL, NULL, g_cclosure_marshal_VOID__POINTER, @@ -5245,7 +5245,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("icon_removed", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, icon_removed), NULL, NULL, g_cclosure_marshal_VOID__POINTER, @@ -5255,7 +5255,7 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) = g_signal_new ("cleared", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusIconContainerClass, + G_STRUCT_OFFSET (NautilusCanvasContainerClass, cleared), NULL, NULL, g_cclosure_marshal_VOID__VOID, @@ -5285,17 +5285,17 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class) gtk_widget_class_install_style_property (widget_class, g_param_spec_boolean ("activate_prelight_icon_label", - "Activate Prelight Icon Label", - "Whether icon labels should make use of its prelight color in prelight state", - FALSE, - G_PARAM_READABLE)); + "Activate Prelight Icon Label", + "Whether icon labels should make use of its prelight color in prelight state", + FALSE, + G_PARAM_READABLE)); } static void -update_selected (NautilusIconContainer *container) +update_selected (NautilusCanvasContainer *container) { GList *node; - NautilusIcon *icon; + NautilusCanvasIcon *icon; for (node = container->details->icons; node != NULL; node = node->next) { icon = node->data; @@ -5308,7 +5308,7 @@ update_selected (NautilusIconContainer *container) static gboolean handle_focus_in_event (GtkWidget *widget, GdkEventFocus *event, gpointer user_data) { - update_selected (NAUTILUS_ICON_CONTAINER (widget)); + update_selected (NAUTILUS_CANVAS_CONTAINER (widget)); return FALSE; } @@ -5317,8 +5317,8 @@ static gboolean handle_focus_out_event (GtkWidget *widget, GdkEventFocus *event, gpointer user_data) { /* End renaming and commit change. */ - end_renaming_mode (NAUTILUS_ICON_CONTAINER (widget), TRUE); - update_selected (NAUTILUS_ICON_CONTAINER (widget)); + end_renaming_mode (NAUTILUS_CANVAS_CONTAINER (widget), TRUE); + update_selected (NAUTILUS_CANVAS_CONTAINER (widget)); return FALSE; } @@ -5408,12 +5408,12 @@ desktop_text_ellipsis_limit_changed_callback (gpointer callback_data) } static void -nautilus_icon_container_init (NautilusIconContainer *container) +nautilus_canvas_container_init (NautilusCanvasContainer *container) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; static gboolean setup_prefs = FALSE; - details = g_new0 (NautilusIconContainerDetails, 1); + details = g_new0 (NautilusCanvasContainerDetails, 1); details->icon_set = g_hash_table_new (g_direct_hash, g_direct_equal); details->layout_timestamp = UNDEFINED_TIME; @@ -5444,16 +5444,16 @@ nautilus_icon_container_init (NautilusIconContainer *container) } typedef struct { - NautilusIconContainer *container; + NautilusCanvasContainer *container; GdkEventButton *event; } ContextMenuParameters; static gboolean -handle_icon_double_click (NautilusIconContainer *container, - NautilusIcon *icon, - GdkEventButton *event) +handle_canvas_double_click (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, + GdkEventButton *event) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; if (event->button != DRAG_BUTTON) { return FALSE; @@ -5478,7 +5478,7 @@ handle_icon_double_click (NautilusIconContainer *container, return FALSE; } -/* NautilusIcon event handling. */ +/* NautilusCanvasIcon event handling. */ /* Conceptually, pressing button 1 together with CTRL or SHIFT toggles * selection of a single icon without affecting the other icons; @@ -5487,14 +5487,14 @@ handle_icon_double_click (NautilusIconContainer *container, * only happen when the button is released if the icon is already * selected, because the user might select multiple icons and drag all * of them by doing a simple click-drag. -*/ + */ static gboolean -handle_icon_button_press (NautilusIconContainer *container, - NautilusIcon *icon, - GdkEventButton *event) +handle_canvas_button_press (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, + GdkEventButton *event) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; details = container->details; @@ -5518,7 +5518,7 @@ handle_icon_button_press (NautilusIconContainer *container, details->double_click_button[0] = event->button; } - if (handle_icon_double_click (container, icon, event)) { + if (handle_canvas_double_click (container, icon, event)) { /* Double clicking does not trigger a D&D action. */ details->drag_button = 0; details->drag_icon = NULL; @@ -5527,7 +5527,7 @@ handle_icon_button_press (NautilusIconContainer *container, if (event->button == DRAG_BUTTON || event->button == DRAG_MENU_BUTTON) { - details->drag_button = event->button; + details->drag_button = event->button; details->drag_icon = icon; details->drag_x = event->x; details->drag_y = event->y; @@ -5551,7 +5551,7 @@ handle_icon_button_press (NautilusIconContainer *container, if ((event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON) && (event->state & GDK_SHIFT_MASK) != 0) { - NautilusIcon *start_icon; + NautilusCanvasIcon *start_icon; start_icon = details->range_selection_base_icon; if (start_icon == NULL || !start_icon->is_selected) { @@ -5593,17 +5593,17 @@ item_event_callback (EelCanvasItem *item, GdkEvent *event, gpointer data) { - NautilusIconContainer *container; - NautilusIcon *icon; + NautilusCanvasContainer *container; + NautilusCanvasIcon *icon; - container = NAUTILUS_ICON_CONTAINER (data); + container = NAUTILUS_CANVAS_CONTAINER (data); - icon = NAUTILUS_ICON_CANVAS_ITEM (item)->user_data; + icon = NAUTILUS_CANVAS_ITEM (item)->user_data; g_assert (icon != NULL); switch (event->type) { case GDK_BUTTON_PRESS: - if (handle_icon_button_press (container, icon, &event->button)) { + if (handle_canvas_button_press (container, icon, &event->button)) { /* Stop the event from being passed along further. Returning * TRUE ain't enough. */ @@ -5616,20 +5616,20 @@ item_event_callback (EelCanvasItem *item, } GtkWidget * -nautilus_icon_container_new (void) +nautilus_canvas_container_new (void) { - return gtk_widget_new (NAUTILUS_TYPE_ICON_CONTAINER, NULL); + return gtk_widget_new (NAUTILUS_TYPE_CANVAS_CONTAINER, NULL); } /* Clear all of the icons in the container. */ void -nautilus_icon_container_clear (NautilusIconContainer *container) +nautilus_canvas_container_clear (NautilusCanvasContainer *container) { - NautilusIconContainerDetails *details; - NautilusIcon *icon; + NautilusCanvasContainerDetails *details; + NautilusCanvasIcon *icon; GList *p; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); details = container->details; details->layout_timestamp = UNDEFINED_TIME; @@ -5651,9 +5651,9 @@ nautilus_icon_container_clear (NautilusIconContainer *container) 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); + nautilus_canvas_container_stop_monitor_top_left (container, + icon->data, + icon); } icon_free (p->data); } @@ -5665,20 +5665,20 @@ nautilus_icon_container_clear (NautilusIconContainer *container) g_hash_table_destroy (details->icon_set); details->icon_set = g_hash_table_new (g_direct_hash, g_direct_equal); - nautilus_icon_container_update_scroll_region (container); + nautilus_canvas_container_update_scroll_region (container); } gboolean -nautilus_icon_container_is_empty (NautilusIconContainer *container) +nautilus_canvas_container_is_empty (NautilusCanvasContainer *container) { return container->details->icons == NULL; } -NautilusIconData * -nautilus_icon_container_get_first_visible_icon (NautilusIconContainer *container) +NautilusCanvasIconData * +nautilus_canvas_container_get_first_visible_icon (NautilusCanvasContainer *container) { GList *l; - NautilusIcon *icon, *best_icon; + NautilusCanvasIcon *icon, *best_icon; double x, y; double x1, y1, x2, y2; double *pos, best_pos; @@ -5690,7 +5690,7 @@ nautilus_icon_container_get_first_visible_icon (NautilusIconContainer *container vadj_v = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))); h_page_size = gtk_adjustment_get_page_size (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))); - if (nautilus_icon_container_is_layout_rtl (container)) { + if (nautilus_canvas_container_is_layout_rtl (container)) { x = hadj_v + h_page_size - ICON_PAD_LEFT - 1; y = vadj_v; } else { @@ -5713,9 +5713,9 @@ nautilus_icon_container_get_first_visible_icon (NautilusIconContainer *container &x1, &y1, &x2, &y2); compare_lt = FALSE; - if (nautilus_icon_container_is_layout_vertical (container)) { + if (nautilus_canvas_container_is_layout_vertical (container)) { pos = &x1; - if (nautilus_icon_container_is_layout_rtl (container)) { + if (nautilus_canvas_container_is_layout_rtl (container)) { compare_lt = TRUE; better_icon = x1 < x + ICON_PAD_LEFT; } else { @@ -5749,11 +5749,11 @@ nautilus_icon_container_get_first_visible_icon (NautilusIconContainer *container /* puts the icon at the top of the screen */ void -nautilus_icon_container_scroll_to_icon (NautilusIconContainer *container, - NautilusIconData *data) +nautilus_canvas_container_scroll_to_canvas (NautilusCanvasContainer *container, + NautilusCanvasIconData *data) { GList *l; - NautilusIcon *icon; + NautilusCanvasIcon *icon; GtkAdjustment *hadj, *vadj; EelIRect bounds; GtkAllocation allocation; @@ -5764,7 +5764,7 @@ nautilus_icon_container_scroll_to_icon (NautilusIconContainer *container, /* We need to force a relayout now if there are updates queued * since we need the final positions */ - nautilus_icon_container_layout_now (container); + nautilus_canvas_container_layout_now (container); l = container->details->icons; while (l != NULL) { @@ -5773,15 +5773,15 @@ nautilus_icon_container_scroll_to_icon (NautilusIconContainer *container, if (icon->data == data && icon_is_positioned (icon)) { - if (nautilus_icon_container_is_auto_layout (container)) { + if (nautilus_canvas_container_is_auto_layout (container)) { /* ensure that we reveal the entire row/column */ icon_get_row_and_column_bounds (container, icon, &bounds, TRUE); } else { item_get_canvas_bounds (EEL_CANVAS_ITEM (icon->item), &bounds, TRUE); } - if (nautilus_icon_container_is_layout_vertical (container)) { - if (nautilus_icon_container_is_layout_rtl (container)) { + if (nautilus_canvas_container_is_layout_vertical (container)) { + if (nautilus_canvas_container_is_layout_rtl (container)) { gtk_adjustment_set_value (hadj, bounds.x1 - allocation.width); } else { gtk_adjustment_set_value (hadj, bounds.x0); @@ -5797,14 +5797,14 @@ nautilus_icon_container_scroll_to_icon (NautilusIconContainer *container, /* Call a function for all the icons. */ typedef struct { - NautilusIconCallback callback; + NautilusCanvasCallback callback; gpointer callback_data; } CallbackAndData; static void -call_icon_callback (gpointer data, gpointer callback_data) +call_canvas_callback (gpointer data, gpointer callback_data) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; CallbackAndData *callback_and_data; icon = data; @@ -5813,27 +5813,27 @@ call_icon_callback (gpointer data, gpointer callback_data) } void -nautilus_icon_container_for_each (NautilusIconContainer *container, - NautilusIconCallback callback, - gpointer callback_data) +nautilus_canvas_container_for_each (NautilusCanvasContainer *container, + NautilusCanvasCallback callback, + gpointer callback_data) { CallbackAndData callback_and_data; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); callback_and_data.callback = callback; callback_and_data.callback_data = callback_data; g_list_foreach (container->details->icons, - call_icon_callback, &callback_and_data); + call_canvas_callback, &callback_and_data); } static int selection_changed_at_idle_callback (gpointer data) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (data); + container = NAUTILUS_CANVAS_CONTAINER (data); g_signal_emit (container, signals[SELECTION_CHANGED], 0); @@ -5845,12 +5845,12 @@ selection_changed_at_idle_callback (gpointer data) /* utility routine to remove a single icon from the container */ static void -icon_destroy (NautilusIconContainer *container, - NautilusIcon *icon) +icon_destroy (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; gboolean was_selected; - NautilusIcon *icon_to_focus; + NautilusCanvasIcon *icon_to_focus; GList *item; details = container->details; @@ -5898,9 +5898,9 @@ icon_destroy (NautilusIconContainer *container, } if (icon->is_monitored) { - nautilus_icon_container_stop_monitor_top_left (container, - icon->data, - icon); + nautilus_canvas_container_stop_monitor_top_left (container, + icon->data, + icon); } icon_free (icon); @@ -5912,32 +5912,32 @@ icon_destroy (NautilusIconContainer *container, /* activate any selected items in the container */ static void -activate_selected_items (NautilusIconContainer *container) +activate_selected_items (NautilusCanvasContainer *container) { GList *selection; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); - selection = nautilus_icon_container_get_selection (container); + selection = nautilus_canvas_container_get_selection (container); if (selection != NULL) { g_signal_emit (container, - signals[ACTIVATE], 0, - selection); + signals[ACTIVATE], 0, + selection); } g_list_free (selection); } static void -preview_selected_items (NautilusIconContainer *container) +preview_selected_items (NautilusCanvasContainer *container) { GList *selection; GArray *locations; gint idx; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); - selection = nautilus_icon_container_get_selection (container); - locations = nautilus_icon_container_get_selected_icon_locations (container); + selection = nautilus_canvas_container_get_selection (container); + locations = nautilus_canvas_container_get_selected_icon_locations (container); for (idx = 0; idx < locations->len; idx++) { GdkPoint *point = &(g_array_index (locations, GdkPoint, idx)); @@ -5959,30 +5959,30 @@ preview_selected_items (NautilusIconContainer *container) } static void -activate_selected_items_alternate (NautilusIconContainer *container, - NautilusIcon *icon) +activate_selected_items_alternate (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { GList *selection; - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); if (icon != NULL) { selection = g_list_prepend (NULL, icon->data); } else { - selection = nautilus_icon_container_get_selection (container); + selection = nautilus_canvas_container_get_selection (container); } if (selection != NULL) { g_signal_emit (container, - signals[ACTIVATE_ALTERNATE], 0, - selection); + signals[ACTIVATE_ALTERNATE], 0, + selection); } g_list_free (selection); } -static NautilusIcon * -get_icon_being_renamed (NautilusIconContainer *container) +static NautilusCanvasIcon * +get_icon_being_renamed (NautilusCanvasContainer *container) { - NautilusIcon *rename_icon; + NautilusCanvasIcon *rename_icon; if (!is_renaming (container)) { return NULL; @@ -5997,67 +5997,67 @@ get_icon_being_renamed (NautilusIconContainer *container) } static NautilusIconInfo * -nautilus_icon_container_get_icon_images (NautilusIconContainer *container, - NautilusIconData *data, - int size, - char **embedded_text, - gboolean for_drag_accept, - gboolean need_large_embeddded_text, - gboolean *embedded_text_needs_loading, - gboolean *has_open_window) -{ - NautilusIconContainerClass *klass; - - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container); +nautilus_canvas_container_get_icon_images (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + int size, + char **embedded_text, + gboolean for_drag_accept, + gboolean need_large_embeddded_text, + gboolean *embedded_text_needs_loading, + gboolean *has_open_window) +{ + NautilusCanvasContainerClass *klass; + + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (container); g_assert (klass->get_icon_images != NULL); return klass->get_icon_images (container, data, size, embedded_text, for_drag_accept, need_large_embeddded_text, embedded_text_needs_loading, has_open_window); } static void -nautilus_icon_container_freeze_updates (NautilusIconContainer *container) +nautilus_canvas_container_freeze_updates (NautilusCanvasContainer *container) { - NautilusIconContainerClass *klass; + NautilusCanvasContainerClass *klass; - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container); + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (container); g_assert (klass->freeze_updates != NULL); klass->freeze_updates (container); } static void -nautilus_icon_container_unfreeze_updates (NautilusIconContainer *container) +nautilus_canvas_container_unfreeze_updates (NautilusCanvasContainer *container) { - NautilusIconContainerClass *klass; + NautilusCanvasContainerClass *klass; - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container); + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (container); g_assert (klass->unfreeze_updates != NULL); klass->unfreeze_updates (container); } static void -nautilus_icon_container_start_monitor_top_left (NautilusIconContainer *container, - NautilusIconData *data, - gconstpointer client, - gboolean large_text) +nautilus_canvas_container_start_monitor_top_left (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + gconstpointer client, + gboolean large_text) { - NautilusIconContainerClass *klass; + NautilusCanvasContainerClass *klass; - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container); + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (container); g_assert (klass->start_monitor_top_left != NULL); klass->start_monitor_top_left (container, data, client, large_text); } static void -nautilus_icon_container_stop_monitor_top_left (NautilusIconContainer *container, - NautilusIconData *data, - gconstpointer client) +nautilus_canvas_container_stop_monitor_top_left (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + gconstpointer client) { - NautilusIconContainerClass *klass; + NautilusCanvasContainerClass *klass; - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container); + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (container); g_return_if_fail (klass->stop_monitor_top_left != NULL); klass->stop_monitor_top_left (container, data, client); @@ -6065,26 +6065,26 @@ nautilus_icon_container_stop_monitor_top_left (NautilusIconContainer *container, static void -nautilus_icon_container_prioritize_thumbnailing (NautilusIconContainer *container, - NautilusIcon *icon) +nautilus_canvas_container_prioritize_thumbnailing (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { - NautilusIconContainerClass *klass; + NautilusCanvasContainerClass *klass; - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container); + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (container); g_assert (klass->prioritize_thumbnailing != NULL); klass->prioritize_thumbnailing (container, icon->data); } static void -nautilus_icon_container_update_visible_icons (NautilusIconContainer *container) +nautilus_canvas_container_update_visible_icons (NautilusCanvasContainer *container) { GtkAdjustment *vadj, *hadj; double min_y, max_y; double min_x, max_x; double x0, y0, x1, y1; GList *node; - NautilusIcon *icon; + NautilusCanvasIcon *icon; gboolean visible; GtkAllocation allocation; @@ -6122,18 +6122,18 @@ nautilus_icon_container_update_visible_icons (NautilusIconContainer *container) &x1, &y1); - if (nautilus_icon_container_is_layout_vertical (container)) { + if (nautilus_canvas_container_is_layout_vertical (container)) { visible = x1 >= min_x && x0 <= max_x; } else { visible = y1 >= min_y && y0 <= max_y; } if (visible) { - nautilus_icon_canvas_item_set_is_visible (icon->item, TRUE); - nautilus_icon_container_prioritize_thumbnailing (container, - icon); + nautilus_canvas_item_set_is_visible (icon->item, TRUE); + nautilus_canvas_container_prioritize_thumbnailing (container, + icon); } else { - nautilus_icon_canvas_item_set_is_visible (icon->item, FALSE); + nautilus_canvas_item_set_is_visible (icon->item, FALSE); } } } @@ -6141,28 +6141,28 @@ nautilus_icon_container_update_visible_icons (NautilusIconContainer *container) static void handle_vadjustment_changed (GtkAdjustment *adjustment, - NautilusIconContainer *container) + NautilusCanvasContainer *container) { - if (!nautilus_icon_container_is_layout_vertical (container)) { - nautilus_icon_container_update_visible_icons (container); + if (!nautilus_canvas_container_is_layout_vertical (container)) { + nautilus_canvas_container_update_visible_icons (container); } } static void handle_hadjustment_changed (GtkAdjustment *adjustment, - NautilusIconContainer *container) + NautilusCanvasContainer *container) { - if (nautilus_icon_container_is_layout_vertical (container)) { - nautilus_icon_container_update_visible_icons (container); + if (nautilus_canvas_container_is_layout_vertical (container)) { + nautilus_canvas_container_update_visible_icons (container); } } void -nautilus_icon_container_update_icon (NautilusIconContainer *container, - NautilusIcon *icon) +nautilus_canvas_container_update_icon (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; guint icon_size; guint min_image_size, max_image_size; NautilusIconInfo *icon_info; @@ -6198,30 +6198,30 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container, /* Get the icons. */ embedded_text = NULL; large_embedded_text = icon_size > ICON_SIZE_FOR_LARGE_EMBEDDED_TEXT; - icon_info = nautilus_icon_container_get_icon_images (container, icon->data, icon_size, - &embedded_text, - icon == details->drop_target, - large_embedded_text, &embedded_text_needs_loading, - &has_open_window); + icon_info = nautilus_canvas_container_get_icon_images (container, icon->data, icon_size, + &embedded_text, + icon == details->drop_target, + large_embedded_text, &embedded_text_needs_loading, + &has_open_window); pixbuf = nautilus_icon_info_get_pixbuf (icon_info); nautilus_icon_info_get_attach_points (icon_info, &attach_points, &n_attach_points); has_embedded_text_rect = nautilus_icon_info_get_embedded_rect (icon_info, - &embedded_text_rect); + &embedded_text_rect); g_object_unref (icon_info); if (has_embedded_text_rect && embedded_text_needs_loading) { icon->is_monitored = TRUE; - nautilus_icon_container_start_monitor_top_left (container, icon->data, icon, large_embedded_text); + nautilus_canvas_container_start_monitor_top_left (container, icon->data, icon, large_embedded_text); } - nautilus_icon_container_get_icon_text (container, - icon->data, - &editable_text, - &additional_text, - FALSE); + nautilus_canvas_container_get_icon_text (container, + icon->data, + &editable_text, + &additional_text, + FALSE); /* If name of icon being renamed was changed from elsewhere, end renaming mode. * Alternatively, we could replace the characters in the editable text widget @@ -6230,7 +6230,7 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container, */ if (icon == get_icon_being_renamed (container) && g_strcmp0 (editable_text, - nautilus_icon_canvas_item_get_editable_text (icon->item)) != 0) { + nautilus_canvas_item_get_editable_text (icon->item)) != 0) { end_renaming_mode (container, FALSE); } @@ -6240,10 +6240,10 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container, "highlighted_for_drop", icon == details->drop_target, NULL); - nautilus_icon_canvas_item_set_image (icon->item, pixbuf); - nautilus_icon_canvas_item_set_attach_points (icon->item, attach_points, n_attach_points); - nautilus_icon_canvas_item_set_embedded_text_rect (icon->item, &embedded_text_rect); - nautilus_icon_canvas_item_set_embedded_text (icon->item, embedded_text); + nautilus_canvas_item_set_image (icon->item, pixbuf); + nautilus_canvas_item_set_attach_points (icon->item, attach_points, n_attach_points); + nautilus_canvas_item_set_embedded_text_rect (icon->item, &embedded_text_rect); + nautilus_canvas_item_set_embedded_text (icon->item, embedded_text); /* Let the pixbufs go. */ g_object_unref (pixbuf); @@ -6253,20 +6253,20 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container, } static gboolean -assign_icon_position (NautilusIconContainer *container, - NautilusIcon *icon) +assign_icon_position (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { gboolean have_stored_position; - NautilusIconPosition position; + NautilusCanvasPosition position; /* Get the stored position. */ have_stored_position = FALSE; position.scale = 1.0; g_signal_emit (container, - signals[GET_STORED_ICON_POSITION], 0, - icon->data, - &position, - &have_stored_position); + signals[GET_STORED_ICON_POSITION], 0, + icon->data, + &position, + &have_stored_position); icon->scale = position.scale; if (!container->details->auto_layout) { if (have_stored_position) { @@ -6280,10 +6280,10 @@ assign_icon_position (NautilusIconContainer *container, } static void -finish_adding_icon (NautilusIconContainer *container, - NautilusIcon *icon) +finish_adding_icon (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { - nautilus_icon_container_update_icon (container, icon); + nautilus_canvas_container_update_icon (container, icon); eel_canvas_item_show (EEL_CANVAS_ITEM (icon->item)); g_signal_connect_object (icon->item, "event", @@ -6293,10 +6293,10 @@ finish_adding_icon (NautilusIconContainer *container, } static void -finish_adding_new_icons (NautilusIconContainer *container) +finish_adding_new_icons (NautilusCanvasContainer *container) { GList *p, *new_icons, *no_position_icons, *semi_position_icons; - NautilusIcon *icon; + NautilusCanvasIcon *icon; double bottom; new_icons = container->details->new_icons; @@ -6342,8 +6342,8 @@ finish_adding_new_icons (NautilusIconContainer *container) now = time (NULL); for (p = semi_position_icons; p != NULL; p = p->next) { - NautilusIcon *icon; - NautilusIconPosition position; + NautilusCanvasIcon *icon; + NautilusCanvasPosition position; int x, y; icon = p->data; @@ -6379,7 +6379,7 @@ finish_adding_new_icons (NautilusIconContainer *container) g_assert (!container->details->auto_layout); sort_icons (container, &no_position_icons); - if (nautilus_icon_container_get_is_desktop (container)) { + if (nautilus_canvas_container_get_is_desktop (container)) { lay_down_icons (container, no_position_icons, CONTAINER_PAD_TOP); } else { get_all_icon_bounds (container, NULL, NULL, NULL, &bottom, BOUNDS_USAGE_FOR_LAYOUT); @@ -6395,8 +6395,8 @@ finish_adding_new_icons (NautilusIconContainer *container) } static gboolean -is_old_or_unknown_icon_data (NautilusIconContainer *container, - NautilusIconData *data) +is_old_or_unknown_icon_data (NautilusCanvasContainer *container, + NautilusCanvasIconData *data) { time_t timestamp; gboolean success; @@ -6413,22 +6413,22 @@ is_old_or_unknown_icon_data (NautilusIconContainer *container, } /** - * nautilus_icon_container_add: - * @container: A NautilusIconContainer + * nautilus_canvas_container_add: + * @container: A NautilusCanvasContainer * @data: Icon data. * * Add icon to represent @data to container. * Returns FALSE if there was already such an icon. **/ gboolean -nautilus_icon_container_add (NautilusIconContainer *container, - NautilusIconData *data) +nautilus_canvas_container_add (NautilusCanvasContainer *container, + NautilusCanvasIconData *data) { - NautilusIconContainerDetails *details; - NautilusIcon *icon; + NautilusCanvasContainerDetails *details; + NautilusCanvasIcon *icon; EelCanvasItem *band, *item; - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), FALSE); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), FALSE); g_return_val_if_fail (data != NULL, FALSE); details = container->details; @@ -6438,7 +6438,7 @@ nautilus_icon_container_add (NautilusIconContainer *container, } /* Create the new icon, including the canvas item. */ - icon = g_new0 (NautilusIcon, 1); + icon = g_new0 (NautilusCanvasIcon, 1); icon->data = data; icon->x = ICON_UNPOSITIONED_VALUE; icon->y = ICON_UNPOSITIONED_VALUE; @@ -6449,16 +6449,16 @@ nautilus_icon_container_add (NautilusIconContainer *container, */ icon->has_lazy_position = is_old_or_unknown_icon_data (container, data); icon->scale = 1.0; - icon->item = NAUTILUS_ICON_CANVAS_ITEM + icon->item = NAUTILUS_CANVAS_ITEM (eel_canvas_item_new (EEL_CANVAS_GROUP (EEL_CANVAS (container)->root), - nautilus_icon_canvas_item_get_type (), + nautilus_canvas_item_get_type (), "visible", FALSE, NULL)); icon->item->user_data = icon; /* Make sure the icon is under the selection_rectangle */ item = EEL_CANVAS_ITEM (icon->item); - band = NAUTILUS_ICON_CONTAINER (item->canvas)->details->rubberband_info.selection_rectangle; + band = NAUTILUS_CANVAS_CONTAINER (item->canvas)->details->rubberband_info.selection_rectangle; if (band) { eel_canvas_item_send_behind (item, band); } @@ -6478,7 +6478,7 @@ nautilus_icon_container_add (NautilusIconContainer *container, } void -nautilus_icon_container_layout_now (NautilusIconContainer *container) +nautilus_canvas_container_layout_now (NautilusCanvasContainer *container) { if (container->details->idle_id != 0) { unschedule_redo_layout (container); @@ -6492,19 +6492,19 @@ nautilus_icon_container_layout_now (NautilusIconContainer *container) } /** - * nautilus_icon_container_remove: - * @container: A NautilusIconContainer. + * nautilus_canvas_container_remove: + * @container: A NautilusCanvasContainer. * @data: Icon data. * * Remove the icon with this data. **/ gboolean -nautilus_icon_container_remove (NautilusIconContainer *container, - NautilusIconData *data) +nautilus_canvas_container_remove (NautilusCanvasContainer *container, + NautilusCanvasIconData *data) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), FALSE); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), FALSE); g_return_val_if_fail (data != NULL, FALSE); end_renaming_mode (container, FALSE); @@ -6524,25 +6524,25 @@ nautilus_icon_container_remove (NautilusIconContainer *container, } /** - * nautilus_icon_container_request_update: - * @container: A NautilusIconContainer. + * nautilus_canvas_container_request_update: + * @container: A NautilusCanvasContainer. * @data: Icon data. * * Update the icon with this data. **/ void -nautilus_icon_container_request_update (NautilusIconContainer *container, - NautilusIconData *data) +nautilus_canvas_container_request_update (NautilusCanvasContainer *container, + NautilusCanvasIconData *data) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); g_return_if_fail (data != NULL); icon = g_hash_table_lookup (container->details->icon_set, data); if (icon != NULL) { - nautilus_icon_container_update_icon (container, icon); + nautilus_canvas_container_update_icon (container, icon); container->details->needs_resort = TRUE; schedule_redo_layout (container); } @@ -6551,15 +6551,15 @@ nautilus_icon_container_request_update (NautilusIconContainer *container, /* zooming */ NautilusZoomLevel -nautilus_icon_container_get_zoom_level (NautilusIconContainer *container) +nautilus_canvas_container_get_zoom_level (NautilusCanvasContainer *container) { return container->details->zoom_level; } void -nautilus_icon_container_set_zoom_level (NautilusIconContainer *container, int new_level) +nautilus_canvas_container_set_zoom_level (NautilusCanvasContainer *container, int new_level) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; int pinned_level; double pixels_per_unit; @@ -6585,27 +6585,27 @@ nautilus_icon_container_set_zoom_level (NautilusIconContainer *container, int ne eel_canvas_set_pixels_per_unit (EEL_CANVAS (container), pixels_per_unit); invalidate_labels (container); - nautilus_icon_container_request_update_all (container); + nautilus_canvas_container_request_update_all (container); } /** - * nautilus_icon_container_request_update_all: + * nautilus_canvas_container_request_update_all: * For each icon, synchronizes the displayed information (image, text) with the * information from the model. * - * @container: An icon container. + * @container: An canvas container. **/ void -nautilus_icon_container_request_update_all (NautilusIconContainer *container) +nautilus_canvas_container_request_update_all (NautilusCanvasContainer *container) { GList *node; - NautilusIcon *icon; + NautilusCanvasIcon *icon; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); for (node = container->details->icons; node != NULL; node = node->next) { icon = node->data; - nautilus_icon_container_update_icon (container, icon); + nautilus_canvas_container_update_icon (container, icon); } container->details->needs_resort = TRUE; @@ -6613,15 +6613,15 @@ nautilus_icon_container_request_update_all (NautilusIconContainer *container) } /** - * nautilus_icon_container_reveal: + * nautilus_canvas_container_reveal: * Change scroll position as necessary to reveal the specified item. */ void -nautilus_icon_container_reveal (NautilusIconContainer *container, NautilusIconData *data) +nautilus_canvas_container_reveal (NautilusCanvasContainer *container, NautilusCanvasIconData *data) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); g_return_if_fail (data != NULL); icon = g_hash_table_lookup (container->details->icon_set, data); @@ -6632,25 +6632,25 @@ nautilus_icon_container_reveal (NautilusIconContainer *container, NautilusIconDa } /** - * nautilus_icon_container_get_selection: - * @container: An icon container. + * nautilus_canvas_container_get_selection: + * @container: An canvas container. * * Get a list of the icons currently selected in @container. * * Return value: A GList of the programmer-specified data associated to each - * selected icon, or NULL if no icon is selected. The caller is expected to + * selected icon, or NULL if no canvas is selected. The caller is expected to * free the list when it is not needed anymore. **/ GList * -nautilus_icon_container_get_selection (NautilusIconContainer *container) +nautilus_canvas_container_get_selection (NautilusCanvasContainer *container) { GList *list, *p; - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), NULL); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), NULL); list = NULL; for (p = container->details->icons; p != NULL; p = p->next) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; icon = p->data; if (icon->is_selected) { @@ -6662,15 +6662,15 @@ nautilus_icon_container_get_selection (NautilusIconContainer *container) } static GList * -nautilus_icon_container_get_selected_icons (NautilusIconContainer *container) +nautilus_canvas_container_get_selected_icons (NautilusCanvasContainer *container) { GList *list, *p; - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), NULL); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), NULL); list = NULL; for (p = container->details->icons; p != NULL; p = p->next) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; icon = p->data; if (icon->is_selected) { @@ -6682,21 +6682,21 @@ nautilus_icon_container_get_selected_icons (NautilusIconContainer *container) } /** - * nautilus_icon_container_invert_selection: - * @container: An icon container. + * nautilus_canvas_container_invert_selection: + * @container: An canvas container. * * Inverts the selection in @container. * **/ void -nautilus_icon_container_invert_selection (NautilusIconContainer *container) +nautilus_canvas_container_invert_selection (NautilusCanvasContainer *container) { GList *p; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); for (p = container->details->icons; p != NULL; p = p->next) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; icon = p->data; icon_toggle_selected (container, icon); @@ -6708,8 +6708,8 @@ nautilus_icon_container_invert_selection (NautilusIconContainer *container) /* Returns an array of GdkPoints of locations of the icons. */ static GArray * -nautilus_icon_container_get_icon_locations (NautilusIconContainer *container, - GList *icons) +nautilus_canvas_container_get_icon_locations (NautilusCanvasContainer *container, + GList *icons) { GArray *result; GList *node; @@ -6720,49 +6720,49 @@ nautilus_icon_container_get_icon_locations (NautilusIconContainer *container, for (index = 0, node = icons; node != NULL; index++, node = node->next) { g_array_index (result, GdkPoint, index).x = - ((NautilusIcon *)node->data)->x; + ((NautilusCanvasIcon *)node->data)->x; g_array_index (result, GdkPoint, index).y = - ((NautilusIcon *)node->data)->y; + ((NautilusCanvasIcon *)node->data)->y; } return result; } /** - * nautilus_icon_container_get_selected_icon_locations: - * @container: An icon container widget. + * nautilus_canvas_container_get_selected_icon_locations: + * @container: An canvas container widget. * * Returns an array of GdkPoints of locations of the selected icons. **/ GArray * -nautilus_icon_container_get_selected_icon_locations (NautilusIconContainer *container) +nautilus_canvas_container_get_selected_icon_locations (NautilusCanvasContainer *container) { GArray *result; GList *icons; - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), NULL); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), NULL); - icons = nautilus_icon_container_get_selected_icons (container); - result = nautilus_icon_container_get_icon_locations (container, icons); + icons = nautilus_canvas_container_get_selected_icons (container); + result = nautilus_canvas_container_get_icon_locations (container, icons); g_list_free (icons); return result; } /** - * nautilus_icon_container_select_all: - * @container: An icon container widget. + * nautilus_canvas_container_select_all: + * @container: An canvas container widget. * * Select all the icons in @container at once. **/ void -nautilus_icon_container_select_all (NautilusIconContainer *container) +nautilus_canvas_container_select_all (NautilusCanvasContainer *container) { gboolean selection_changed; GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); selection_changed = FALSE; @@ -6774,29 +6774,29 @@ nautilus_icon_container_select_all (NautilusIconContainer *container) if (selection_changed) { g_signal_emit (container, - signals[SELECTION_CHANGED], 0); + signals[SELECTION_CHANGED], 0); } } /** - * nautilus_icon_container_set_selection: - * @container: An icon container widget. - * @selection: A list of NautilusIconData *. + * nautilus_canvas_container_set_selection: + * @container: An canvas container widget. + * @selection: A list of NautilusCanvasIconData *. * * Set the selection to exactly the icons in @container which have * programmer data matching one of the items in @selection. **/ void -nautilus_icon_container_set_selection (NautilusIconContainer *container, - GList *selection) +nautilus_canvas_container_set_selection (NautilusCanvasContainer *container, + GList *selection) { gboolean selection_changed; GHashTable *hash; GList *p; gboolean res; - NautilusIcon *icon, *selected_icon; + NautilusCanvasIcon *icon, *selected_icon; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); selection_changed = FALSE; selected_icon = NULL; @@ -6821,33 +6821,33 @@ nautilus_icon_container_set_selection (NautilusIconContainer *container, if (selection_changed) { /* if only one item has been selected, use it as range - * selection base (cf. handle_icon_button_press) */ + * selection base (cf. handle_canvas_button_press) */ if (g_list_length (selection) == 1) { container->details->range_selection_base_icon = selected_icon; } g_signal_emit (container, - signals[SELECTION_CHANGED], 0); + signals[SELECTION_CHANGED], 0); } } /** - * nautilus_icon_container_select_list_unselect_others. - * @container: An icon container widget. - * @selection: A list of NautilusIcon *. + * nautilus_canvas_container_select_list_unselect_others. + * @container: An canvas container widget. + * @selection: A list of NautilusCanvasIcon *. * * Set the selection to exactly the icons in @selection. **/ void -nautilus_icon_container_select_list_unselect_others (NautilusIconContainer *container, - GList *selection) +nautilus_canvas_container_select_list_unselect_others (NautilusCanvasContainer *container, + GList *selection) { gboolean selection_changed; GHashTable *hash; GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); selection_changed = FALSE; @@ -6866,56 +6866,56 @@ nautilus_icon_container_select_list_unselect_others (NautilusIconContainer *cont if (selection_changed) { g_signal_emit (container, - signals[SELECTION_CHANGED], 0); + signals[SELECTION_CHANGED], 0); } } /** - * nautilus_icon_container_unselect_all: - * @container: An icon container widget. + * nautilus_canvas_container_unselect_all: + * @container: An canvas container widget. * * Deselect all the icons in @container. **/ void -nautilus_icon_container_unselect_all (NautilusIconContainer *container) +nautilus_canvas_container_unselect_all (NautilusCanvasContainer *container) { if (unselect_all (container)) { g_signal_emit (container, - signals[SELECTION_CHANGED], 0); + signals[SELECTION_CHANGED], 0); } } /** - * nautilus_icon_container_get_icon_by_uri: - * @container: An icon container widget. - * @uri: The uri of an icon to find. + * nautilus_canvas_container_get_icon_by_uri: + * @container: An canvas container widget. + * @uri: The uri of an canvas to find. * * Locate an icon, given the URI. The URI must match exactly. * Later we may have to have some way of figuring out if the * URI specifies the same object that does not require an exact match. **/ -NautilusIcon * -nautilus_icon_container_get_icon_by_uri (NautilusIconContainer *container, - const char *uri) +NautilusCanvasIcon * +nautilus_canvas_container_get_icon_by_uri (NautilusCanvasContainer *container, + const char *uri) { - NautilusIconContainerDetails *details; + NautilusCanvasContainerDetails *details; GList *p; - /* Eventually, we must avoid searching the entire icon list, + /* Eventually, we must avoid searching the entire canvas list, but it's OK for now. - A hash table mapping uri to icon is one possibility. + A hash table mapping uri to canvas is one possibility. */ details = container->details; for (p = details->icons; p != NULL; p = p->next) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; char *icon_uri; gboolean is_match; icon = p->data; - icon_uri = nautilus_icon_container_get_icon_uri + icon_uri = nautilus_canvas_container_get_icon_uri (container, icon); is_match = strcmp (uri, icon_uri) == 0; g_free (icon_uri); @@ -6928,11 +6928,11 @@ nautilus_icon_container_get_icon_by_uri (NautilusIconContainer *container, return NULL; } -static NautilusIcon * -get_nth_selected_icon (NautilusIconContainer *container, int index) +static NautilusCanvasIcon * +get_nth_selected_icon (NautilusCanvasContainer *container, int index) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; int selection_count; g_assert (index > 0); @@ -6950,23 +6950,23 @@ get_nth_selected_icon (NautilusIconContainer *container, int index) return NULL; } -static NautilusIcon * -get_first_selected_icon (NautilusIconContainer *container) +static NautilusCanvasIcon * +get_first_selected_icon (NautilusCanvasContainer *container) { return get_nth_selected_icon (container, 1); } static gboolean -has_multiple_selection (NautilusIconContainer *container) +has_multiple_selection (NautilusCanvasContainer *container) { return get_nth_selected_icon (container, 2) != NULL; } static gboolean -all_selected (NautilusIconContainer *container) +all_selected (NautilusCanvasContainer *container) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; for (p = container->details->icons; p != NULL; p = p->next) { icon = p->data; @@ -6978,22 +6978,22 @@ all_selected (NautilusIconContainer *container) } static gboolean -has_selection (NautilusIconContainer *container) +has_selection (NautilusCanvasContainer *container) { return get_nth_selected_icon (container, 1) != NULL; } /** - * nautilus_icon_container_show_stretch_handles: - * @container: An icon container widget. + * nautilus_canvas_container_show_stretch_handles: + * @container: An canvas container widget. * * Makes stretch handles visible on the first selected icon. **/ void -nautilus_icon_container_show_stretch_handles (NautilusIconContainer *container) +nautilus_canvas_container_show_stretch_handles (NautilusCanvasContainer *container) { - NautilusIconContainerDetails *details; - NautilusIcon *icon; + NautilusCanvasContainerDetails *details; + NautilusCanvasIcon *icon; guint initial_size; icon = get_first_selected_icon (container); @@ -7007,14 +7007,14 @@ nautilus_icon_container_show_stretch_handles (NautilusIconContainer *container) return; } - /* Get rid of the existing stretch handles and put them on the new icon. */ + /* Get rid of the existing stretch handles and put them on the new canvas. */ if (details->stretch_icon != NULL) { - nautilus_icon_canvas_item_set_show_stretch_handles + nautilus_canvas_item_set_show_stretch_handles (details->stretch_icon->item, FALSE); ungrab_stretch_icon (container); emit_stretch_ended (container, details->stretch_icon); } - nautilus_icon_canvas_item_set_show_stretch_handles (icon->item, TRUE); + nautilus_canvas_item_set_show_stretch_handles (icon->item, TRUE); details->stretch_icon = icon; icon_get_size (container, icon, &initial_size); @@ -7028,15 +7028,15 @@ nautilus_icon_container_show_stretch_handles (NautilusIconContainer *container) } /** - * nautilus_icon_container_has_stretch_handles - * @container: An icon container widget. + * nautilus_canvas_container_has_stretch_handles + * @container: An canvas container widget. * * Returns true if the first selected item has stretch handles. **/ gboolean -nautilus_icon_container_has_stretch_handles (NautilusIconContainer *container) +nautilus_canvas_container_has_stretch_handles (NautilusCanvasContainer *container) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; icon = get_first_selected_icon (container); if (icon == NULL) { @@ -7047,16 +7047,16 @@ nautilus_icon_container_has_stretch_handles (NautilusIconContainer *container) } /** - * nautilus_icon_container_is_stretched - * @container: An icon container widget. + * nautilus_canvas_container_is_stretched + * @container: An canvas container widget. * * Returns true if the any selected item is stretched to a size other than 1.0. **/ gboolean -nautilus_icon_container_is_stretched (NautilusIconContainer *container) +nautilus_canvas_container_is_stretched (NautilusCanvasContainer *container) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; for (p = container->details->icons; p != NULL; p = p->next) { icon = p->data; @@ -7068,24 +7068,24 @@ nautilus_icon_container_is_stretched (NautilusIconContainer *container) } /** - * nautilus_icon_container_unstretch - * @container: An icon container widget. + * nautilus_canvas_container_unstretch + * @container: An canvas container widget. * - * Gets rid of any icon stretching. + * Gets rid of any canvas stretching. **/ void -nautilus_icon_container_unstretch (NautilusIconContainer *container) +nautilus_canvas_container_unstretch (NautilusCanvasContainer *container) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; for (p = container->details->icons; p != NULL; p = p->next) { icon = p->data; if (icon->is_selected) { - nautilus_icon_container_move_icon (container, icon, - icon->x, icon->y, - 1.0, - FALSE, TRUE, TRUE); + nautilus_canvas_container_move_icon (container, icon, + icon->x, icon->y, + 1.0, + FALSE, TRUE, TRUE); } } } @@ -7114,7 +7114,7 @@ compute_stretch (StretchState *start, y_stretch = - y_stretch; } current->icon_size = MAX ((int) start->icon_size + MIN (x_stretch, y_stretch), - (int) NAUTILUS_ICON_SIZE_SMALLEST); + (int) NAUTILUS_ICON_SIZE_SMALLEST); /* Figure out where the corner of the icon should be. */ current->icon_x = start->icon_x; @@ -7128,30 +7128,30 @@ compute_stretch (StretchState *start, } char * -nautilus_icon_container_get_icon_uri (NautilusIconContainer *container, - NautilusIcon *icon) +nautilus_canvas_container_get_icon_uri (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { char *uri; uri = NULL; g_signal_emit (container, - signals[GET_ICON_URI], 0, - icon->data, - &uri); + signals[GET_ICON_URI], 0, + icon->data, + &uri); return uri; } char * -nautilus_icon_container_get_icon_drop_target_uri (NautilusIconContainer *container, - NautilusIcon *icon) +nautilus_canvas_container_get_icon_drop_target_uri (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { char *uri; uri = NULL; g_signal_emit (container, - signals[GET_ICON_DROP_TARGET_URI], 0, - icon->data, - &uri); + signals[GET_ICON_DROP_TARGET_URI], 0, + icon->data, + &uri); return uri; } @@ -7159,10 +7159,10 @@ nautilus_icon_container_get_icon_drop_target_uri (NautilusIconContainer *contain * to avoid having the flag linger until the next file is added. */ static void -reset_scroll_region_if_not_empty (NautilusIconContainer *container) +reset_scroll_region_if_not_empty (NautilusCanvasContainer *container) { - if (!nautilus_icon_container_is_empty (container)) { - nautilus_icon_container_reset_scroll_region (container); + if (!nautilus_canvas_container_is_empty (container)) { + nautilus_canvas_container_reset_scroll_region (container); } } @@ -7171,10 +7171,10 @@ reset_scroll_region_if_not_empty (NautilusIconContainer *container) * last manual layout. */ void -nautilus_icon_container_set_auto_layout (NautilusIconContainer *container, - gboolean auto_layout) +nautilus_canvas_container_set_auto_layout (NautilusCanvasContainer *container, + gboolean auto_layout) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); g_return_if_fail (auto_layout == FALSE || auto_layout == TRUE); if (container->details->auto_layout == auto_layout) { @@ -7186,7 +7186,7 @@ nautilus_icon_container_set_auto_layout (NautilusIconContainer *container, if (!auto_layout) { reload_icon_positions (container); - nautilus_icon_container_freeze_icon_positions (container); + nautilus_canvas_container_freeze_icon_positions (container); } container->details->needs_resort = TRUE; @@ -7196,7 +7196,7 @@ nautilus_icon_container_set_auto_layout (NautilusIconContainer *container, } gboolean -nautilus_icon_container_is_keep_aligned (NautilusIconContainer *container) +nautilus_canvas_container_is_keep_aligned (NautilusCanvasContainer *container) { return container->details->keep_aligned; } @@ -7204,9 +7204,9 @@ nautilus_icon_container_is_keep_aligned (NautilusIconContainer *container) static gboolean align_icons_callback (gpointer callback_data) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - container = NAUTILUS_ICON_CONTAINER (callback_data); + container = NAUTILUS_CANVAS_CONTAINER (callback_data); align_icons (container); container->details->align_idle_id = 0; @@ -7214,7 +7214,7 @@ align_icons_callback (gpointer callback_data) } static void -unschedule_align_icons (NautilusIconContainer *container) +unschedule_align_icons (NautilusCanvasContainer *container) { if (container->details->align_idle_id != 0) { g_source_remove (container->details->align_idle_id); @@ -7223,7 +7223,7 @@ unschedule_align_icons (NautilusIconContainer *container) } static void -schedule_align_icons (NautilusIconContainer *container) +schedule_align_icons (NautilusCanvasContainer *container) { if (container->details->align_idle_id == 0 && container->details->has_been_allocated) { @@ -7233,8 +7233,8 @@ schedule_align_icons (NautilusIconContainer *container) } void -nautilus_icon_container_set_keep_aligned (NautilusIconContainer *container, - gboolean keep_aligned) +nautilus_canvas_container_set_keep_aligned (NautilusCanvasContainer *container, + gboolean keep_aligned) { if (container->details->keep_aligned != keep_aligned) { container->details->keep_aligned = keep_aligned; @@ -7248,10 +7248,10 @@ nautilus_icon_container_set_keep_aligned (NautilusIconContainer *container, } void -nautilus_icon_container_set_layout_mode (NautilusIconContainer *container, - NautilusIconLayoutMode mode) +nautilus_canvas_container_set_layout_mode (NautilusCanvasContainer *container, + NautilusCanvasLayoutMode mode) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); container->details->layout_mode = mode; invalidate_labels (container); @@ -7263,32 +7263,32 @@ nautilus_icon_container_set_layout_mode (NautilusIconContainer *container, } void -nautilus_icon_container_set_label_position (NautilusIconContainer *container, - NautilusIconLabelPosition position) +nautilus_canvas_container_set_label_position (NautilusCanvasContainer *container, + NautilusCanvasLabelPosition position) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); if (container->details->label_position != position) { container->details->label_position = position; invalidate_labels (container); - nautilus_icon_container_request_update_all (container); + nautilus_canvas_container_request_update_all (container); schedule_redo_layout (container); } } /* Switch from automatic to manual layout, freezing all the icons in their - * current positions instead of restoring icon positions from the last manual + * current positions instead of restoring canvas positions from the last manual * layout as set_auto_layout does. */ void -nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container) +nautilus_canvas_container_freeze_icon_positions (NautilusCanvasContainer *container) { gboolean changed; GList *p; - NautilusIcon *icon; - NautilusIconPosition position; + NautilusCanvasIcon *icon; + NautilusCanvasPosition position; changed = container->details->auto_layout; container->details->auto_layout = FALSE; @@ -7300,7 +7300,7 @@ nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container) position.y = icon->y; position.scale = icon->scale; g_signal_emit (container, signals[ICON_POSITION_CHANGED], 0, - icon->data, &position); + icon->data, &position); } if (changed) { @@ -7310,7 +7310,7 @@ nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container) /* Re-sort, switching to automatic layout if it was in manual layout. */ void -nautilus_icon_container_sort (NautilusIconContainer *container) +nautilus_canvas_container_sort (NautilusCanvasContainer *container) { gboolean changed; @@ -7327,31 +7327,31 @@ nautilus_icon_container_sort (NautilusIconContainer *container) } gboolean -nautilus_icon_container_is_auto_layout (NautilusIconContainer *container) +nautilus_canvas_container_is_auto_layout (NautilusCanvasContainer *container) { - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), FALSE); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), FALSE); return container->details->auto_layout; } static void -pending_icon_to_rename_destroy_callback (NautilusIconCanvasItem *item, NautilusIconContainer *container) +pending_icon_to_rename_destroy_callback (NautilusCanvasItem *item, NautilusCanvasContainer *container) { g_assert (container->details->pending_icon_to_rename != NULL); g_assert (container->details->pending_icon_to_rename->item == item); container->details->pending_icon_to_rename = NULL; } -static NautilusIcon* -get_pending_icon_to_rename (NautilusIconContainer *container) +static NautilusCanvasIcon * +get_pending_icon_to_rename (NautilusCanvasContainer *container) { return container->details->pending_icon_to_rename; } static void -set_pending_icon_to_rename (NautilusIconContainer *container, NautilusIcon *icon) +set_pending_icon_to_rename (NautilusCanvasContainer *container, NautilusCanvasIcon *icon) { - NautilusIcon *old_icon; + NautilusCanvasIcon *old_icon; old_icon = container->details->pending_icon_to_rename; @@ -7375,15 +7375,15 @@ set_pending_icon_to_rename (NautilusIconContainer *container, NautilusIcon *icon } static void -process_pending_icon_to_rename (NautilusIconContainer *container) +process_pending_icon_to_rename (NautilusCanvasContainer *container) { - NautilusIcon *pending_icon_to_rename; + NautilusCanvasIcon *pending_icon_to_rename; pending_icon_to_rename = get_pending_icon_to_rename (container); if (pending_icon_to_rename != NULL) { if (pending_icon_to_rename->is_selected && !has_multiple_selection (container)) { - nautilus_icon_container_start_renaming_selected_item (container, FALSE); + nautilus_canvas_container_start_renaming_selected_item (container, FALSE); } else { set_pending_icon_to_rename (container, NULL); } @@ -7391,31 +7391,31 @@ process_pending_icon_to_rename (NautilusIconContainer *container) } static gboolean -is_renaming_pending (NautilusIconContainer *container) +is_renaming_pending (NautilusCanvasContainer *container) { return get_pending_icon_to_rename (container) != NULL; } static gboolean -is_renaming (NautilusIconContainer *container) +is_renaming (NautilusCanvasContainer *container) { return container->details->renaming; } /** - * nautilus_icon_container_start_renaming_selected_item - * @container: An icon container widget. + * nautilus_canvas_container_start_renaming_selected_item + * @container: An canvas container widget. * @select_all: Whether the whole file should initially be selected, or * only its basename (i.e. everything except its extension). * * Displays the edit name widget on the first selected icon **/ void -nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container, - gboolean select_all) +nautilus_canvas_container_start_renaming_selected_item (NautilusCanvasContainer *container, + gboolean select_all) { - NautilusIconContainerDetails *details; - NautilusIcon *icon; + NautilusCanvasContainerDetails *details; + NautilusCanvasIcon *icon; EelDRect icon_rect; PangoContext *context; PangoFontDescription *desc; @@ -7449,7 +7449,7 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con set_pending_icon_to_rename (container, NULL); /* Make a copy of the original editable text for a later compare */ - editable_text = nautilus_icon_canvas_item_get_editable_text (icon->item); + editable_text = nautilus_canvas_item_get_editable_text (icon->item); /* This could conceivably be NULL if a rename was triggered really early. */ if (editable_text == NULL) { @@ -7459,10 +7459,10 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con details->original_text = g_strdup (editable_text); /* Freeze updates so files added while renaming don't cause rename to loose focus, bug #318373 */ - nautilus_icon_container_freeze_updates (container); + nautilus_canvas_container_freeze_updates (container); /* Create text renaming widget, if it hasn't been created already. - * We deal with the broken icon text item widget by keeping it around + * We deal with the broken canvas text item widget by keeping it around * so its contents can still be cut and pasted as part of the clipboard */ if (details->rename_widget == NULL) { @@ -7489,9 +7489,9 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con desc); pango_font_description_free (desc); - icon_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + icon_rect = nautilus_canvas_item_get_icon_rectangle (icon->item); - width = nautilus_icon_canvas_item_get_max_text_width (icon->item); + width = nautilus_canvas_item_get_max_text_width (icon->item); eel_canvas_w2c (EEL_CANVAS_ITEM (icon->item)->canvas, (icon_rect.x0 + icon_rect.x1) / 2, @@ -7525,17 +7525,17 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con signals[ICON_RENAME_STARTED], 0, GTK_EDITABLE (details->rename_widget)); - nautilus_icon_container_update_icon (container, icon); + nautilus_canvas_container_update_icon (container, icon); /* We are in renaming mode */ details->renaming = TRUE; - nautilus_icon_canvas_item_set_renaming (icon->item, TRUE); + nautilus_canvas_item_set_renaming (icon->item, TRUE); } static void -end_renaming_mode (NautilusIconContainer *container, gboolean commit) +end_renaming_mode (NautilusCanvasContainer *container, gboolean commit) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; const char *changed_text = NULL; set_pending_icon_to_rename (container, NULL); @@ -7547,9 +7547,9 @@ end_renaming_mode (NautilusIconContainer *container, gboolean commit) /* We are not in renaming mode */ container->details->renaming = FALSE; - nautilus_icon_canvas_item_set_renaming (icon->item, FALSE); + nautilus_canvas_item_set_renaming (icon->item, FALSE); - nautilus_icon_container_unfreeze_updates (container); + nautilus_canvas_container_unfreeze_updates (container); if (commit) { set_pending_icon_to_reveal (container, icon); @@ -7567,30 +7567,29 @@ end_renaming_mode (NautilusIconContainer *container, gboolean commit) g_signal_emit (container, signals[ICON_RENAME_ENDED], 0, - icon->data, - changed_text); + icon->data, changed_text); gtk_widget_hide (container->details->rename_widget); g_free (container->details->original_text); } gboolean -nautilus_icon_container_has_stored_icon_positions (NautilusIconContainer *container) +nautilus_canvas_container_has_stored_icon_positions (NautilusCanvasContainer *container) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; gboolean have_stored_position; - NautilusIconPosition position; + NautilusCanvasPosition position; for (p = container->details->icons; p != NULL; p = p->next) { icon = p->data; have_stored_position = FALSE; g_signal_emit (container, - signals[GET_STORED_ICON_POSITION], 0, - icon->data, - &position, - &have_stored_position); + signals[GET_STORED_ICON_POSITION], 0, + icon->data, + &position, + &have_stored_position); if (have_stored_position) { return TRUE; } @@ -7599,46 +7598,46 @@ nautilus_icon_container_has_stored_icon_positions (NautilusIconContainer *contai } void -nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container, - gboolean single_click_mode) +nautilus_canvas_container_set_single_click_mode (NautilusCanvasContainer *container, + gboolean single_click_mode) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); container->details->single_click_mode = single_click_mode; } -/* Return if the icon container is a fixed size */ +/* Return if the canvas container is a fixed size */ gboolean -nautilus_icon_container_get_is_fixed_size (NautilusIconContainer *container) +nautilus_canvas_container_get_is_fixed_size (NautilusCanvasContainer *container) { - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), FALSE); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), FALSE); return container->details->is_fixed_size; } -/* Set the icon container to be a fixed size */ +/* Set the canvas container to be a fixed size */ void -nautilus_icon_container_set_is_fixed_size (NautilusIconContainer *container, - gboolean is_fixed_size) +nautilus_canvas_container_set_is_fixed_size (NautilusCanvasContainer *container, + gboolean is_fixed_size) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); container->details->is_fixed_size = is_fixed_size; } gboolean -nautilus_icon_container_get_is_desktop (NautilusIconContainer *container) +nautilus_canvas_container_get_is_desktop (NautilusCanvasContainer *container) { - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), FALSE); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), FALSE); return container->details->is_desktop; } void -nautilus_icon_container_set_is_desktop (NautilusIconContainer *container, - gboolean is_desktop) +nautilus_canvas_container_set_is_desktop (NautilusCanvasContainer *container, + gboolean is_desktop) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); container->details->is_desktop = is_desktop; @@ -7651,13 +7650,13 @@ nautilus_icon_container_set_is_desktop (NautilusIconContainer *container, } void -nautilus_icon_container_set_margins (NautilusIconContainer *container, - int left_margin, - int right_margin, - int top_margin, - int bottom_margin) +nautilus_canvas_container_set_margins (NautilusCanvasContainer *container, + int left_margin, + int right_margin, + int top_margin, + int bottom_margin) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); container->details->left_margin = left_margin; container->details->right_margin = right_margin; @@ -7669,8 +7668,8 @@ nautilus_icon_container_set_margins (NautilusIconContainer *container, } void -nautilus_icon_container_set_use_drop_shadows (NautilusIconContainer *container, - gboolean use_drop_shadows) +nautilus_canvas_container_set_use_drop_shadows (NautilusCanvasContainer *container, + gboolean use_drop_shadows) { if (container->details->drop_shadows_requested == use_drop_shadows) { return; @@ -7684,10 +7683,10 @@ nautilus_icon_container_set_use_drop_shadows (NautilusIconContainer *container, /* handle theme changes */ void -nautilus_icon_container_set_font (NautilusIconContainer *container, - const char *font) +nautilus_canvas_container_set_font (NautilusCanvasContainer *container, + const char *font) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); if (g_strcmp0 (container->details->font, font) == 0) { return; @@ -7697,24 +7696,24 @@ nautilus_icon_container_set_font (NautilusIconContainer *container, container->details->font = g_strdup (font); invalidate_labels (container); - nautilus_icon_container_request_update_all (container); + nautilus_canvas_container_request_update_all (container); gtk_widget_queue_draw (GTK_WIDGET (container)); } /** - * nautilus_icon_container_get_icon_description - * @container: An icon container widget. + * nautilus_canvas_container_get_icon_description + * @container: An canvas container widget. * @data: Icon data * * Gets the description for the icon. This function may return NULL. **/ char* -nautilus_icon_container_get_icon_description (NautilusIconContainer *container, - NautilusIconData *data) +nautilus_canvas_container_get_icon_description (NautilusCanvasContainer *container, + NautilusCanvasIconData *data) { - NautilusIconContainerClass *klass; + NautilusCanvasContainerClass *klass; - klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container); + klass = NAUTILUS_CANVAS_CONTAINER_GET_CLASS (container); if (klass->get_icon_description) { return klass->get_icon_description (container, data); @@ -7724,41 +7723,41 @@ nautilus_icon_container_get_icon_description (NautilusIconContainer *container, } gboolean -nautilus_icon_container_get_allow_moves (NautilusIconContainer *container) +nautilus_canvas_container_get_allow_moves (NautilusCanvasContainer *container) { - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), FALSE); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), FALSE); return container->details->drag_allow_moves; } void -nautilus_icon_container_set_allow_moves (NautilusIconContainer *container, - gboolean allow_moves) +nautilus_canvas_container_set_allow_moves (NautilusCanvasContainer *container, + gboolean allow_moves) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); container->details->drag_allow_moves = allow_moves; } /** - * nautilus_icon_container_set_highlighted_for_clipboard - * @container: An icon container widget. - * @data: Icon Data associated with all icons that should be highlighted. + * nautilus_canvas_container_set_highlighted_for_clipboard + * @container: An canvas container widget. + * @data: Canvas Data associated with all icons that should be highlighted. * Others will be unhighlighted. **/ void -nautilus_icon_container_set_highlighted_for_clipboard (NautilusIconContainer *container, - GList *clipboard_icon_data) +nautilus_canvas_container_set_highlighted_for_clipboard (NautilusCanvasContainer *container, + GList *clipboard_canvas_data) { GList *l; - NautilusIcon *icon; + NautilusCanvasIcon *icon; gboolean highlighted_for_clipboard; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); for (l = container->details->icons; l != NULL; l = l->next) { icon = l->data; - highlighted_for_clipboard = (g_list_find (clipboard_icon_data, icon->data) != NULL); + highlighted_for_clipboard = (g_list_find (clipboard_canvas_data, icon->data) != NULL); eel_canvas_item_set (EEL_CANVAS_ITEM (icon->item), "highlighted-for-clipboard", highlighted_for_clipboard, @@ -7767,22 +7766,22 @@ nautilus_icon_container_set_highlighted_for_clipboard (NautilusIconContainer *co } -/* NautilusIconContainerAccessible */ +/* NautilusCanvasContainerAccessible */ typedef struct { EelCanvasAccessible parent; - NautilusIconContainerAccessiblePrivate *priv; -} NautilusIconContainerAccessible; + NautilusCanvasContainerAccessiblePrivate *priv; +} NautilusCanvasContainerAccessible; -typedef EelCanvasAccessibleClass NautilusIconContainerAccessibleClass; +typedef EelCanvasAccessibleClass NautilusCanvasContainerAccessibleClass; -#define GET_ACCESSIBLE_PRIV(o) ((NautilusIconContainerAccessible *) o)->priv +#define GET_ACCESSIBLE_PRIV(o) ((NautilusCanvasContainerAccessible *) o)->priv /* AtkAction interface */ static gboolean -nautilus_icon_container_accessible_do_action (AtkAction *accessible, int i) +nautilus_canvas_container_accessible_do_action (AtkAction *accessible, int i) { GtkWidget *widget; - NautilusIconContainer *container; + NautilusCanvasContainer *container; GList *selection; g_return_val_if_fail (i < LAST_ACTION, FALSE); @@ -7792,10 +7791,10 @@ nautilus_icon_container_accessible_do_action (AtkAction *accessible, int i) return FALSE; } - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); switch (i) { case ACTION_ACTIVATE : - selection = nautilus_icon_container_get_selection (container); + selection = nautilus_canvas_container_get_selection (container); if (selection) { g_signal_emit_by_name (container, "activate", selection); @@ -7806,23 +7805,23 @@ nautilus_icon_container_accessible_do_action (AtkAction *accessible, int i) handle_popups (container, NULL,"context_click_background"); break; default : - g_warning ("Invalid action passed to NautilusIconContainerAccessible::do_action"); + g_warning ("Invalid action passed to NautilusCanvasContainerAccessible::do_action"); return FALSE; } return TRUE; } static int -nautilus_icon_container_accessible_get_n_actions (AtkAction *accessible) +nautilus_canvas_container_accessible_get_n_actions (AtkAction *accessible) { return LAST_ACTION; } static const char * -nautilus_icon_container_accessible_action_get_description (AtkAction *accessible, - int i) +nautilus_canvas_container_accessible_action_get_description (AtkAction *accessible, + int i) { - NautilusIconContainerAccessiblePrivate *priv; + NautilusCanvasContainerAccessiblePrivate *priv; g_assert (i < LAST_ACTION); @@ -7831,21 +7830,21 @@ nautilus_icon_container_accessible_action_get_description (AtkAction *accessible if (priv->action_descriptions[i]) { return priv->action_descriptions[i]; } else { - return nautilus_icon_container_accessible_action_descriptions[i]; + return nautilus_canvas_container_accessible_action_descriptions[i]; } } static const char * -nautilus_icon_container_accessible_action_get_name (AtkAction *accessible, int i) +nautilus_canvas_container_accessible_action_get_name (AtkAction *accessible, int i) { g_assert (i < LAST_ACTION); - return nautilus_icon_container_accessible_action_names[i]; + return nautilus_canvas_container_accessible_action_names[i]; } static const char * -nautilus_icon_container_accessible_action_get_keybinding (AtkAction *accessible, - int i) +nautilus_canvas_container_accessible_action_get_keybinding (AtkAction *accessible, + int i) { g_assert (i < LAST_ACTION); @@ -7853,11 +7852,11 @@ nautilus_icon_container_accessible_action_get_keybinding (AtkAction *accessible, } static gboolean -nautilus_icon_container_accessible_action_set_description (AtkAction *accessible, - int i, - const char *description) +nautilus_canvas_container_accessible_action_set_description (AtkAction *accessible, + int i, + const char *description) { - NautilusIconContainerAccessiblePrivate *priv; + NautilusCanvasContainerAccessiblePrivate *priv; g_assert (i < LAST_ACTION); @@ -7872,27 +7871,27 @@ nautilus_icon_container_accessible_action_set_description (AtkAction *accessible } static void -nautilus_icon_container_accessible_action_interface_init (AtkActionIface *iface) +nautilus_canvas_container_accessible_action_interface_init (AtkActionIface *iface) { - iface->do_action = nautilus_icon_container_accessible_do_action; - iface->get_n_actions = nautilus_icon_container_accessible_get_n_actions; - iface->get_description = nautilus_icon_container_accessible_action_get_description; - iface->get_name = nautilus_icon_container_accessible_action_get_name; - iface->get_keybinding = nautilus_icon_container_accessible_action_get_keybinding; - iface->set_description = nautilus_icon_container_accessible_action_set_description; + iface->do_action = nautilus_canvas_container_accessible_do_action; + iface->get_n_actions = nautilus_canvas_container_accessible_get_n_actions; + iface->get_description = nautilus_canvas_container_accessible_action_get_description; + iface->get_name = nautilus_canvas_container_accessible_action_get_name; + iface->get_keybinding = nautilus_canvas_container_accessible_action_get_keybinding; + iface->set_description = nautilus_canvas_container_accessible_action_set_description; } /* AtkSelection interface */ static void -nautilus_icon_container_accessible_update_selection (AtkObject *accessible) +nautilus_canvas_container_accessible_update_selection (AtkObject *accessible) { - NautilusIconContainer *container; - NautilusIconContainerAccessiblePrivate *priv; + NautilusCanvasContainer *container; + NautilusCanvasContainerAccessiblePrivate *priv; GList *l; - NautilusIcon *icon; + NautilusCanvasIcon *icon; - container = NAUTILUS_ICON_CONTAINER (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible))); + container = NAUTILUS_CANVAS_CONTAINER (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible))); priv = GET_ACCESSIBLE_PRIV (accessible); if (priv->selection) { @@ -7912,18 +7911,18 @@ nautilus_icon_container_accessible_update_selection (AtkObject *accessible) } static void -nautilus_icon_container_accessible_selection_changed_cb (NautilusIconContainer *container, - gpointer data) +nautilus_canvas_container_accessible_selection_changed_cb (NautilusCanvasContainer *container, + gpointer data) { g_signal_emit_by_name (data, "selection_changed"); } static void -nautilus_icon_container_accessible_icon_added_cb (NautilusIconContainer *container, - NautilusIconData *icon_data, - gpointer data) +nautilus_canvas_container_accessible_icon_added_cb (NautilusCanvasContainer *container, + NautilusCanvasIconData *icon_data, + gpointer data) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; AtkObject *atk_parent; AtkObject *atk_child; int index; @@ -7941,11 +7940,11 @@ nautilus_icon_container_accessible_icon_added_cb (NautilusIconContainer *contain } static void -nautilus_icon_container_accessible_icon_removed_cb (NautilusIconContainer *container, - NautilusIconData *icon_data, - gpointer data) +nautilus_canvas_container_accessible_icon_removed_cb (NautilusCanvasContainer *container, + NautilusCanvasIconData *icon_data, + gpointer data) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; AtkObject *atk_parent; AtkObject *atk_child; int index; @@ -7963,37 +7962,37 @@ nautilus_icon_container_accessible_icon_removed_cb (NautilusIconContainer *conta } static void -nautilus_icon_container_accessible_cleared_cb (NautilusIconContainer *container, - gpointer data) +nautilus_canvas_container_accessible_cleared_cb (NautilusCanvasContainer *container, + gpointer data) { g_signal_emit_by_name (data, "children_changed", 0, NULL, NULL); } static gboolean -nautilus_icon_container_accessible_add_selection (AtkSelection *accessible, - int i) +nautilus_canvas_container_accessible_add_selection (AtkSelection *accessible, + int i) { GtkWidget *widget; - NautilusIconContainer *container; + NautilusCanvasContainer *container; GList *l; GList *selection; - NautilusIcon *icon; + NautilusCanvasIcon *icon; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); if (!widget) { return FALSE; } - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); l = g_list_nth (container->details->icons, i); if (l) { icon = l->data; - selection = nautilus_icon_container_get_selection (container); + selection = nautilus_canvas_container_get_selection (container); selection = g_list_prepend (selection, icon->data); - nautilus_icon_container_set_selection (container, selection); + nautilus_canvas_container_set_selection (container, selection); g_list_free (selection); return TRUE; @@ -8003,33 +8002,33 @@ nautilus_icon_container_accessible_add_selection (AtkSelection *accessible, } static gboolean -nautilus_icon_container_accessible_clear_selection (AtkSelection *accessible) +nautilus_canvas_container_accessible_clear_selection (AtkSelection *accessible) { GtkWidget *widget; - NautilusIconContainer *container; + NautilusCanvasContainer *container; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); if (!widget) { return FALSE; } - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); - nautilus_icon_container_unselect_all (container); + nautilus_canvas_container_unselect_all (container); return TRUE; } static AtkObject * -nautilus_icon_container_accessible_ref_selection (AtkSelection *accessible, - int i) +nautilus_canvas_container_accessible_ref_selection (AtkSelection *accessible, + int i) { - NautilusIconContainerAccessiblePrivate *priv; + NautilusCanvasContainerAccessiblePrivate *priv; AtkObject *atk_object; GList *item; - NautilusIcon *icon; + NautilusCanvasIcon *icon; - nautilus_icon_container_accessible_update_selection (ATK_OBJECT (accessible)); + nautilus_canvas_container_accessible_update_selection (ATK_OBJECT (accessible)); priv = GET_ACCESSIBLE_PRIV (accessible); item = (g_list_nth (priv->selection, i)); @@ -8048,25 +8047,25 @@ nautilus_icon_container_accessible_ref_selection (AtkSelection *accessible, } static int -nautilus_icon_container_accessible_get_selection_count (AtkSelection *accessible) +nautilus_canvas_container_accessible_get_selection_count (AtkSelection *accessible) { - NautilusIconContainerAccessiblePrivate *priv; + NautilusCanvasContainerAccessiblePrivate *priv; int count; priv = GET_ACCESSIBLE_PRIV (accessible); - nautilus_icon_container_accessible_update_selection (ATK_OBJECT (accessible)); + nautilus_canvas_container_accessible_update_selection (ATK_OBJECT (accessible)); count = g_list_length (priv->selection); return count; } static gboolean -nautilus_icon_container_accessible_is_child_selected (AtkSelection *accessible, - int i) +nautilus_canvas_container_accessible_is_child_selected (AtkSelection *accessible, + int i) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; GList *l; - NautilusIcon *icon; + NautilusCanvasIcon *icon; GtkWidget *widget; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); @@ -8074,7 +8073,7 @@ nautilus_icon_container_accessible_is_child_selected (AtkSelection *accessible, return FALSE; } - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); l = g_list_nth (container->details->icons, i); if (l) { @@ -8085,14 +8084,14 @@ nautilus_icon_container_accessible_is_child_selected (AtkSelection *accessible, } static gboolean -nautilus_icon_container_accessible_remove_selection (AtkSelection *accessible, - int i) +nautilus_canvas_container_accessible_remove_selection (AtkSelection *accessible, + int i) { - NautilusIconContainerAccessiblePrivate *priv; - NautilusIconContainer *container; + NautilusCanvasContainerAccessiblePrivate *priv; + NautilusCanvasContainer *container; GList *l; GList *selection; - NautilusIcon *icon; + NautilusCanvasIcon *icon; GtkWidget *widget; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); @@ -8100,17 +8099,17 @@ nautilus_icon_container_accessible_remove_selection (AtkSelection *accessible, return FALSE; } - container = NAUTILUS_ICON_CONTAINER (widget); - nautilus_icon_container_accessible_update_selection (ATK_OBJECT (accessible)); + container = NAUTILUS_CANVAS_CONTAINER (widget); + nautilus_canvas_container_accessible_update_selection (ATK_OBJECT (accessible)); priv = GET_ACCESSIBLE_PRIV (accessible); l = g_list_nth (priv->selection, i); if (l) { icon = l->data; - selection = nautilus_icon_container_get_selection (container); + selection = nautilus_canvas_container_get_selection (container); selection = g_list_remove (selection, icon->data); - nautilus_icon_container_set_selection (container, selection); + nautilus_canvas_container_set_selection (container, selection); g_list_free (selection); return TRUE; @@ -8120,9 +8119,9 @@ nautilus_icon_container_accessible_remove_selection (AtkSelection *accessible, } static gboolean -nautilus_icon_container_accessible_select_all_selection (AtkSelection *accessible) +nautilus_canvas_container_accessible_select_all_selection (AtkSelection *accessible) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; GtkWidget *widget; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); @@ -8130,16 +8129,16 @@ nautilus_icon_container_accessible_select_all_selection (AtkSelection *accessibl return FALSE; } - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); - nautilus_icon_container_select_all (container); + nautilus_canvas_container_select_all (container); return TRUE; } void -nautilus_icon_container_widget_to_file_operation_position (NautilusIconContainer *container, - GdkPoint *position) +nautilus_canvas_container_widget_to_file_operation_position (NautilusCanvasContainer *container, + GdkPoint *position) { double x, y; @@ -8159,22 +8158,22 @@ nautilus_icon_container_widget_to_file_operation_position (NautilusIconContainer } static void -nautilus_icon_container_accessible_selection_interface_init (AtkSelectionIface *iface) +nautilus_canvas_container_accessible_selection_interface_init (AtkSelectionIface *iface) { - iface->add_selection = nautilus_icon_container_accessible_add_selection; - iface->clear_selection = nautilus_icon_container_accessible_clear_selection; - iface->ref_selection = nautilus_icon_container_accessible_ref_selection; - iface->get_selection_count = nautilus_icon_container_accessible_get_selection_count; - iface->is_child_selected = nautilus_icon_container_accessible_is_child_selected; - iface->remove_selection = nautilus_icon_container_accessible_remove_selection; - iface->select_all_selection = nautilus_icon_container_accessible_select_all_selection; + iface->add_selection = nautilus_canvas_container_accessible_add_selection; + iface->clear_selection = nautilus_canvas_container_accessible_clear_selection; + iface->ref_selection = nautilus_canvas_container_accessible_ref_selection; + iface->get_selection_count = nautilus_canvas_container_accessible_get_selection_count; + iface->is_child_selected = nautilus_canvas_container_accessible_is_child_selected; + iface->remove_selection = nautilus_canvas_container_accessible_remove_selection; + iface->select_all_selection = nautilus_canvas_container_accessible_select_all_selection; } static gint -nautilus_icon_container_accessible_get_n_children (AtkObject *accessible) +nautilus_canvas_container_accessible_get_n_children (AtkObject *accessible) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; GtkWidget *widget; gint i; @@ -8183,7 +8182,7 @@ nautilus_icon_container_accessible_get_n_children (AtkObject *accessible) return FALSE; } - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); i = g_hash_table_size (container->details->icon_set); if (container->details->rename_widget) { @@ -8194,12 +8193,12 @@ nautilus_icon_container_accessible_get_n_children (AtkObject *accessible) } static AtkObject* -nautilus_icon_container_accessible_ref_child (AtkObject *accessible, int i) +nautilus_canvas_container_accessible_ref_child (AtkObject *accessible, int i) { AtkObject *atk_object; - NautilusIconContainer *container; + NautilusCanvasContainer *container; GList *item; - NautilusIcon *icon; + NautilusCanvasIcon *icon; GtkWidget *widget; widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); @@ -8207,7 +8206,7 @@ nautilus_icon_container_accessible_ref_child (AtkObject *accessible, int i) return NULL; } - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); item = (g_list_nth (container->details->icons, i)); @@ -8231,47 +8230,47 @@ nautilus_icon_container_accessible_ref_child (AtkObject *accessible, int i) } } -static GType nautilus_icon_container_accessible_get_type (void); +static GType nautilus_canvas_container_accessible_get_type (void); -G_DEFINE_TYPE_WITH_CODE (NautilusIconContainerAccessible, nautilus_icon_container_accessible, +G_DEFINE_TYPE_WITH_CODE (NautilusCanvasContainerAccessible, nautilus_canvas_container_accessible, eel_canvas_accessible_get_type (), - G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, nautilus_icon_container_accessible_action_interface_init) - G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, nautilus_icon_container_accessible_selection_interface_init)) + G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, nautilus_canvas_container_accessible_action_interface_init) + G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, nautilus_canvas_container_accessible_selection_interface_init)) static void -nautilus_icon_container_accessible_initialize (AtkObject *accessible, - gpointer data) +nautilus_canvas_container_accessible_initialize (AtkObject *accessible, + gpointer data) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; - if (ATK_OBJECT_CLASS (nautilus_icon_container_accessible_parent_class)->initialize) { - ATK_OBJECT_CLASS (nautilus_icon_container_accessible_parent_class)->initialize (accessible, data); + if (ATK_OBJECT_CLASS (nautilus_canvas_container_accessible_parent_class)->initialize) { + ATK_OBJECT_CLASS (nautilus_canvas_container_accessible_parent_class)->initialize (accessible, data); } if (GTK_IS_ACCESSIBLE (accessible)) { - nautilus_icon_container_accessible_update_selection + nautilus_canvas_container_accessible_update_selection (ATK_OBJECT (accessible)); - container = NAUTILUS_ICON_CONTAINER (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible))); + container = NAUTILUS_CANVAS_CONTAINER (gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible))); g_signal_connect (container, "selection_changed", - G_CALLBACK (nautilus_icon_container_accessible_selection_changed_cb), + G_CALLBACK (nautilus_canvas_container_accessible_selection_changed_cb), accessible); g_signal_connect (container, "icon_added", - G_CALLBACK (nautilus_icon_container_accessible_icon_added_cb), + G_CALLBACK (nautilus_canvas_container_accessible_icon_added_cb), accessible); g_signal_connect (container, "icon_removed", - G_CALLBACK (nautilus_icon_container_accessible_icon_removed_cb), + G_CALLBACK (nautilus_canvas_container_accessible_icon_removed_cb), accessible); g_signal_connect (container, "cleared", - G_CALLBACK (nautilus_icon_container_accessible_cleared_cb), + G_CALLBACK (nautilus_canvas_container_accessible_cleared_cb), accessible); } } static void -nautilus_icon_container_accessible_finalize (GObject *object) +nautilus_canvas_container_accessible_finalize (GObject *object) { - NautilusIconContainerAccessiblePrivate *priv; + NautilusCanvasContainerAccessiblePrivate *priv; int i; priv = GET_ACCESSIBLE_PRIV (object); @@ -8286,29 +8285,29 @@ nautilus_icon_container_accessible_finalize (GObject *object) } } - G_OBJECT_CLASS (nautilus_icon_container_accessible_parent_class)->finalize (object); + G_OBJECT_CLASS (nautilus_canvas_container_accessible_parent_class)->finalize (object); } static void -nautilus_icon_container_accessible_init (NautilusIconContainerAccessible *self) +nautilus_canvas_container_accessible_init (NautilusCanvasContainerAccessible *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, nautilus_icon_container_accessible_get_type (), - NautilusIconContainerAccessiblePrivate); + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, nautilus_canvas_container_accessible_get_type (), + NautilusCanvasContainerAccessiblePrivate); } static void -nautilus_icon_container_accessible_class_init (NautilusIconContainerAccessibleClass *klass) +nautilus_canvas_container_accessible_class_init (NautilusCanvasContainerAccessibleClass *klass) { AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = nautilus_icon_container_accessible_finalize; + gobject_class->finalize = nautilus_canvas_container_accessible_finalize; - atk_class->get_n_children = nautilus_icon_container_accessible_get_n_children; - atk_class->ref_child = nautilus_icon_container_accessible_ref_child; - atk_class->initialize = nautilus_icon_container_accessible_initialize; + atk_class->get_n_children = nautilus_canvas_container_accessible_get_n_children; + atk_class->ref_child = nautilus_canvas_container_accessible_ref_child; + atk_class->initialize = nautilus_canvas_container_accessible_initialize; - g_type_class_add_private (klass, sizeof (NautilusIconContainerAccessiblePrivate)); + g_type_class_add_private (klass, sizeof (NautilusCanvasContainerAccessiblePrivate)); } static AtkObject * @@ -8320,35 +8319,35 @@ get_accessible (GtkWidget *widget) return accessible; } - accessible = g_object_new (nautilus_icon_container_accessible_get_type (), "widget", widget, NULL); + accessible = g_object_new (nautilus_canvas_container_accessible_get_type (), "widget", widget, NULL); return eel_accessibility_set_atk_object_return (widget, accessible); } gboolean -nautilus_icon_container_is_layout_rtl (NautilusIconContainer *container) +nautilus_canvas_container_is_layout_rtl (NautilusCanvasContainer *container) { - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), 0); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), 0); - return container->details->layout_mode == NAUTILUS_ICON_LAYOUT_T_B_R_L || - container->details->layout_mode == NAUTILUS_ICON_LAYOUT_R_L_T_B; + return container->details->layout_mode == NAUTILUS_CANVAS_LAYOUT_T_B_R_L || + container->details->layout_mode == NAUTILUS_CANVAS_LAYOUT_R_L_T_B; } gboolean -nautilus_icon_container_is_layout_vertical (NautilusIconContainer *container) +nautilus_canvas_container_is_layout_vertical (NautilusCanvasContainer *container) { - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), FALSE); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), FALSE); - return (container->details->layout_mode == NAUTILUS_ICON_LAYOUT_T_B_L_R || - container->details->layout_mode == NAUTILUS_ICON_LAYOUT_T_B_R_L); + return (container->details->layout_mode == NAUTILUS_CANVAS_LAYOUT_T_B_L_R || + container->details->layout_mode == NAUTILUS_CANVAS_LAYOUT_T_B_R_L); } int -nautilus_icon_container_get_max_layout_lines_for_pango (NautilusIconContainer *container) +nautilus_canvas_container_get_max_layout_lines_for_pango (NautilusCanvasContainer *container) { int limit; - if (nautilus_icon_container_get_is_desktop (container)) { + if (nautilus_canvas_container_get_is_desktop (container)) { limit = desktop_text_ellipsis_limit; } else { limit = text_ellipsis_limits[container->details->zoom_level]; @@ -8362,11 +8361,11 @@ nautilus_icon_container_get_max_layout_lines_for_pango (NautilusIconContainer * } int -nautilus_icon_container_get_max_layout_lines (NautilusIconContainer *container) +nautilus_canvas_container_get_max_layout_lines (NautilusCanvasContainer *container) { int limit; - if (nautilus_icon_container_get_is_desktop (container)) { + if (nautilus_canvas_container_get_is_desktop (container)) { limit = desktop_text_ellipsis_limit; } else { limit = text_ellipsis_limits[container->details->zoom_level]; @@ -8380,11 +8379,11 @@ nautilus_icon_container_get_max_layout_lines (NautilusIconContainer *container) } void -nautilus_icon_container_begin_loading (NautilusIconContainer *container) +nautilus_canvas_container_begin_loading (NautilusCanvasContainer *container) { gboolean dummy; - if (nautilus_icon_container_get_store_layout_timestamps (container)) { + if (nautilus_canvas_container_get_store_layout_timestamps (container)) { container->details->layout_timestamp = UNDEFINED_TIME; g_signal_emit (container, signals[GET_STORED_LAYOUT_TIMESTAMP], 0, @@ -8393,9 +8392,9 @@ nautilus_icon_container_begin_loading (NautilusIconContainer *container) } static void -store_layout_timestamps_now (NautilusIconContainer *container) +store_layout_timestamps_now (NautilusCanvasContainer *container) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; GList *p; gboolean dummy; @@ -8415,11 +8414,11 @@ store_layout_timestamps_now (NautilusIconContainer *container) void -nautilus_icon_container_end_loading (NautilusIconContainer *container, - gboolean all_icons_added) +nautilus_canvas_container_end_loading (NautilusCanvasContainer *container, + gboolean all_icons_added) { if (all_icons_added && - nautilus_icon_container_get_store_layout_timestamps (container)) { + nautilus_canvas_container_get_store_layout_timestamps (container)) { if (container->details->new_icons == NULL) { store_layout_timestamps_now (container); } else { @@ -8429,15 +8428,15 @@ nautilus_icon_container_end_loading (NautilusIconContainer *container, } gboolean -nautilus_icon_container_get_store_layout_timestamps (NautilusIconContainer *container) +nautilus_canvas_container_get_store_layout_timestamps (NautilusCanvasContainer *container) { return container->details->store_layout_timestamps; } void -nautilus_icon_container_set_store_layout_timestamps (NautilusIconContainer *container, - gboolean store_layout_timestamps) +nautilus_canvas_container_set_store_layout_timestamps (NautilusCanvasContainer *container, + gboolean store_layout_timestamps) { container->details->store_layout_timestamps = store_layout_timestamps; } @@ -8469,7 +8468,7 @@ check_compute_stretch (int icon_x, int icon_y, int icon_size, } void -nautilus_self_check_icon_container (void) +nautilus_self_check_canvas_container (void) { EEL_CHECK_STRING_RESULT (check_compute_stretch (0, 0, 16, 0, 0, 0, 0), "0,0:16"); EEL_CHECK_STRING_RESULT (check_compute_stretch (0, 0, 16, 16, 16, 17, 17), "0,0:17"); diff --git a/libnautilus-private/nautilus-canvas-container.h b/libnautilus-private/nautilus-canvas-container.h new file mode 100644 index 000000000..5e553eaea --- /dev/null +++ b/libnautilus-private/nautilus-canvas-container.h @@ -0,0 +1,357 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* gnome-canvas-container.h - Canvas container widget. + + Copyright (C) 1999, 2000 Free Software Foundation + Copyright (C) 2000 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Ettore Perazzoli <ettore@gnu.org>, Darin Adler <darin@bentspoon.com> +*/ + +#ifndef NAUTILUS_CANVAS_CONTAINER_H +#define NAUTILUS_CANVAS_CONTAINER_H + +#include <eel/eel-canvas.h> +#include <libnautilus-private/nautilus-icon-info.h> + +#define NAUTILUS_TYPE_CANVAS_CONTAINER nautilus_canvas_container_get_type() +#define NAUTILUS_CANVAS_CONTAINER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_CANVAS_CONTAINER, NautilusCanvasContainer)) +#define NAUTILUS_CANVAS_CONTAINER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CANVAS_CONTAINER, NautilusCanvasContainerClass)) +#define NAUTILUS_IS_CANVAS_CONTAINER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_CANVAS_CONTAINER)) +#define NAUTILUS_IS_CANVAS_CONTAINER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_CANVAS_CONTAINER)) +#define NAUTILUS_CANVAS_CONTAINER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_CANVAS_CONTAINER, NautilusCanvasContainerClass)) + + +#define NAUTILUS_CANVAS_ICON_DATA(pointer) \ + ((NautilusCanvasIconData *) (pointer)) + +typedef struct NautilusCanvasIconData NautilusCanvasIconData; + +typedef void (* NautilusCanvasCallback) (NautilusCanvasIconData *icon_data, + gpointer callback_data); + +typedef struct { + int x; + int y; + double scale; +} NautilusCanvasPosition; + +typedef enum { + NAUTILUS_CANVAS_LAYOUT_L_R_T_B, + NAUTILUS_CANVAS_LAYOUT_R_L_T_B, + NAUTILUS_CANVAS_LAYOUT_T_B_L_R, + NAUTILUS_CANVAS_LAYOUT_T_B_R_L +} NautilusCanvasLayoutMode; + +typedef enum { + NAUTILUS_CANVAS_LABEL_POSITION_UNDER, +} NautilusCanvasLabelPosition; + +#define NAUTILUS_CANVAS_CONTAINER_TYPESELECT_FLUSH_DELAY 1000000 + +typedef struct NautilusCanvasContainerDetails NautilusCanvasContainerDetails; + +typedef struct { + EelCanvas canvas; + NautilusCanvasContainerDetails *details; +} NautilusCanvasContainer; + +typedef struct { + EelCanvasClass parent_slot; + + /* Operations on the container. */ + int (* button_press) (NautilusCanvasContainer *container, + GdkEventButton *event); + void (* context_click_background) (NautilusCanvasContainer *container, + GdkEventButton *event); + void (* middle_click) (NautilusCanvasContainer *container, + GdkEventButton *event); + + /* Operations on icons. */ + void (* activate) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + void (* activate_alternate) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + void (* activate_previewer) (NautilusCanvasContainer *container, + GList *files, + GArray *locations); + void (* context_click_selection) (NautilusCanvasContainer *container, + GdkEventButton *event); + void (* move_copy_items) (NautilusCanvasContainer *container, + const GList *item_uris, + GdkPoint *relative_item_points, + const char *target_uri, + GdkDragAction action, + int x, + int y); + void (* handle_netscape_url) (NautilusCanvasContainer *container, + const char *url, + const char *target_uri, + GdkDragAction action, + int x, + int y); + void (* handle_uri_list) (NautilusCanvasContainer *container, + const char *uri_list, + const char *target_uri, + GdkDragAction action, + int x, + int y); + void (* handle_text) (NautilusCanvasContainer *container, + const char *text, + const char *target_uri, + GdkDragAction action, + int x, + int y); + void (* handle_raw) (NautilusCanvasContainer *container, + char *raw_data, + int length, + const char *target_uri, + const char *direct_save_uri, + GdkDragAction action, + int x, + int y); + + /* Queries on the container for subclass/client. + * These must be implemented. The default "do nothing" is not good enough. + */ + char * (* get_container_uri) (NautilusCanvasContainer *container); + + /* Queries on icons for subclass/client. + * These must be implemented. The default "do nothing" is not + * good enough, these are _not_ signals. + */ + NautilusIconInfo *(* get_icon_images) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + int canvas_size, + char **embedded_text, + gboolean for_drag_accept, + gboolean need_large_embeddded_text, + gboolean *embedded_text_needs_loading, + gboolean *has_window_open); + void (* get_icon_text) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + char **editable_text, + char **additional_text, + gboolean include_invisible); + char * (* get_icon_description) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + int (* compare_icons) (NautilusCanvasContainer *container, + NautilusCanvasIconData *canvas_a, + NautilusCanvasIconData *canvas_b); + int (* compare_icons_by_name) (NautilusCanvasContainer *container, + NautilusCanvasIconData *canvas_a, + NautilusCanvasIconData *canvas_b); + void (* freeze_updates) (NautilusCanvasContainer *container); + void (* unfreeze_updates) (NautilusCanvasContainer *container); + void (* start_monitor_top_left) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + gconstpointer client, + gboolean large_text); + void (* stop_monitor_top_left) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + gconstpointer client); + void (* prioritize_thumbnailing) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + + /* Queries on icons for subclass/client. + * These must be implemented => These are signals ! + * The default "do nothing" is not good enough. + */ + gboolean (* can_accept_item) (NautilusCanvasContainer *container, + NautilusCanvasIconData *target, + const char *item_uri); + gboolean (* get_stored_icon_position) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + NautilusCanvasPosition *position); + char * (* get_icon_uri) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + char * (* get_icon_drop_target_uri) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + + /* If canvas data is NULL, the layout timestamp of the container should be retrieved. + * That is the time when the container displayed a fully loaded directory with + * all canvas positions assigned. + * + * If canvas data is not NULL, the position timestamp of the canvas should be retrieved. + * That is the time when the file (i.e. canvas data payload) was last displayed in a + * fully loaded directory with all canvas positions assigned. + */ + gboolean (* get_stored_layout_timestamp) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + time_t *time); + /* If canvas data is NULL, the layout timestamp of the container should be stored. + * If canvas data is not NULL, the position timestamp of the container should be stored. + */ + gboolean (* store_layout_timestamp) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + const time_t *time); + + /* Notifications for the whole container. */ + void (* band_select_started) (NautilusCanvasContainer *container); + void (* band_select_ended) (NautilusCanvasContainer *container); + void (* selection_changed) (NautilusCanvasContainer *container); + void (* layout_changed) (NautilusCanvasContainer *container); + + /* Notifications for icons. */ + void (* icon_position_changed) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + const NautilusCanvasPosition *position); + void (* icon_rename_started) (NautilusCanvasContainer *container, + GtkWidget *renaming_widget); + void (* icon_rename_ended) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + const char *text); + void (* icon_stretch_started) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + void (* icon_stretch_ended) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + int (* preview) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, + gboolean start_flag); + void (* icon_added) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + void (* icon_removed) (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + void (* cleared) (NautilusCanvasContainer *container); + gboolean (* start_interactive_search) (NautilusCanvasContainer *container); +} NautilusCanvasContainerClass; + +/* GtkObject */ +GType nautilus_canvas_container_get_type (void); +GtkWidget * nautilus_canvas_container_new (void); + + +/* adding, removing, and managing icons */ +void nautilus_canvas_container_clear (NautilusCanvasContainer *view); +gboolean nautilus_canvas_container_add (NautilusCanvasContainer *view, + NautilusCanvasIconData *data); +void nautilus_canvas_container_layout_now (NautilusCanvasContainer *container); +gboolean nautilus_canvas_container_remove (NautilusCanvasContainer *view, + NautilusCanvasIconData *data); +void nautilus_canvas_container_for_each (NautilusCanvasContainer *view, + NautilusCanvasCallback callback, + gpointer callback_data); +void nautilus_canvas_container_request_update (NautilusCanvasContainer *view, + NautilusCanvasIconData *data); +void nautilus_canvas_container_request_update_all (NautilusCanvasContainer *container); +void nautilus_canvas_container_reveal (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); +gboolean nautilus_canvas_container_is_empty (NautilusCanvasContainer *container); +NautilusCanvasIconData *nautilus_canvas_container_get_first_visible_icon (NautilusCanvasContainer *container); +void nautilus_canvas_container_scroll_to_canvas (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); + +void nautilus_canvas_container_begin_loading (NautilusCanvasContainer *container); +void nautilus_canvas_container_end_loading (NautilusCanvasContainer *container, + gboolean all_icons_added); + +/* control the layout */ +gboolean nautilus_canvas_container_is_auto_layout (NautilusCanvasContainer *container); +void nautilus_canvas_container_set_auto_layout (NautilusCanvasContainer *container, + gboolean auto_layout); + +gboolean nautilus_canvas_container_is_keep_aligned (NautilusCanvasContainer *container); +void nautilus_canvas_container_set_keep_aligned (NautilusCanvasContainer *container, + gboolean keep_aligned); +void nautilus_canvas_container_set_layout_mode (NautilusCanvasContainer *container, + NautilusCanvasLayoutMode mode); +void nautilus_canvas_container_set_label_position (NautilusCanvasContainer *container, + NautilusCanvasLabelPosition pos); +void nautilus_canvas_container_sort (NautilusCanvasContainer *container); +void nautilus_canvas_container_freeze_icon_positions (NautilusCanvasContainer *container); + +int nautilus_canvas_container_get_max_layout_lines (NautilusCanvasContainer *container); +int nautilus_canvas_container_get_max_layout_lines_for_pango (NautilusCanvasContainer *container); + +void nautilus_canvas_container_set_highlighted_for_clipboard (NautilusCanvasContainer *container, + GList *clipboard_canvas_data); + +/* operations on all icons */ +void nautilus_canvas_container_unselect_all (NautilusCanvasContainer *view); +void nautilus_canvas_container_select_all (NautilusCanvasContainer *view); + + +/* operations on the selection */ +GList * nautilus_canvas_container_get_selection (NautilusCanvasContainer *view); +void nautilus_canvas_container_invert_selection (NautilusCanvasContainer *view); +void nautilus_canvas_container_set_selection (NautilusCanvasContainer *view, + GList *selection); +GArray * nautilus_canvas_container_get_selected_icon_locations (NautilusCanvasContainer *view); +gboolean nautilus_canvas_container_has_stretch_handles (NautilusCanvasContainer *container); +gboolean nautilus_canvas_container_is_stretched (NautilusCanvasContainer *container); +void nautilus_canvas_container_show_stretch_handles (NautilusCanvasContainer *container); +void nautilus_canvas_container_unstretch (NautilusCanvasContainer *container); +void nautilus_canvas_container_start_renaming_selected_item (NautilusCanvasContainer *container, + gboolean select_all); + +/* options */ +NautilusZoomLevel nautilus_canvas_container_get_zoom_level (NautilusCanvasContainer *view); +void nautilus_canvas_container_set_zoom_level (NautilusCanvasContainer *view, + int new_zoom_level); +void nautilus_canvas_container_set_single_click_mode (NautilusCanvasContainer *container, + gboolean single_click_mode); +void nautilus_canvas_container_enable_linger_selection (NautilusCanvasContainer *view, + gboolean enable); +gboolean nautilus_canvas_container_get_is_fixed_size (NautilusCanvasContainer *container); +void nautilus_canvas_container_set_is_fixed_size (NautilusCanvasContainer *container, + gboolean is_fixed_size); +gboolean nautilus_canvas_container_get_is_desktop (NautilusCanvasContainer *container); +void nautilus_canvas_container_set_is_desktop (NautilusCanvasContainer *container, + gboolean is_desktop); +void nautilus_canvas_container_reset_scroll_region (NautilusCanvasContainer *container); +void nautilus_canvas_container_set_font (NautilusCanvasContainer *container, + const char *font); +void nautilus_canvas_container_set_margins (NautilusCanvasContainer *container, + int left_margin, + int right_margin, + int top_margin, + int bottom_margin); +void nautilus_canvas_container_set_use_drop_shadows (NautilusCanvasContainer *container, + gboolean use_drop_shadows); +char* nautilus_canvas_container_get_icon_description (NautilusCanvasContainer *container, + NautilusCanvasIconData *data); +gboolean nautilus_canvas_container_get_allow_moves (NautilusCanvasContainer *container); +void nautilus_canvas_container_set_allow_moves (NautilusCanvasContainer *container, + gboolean allow_moves); + +gboolean nautilus_canvas_container_is_layout_rtl (NautilusCanvasContainer *container); +gboolean nautilus_canvas_container_is_layout_vertical (NautilusCanvasContainer *container); + +gboolean nautilus_canvas_container_get_store_layout_timestamps (NautilusCanvasContainer *container); +void nautilus_canvas_container_set_store_layout_timestamps (NautilusCanvasContainer *container, + gboolean store_layout); + +void nautilus_canvas_container_widget_to_file_operation_position (NautilusCanvasContainer *container, + GdkPoint *position); + +#define CANVAS_WIDTH(container,allocation) ((allocation.width \ + - container->details->left_margin \ + - container->details->right_margin) \ + / EEL_CANVAS (container)->pixels_per_unit) + +#define CANVAS_HEIGHT(container,allocation) ((allocation.height \ + - container->details->top_margin \ + - container->details->bottom_margin) \ + / EEL_CANVAS (container)->pixels_per_unit) + +#endif /* NAUTILUS_CANVAS_CONTAINER_H */ diff --git a/libnautilus-private/nautilus-icon-dnd.c b/libnautilus-private/nautilus-canvas-dnd.c index 3342e27f7..bbaba7391 100644 --- a/libnautilus-private/nautilus-icon-dnd.c +++ b/libnautilus-private/nautilus-canvas-dnd.c @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* nautilus-icon-dnd.c - Drag & drop handling for the icon container widget. +/* nautilus-canvas-dnd.c - Drag & drop handling for the canvas container widget. Copyright (C) 1999, 2000 Free Software Foundation Copyright (C) 2000 Eazel, Inc. @@ -33,10 +33,10 @@ #include <config.h> #include <math.h> -#include "nautilus-icon-dnd.h" +#include "nautilus-canvas-dnd.h" #include "nautilus-file-dnd.h" -#include "nautilus-icon-private.h" +#include "nautilus-canvas-private.h" #include "nautilus-link.h" #include "nautilus-metadata.h" #include "nautilus-selection-canvas-item.h" @@ -58,7 +58,7 @@ #include <stdio.h> #include <string.h> -#define DEBUG_FLAG NAUTILUS_DEBUG_ICON_CONTAINER +#define DEBUG_FLAG NAUTILUS_DEBUG_CANVAS_CONTAINER #include "nautilus-debug.h" static const GtkTargetEntry drag_types [] = { @@ -82,13 +82,13 @@ static void dnd_highlight_queue_redraw (GtkWidget *widget); static GtkTargetList *drop_types_list = NULL; static GtkTargetList *drop_types_list_root = NULL; -static char * nautilus_icon_container_find_drop_target (NautilusIconContainer *container, +static char * nautilus_canvas_container_find_drop_target (NautilusCanvasContainer *container, GdkDragContext *context, int x, int y, gboolean *icon_hit, gboolean rewrite_desktop); static EelCanvasItem * -create_selection_shadow (NautilusIconContainer *container, +create_selection_shadow (NautilusCanvasContainer *container, GList *list) { EelCanvasGroup *group; @@ -180,7 +180,7 @@ typedef struct { gpointer iterator_context; NautilusDragEachSelectedItemDataGet iteratee; gpointer iteratee_data; -} IconGetDataBinderContext; +} CanvasGetDataBinderContext; static void canvas_rect_world_to_widget (EelCanvas *canvas, @@ -217,25 +217,25 @@ canvas_widget_to_world (EelCanvas *canvas, } static gboolean -icon_get_data_binder (NautilusIcon *icon, gpointer data) +icon_get_data_binder (NautilusCanvasIcon *icon, gpointer data) { - IconGetDataBinderContext *context; + CanvasGetDataBinderContext *context; EelDRect world_rect; EelIRect widget_rect; char *uri; - NautilusIconContainer *container; + NautilusCanvasContainer *container; - context = (IconGetDataBinderContext *)data; + context = (CanvasGetDataBinderContext *)data; - g_assert (NAUTILUS_IS_ICON_CONTAINER (context->iterator_context)); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (context->iterator_context)); - container = NAUTILUS_ICON_CONTAINER (context->iterator_context); + container = NAUTILUS_CANVAS_CONTAINER (context->iterator_context); - world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item); + world_rect = nautilus_canvas_item_get_icon_rectangle (icon->item); canvas_rect_world_to_widget (EEL_CANVAS (container), &world_rect, &widget_rect); - uri = nautilus_icon_container_get_icon_uri (container, icon); + uri = nautilus_canvas_container_get_icon_uri (container, icon); if (uri == NULL) { g_warning ("no URI for one of the iterated icons"); return TRUE; @@ -261,15 +261,15 @@ icon_get_data_binder (NautilusIcon *icon, gpointer data) return TRUE; } -/* Iterate over each selected icon in a NautilusIconContainer, +/* Iterate over each selected icon in a NautilusCanvasContainer, * calling each_function on each. */ static void -nautilus_icon_container_each_selected_icon (NautilusIconContainer *container, - gboolean (*each_function) (NautilusIcon *, gpointer), gpointer data) +nautilus_canvas_container_each_selected_icon (NautilusCanvasContainer *container, + gboolean (*each_function) (NautilusCanvasIcon *, gpointer), gpointer data) { GList *p; - NautilusIcon *icon; + NautilusCanvasIcon *icon; for (p = container->details->icons; p != NULL; p = p->next) { icon = p->data; @@ -282,7 +282,7 @@ nautilus_icon_container_each_selected_icon (NautilusIconContainer *container, } } -/* Adaptor function used with nautilus_icon_container_each_selected_icon +/* Adaptor function used with nautilus_canvas_container_each_selected_icon * to help iterate over all selected items, passing uris, x, y, w and h * values to the iteratee */ @@ -290,16 +290,16 @@ static void each_icon_get_data_binder (NautilusDragEachSelectedItemDataGet iteratee, gpointer iterator_context, gpointer data) { - IconGetDataBinderContext context; - NautilusIconContainer *container; + CanvasGetDataBinderContext context; + NautilusCanvasContainer *container; - g_assert (NAUTILUS_IS_ICON_CONTAINER (iterator_context)); - container = NAUTILUS_ICON_CONTAINER (iterator_context); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (iterator_context)); + container = NAUTILUS_CANVAS_CONTAINER (iterator_context); context.iterator_context = iterator_context; context.iteratee = iteratee; context.iteratee_data = data; - nautilus_icon_container_each_selected_icon (container, icon_get_data_binder, &context); + nautilus_canvas_container_each_selected_icon (container, icon_get_data_binder, &context); } /* Called when the data for drag&drop is needed */ @@ -312,7 +312,7 @@ drag_data_get_callback (GtkWidget *widget, gpointer data) { g_assert (widget != NULL); - g_assert (NAUTILUS_IS_ICON_CONTAINER (widget)); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (widget)); g_return_if_fail (context != NULL); /* Call common function from nautilus-drag that set's up @@ -327,7 +327,7 @@ drag_data_get_callback (GtkWidget *widget, /* Target-side handling of the drag. */ static void -nautilus_icon_container_position_shadow (NautilusIconContainer *container, +nautilus_canvas_container_position_shadow (NautilusCanvasContainer *container, int x, int y) { EelCanvasItem *shadow; @@ -346,14 +346,14 @@ nautilus_icon_container_position_shadow (NautilusIconContainer *container, } static void -nautilus_icon_container_dropped_icon_feedback (GtkWidget *widget, +nautilus_canvas_container_dropped_canvas_feedback (GtkWidget *widget, GtkSelectionData *data, int x, int y) { - NautilusIconContainer *container; - NautilusIconDndInfo *dnd_info; + NautilusCanvasContainer *container; + NautilusCanvasDndInfo *dnd_info; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); dnd_info = container->details->dnd_info; /* Delete old selection list. */ @@ -370,7 +370,7 @@ nautilus_icon_container_dropped_icon_feedback (GtkWidget *widget, /* Build the selection list and the shadow. */ dnd_info->drag_info.selection_list = nautilus_drag_build_selection_list (data); dnd_info->shadow = create_selection_shadow (container, dnd_info->drag_info.selection_list); - nautilus_icon_container_position_shadow (container, x, y); + nautilus_canvas_container_position_shadow (container, x, y); } static char * @@ -413,7 +413,7 @@ set_direct_save_uri (GtkWidget *widget, GdkDragContext *context, NautilusDragInf uri = NULL; filename = get_direct_save_filename (context); - drop_target = nautilus_icon_container_find_drop_target (NAUTILUS_ICON_CONTAINER (widget), + drop_target = nautilus_canvas_container_find_drop_target (NAUTILUS_CANVAS_CONTAINER (widget), context, x, y, NULL, TRUE); if (drop_target && eel_uri_is_trash (drop_target)) { @@ -461,7 +461,7 @@ get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context, gtk_target_list_add_text_targets (drop_types_list_root, NAUTILUS_ICON_DND_TEXT); } - if (nautilus_icon_container_get_is_desktop (NAUTILUS_ICON_CONTAINER (widget))) { + if (nautilus_canvas_container_get_is_desktop (NAUTILUS_CANVAS_CONTAINER (widget))) { list = drop_types_list_root; } else { list = drop_types_list; @@ -473,7 +473,7 @@ get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context, NautilusDragInfo *drag_info; gboolean found; - drag_info = &(NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info->drag_info); + drag_info = &(NAUTILUS_CANVAS_CONTAINER (widget)->details->dnd_info->drag_info); found = gtk_target_list_find (list, target, &info); g_assert (found); @@ -497,11 +497,11 @@ get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context, } static void -nautilus_icon_container_ensure_drag_data (NautilusIconContainer *container, +nautilus_canvas_container_ensure_drag_data (NautilusCanvasContainer *container, GdkDragContext *context, guint32 time) { - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; dnd_info = container->details->dnd_info; @@ -515,18 +515,18 @@ drag_end_callback (GtkWidget *widget, GdkDragContext *context, gpointer data) { - NautilusIconContainer *container; - NautilusIconDndInfo *dnd_info; + NautilusCanvasContainer *container; + NautilusCanvasDndInfo *dnd_info; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); dnd_info = container->details->dnd_info; nautilus_drag_destroy_selection_list (dnd_info->drag_info.selection_list); dnd_info->drag_info.selection_list = NULL; } -static NautilusIcon * -nautilus_icon_container_item_at (NautilusIconContainer *container, +static NautilusCanvasIcon * +nautilus_canvas_container_item_at (NautilusCanvasContainer *container, int x, int y) { GList *p; @@ -545,7 +545,7 @@ nautilus_icon_container_item_at (NautilusIconContainer *container, point.y1 = y + size; for (p = container->details->icons; p != NULL; p = p->next) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; icon = p->data; eel_canvas_w2c (EEL_CANVAS (container), @@ -558,7 +558,7 @@ nautilus_icon_container_item_at (NautilusIconContainer *container, point.y1, &canvas_point.x1, &canvas_point.y1); - if (nautilus_icon_canvas_item_hit_test_rectangle (icon->item, canvas_point)) { + if (nautilus_canvas_item_hit_test_rectangle (icon->item, canvas_point)) { return icon; } } @@ -567,7 +567,7 @@ nautilus_icon_container_item_at (NautilusIconContainer *container, } static char * -get_container_uri (NautilusIconContainer *container) +get_container_uri (NautilusCanvasContainer *container) { char *uri; @@ -578,7 +578,7 @@ get_container_uri (NautilusIconContainer *container) } static gboolean -nautilus_icon_container_selection_items_local (NautilusIconContainer *container, +nautilus_canvas_container_selection_items_local (NautilusCanvasContainer *container, GList *items) { char *container_uri_string; @@ -602,7 +602,7 @@ nautilus_icon_container_selection_items_local (NautilusIconContainer *container, /* handle dropped url */ static void -receive_dropped_netscape_url (NautilusIconContainer *container, const char *encoded_url, GdkDragContext *context, int x, int y) +receive_dropped_netscape_url (NautilusCanvasContainer *container, const char *encoded_url, GdkDragContext *context, int x, int y) { char *drop_target; @@ -610,7 +610,7 @@ receive_dropped_netscape_url (NautilusIconContainer *container, const char *enco return; } - drop_target = nautilus_icon_container_find_drop_target (container, context, x, y, NULL, TRUE); + drop_target = nautilus_canvas_container_find_drop_target (container, context, x, y, NULL, TRUE); g_signal_emit_by_name (container, "handle_netscape_url", encoded_url, @@ -623,7 +623,7 @@ receive_dropped_netscape_url (NautilusIconContainer *container, const char *enco /* handle dropped uri list */ static void -receive_dropped_uri_list (NautilusIconContainer *container, const char *uri_list, GdkDragContext *context, int x, int y) +receive_dropped_uri_list (NautilusCanvasContainer *container, const char *uri_list, GdkDragContext *context, int x, int y) { char *drop_target; @@ -631,7 +631,7 @@ receive_dropped_uri_list (NautilusIconContainer *container, const char *uri_list return; } - drop_target = nautilus_icon_container_find_drop_target (container, context, x, y, NULL, TRUE); + drop_target = nautilus_canvas_container_find_drop_target (container, context, x, y, NULL, TRUE); g_signal_emit_by_name (container, "handle_uri_list", uri_list, @@ -644,7 +644,7 @@ receive_dropped_uri_list (NautilusIconContainer *container, const char *uri_list /* handle dropped text */ static void -receive_dropped_text (NautilusIconContainer *container, const char *text, GdkDragContext *context, int x, int y) +receive_dropped_text (NautilusCanvasContainer *container, const char *text, GdkDragContext *context, int x, int y) { char *drop_target; @@ -652,7 +652,7 @@ receive_dropped_text (NautilusIconContainer *container, const char *text, GdkDra return; } - drop_target = nautilus_icon_container_find_drop_target (container, context, x, y, NULL, TRUE); + drop_target = nautilus_canvas_container_find_drop_target (container, context, x, y, NULL, TRUE); g_signal_emit_by_name (container, "handle_text", text, @@ -665,7 +665,7 @@ receive_dropped_text (NautilusIconContainer *container, const char *text, GdkDra /* handle dropped raw data */ static void -receive_dropped_raw (NautilusIconContainer *container, const char *raw_data, int length, const char *direct_save_uri, GdkDragContext *context, int x, int y) +receive_dropped_raw (NautilusCanvasContainer *container, const char *raw_data, int length, const char *direct_save_uri, GdkDragContext *context, int x, int y) { char *drop_target; @@ -673,7 +673,7 @@ receive_dropped_raw (NautilusIconContainer *container, const char *raw_data, int return; } - drop_target = nautilus_icon_container_find_drop_target (container, context, x, y, NULL, TRUE); + drop_target = nautilus_canvas_container_find_drop_target (container, context, x, y, NULL, TRUE); g_signal_emit_by_name (container, "handle_raw", raw_data, @@ -689,15 +689,15 @@ receive_dropped_raw (NautilusIconContainer *container, const char *raw_data, int static int auto_scroll_timeout_callback (gpointer data) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; GtkWidget *widget; float x_scroll_delta, y_scroll_delta; GdkRectangle exposed_area; GtkAllocation allocation; - g_assert (NAUTILUS_IS_ICON_CONTAINER (data)); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (data)); widget = GTK_WIDGET (data); - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); if (container->details->dnd_info->drag_info.waiting_to_autoscroll && container->details->dnd_info->drag_info.start_auto_scroll_in > g_get_monotonic_time ()) { @@ -716,7 +716,7 @@ auto_scroll_timeout_callback (gpointer data) /* Clear the old dnd highlight frame */ dnd_highlight_queue_redraw (widget); - if (!nautilus_icon_container_scroll (container, (int)x_scroll_delta, (int)y_scroll_delta)) { + if (!nautilus_canvas_container_scroll (container, (int)x_scroll_delta, (int)y_scroll_delta)) { /* the scroll value got pinned to a min or max adjustment value, * we ended up not scrolling */ @@ -766,7 +766,7 @@ auto_scroll_timeout_callback (gpointer data) } static void -set_up_auto_scroll_if_needed (NautilusIconContainer *container) +set_up_auto_scroll_if_needed (NautilusCanvasContainer *container) { nautilus_drag_autoscroll_start (&container->details->dnd_info->drag_info, GTK_WIDGET (container), @@ -775,18 +775,18 @@ set_up_auto_scroll_if_needed (NautilusIconContainer *container) } static void -stop_auto_scroll (NautilusIconContainer *container) +stop_auto_scroll (NautilusCanvasContainer *container) { nautilus_drag_autoscroll_stop (&container->details->dnd_info->drag_info); } static void -handle_local_move (NautilusIconContainer *container, +handle_local_move (NautilusCanvasContainer *container, double world_x, double world_y) { GList *moved_icons, *p; NautilusDragSelectionItem *item; - NautilusIcon *icon; + NautilusCanvasIcon *icon; NautilusFile *file; char screen_string[32]; GdkScreen *screen; @@ -803,7 +803,7 @@ handle_local_move (NautilusIconContainer *container, for (p = container->details->dnd_info->drag_info.selection_list; p != NULL; p = p->next) { item = p->data; - icon = nautilus_icon_container_get_icon_by_uri + icon = nautilus_canvas_container_get_icon_by_uri (container, item->uri); if (icon == NULL) { @@ -822,14 +822,14 @@ handle_local_move (NautilusIconContainer *container, nautilus_file_set_time_metadata (file, NAUTILUS_METADATA_KEY_ICON_POSITION_TIMESTAMP, now); - nautilus_icon_container_add (container, NAUTILUS_ICON_CONTAINER_ICON_DATA (file)); + nautilus_canvas_container_add (container, NAUTILUS_CANVAS_ICON_DATA (file)); - icon = nautilus_icon_container_get_icon_by_uri + icon = nautilus_canvas_container_get_icon_by_uri (container, item->uri); } if (item->got_icon_position) { - nautilus_icon_container_move_icon + nautilus_canvas_container_move_icon (container, icon, world_x + item->icon_x, world_y + item->icon_y, icon->scale, @@ -837,15 +837,15 @@ handle_local_move (NautilusIconContainer *container, } moved_icons = g_list_prepend (moved_icons, icon); } - nautilus_icon_container_select_list_unselect_others + nautilus_canvas_container_select_list_unselect_others (container, moved_icons); /* Might have been moved in a way that requires adjusting scroll region. */ - nautilus_icon_container_update_scroll_region (container); + nautilus_canvas_container_update_scroll_region (container); g_list_free (moved_icons); } static void -handle_nonlocal_move (NautilusIconContainer *container, +handle_nonlocal_move (NautilusCanvasContainer *container, GdkDragAction action, int x, int y, const char *target_uri, @@ -868,7 +868,7 @@ handle_nonlocal_move (NautilusIconContainer *container, } source_uris = g_list_reverse (source_uris); - is_rtl = nautilus_icon_container_is_layout_rtl (container); + is_rtl = nautilus_canvas_container_is_layout_rtl (container); source_item_locations = g_array_new (FALSE, TRUE, sizeof (GdkPoint)); if (!icon_hit) { @@ -918,13 +918,13 @@ handle_nonlocal_move (NautilusIconContainer *container, } static char * -nautilus_icon_container_find_drop_target (NautilusIconContainer *container, +nautilus_canvas_container_find_drop_target (NautilusCanvasContainer *container, GdkDragContext *context, int x, int y, gboolean *icon_hit, gboolean rewrite_desktop) { - NautilusIcon *drop_target_icon; + NautilusCanvasIcon *drop_target_icon; double world_x, world_y; NautilusFile *file; char *icon_uri; @@ -942,14 +942,14 @@ nautilus_icon_container_find_drop_target (NautilusIconContainer *container, /* FIXME bugzilla.gnome.org 42485: * These "can_accept_items" tests need to be done by - * the icon view, not here. This file is not supposed to know + * the canvas view, not here. This file is not supposed to know * that the target is a file. */ /* Find the item we hit with our drop, if any */ - drop_target_icon = nautilus_icon_container_item_at (container, world_x, world_y); + drop_target_icon = nautilus_canvas_container_item_at (container, world_x, world_y); if (drop_target_icon != NULL) { - icon_uri = nautilus_icon_container_get_icon_uri (container, drop_target_icon); + icon_uri = nautilus_canvas_container_get_icon_uri (container, drop_target_icon); if (icon_uri != NULL) { file = nautilus_file_get_by_uri (icon_uri); @@ -987,7 +987,7 @@ nautilus_icon_container_find_drop_target (NautilusIconContainer *container, if (icon_hit) { *icon_hit = TRUE; } - return nautilus_icon_container_get_icon_drop_target_uri (container, drop_target_icon); + return nautilus_canvas_container_get_icon_drop_target_uri (container, drop_target_icon); } static gboolean @@ -1029,7 +1029,7 @@ selection_is_image_file (GList *selection_list) static void -nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container, +nautilus_canvas_container_receive_dropped_icons (NautilusCanvasContainer *container, GdkDragContext *context, int x, int y) { @@ -1089,15 +1089,15 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container, y + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))), &world_x, &world_y); - drop_target = nautilus_icon_container_find_drop_target (container, + drop_target = nautilus_canvas_container_find_drop_target (container, context, x, y, &icon_hit, FALSE); local_move_only = FALSE; if (!icon_hit && real_action == GDK_ACTION_MOVE) { - /* we can just move the icon positions if the move ended up in + /* we can just move the canvas positions if the move ended up in * the item's parent container */ - local_move_only = nautilus_icon_container_selection_items_local + local_move_only = nautilus_canvas_container_selection_items_local (container, container->details->dnd_info->drag_info.selection_list); } @@ -1114,7 +1114,7 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container, } static void -nautilus_icon_container_get_drop_action (NautilusIconContainer *container, +nautilus_canvas_container_get_drop_action (NautilusCanvasContainer *container, GdkDragContext *context, int x, int y, int *action) @@ -1129,7 +1129,7 @@ nautilus_icon_container_get_drop_action (NautilusIconContainer *container, return; } - /* find out if we're over an icon */ + /* find out if we're over an canvas */ canvas_widget_to_world (EEL_CANVAS (container), x, y, &world_x, &world_y); *action = 0; @@ -1139,7 +1139,7 @@ nautilus_icon_container_get_drop_action (NautilusIconContainer *container, if (container->details->dnd_info->drag_info.selection_list == NULL) { return; } - drop_target = nautilus_icon_container_find_drop_target (container, + drop_target = nautilus_canvas_container_find_drop_target (container, context, x, y, &icon_hit, FALSE); if (!drop_target) { return; @@ -1150,7 +1150,7 @@ nautilus_icon_container_get_drop_action (NautilusIconContainer *container, g_free (drop_target); break; case NAUTILUS_ICON_DND_URI_LIST: - drop_target = nautilus_icon_container_find_drop_target (container, + drop_target = nautilus_canvas_container_find_drop_target (container, context, x, y, &icon_hit, FALSE); *action = nautilus_drag_default_drop_action_for_uri_list (context, drop_target); @@ -1174,10 +1174,10 @@ nautilus_icon_container_get_drop_action (NautilusIconContainer *container, } static void -set_drop_target (NautilusIconContainer *container, - NautilusIcon *icon) +set_drop_target (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon) { - NautilusIcon *old_icon; + NautilusCanvasIcon *old_icon; /* Check if current drop target changed, update icon drop * higlight if needed. @@ -1189,36 +1189,36 @@ set_drop_target (NautilusIconContainer *container, /* Remember the new drop target for the next round. */ container->details->drop_target = icon; - nautilus_icon_container_update_icon (container, old_icon); - nautilus_icon_container_update_icon (container, icon); + nautilus_canvas_container_update_icon (container, old_icon); + nautilus_canvas_container_update_icon (container, icon); } static void -nautilus_icon_dnd_update_drop_target (NautilusIconContainer *container, +nautilus_canvas_dnd_update_drop_target (NautilusCanvasContainer *container, GdkDragContext *context, int x, int y) { - NautilusIcon *icon; + NautilusCanvasIcon *icon; NautilusFile *file; double world_x, world_y; char *uri; - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); canvas_widget_to_world (EEL_CANVAS (container), x, y, &world_x, &world_y); /* Find the item we hit with our drop, if any. */ - icon = nautilus_icon_container_item_at (container, world_x, world_y); + icon = nautilus_canvas_container_item_at (container, world_x, world_y); /* FIXME bugzilla.gnome.org 42485: * These "can_accept_items" tests need to be done by - * the icon view, not here. This file is not supposed to know + * the canvas view, not here. This file is not supposed to know * that the target is a file. */ - /* Find if target icon accepts our drop. */ + /* Find if target canvas accepts our drop. */ if (icon != NULL) { - uri = nautilus_icon_container_get_icon_uri (container, icon); + uri = nautilus_canvas_container_get_icon_uri (container, icon); file = nautilus_file_get_by_uri (uri); g_free (uri); @@ -1235,9 +1235,9 @@ nautilus_icon_dnd_update_drop_target (NautilusIconContainer *container, } static void -nautilus_icon_container_free_drag_data (NautilusIconContainer *container) +nautilus_canvas_container_free_drag_data (NautilusCanvasContainer *container) { - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; dnd_info = container->details->dnd_info; @@ -1265,18 +1265,18 @@ drag_leave_callback (GtkWidget *widget, guint32 time, gpointer data) { - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; - dnd_info = NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info; + dnd_info = NAUTILUS_CANVAS_CONTAINER (widget)->details->dnd_info; if (dnd_info->shadow != NULL) eel_canvas_item_hide (dnd_info->shadow); stop_dnd_highlight (widget); - set_drop_target (NAUTILUS_ICON_CONTAINER (widget), NULL); - stop_auto_scroll (NAUTILUS_ICON_CONTAINER (widget)); - nautilus_icon_container_free_drag_data(NAUTILUS_ICON_CONTAINER (widget)); + set_drop_target (NAUTILUS_CANVAS_CONTAINER (widget), NULL); + stop_auto_scroll (NAUTILUS_CANVAS_CONTAINER (widget)); + nautilus_canvas_container_free_drag_data(NAUTILUS_CANVAS_CONTAINER (widget)); } static void @@ -1284,13 +1284,13 @@ drag_begin_callback (GtkWidget *widget, GdkDragContext *context, gpointer data) { - NautilusIconContainer *container; + NautilusCanvasContainer *container; cairo_surface_t *surface; double x1, y1, x2, y2, winx, winy; int x_offset, y_offset; int start_x, start_y; - container = NAUTILUS_ICON_CONTAINER (widget); + container = NAUTILUS_CANVAS_CONTAINER (widget); start_x = container->details->dnd_info->drag_info.start_x + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))); @@ -1298,7 +1298,7 @@ drag_begin_callback (GtkWidget *widget, gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))); /* create a pixmap and mask to drag with */ - surface = nautilus_icon_canvas_item_get_drag_surface (container->details->drag_icon->item); + surface = nautilus_canvas_item_get_drag_surface (container->details->drag_icon->item); /* compute the image's offset */ eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (container->details->drag_icon->item), @@ -1314,16 +1314,16 @@ drag_begin_callback (GtkWidget *widget, } void -nautilus_icon_dnd_begin_drag (NautilusIconContainer *container, +nautilus_canvas_dnd_begin_drag (NautilusCanvasContainer *container, GdkDragAction actions, int button, GdkEventMotion *event, int start_x, int start_y) { - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); g_return_if_fail (event != NULL); dnd_info = container->details->dnd_info; @@ -1377,11 +1377,11 @@ drag_highlight_draw (GtkWidget *widget, static void dnd_highlight_queue_redraw (GtkWidget *widget) { - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; int width, height; GtkAllocation allocation; - dnd_info = NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info; + dnd_info = NAUTILUS_CANVAS_CONTAINER (widget)->details->dnd_info; if (!dnd_info->highlighted) { return; @@ -1411,10 +1411,10 @@ dnd_highlight_queue_redraw (GtkWidget *widget) static void start_dnd_highlight (GtkWidget *widget) { - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; GtkWidget *toplevel; - dnd_info = NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info; + dnd_info = NAUTILUS_CANVAS_CONTAINER (widget)->details->dnd_info; toplevel = gtk_widget_get_toplevel (widget); if (toplevel != NULL && @@ -1434,9 +1434,9 @@ start_dnd_highlight (GtkWidget *widget) static void stop_dnd_highlight (GtkWidget *widget) { - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; - dnd_info = NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info; + dnd_info = NAUTILUS_CANVAS_CONTAINER (widget)->details->dnd_info; if (dnd_info->highlighted) { g_signal_handlers_disconnect_by_func (widget, @@ -1455,15 +1455,15 @@ drag_motion_callback (GtkWidget *widget, { int action; - nautilus_icon_container_ensure_drag_data (NAUTILUS_ICON_CONTAINER (widget), context, time); - nautilus_icon_container_position_shadow (NAUTILUS_ICON_CONTAINER (widget), x, y); - nautilus_icon_dnd_update_drop_target (NAUTILUS_ICON_CONTAINER (widget), context, x, y); - set_up_auto_scroll_if_needed (NAUTILUS_ICON_CONTAINER (widget)); + nautilus_canvas_container_ensure_drag_data (NAUTILUS_CANVAS_CONTAINER (widget), context, time); + nautilus_canvas_container_position_shadow (NAUTILUS_CANVAS_CONTAINER (widget), x, y); + nautilus_canvas_dnd_update_drop_target (NAUTILUS_CANVAS_CONTAINER (widget), context, x, y); + set_up_auto_scroll_if_needed (NAUTILUS_CANVAS_CONTAINER (widget)); /* Find out what the drop actions are based on our drag selection and * the drop target. */ action = 0; - nautilus_icon_container_get_drop_action (NAUTILUS_ICON_CONTAINER (widget), context, x, y, + nautilus_canvas_container_get_drop_action (NAUTILUS_CANVAS_CONTAINER (widget), context, x, y, &action); if (action != 0) { start_dnd_highlight (widget); @@ -1482,9 +1482,9 @@ drag_drop_callback (GtkWidget *widget, guint32 time, gpointer data) { - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; - dnd_info = NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info; + dnd_info = NAUTILUS_CANVAS_CONTAINER (widget)->details->dnd_info; /* tell the drag_data_received callback that the drop occured and that it can actually @@ -1499,11 +1499,11 @@ drag_drop_callback (GtkWidget *widget, } void -nautilus_icon_dnd_end_drag (NautilusIconContainer *container) +nautilus_canvas_dnd_end_drag (NautilusCanvasContainer *container) { - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); dnd_info = container->details->dnd_info; g_return_if_fail (dnd_info != NULL); @@ -1537,14 +1537,14 @@ drag_data_received_callback (GtkWidget *widget, int length; gboolean success; - drag_info = &(NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info->drag_info); + drag_info = &(NAUTILUS_CANVAS_CONTAINER (widget)->details->dnd_info->drag_info); drag_info->got_drop_data_type = TRUE; drag_info->data_type = info; switch (info) { case NAUTILUS_ICON_DND_GNOME_ICON_LIST: - nautilus_icon_container_dropped_icon_feedback (widget, data, x, y); + nautilus_canvas_container_dropped_canvas_feedback (widget, data, x, y); break; case NAUTILUS_ICON_DND_URI_LIST: case NAUTILUS_ICON_DND_TEXT: @@ -1577,26 +1577,26 @@ drag_data_received_callback (GtkWidget *widget, success = FALSE; switch (info) { case NAUTILUS_ICON_DND_GNOME_ICON_LIST: - nautilus_icon_container_receive_dropped_icons - (NAUTILUS_ICON_CONTAINER (widget), + nautilus_canvas_container_receive_dropped_icons + (NAUTILUS_CANVAS_CONTAINER (widget), context, x, y); break; case NAUTILUS_ICON_DND_NETSCAPE_URL: receive_dropped_netscape_url - (NAUTILUS_ICON_CONTAINER (widget), + (NAUTILUS_CANVAS_CONTAINER (widget), (char *) gtk_selection_data_get_data (data), context, x, y); success = TRUE; break; case NAUTILUS_ICON_DND_URI_LIST: receive_dropped_uri_list - (NAUTILUS_ICON_CONTAINER (widget), + (NAUTILUS_CANVAS_CONTAINER (widget), (char *) gtk_selection_data_get_data (data), context, x, y); success = TRUE; break; case NAUTILUS_ICON_DND_TEXT: tmp = gtk_selection_data_get_text (data); receive_dropped_text - (NAUTILUS_ICON_CONTAINER (widget), + (NAUTILUS_CANVAS_CONTAINER (widget), (char *) tmp, context, x, y); success = TRUE; g_free (tmp); @@ -1605,7 +1605,7 @@ drag_data_received_callback (GtkWidget *widget, length = gtk_selection_data_get_length (data); tmp_raw = gtk_selection_data_get_data (data); receive_dropped_raw - (NAUTILUS_ICON_CONTAINER (widget), + (NAUTILUS_CANVAS_CONTAINER (widget), (const gchar *) tmp_raw, length, drag_info->direct_save_uri, context, x, y); success = TRUE; @@ -1656,9 +1656,9 @@ drag_data_received_callback (GtkWidget *widget, } gtk_drag_finish (context, success, FALSE, time); - nautilus_icon_container_free_drag_data (NAUTILUS_ICON_CONTAINER (widget)); + nautilus_canvas_container_free_drag_data (NAUTILUS_CANVAS_CONTAINER (widget)); - set_drop_target (NAUTILUS_ICON_CONTAINER (widget), NULL); + set_drop_target (NAUTILUS_CANVAS_CONTAINER (widget), NULL); /* reinitialise it for the next dnd */ drag_info->drop_occured = FALSE; @@ -1667,16 +1667,16 @@ drag_data_received_callback (GtkWidget *widget, } void -nautilus_icon_dnd_init (NautilusIconContainer *container) +nautilus_canvas_dnd_init (NautilusCanvasContainer *container) { GtkTargetList *targets; int n_elements; g_return_if_fail (container != NULL); - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); - container->details->dnd_info = g_new0 (NautilusIconDndInfo, 1); + container->details->dnd_info = g_new0 (NautilusCanvasDndInfo, 1); nautilus_drag_init (&container->details->dnd_info->drag_info, drag_types, G_N_ELEMENTS (drag_types), TRUE); @@ -1685,7 +1685,7 @@ nautilus_icon_dnd_init (NautilusIconContainer *container) * implemented by dealing with events manually.) */ n_elements = G_N_ELEMENTS (drop_types); - if (!nautilus_icon_container_get_is_desktop (container)) { + if (!nautilus_canvas_container_get_is_desktop (container)) { /* Don't set up rootwindow drop */ n_elements -= 1; } @@ -1718,9 +1718,9 @@ nautilus_icon_dnd_init (NautilusIconContainer *container) } void -nautilus_icon_dnd_fini (NautilusIconContainer *container) +nautilus_canvas_dnd_fini (NautilusCanvasContainer *container) { - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container)); if (container->details->dnd_info != NULL) { stop_auto_scroll (container); diff --git a/libnautilus-private/nautilus-icon-dnd.h b/libnautilus-private/nautilus-canvas-dnd.h index 4a1fde1e8..00d8719b2 100644 --- a/libnautilus-private/nautilus-icon-dnd.h +++ b/libnautilus-private/nautilus-canvas-dnd.h @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* nautilus-icon-dnd.h - Drag & drop handling for the icon container widget. +/* nautilus-canvas-dnd.h - Drag & drop handling for the canvas container widget. Copyright (C) 1999, 2000 Free Software Foundation Copyright (C) 2000 Eazel, Inc. @@ -25,10 +25,10 @@ Andy Hertzfeld <andy@eazel.com> */ -#ifndef NAUTILUS_ICON_DND_H -#define NAUTILUS_ICON_DND_H +#ifndef NAUTILUS_CANVAS_DND_H +#define NAUTILUS_CANVAS_DND_H -#include <libnautilus-private/nautilus-icon-container.h> +#include <libnautilus-private/nautilus-canvas-container.h> #include <libnautilus-private/nautilus-dnd.h> /* DnD-related information. */ @@ -40,17 +40,17 @@ typedef struct { /* Shadow for the icons being dragged. */ EelCanvasItem *shadow; -} NautilusIconDndInfo; +} NautilusCanvasDndInfo; -void nautilus_icon_dnd_init (NautilusIconContainer *container); -void nautilus_icon_dnd_fini (NautilusIconContainer *container); -void nautilus_icon_dnd_begin_drag (NautilusIconContainer *container, - GdkDragAction actions, - gint button, - GdkEventMotion *event, - int start_x, - int start_y); -void nautilus_icon_dnd_end_drag (NautilusIconContainer *container); +void nautilus_canvas_dnd_init (NautilusCanvasContainer *container); +void nautilus_canvas_dnd_fini (NautilusCanvasContainer *container); +void nautilus_canvas_dnd_begin_drag (NautilusCanvasContainer *container, + GdkDragAction actions, + gint button, + GdkEventMotion *event, + int start_x, + int start_y); +void nautilus_canvas_dnd_end_drag (NautilusCanvasContainer *container); -#endif /* NAUTILUS_ICON_DND_H */ +#endif /* NAUTILUS_CANVAS_DND_H */ diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-canvas-item.c index 01c6e061a..c564663ab 100644 --- a/libnautilus-private/nautilus-icon-canvas-item.c +++ b/libnautilus-private/nautilus-canvas-item.c @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* Nautilus - Icon canvas item class for icon container. +/* Nautilus - Canvas item class for canvas container. * * Copyright (C) 2000 Eazel, Inc * @@ -24,13 +24,13 @@ #include <config.h> #include <math.h> -#include "nautilus-icon-canvas-item.h" +#include "nautilus-canvas-item.h" #include <glib/gi18n.h> #include "nautilus-file-utilities.h" #include "nautilus-global-preferences.h" -#include "nautilus-icon-private.h" +#include "nautilus-canvas-private.h" #include <eel/eel-art-extensions.h> #include <eel/eel-gdk-extensions.h> #include <eel/eel-glib-extensions.h> @@ -56,7 +56,7 @@ /* special text height handling * each item has three text height variables: * + text_height: actual height of the displayed (i.e. on-screen) PangoLayout. - * + text_height_for_layout: height used in icon grid layout algorithms. + * + text_height_for_layout: height used in canvas grid layout algorithms. * “sane amount” of text. * “sane amount“ as of * + hard-coded to three lines in text-below-icon mode. @@ -69,8 +69,8 @@ * if it wasn't ellipsized. */ -/* Private part of the NautilusIconCanvasItem structure. */ -struct NautilusIconCanvasItemDetails { +/* Private part of the NautilusCanvasItem structure. */ +struct NautilusCanvasItemDetails { /* The image, text, font. */ double x, y; GdkPixbuf *pixbuf; @@ -127,7 +127,7 @@ struct NautilusIconCanvasItemDetails { PangoLayout *embedded_text_layout; /* Cached rectangle in canvas coordinates */ - EelIRect canvas_rect; + EelIRect icon_rect; EelIRect text_rect; EelIRect bounds_cache; @@ -158,53 +158,53 @@ typedef enum { TOP_SIDE } RectangleSide; -static void nautilus_icon_canvas_item_text_interface_init (EelAccessibleTextIface *iface); -static GType nautilus_icon_canvas_item_accessible_factory_get_type (void); +static void nautilus_canvas_item_text_interface_init (EelAccessibleTextIface *iface); +static GType nautilus_canvas_item_accessible_factory_get_type (void); -G_DEFINE_TYPE_WITH_CODE (NautilusIconCanvasItem, nautilus_icon_canvas_item, EEL_TYPE_CANVAS_ITEM, +G_DEFINE_TYPE_WITH_CODE (NautilusCanvasItem, nautilus_canvas_item, EEL_TYPE_CANVAS_ITEM, G_IMPLEMENT_INTERFACE (EEL_TYPE_ACCESSIBLE_TEXT, - nautilus_icon_canvas_item_text_interface_init)); + nautilus_canvas_item_text_interface_init)); /* private */ -static void draw_label_text (NautilusIconCanvasItem *item, +static void draw_label_text (NautilusCanvasItem *item, cairo_t *cr, EelIRect icon_rect); -static void measure_label_text (NautilusIconCanvasItem *item); -static void get_icon_canvas_rectangle (NautilusIconCanvasItem *item, - EelIRect *rect); +static void measure_label_text (NautilusCanvasItem *item); +static void get_icon_rectangle (NautilusCanvasItem *item, + EelIRect *rect); static void draw_pixbuf (GdkPixbuf *pixbuf, cairo_t *cr, int x, int y); static PangoLayout *get_label_layout (PangoLayout **layout, - NautilusIconCanvasItem *item, + NautilusCanvasItem *item, const char *text); -static gboolean hit_test_stretch_handle (NautilusIconCanvasItem *item, - EelIRect canvas_rect, +static gboolean hit_test_stretch_handle (NautilusCanvasItem *item, + EelIRect icon_rect, GtkCornerType *corner); -static void draw_embedded_text (NautilusIconCanvasItem *icon_item, +static void draw_embedded_text (NautilusCanvasItem *canvas_item, cairo_t *cr, int x, int y); -static void nautilus_icon_canvas_item_ensure_bounds_up_to_date (NautilusIconCanvasItem *icon_item); +static void nautilus_canvas_item_ensure_bounds_up_to_date (NautilusCanvasItem *canvas_item); -/* Object initialization function for the icon item. */ +/* Object initialization function for the canvas item. */ static void -nautilus_icon_canvas_item_init (NautilusIconCanvasItem *icon_item) +nautilus_canvas_item_init (NautilusCanvasItem *canvas_item) { - icon_item->details = G_TYPE_INSTANCE_GET_PRIVATE ((icon_item), NAUTILUS_TYPE_ICON_CANVAS_ITEM, NautilusIconCanvasItemDetails); - nautilus_icon_canvas_item_invalidate_label_size (icon_item); + canvas_item->details = G_TYPE_INSTANCE_GET_PRIVATE ((canvas_item), NAUTILUS_TYPE_CANVAS_ITEM, NautilusCanvasItemDetails); + nautilus_canvas_item_invalidate_label_size (canvas_item); } static void -nautilus_icon_canvas_item_finalize (GObject *object) +nautilus_canvas_item_finalize (GObject *object) { - NautilusIconCanvasItemDetails *details; + NautilusCanvasItemDetails *details; - g_assert (NAUTILUS_IS_ICON_CANVAS_ITEM (object)); + g_assert (NAUTILUS_IS_CANVAS_ITEM (object)); - details = NAUTILUS_ICON_CANVAS_ITEM (object)->details; + details = NAUTILUS_CANVAS_ITEM (object)->details; if (details->cursor_window != NULL) { gdk_window_set_cursor (details->cursor_window, NULL); @@ -241,7 +241,7 @@ nautilus_icon_canvas_item_finalize (GObject *object) g_free (details->embedded_text); - G_OBJECT_CLASS (nautilus_icon_canvas_item_parent_class)->finalize (object); + G_OBJECT_CLASS (nautilus_canvas_item_parent_class)->finalize (object); } /* Currently we require pixbufs in this format (for hit testing). @@ -260,14 +260,14 @@ pixbuf_is_acceptable (GdkPixbuf *pixbuf) } static void -nautilus_icon_canvas_item_invalidate_bounds_cache (NautilusIconCanvasItem *item) +nautilus_canvas_item_invalidate_bounds_cache (NautilusCanvasItem *item) { item->details->bounds_cached = FALSE; } /* invalidate the text width and height cached in the item details. */ void -nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item) +nautilus_canvas_item_invalidate_label_size (NautilusCanvasItem *item) { if (item->details->editable_text_layout != NULL) { pango_layout_context_changed (item->details->editable_text_layout); @@ -278,7 +278,7 @@ nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item) if (item->details->embedded_text_layout != NULL) { pango_layout_context_changed (item->details->embedded_text_layout); } - nautilus_icon_canvas_item_invalidate_bounds_cache (item); + nautilus_canvas_item_invalidate_bounds_cache (item); item->details->text_width = -1; item->details->text_height = -1; item->details->text_height_for_layout = -1; @@ -286,18 +286,18 @@ nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item) item->details->editable_text_height = -1; } -/* Set property handler for the icon item. */ +/* Set property handler for the canvas item. */ static void -nautilus_icon_canvas_item_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) +nautilus_canvas_item_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { - NautilusIconCanvasItem *item; - NautilusIconCanvasItemDetails *details; + NautilusCanvasItem *item; + NautilusCanvasItemDetails *details; AtkObject *accessible; - item = NAUTILUS_ICON_CANVAS_ITEM (object); + item = NAUTILUS_CANVAS_ITEM (object); accessible = atk_gobject_accessible_for_object (G_OBJECT (item)); details = item->details; @@ -305,7 +305,7 @@ nautilus_icon_canvas_item_set_property (GObject *object, case PROP_EDITABLE_TEXT: if (g_strcmp0 (details->editable_text, - g_value_get_string (value)) == 0) { + g_value_get_string (value)) == 0) { return; } @@ -317,7 +317,7 @@ nautilus_icon_canvas_item_set_property (GObject *object, g_object_notify (G_OBJECT(accessible), "accessible-name"); } - nautilus_icon_canvas_item_invalidate_label_size (item); + nautilus_canvas_item_invalidate_label_size (item); if (details->editable_text_layout) { g_object_unref (details->editable_text_layout); details->editable_text_layout = NULL; @@ -333,7 +333,7 @@ nautilus_icon_canvas_item_set_property (GObject *object, g_free (details->additional_text); details->additional_text = g_strdup (g_value_get_string (value)); - nautilus_icon_canvas_item_invalidate_label_size (item); + nautilus_canvas_item_invalidate_label_size (item); if (details->additional_text_layout) { g_object_unref (details->additional_text_layout); details->additional_text_layout = NULL; @@ -345,7 +345,7 @@ nautilus_icon_canvas_item_set_property (GObject *object, return; } details->is_highlighted_for_selection = g_value_get_boolean (value); - nautilus_icon_canvas_item_invalidate_label_size (item); + nautilus_canvas_item_invalidate_label_size (item); atk_object_notify_state_change (accessible, ATK_STATE_SELECTED, details->is_highlighted_for_selection); @@ -378,23 +378,23 @@ nautilus_icon_canvas_item_set_property (GObject *object, break; default: - g_warning ("nautilus_icons_view_item_item_set_arg on unknown argument"); + g_warning ("nautilus_canvas_item_set_property on unknown argument"); return; } eel_canvas_item_request_update (EEL_CANVAS_ITEM (object)); } -/* Get property handler for the icon item */ +/* Get property handler for the canvas item */ static void -nautilus_icon_canvas_item_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +nautilus_canvas_item_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - NautilusIconCanvasItemDetails *details; + NautilusCanvasItemDetails *details; - details = NAUTILUS_ICON_CANVAS_ITEM (object)->details; + details = NAUTILUS_CANVAS_ITEM (object)->details; switch (property_id) { @@ -429,7 +429,7 @@ nautilus_icon_canvas_item_get_property (GObject *object, } cairo_surface_t * -nautilus_icon_canvas_item_get_drag_surface (NautilusIconCanvasItem *item) +nautilus_canvas_item_get_drag_surface (NautilusCanvasItem *item) { cairo_surface_t *surface; EelCanvas *canvas; @@ -441,7 +441,7 @@ nautilus_icon_canvas_item_get_drag_surface (NautilusIconCanvasItem *item) cairo_t *cr; GtkStyleContext *context; - g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), NULL); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_ITEM (item), NULL); canvas = EEL_CANVAS_ITEM (item)->canvas; screen = gtk_widget_get_screen (GTK_WIDGET (canvas)); @@ -472,7 +472,7 @@ nautilus_icon_canvas_item_get_drag_surface (NautilusIconCanvasItem *item) cr = cairo_create (surface); gtk_render_icon (context, cr, item->details->pixbuf, - item_offset_x, item_offset_y); + item_offset_x, item_offset_y); icon_rect.x0 = item_offset_x; icon_rect.y0 = item_offset_y; @@ -490,12 +490,12 @@ nautilus_icon_canvas_item_get_drag_surface (NautilusIconCanvasItem *item) } void -nautilus_icon_canvas_item_set_image (NautilusIconCanvasItem *item, - GdkPixbuf *image) +nautilus_canvas_item_set_image (NautilusCanvasItem *item, + GdkPixbuf *image) { - NautilusIconCanvasItemDetails *details; + NautilusCanvasItemDetails *details; - g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item)); + g_return_if_fail (NAUTILUS_IS_CANVAS_ITEM (item)); g_return_if_fail (image == NULL || pixbuf_is_acceptable (image)); details = item->details; @@ -516,14 +516,14 @@ nautilus_icon_canvas_item_set_image (NautilusIconCanvasItem *item, details->pixbuf = image; - nautilus_icon_canvas_item_invalidate_bounds_cache (item); + nautilus_canvas_item_invalidate_bounds_cache (item); eel_canvas_item_request_update (EEL_CANVAS_ITEM (item)); } void -nautilus_icon_canvas_item_set_attach_points (NautilusIconCanvasItem *item, - GdkPoint *attach_points, - int n_attach_points) +nautilus_canvas_item_set_attach_points (NautilusCanvasItem *item, + GdkPoint *attach_points, + int n_attach_points) { g_free (item->details->attach_points); item->details->attach_points = NULL; @@ -534,22 +534,22 @@ nautilus_icon_canvas_item_set_attach_points (NautilusIconCanvasItem *item, item->details->n_attach_points = n_attach_points; } - nautilus_icon_canvas_item_invalidate_bounds_cache (item); + nautilus_canvas_item_invalidate_bounds_cache (item); } void -nautilus_icon_canvas_item_set_embedded_text_rect (NautilusIconCanvasItem *item, - const GdkRectangle *text_rect) +nautilus_canvas_item_set_embedded_text_rect (NautilusCanvasItem *item, + const GdkRectangle *text_rect) { item->details->embedded_text_rect = *text_rect; - nautilus_icon_canvas_item_invalidate_bounds_cache (item); + nautilus_canvas_item_invalidate_bounds_cache (item); eel_canvas_item_request_update (EEL_CANVAS_ITEM (item)); } void -nautilus_icon_canvas_item_set_embedded_text (NautilusIconCanvasItem *item, - const char *text) +nautilus_canvas_item_set_embedded_text (NautilusCanvasItem *item, + const char *text) { g_free (item->details->embedded_text); item->details->embedded_text = g_strdup (text); @@ -566,12 +566,12 @@ nautilus_icon_canvas_item_set_embedded_text (NautilusIconCanvasItem *item, } -/* Recomputes the bounding box of a icon canvas item. +/* Recomputes the bounding box of a 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. */ static void -recompute_bounding_box (NautilusIconCanvasItem *icon_item, +recompute_bounding_box (NautilusCanvasItem *canvas_item, double i2w_dx, double i2w_dy) { /* The bounds stored in the item is the same as what get_bounds @@ -582,7 +582,7 @@ recompute_bounding_box (NautilusIconCanvasItem *icon_item, EelCanvasItem *item; EelDRect bounds_rect; - item = EEL_CANVAS_ITEM (icon_item); + item = EEL_CANVAS_ITEM (canvas_item); eel_canvas_item_get_bounds (item, &bounds_rect.x0, &bounds_rect.y0, @@ -601,10 +601,10 @@ recompute_bounding_box (NautilusIconCanvasItem *icon_item, } static EelIRect -compute_text_rectangle (const NautilusIconCanvasItem *item, +compute_text_rectangle (const NautilusCanvasItem *item, EelIRect icon_rectangle, gboolean canvas_coords, - NautilusIconCanvasItemBoundsUsage usage) + NautilusCanvasItemBoundsUsage usage) { EelIRect text_rectangle; double pixels_per_unit; @@ -658,8 +658,8 @@ get_current_canvas_bounds (EelCanvasItem *item) } void -nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item, - double i2w_dx, double i2w_dy) +nautilus_canvas_item_update_bounds (NautilusCanvasItem *item, + double i2w_dx, double i2w_dy) { EelIRect before, after; EelCanvasItem *canvas_item; @@ -677,8 +677,8 @@ nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item, } /* Update canvas and text rect cache */ - get_icon_canvas_rectangle (item, &item->details->canvas_rect); - item->details->text_rect = compute_text_rectangle (item, item->details->canvas_rect, + get_icon_rectangle (item, &item->details->icon_rect); + item->details->text_rect = compute_text_rectangle (item, item->details->icon_rect, TRUE, BOUNDS_USAGE_FOR_DISPLAY); /* queue a redraw. */ @@ -687,17 +687,17 @@ nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item, before.x1 + 1, before.y1 + 1); } -/* Update handler for the icon canvas item. */ +/* Update handler for the canvas canvas item. */ static void -nautilus_icon_canvas_item_update (EelCanvasItem *item, - double i2w_dx, double i2w_dy, - gint flags) +nautilus_canvas_item_update (EelCanvasItem *item, + double i2w_dx, double i2w_dy, + gint flags) { - nautilus_icon_canvas_item_update_bounds (NAUTILUS_ICON_CANVAS_ITEM (item), i2w_dx, i2w_dy); + nautilus_canvas_item_update_bounds (NAUTILUS_CANVAS_ITEM (item), i2w_dx, i2w_dy); eel_canvas_item_request_redraw (EEL_CANVAS_ITEM (item)); - EEL_CANVAS_ITEM_CLASS (nautilus_icon_canvas_item_parent_class)->update (item, i2w_dx, i2w_dy, flags); + EEL_CANVAS_ITEM_CLASS (nautilus_canvas_item_parent_class)->update (item, i2w_dx, i2w_dy, flags); } /* Rendering */ @@ -783,19 +783,19 @@ layout_get_size_for_layout (PangoLayout *layout, #define TEXT_BACK_PADDING_Y 1 static void -prepare_pango_layout_width (NautilusIconCanvasItem *item, +prepare_pango_layout_width (NautilusCanvasItem *item, PangoLayout *layout) { - if (nautilus_icon_canvas_item_get_max_text_width (item) < 0) { + if (nautilus_canvas_item_get_max_text_width (item) < 0) { pango_layout_set_width (layout, -1); } else { - pango_layout_set_width (layout, floor (nautilus_icon_canvas_item_get_max_text_width (item)) * PANGO_SCALE); + pango_layout_set_width (layout, floor (nautilus_canvas_item_get_max_text_width (item)) * PANGO_SCALE); pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); } } static void -prepare_pango_layout_for_measure_entire_text (NautilusIconCanvasItem *item, +prepare_pango_layout_for_measure_entire_text (NautilusCanvasItem *item, PangoLayout *layout) { prepare_pango_layout_width (item, layout); @@ -803,16 +803,16 @@ prepare_pango_layout_for_measure_entire_text (NautilusIconCanvasItem *item, } static void -prepare_pango_layout_for_draw (NautilusIconCanvasItem *item, +prepare_pango_layout_for_draw (NautilusCanvasItem *item, PangoLayout *layout) { - NautilusIconCanvasItemDetails *details; - NautilusIconContainer *container; + NautilusCanvasItemDetails *details; + NautilusCanvasContainer *container; gboolean needs_highlight; prepare_pango_layout_width (item, layout); - container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); + container = NAUTILUS_CANVAS_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); details = item->details; needs_highlight = details->is_highlighted_for_selection || details->is_highlighted_for_drop; @@ -829,15 +829,15 @@ prepare_pango_layout_for_draw (NautilusIconCanvasItem *item, * out itself (which it doesn't ATM). */ pango_layout_set_height (layout, - nautilus_icon_container_get_max_layout_lines_for_pango (container)); + nautilus_canvas_container_get_max_layout_lines_for_pango (container)); } } static void -measure_label_text (NautilusIconCanvasItem *item) +measure_label_text (NautilusCanvasItem *item) { - NautilusIconCanvasItemDetails *details; - NautilusIconContainer *container; + NautilusCanvasItemDetails *details; + NautilusCanvasContainer *container; gint editable_height, editable_height_for_layout, editable_height_for_entire_text, editable_width, editable_dx; gint additional_height, additional_width, additional_dx; PangoLayout *editable_layout; @@ -884,7 +884,7 @@ measure_label_text (NautilusIconCanvasItem *item) additional_height = 0; additional_dx = 0; - container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); + container = NAUTILUS_CANVAS_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); editable_layout = NULL; additional_layout = NULL; @@ -901,7 +901,7 @@ measure_label_text (NautilusIconCanvasItem *item) &editable_height_for_entire_text, NULL); layout_get_size_for_layout (editable_layout, - nautilus_icon_container_get_max_layout_lines (container), + nautilus_canvas_container_get_max_layout_lines (container), editable_height_for_entire_text, &editable_height_for_layout); @@ -960,12 +960,12 @@ measure_label_text (NautilusIconCanvasItem *item) } static void -draw_label_text (NautilusIconCanvasItem *item, +draw_label_text (NautilusCanvasItem *item, cairo_t *cr, EelIRect icon_rect) { - NautilusIconCanvasItemDetails *details; - NautilusIconContainer *container; + NautilusCanvasItemDetails *details; + NautilusCanvasContainer *container; PangoLayout *editable_layout; PangoLayout *additional_layout; GtkStyleContext *context; @@ -990,7 +990,7 @@ draw_label_text (NautilusIconCanvasItem *item, return; } - container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); + container = NAUTILUS_CANVAS_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); context = gtk_widget_get_style_context (GTK_WIDGET (container)); text_rect = compute_text_rectangle (item, icon_rect, TRUE, BOUNDS_USAGE_FOR_DISPLAY); @@ -1004,7 +1004,7 @@ draw_label_text (NautilusIconCanvasItem *item, have_additional = details->additional_text != NULL && details->additional_text[0] != '\0'; g_assert (have_editable || have_additional); - max_text_width = floor (nautilus_icon_canvas_item_get_max_text_width (item)); + max_text_width = floor (nautilus_canvas_item_get_max_text_width (item)); base_state = gtk_widget_get_state_flags (GTK_WIDGET (container)); base_state &= ~(GTK_STATE_FLAG_SELECTED | @@ -1015,7 +1015,7 @@ draw_label_text (NautilusIconCanvasItem *item, "activate_prelight_icon_label", &prelight_label, NULL); - /* if the icon is highlighted, do some set-up */ + /* if the canvas is highlighted, do some set-up */ if (needs_highlight && !details->is_renaming) { state |= GTK_STATE_FLAG_SELECTED; @@ -1126,8 +1126,8 @@ draw_label_text (NautilusIconCanvasItem *item, } void -nautilus_icon_canvas_item_set_is_visible (NautilusIconCanvasItem *item, - gboolean visible) +nautilus_canvas_item_set_is_visible (NautilusCanvasItem *item, + gboolean visible) { if (item->details->is_visible == visible) return; @@ -1135,14 +1135,14 @@ nautilus_icon_canvas_item_set_is_visible (NautilusIconCanvasItem *item, item->details->is_visible = visible; if (!visible) { - nautilus_icon_canvas_item_invalidate_label (item); + nautilus_canvas_item_invalidate_label (item); } } void -nautilus_icon_canvas_item_invalidate_label (NautilusIconCanvasItem *item) +nautilus_canvas_item_invalidate_label (NautilusCanvasItem *item) { - nautilus_icon_canvas_item_invalidate_label_size (item); + nautilus_canvas_item_invalidate_label_size (item); if (item->details->editable_text_layout) { g_object_unref (item->details->editable_text_layout); @@ -1167,8 +1167,8 @@ get_knob_pixbuf (void) GdkPixbuf *knob_pixbuf; knob_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), - "stock-nautilus-knob", - 8, 0, NULL); + "stock-nautilus-knob", + 8, 0, NULL); if (!knob_pixbuf) { GInputStream *stream = g_resources_open_stream ("/org/gnome/nautilus/icons/knob.png", 0, NULL); if (stream != NULL) { @@ -1181,7 +1181,7 @@ get_knob_pixbuf (void) } static void -draw_stretch_handles (NautilusIconCanvasItem *item, +draw_stretch_handles (NautilusCanvasItem *item, cairo_t *cr, const EelIRect *rect) { @@ -1240,28 +1240,28 @@ draw_pixbuf (GdkPixbuf *pixbuf, /* shared code to highlight or dim the passed-in pixbuf */ static GdkPixbuf * -real_map_pixbuf (NautilusIconCanvasItem *icon_item) +real_map_pixbuf (NautilusCanvasItem *canvas_item) { EelCanvas *canvas; GdkPixbuf *temp_pixbuf, *old_pixbuf; GtkStyleContext *style; GdkRGBA color; - temp_pixbuf = icon_item->details->pixbuf; - canvas = EEL_CANVAS_ITEM(icon_item)->canvas; + temp_pixbuf = canvas_item->details->pixbuf; + canvas = EEL_CANVAS_ITEM(canvas_item)->canvas; g_object_ref (temp_pixbuf); - if (icon_item->details->is_prelit || - icon_item->details->is_highlighted_for_clipboard) { + if (canvas_item->details->is_prelit || + canvas_item->details->is_highlighted_for_clipboard) { old_pixbuf = temp_pixbuf; temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf); g_object_unref (old_pixbuf); } - if (icon_item->details->is_highlighted_for_selection - || icon_item->details->is_highlighted_for_drop) { + if (canvas_item->details->is_highlighted_for_selection + || canvas_item->details->is_highlighted_for_drop) { style = gtk_widget_get_style_context (GTK_WIDGET (canvas)); if (gtk_widget_has_focus (GTK_WIDGET (canvas))) { @@ -1280,32 +1280,32 @@ real_map_pixbuf (NautilusIconCanvasItem *icon_item) } static GdkPixbuf * -map_pixbuf (NautilusIconCanvasItem *icon_item) -{ - if (!(icon_item->details->rendered_pixbuf != NULL - && icon_item->details->rendered_is_prelit == icon_item->details->is_prelit - && icon_item->details->rendered_is_highlighted_for_selection == icon_item->details->is_highlighted_for_selection - && icon_item->details->rendered_is_highlighted_for_drop == icon_item->details->is_highlighted_for_drop - && icon_item->details->rendered_is_highlighted_for_clipboard == icon_item->details->is_highlighted_for_clipboard - && (icon_item->details->is_highlighted_for_selection && icon_item->details->rendered_is_focused == gtk_widget_has_focus (GTK_WIDGET (EEL_CANVAS_ITEM (icon_item)->canvas))))) { - if (icon_item->details->rendered_pixbuf != NULL) { - g_object_unref (icon_item->details->rendered_pixbuf); +map_pixbuf (NautilusCanvasItem *canvas_item) +{ + if (!(canvas_item->details->rendered_pixbuf != NULL + && canvas_item->details->rendered_is_prelit == canvas_item->details->is_prelit + && canvas_item->details->rendered_is_highlighted_for_selection == canvas_item->details->is_highlighted_for_selection + && canvas_item->details->rendered_is_highlighted_for_drop == canvas_item->details->is_highlighted_for_drop + && canvas_item->details->rendered_is_highlighted_for_clipboard == canvas_item->details->is_highlighted_for_clipboard + && (canvas_item->details->is_highlighted_for_selection && canvas_item->details->rendered_is_focused == gtk_widget_has_focus (GTK_WIDGET (EEL_CANVAS_ITEM (canvas_item)->canvas))))) { + if (canvas_item->details->rendered_pixbuf != NULL) { + g_object_unref (canvas_item->details->rendered_pixbuf); } - icon_item->details->rendered_pixbuf = real_map_pixbuf (icon_item); - icon_item->details->rendered_is_prelit = icon_item->details->is_prelit; - icon_item->details->rendered_is_highlighted_for_selection = icon_item->details->is_highlighted_for_selection; - icon_item->details->rendered_is_highlighted_for_drop = icon_item->details->is_highlighted_for_drop; - icon_item->details->rendered_is_highlighted_for_clipboard = icon_item->details->is_highlighted_for_clipboard; - icon_item->details->rendered_is_focused = gtk_widget_has_focus (GTK_WIDGET (EEL_CANVAS_ITEM (icon_item)->canvas)); + canvas_item->details->rendered_pixbuf = real_map_pixbuf (canvas_item); + canvas_item->details->rendered_is_prelit = canvas_item->details->is_prelit; + canvas_item->details->rendered_is_highlighted_for_selection = canvas_item->details->is_highlighted_for_selection; + canvas_item->details->rendered_is_highlighted_for_drop = canvas_item->details->is_highlighted_for_drop; + canvas_item->details->rendered_is_highlighted_for_clipboard = canvas_item->details->is_highlighted_for_clipboard; + canvas_item->details->rendered_is_focused = gtk_widget_has_focus (GTK_WIDGET (EEL_CANVAS_ITEM (canvas_item)->canvas)); } - g_object_ref (icon_item->details->rendered_pixbuf); + g_object_ref (canvas_item->details->rendered_pixbuf); - return icon_item->details->rendered_pixbuf; + return canvas_item->details->rendered_pixbuf; } static void -draw_embedded_text (NautilusIconCanvasItem *item, +draw_embedded_text (NautilusCanvasItem *item, cairo_t *cr, int x, int y) { @@ -1361,22 +1361,22 @@ draw_embedded_text (NautilusIconCanvasItem *item, cairo_restore (cr); } -/* Draw the icon item for non-anti-aliased mode. */ +/* Draw the canvas item for non-anti-aliased mode. */ static void -nautilus_icon_canvas_item_draw (EelCanvasItem *item, - cairo_t *cr, - cairo_region_t *region) +nautilus_canvas_item_draw (EelCanvasItem *item, + cairo_t *cr, + cairo_region_t *region) { - NautilusIconContainer *container; - NautilusIconCanvasItem *icon_item; - NautilusIconCanvasItemDetails *details; + NautilusCanvasContainer *container; + NautilusCanvasItem *canvas_item; + NautilusCanvasItemDetails *details; EelIRect icon_rect; GdkPixbuf *temp_pixbuf; GtkStyleContext *context; - container = NAUTILUS_ICON_CONTAINER (item->canvas); - icon_item = NAUTILUS_ICON_CANVAS_ITEM (item); - details = icon_item->details; + container = NAUTILUS_CANVAS_CONTAINER (item->canvas); + canvas_item = NAUTILUS_CANVAS_ITEM (item); + details = canvas_item->details; /* Draw the pixbuf. */ if (details->pixbuf == NULL) { @@ -1387,41 +1387,41 @@ nautilus_icon_canvas_item_draw (EelCanvasItem *item, gtk_style_context_save (context); gtk_style_context_add_class (context, "nautilus-canvas-item"); - icon_rect = icon_item->details->canvas_rect; - temp_pixbuf = map_pixbuf (icon_item); + icon_rect = canvas_item->details->icon_rect; + temp_pixbuf = map_pixbuf (canvas_item); gtk_render_icon (context, cr, - temp_pixbuf, - icon_rect.x0, icon_rect.y0); + temp_pixbuf, + icon_rect.x0, icon_rect.y0); g_object_unref (temp_pixbuf); - draw_embedded_text (icon_item, cr, icon_rect.x0, icon_rect.y0); + draw_embedded_text (canvas_item, cr, icon_rect.x0, icon_rect.y0); /* Draw stretching handles (if necessary). */ - draw_stretch_handles (icon_item, cr, &icon_rect); + draw_stretch_handles (canvas_item, cr, &icon_rect); /* Draw the label text. */ - draw_label_text (icon_item, cr, icon_rect); + draw_label_text (canvas_item, cr, icon_rect); gtk_style_context_restore (context); } #define ZERO_WIDTH_SPACE "\xE2\x80\x8B" -#define ZERO_OR_THREE_DIGITS(p) \ - (!g_ascii_isdigit (*(p)) || \ - (g_ascii_isdigit (*(p+1)) && \ +#define ZERO_OR_THREE_DIGITS(p) \ + (!g_ascii_isdigit (*(p)) || \ + (g_ascii_isdigit (*(p+1)) && \ g_ascii_isdigit (*(p+2)))) static PangoLayout * -create_label_layout (NautilusIconCanvasItem *item, +create_label_layout (NautilusCanvasItem *item, const char *text) { PangoLayout *layout; PangoContext *context; PangoFontDescription *desc; - NautilusIconContainer *container; + NautilusCanvasContainer *container; EelCanvasItem *canvas_item; GString *str; char *zeroified_text; @@ -1429,7 +1429,7 @@ create_label_layout (NautilusIconCanvasItem *item, canvas_item = EEL_CANVAS_ITEM (item); - container = NAUTILUS_ICON_CONTAINER (canvas_item->canvas); + container = NAUTILUS_CANVAS_CONTAINER (canvas_item->canvas); context = gtk_widget_get_pango_context (GTK_WIDGET (canvas_item->canvas)); layout = pango_layout_new (context); @@ -1475,7 +1475,7 @@ create_label_layout (NautilusIconCanvasItem *item, static PangoLayout * get_label_layout (PangoLayout **layout_cache, - NautilusIconCanvasItem *item, + NautilusCanvasItem *item, const char *text) { PangoLayout *layout; @@ -1496,23 +1496,23 @@ get_label_layout (PangoLayout **layout_cache, /* handle events */ static int -nautilus_icon_canvas_item_event (EelCanvasItem *item, GdkEvent *event) +nautilus_canvas_item_event (EelCanvasItem *item, GdkEvent *event) { - NautilusIconCanvasItem *icon_item; + NautilusCanvasItem *canvas_item; GdkCursor *cursor; GdkWindow *cursor_window; - icon_item = NAUTILUS_ICON_CANVAS_ITEM (item); + canvas_item = NAUTILUS_CANVAS_ITEM (item); cursor_window = ((GdkEventAny *)event)->window; switch (event->type) { case GDK_ENTER_NOTIFY: - if (!icon_item->details->is_prelit) { - icon_item->details->is_prelit = TRUE; - nautilus_icon_canvas_item_invalidate_label_size (icon_item); + if (!canvas_item->details->is_prelit) { + canvas_item->details->is_prelit = TRUE; + nautilus_canvas_item_invalidate_label_size (canvas_item); eel_canvas_item_request_update (item); eel_canvas_item_send_behind (item, - NAUTILUS_ICON_CONTAINER (item->canvas)->details->rubberband_info.selection_rectangle); + NAUTILUS_CANVAS_CONTAINER (item->canvas)->details->rubberband_info.selection_rectangle); /* show a hand cursor */ if (in_single_click_mode ()) { @@ -1521,80 +1521,80 @@ nautilus_icon_canvas_item_event (EelCanvasItem *item, GdkEvent *event) gdk_window_set_cursor (cursor_window, cursor); g_object_unref (cursor); - icon_item->details->cursor_window = g_object_ref (cursor_window); + canvas_item->details->cursor_window = g_object_ref (cursor_window); } } return TRUE; case GDK_LEAVE_NOTIFY: - if (icon_item->details->is_prelit - || icon_item->details->is_highlighted_for_drop) { + if (canvas_item->details->is_prelit + || canvas_item->details->is_highlighted_for_drop) { /* When leaving, turn of the prelight state and the * higlighted for drop. The latter gets turned on * by the drag&drop motion callback. */ - icon_item->details->is_prelit = FALSE; - icon_item->details->is_highlighted_for_drop = FALSE; - nautilus_icon_canvas_item_invalidate_label_size (icon_item); + canvas_item->details->is_prelit = FALSE; + canvas_item->details->is_highlighted_for_drop = FALSE; + nautilus_canvas_item_invalidate_label_size (canvas_item); eel_canvas_item_request_update (item); /* show default cursor */ gdk_window_set_cursor (cursor_window, NULL); - g_clear_object (&icon_item->details->cursor_window); + g_clear_object (&canvas_item->details->cursor_window); } return TRUE; default: - /* Don't eat up other events; icon container might use them. */ + /* Don't eat up other events; canvas container might use them. */ return FALSE; } } static gboolean -hit_test (NautilusIconCanvasItem *icon_item, EelIRect canvas_rect) +hit_test (NautilusCanvasItem *canvas_item, EelIRect icon_rect) { - NautilusIconCanvasItemDetails *details; + NautilusCanvasItemDetails *details; - details = icon_item->details; + details = canvas_item->details; - /* Quick check to see if the rect hits the icon or text at all. */ - if (!eel_irect_hits_irect (icon_item->details->canvas_rect, canvas_rect) - && (!eel_irect_hits_irect (details->text_rect, canvas_rect))) { + /* Quick check to see if the rect hits the canvas or text at all. */ + if (!eel_irect_hits_irect (canvas_item->details->icon_rect, icon_rect) + && (!eel_irect_hits_irect (details->text_rect, icon_rect))) { return FALSE; } /* Check for hits in the stretch handles. */ - if (hit_test_stretch_handle (icon_item, canvas_rect, NULL)) { + if (hit_test_stretch_handle (canvas_item, icon_rect, NULL)) { return TRUE; } - /* Check for hit in the icon. */ - if (eel_irect_hits_irect (icon_item->details->canvas_rect, canvas_rect)) { + /* Check for hit in the canvas. */ + if (eel_irect_hits_irect (canvas_item->details->icon_rect, icon_rect)) { return TRUE; } /* Check for hit in the text. */ - if (eel_irect_hits_irect (details->text_rect, canvas_rect) - && !icon_item->details->is_renaming) { + if (eel_irect_hits_irect (details->text_rect, icon_rect) + && !canvas_item->details->is_renaming) { return TRUE; } return FALSE; } -/* Point handler for the icon canvas item. */ +/* Point handler for the canvas canvas item. */ static double -nautilus_icon_canvas_item_point (EelCanvasItem *item, double x, double y, int cx, int cy, - EelCanvasItem **actual_item) +nautilus_canvas_item_point (EelCanvasItem *item, double x, double y, int cx, int cy, + EelCanvasItem **actual_item) { - EelIRect canvas_rect; + EelIRect icon_rect; *actual_item = item; - canvas_rect.x0 = cx; - canvas_rect.y0 = cy; - canvas_rect.x1 = cx + 1; - canvas_rect.y1 = cy + 1; - if (hit_test (NAUTILUS_ICON_CANVAS_ITEM (item), canvas_rect)) { + icon_rect.x0 = cx; + icon_rect.y0 = cy; + icon_rect.x1 = cx + 1; + icon_rect.y1 = cy + 1; + if (hit_test (NAUTILUS_CANVAS_ITEM (item), icon_rect)) { return 0.0; } else { /* This value means not hit. @@ -1605,28 +1605,28 @@ nautilus_icon_canvas_item_point (EelCanvasItem *item, double x, double y, int cx } static void -nautilus_icon_canvas_item_translate (EelCanvasItem *item, double dx, double dy) +nautilus_canvas_item_translate (EelCanvasItem *item, double dx, double dy) { - NautilusIconCanvasItem *icon_item; - NautilusIconCanvasItemDetails *details; + NautilusCanvasItem *canvas_item; + NautilusCanvasItemDetails *details; - icon_item = NAUTILUS_ICON_CANVAS_ITEM (item); - details = icon_item->details; + canvas_item = NAUTILUS_CANVAS_ITEM (item); + details = canvas_item->details; details->x += dx; details->y += dy; } void -nautilus_icon_canvas_item_get_bounds_for_layout (NautilusIconCanvasItem *icon_item, - double *x1, double *y1, double *x2, double *y2) +nautilus_canvas_item_get_bounds_for_layout (NautilusCanvasItem *canvas_item, + double *x1, double *y1, double *x2, double *y2) { - NautilusIconCanvasItemDetails *details; + NautilusCanvasItemDetails *details; EelIRect *total_rect; - details = icon_item->details; + details = canvas_item->details; - nautilus_icon_canvas_item_ensure_bounds_up_to_date (icon_item); + nautilus_canvas_item_ensure_bounds_up_to_date (canvas_item); g_assert (details->bounds_cached); total_rect = &details->bounds_cache_for_layout; @@ -1647,15 +1647,15 @@ nautilus_icon_canvas_item_get_bounds_for_layout (NautilusIconCanvasItem *icon_it } void -nautilus_icon_canvas_item_get_bounds_for_entire_item (NautilusIconCanvasItem *icon_item, - double *x1, double *y1, double *x2, double *y2) +nautilus_canvas_item_get_bounds_for_entire_item (NautilusCanvasItem *canvas_item, + double *x1, double *y1, double *x2, double *y2) { - NautilusIconCanvasItemDetails *details; + NautilusCanvasItemDetails *details; EelIRect *total_rect; - details = icon_item->details; + details = canvas_item->details; - nautilus_icon_canvas_item_ensure_bounds_up_to_date (icon_item); + nautilus_canvas_item_ensure_bounds_up_to_date (canvas_item); g_assert (details->bounds_cached); total_rect = &details->bounds_cache_for_entire_item; @@ -1675,24 +1675,24 @@ nautilus_icon_canvas_item_get_bounds_for_entire_item (NautilusIconCanvasItem *ic } } -/* Bounds handler for the icon canvas item. */ +/* Bounds handler for the canvas canvas item. */ static void -nautilus_icon_canvas_item_bounds (EelCanvasItem *item, - double *x1, double *y1, double *x2, double *y2) +nautilus_canvas_item_bounds (EelCanvasItem *item, + double *x1, double *y1, double *x2, double *y2) { - NautilusIconCanvasItem *icon_item; - NautilusIconCanvasItemDetails *details; + NautilusCanvasItem *canvas_item; + NautilusCanvasItemDetails *details; EelIRect *total_rect; - icon_item = NAUTILUS_ICON_CANVAS_ITEM (item); - details = icon_item->details; + canvas_item = NAUTILUS_CANVAS_ITEM (item); + details = canvas_item->details; g_assert (x1 != NULL); g_assert (y1 != NULL); g_assert (x2 != NULL); g_assert (y2 != NULL); - nautilus_icon_canvas_item_ensure_bounds_up_to_date (icon_item); + nautilus_canvas_item_ensure_bounds_up_to_date (canvas_item); g_assert (details->bounds_cached); total_rect = &details->bounds_cache; @@ -1705,24 +1705,24 @@ nautilus_icon_canvas_item_bounds (EelCanvasItem *item, } static void -nautilus_icon_canvas_item_ensure_bounds_up_to_date (NautilusIconCanvasItem *icon_item) +nautilus_canvas_item_ensure_bounds_up_to_date (NautilusCanvasItem *canvas_item) { - NautilusIconCanvasItemDetails *details; + NautilusCanvasItemDetails *details; EelIRect icon_rect, icon_rect_raw; EelIRect text_rect, text_rect_for_layout, text_rect_for_entire_text; EelIRect total_rect, total_rect_for_layout, total_rect_for_entire_text; EelCanvasItem *item; double pixels_per_unit; - details = icon_item->details; - item = EEL_CANVAS_ITEM (icon_item); + details = canvas_item->details; + item = EEL_CANVAS_ITEM (canvas_item); if (!details->bounds_cached) { - measure_label_text (icon_item); + measure_label_text (canvas_item); pixels_per_unit = EEL_CANVAS_ITEM (item)->canvas->pixels_per_unit; - /* Compute raw and scaled icon rectangle. */ + /* Compute raw and scaled canvas rectangle. */ icon_rect.x0 = 0; icon_rect.y0 = 0; icon_rect_raw.x0 = 0; @@ -1740,9 +1740,9 @@ nautilus_icon_canvas_item_ensure_bounds_up_to_date (NautilusIconCanvasItem *icon } /* Compute text rectangle. */ - text_rect = compute_text_rectangle (icon_item, icon_rect, FALSE, BOUNDS_USAGE_FOR_DISPLAY); - text_rect_for_layout = compute_text_rectangle (icon_item, icon_rect, FALSE, BOUNDS_USAGE_FOR_LAYOUT); - text_rect_for_entire_text = compute_text_rectangle (icon_item, icon_rect, FALSE, BOUNDS_USAGE_FOR_ENTIRE_ITEM); + text_rect = compute_text_rectangle (canvas_item, icon_rect, FALSE, BOUNDS_USAGE_FOR_DISPLAY); + text_rect_for_layout = compute_text_rectangle (canvas_item, icon_rect, FALSE, BOUNDS_USAGE_FOR_LAYOUT); + text_rect_for_entire_text = compute_text_rectangle (canvas_item, icon_rect, FALSE, BOUNDS_USAGE_FOR_ENTIRE_ITEM); /* Compute total rectangle */ eel_irect_union (&total_rect, &icon_rect, &text_rect); @@ -1756,15 +1756,15 @@ nautilus_icon_canvas_item_ensure_bounds_up_to_date (NautilusIconCanvasItem *icon } } -/* Get the rectangle of the icon only, in world coordinates. */ +/* Get the rectangle of the canvas only, in world coordinates. */ EelDRect -nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item) +nautilus_canvas_item_get_icon_rectangle (const NautilusCanvasItem *item) { EelDRect rectangle; double pixels_per_unit; GdkPixbuf *pixbuf; - g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), eel_drect_empty); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_ITEM (item), eel_drect_empty); rectangle.x0 = item->details->x; rectangle.y0 = item->details->y; @@ -1786,8 +1786,8 @@ nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item } EelDRect -nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item, - gboolean for_layout) +nautilus_canvas_item_get_text_rectangle (NautilusCanvasItem *item, + gboolean for_layout) { /* FIXME */ EelIRect icon_rectangle; @@ -1796,7 +1796,7 @@ nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item, double pixels_per_unit; GdkPixbuf *pixbuf; - g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), eel_drect_empty); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_ITEM (item), eel_drect_empty); icon_rectangle.x0 = item->details->x; icon_rectangle.y0 = item->details->y; @@ -1830,12 +1830,12 @@ nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item, /* Get the rectangle of the icon only, in canvas coordinates. */ static void -get_icon_canvas_rectangle (NautilusIconCanvasItem *item, - EelIRect *rect) +get_icon_rectangle (NautilusCanvasItem *item, + EelIRect *rect) { GdkPixbuf *pixbuf; - g_assert (NAUTILUS_IS_ICON_CANVAS_ITEM (item)); + g_assert (NAUTILUS_IS_CANVAS_ITEM (item)); g_assert (rect != NULL); eel_canvas_w2c (EEL_CANVAS_ITEM (item)->canvas, @@ -1851,10 +1851,10 @@ get_icon_canvas_rectangle (NautilusIconCanvasItem *item, } void -nautilus_icon_canvas_item_set_show_stretch_handles (NautilusIconCanvasItem *item, - gboolean show_stretch_handles) +nautilus_canvas_item_set_show_stretch_handles (NautilusCanvasItem *item, + gboolean show_stretch_handles) { - g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item)); + g_return_if_fail (NAUTILUS_IS_CANVAS_ITEM (item)); g_return_if_fail (show_stretch_handles == FALSE || show_stretch_handles == TRUE); if (!item->details->show_stretch_handles == !show_stretch_handles) { @@ -1867,8 +1867,8 @@ nautilus_icon_canvas_item_set_show_stretch_handles (NautilusIconCanvasItem *item /* Check if one of the stretch handles was hit. */ static gboolean -hit_test_stretch_handle (NautilusIconCanvasItem *item, - EelIRect probe_canvas_rect, +hit_test_stretch_handle (NautilusCanvasItem *item, + EelIRect probe_icon_rect, GtkCornerType *corner) { EelIRect icon_rect; @@ -1876,16 +1876,16 @@ hit_test_stretch_handle (NautilusIconCanvasItem *item, int knob_width, knob_height; int hit_corner; - g_assert (NAUTILUS_IS_ICON_CANVAS_ITEM (item)); + g_assert (NAUTILUS_IS_CANVAS_ITEM (item)); /* Make sure there are handles to hit. */ if (!item->details->show_stretch_handles) { return FALSE; } - /* Quick check to see if the rect hits the icon at all. */ - icon_rect = item->details->canvas_rect; - if (!eel_irect_hits_irect (probe_canvas_rect, icon_rect)) { + /* Quick check to see if the rect hits the canvas at all. */ + icon_rect = item->details->icon_rect; + if (!eel_irect_hits_irect (probe_icon_rect, icon_rect)) { return FALSE; } @@ -1896,16 +1896,16 @@ hit_test_stretch_handle (NautilusIconCanvasItem *item, /* Check for hits in the stretch handles. */ hit_corner = -1; - if (probe_canvas_rect.x0 < icon_rect.x0 + knob_width) { - if (probe_canvas_rect.y0 < icon_rect.y0 + knob_height) + if (probe_icon_rect.x0 < icon_rect.x0 + knob_width) { + if (probe_icon_rect.y0 < icon_rect.y0 + knob_height) hit_corner = GTK_CORNER_TOP_LEFT; - else if (probe_canvas_rect.y1 >= icon_rect.y1 - knob_height) + else if (probe_icon_rect.y1 >= icon_rect.y1 - knob_height) hit_corner = GTK_CORNER_BOTTOM_LEFT; } - else if (probe_canvas_rect.x1 >= icon_rect.x1 - knob_width) { - if (probe_canvas_rect.y0 < icon_rect.y0 + knob_height) + else if (probe_icon_rect.x1 >= icon_rect.x1 - knob_width) { + if (probe_icon_rect.y0 < icon_rect.y0 + knob_height) hit_corner = GTK_CORNER_TOP_RIGHT; - else if (probe_canvas_rect.y1 >= icon_rect.y1 - knob_height) + else if (probe_icon_rect.y1 >= icon_rect.y1 - knob_height) hit_corner = GTK_CORNER_BOTTOM_RIGHT; } if (corner) @@ -1915,50 +1915,50 @@ hit_test_stretch_handle (NautilusIconCanvasItem *item, } gboolean -nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item, - gdouble world_x, - gdouble world_y, - GtkCornerType *corner) +nautilus_canvas_item_hit_test_stretch_handles (NautilusCanvasItem *item, + gdouble world_x, + gdouble world_y, + GtkCornerType *corner) { - EelIRect canvas_rect; + EelIRect icon_rect; - g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), FALSE); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_ITEM (item), FALSE); eel_canvas_w2c (EEL_CANVAS_ITEM (item)->canvas, - world_x, - world_y, - &canvas_rect.x0, - &canvas_rect.y0); - canvas_rect.x1 = canvas_rect.x0 + 1; - canvas_rect.y1 = canvas_rect.y0 + 1; - return hit_test_stretch_handle (item, canvas_rect, corner); + world_x, + world_y, + &icon_rect.x0, + &icon_rect.y0); + icon_rect.x1 = icon_rect.x0 + 1; + icon_rect.y1 = icon_rect.y0 + 1; + return hit_test_stretch_handle (item, icon_rect, corner); } -/* nautilus_icon_canvas_item_hit_test_rectangle +/* nautilus_canvas_item_hit_test_rectangle * * Check and see if there is an intersection between the item and the * canvas rect. */ gboolean -nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item, EelIRect canvas_rect) +nautilus_canvas_item_hit_test_rectangle (NautilusCanvasItem *item, EelIRect icon_rect) { - g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), FALSE); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_ITEM (item), FALSE); - return hit_test (item, canvas_rect); + return hit_test (item, icon_rect); } const char * -nautilus_icon_canvas_item_get_editable_text (NautilusIconCanvasItem *icon_item) +nautilus_canvas_item_get_editable_text (NautilusCanvasItem *canvas_item) { - g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (icon_item), NULL); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_ITEM (canvas_item), NULL); - return icon_item->details->editable_text; + return canvas_item->details->editable_text; } void -nautilus_icon_canvas_item_set_renaming (NautilusIconCanvasItem *item, gboolean state) +nautilus_canvas_item_set_renaming (NautilusCanvasItem *item, gboolean state) { - g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item)); + g_return_if_fail (NAUTILUS_IS_CANVAS_ITEM (item)); g_return_if_fail (state == FALSE || state == TRUE); if (!item->details->is_renaming == !state) { @@ -1970,7 +1970,7 @@ nautilus_icon_canvas_item_set_renaming (NautilusIconCanvasItem *item, gboolean s } double -nautilus_icon_canvas_item_get_max_text_width (NautilusIconCanvasItem *item) +nautilus_canvas_item_get_max_text_width (NautilusCanvasItem *item) { EelCanvasItem *canvas_item; @@ -1980,20 +1980,20 @@ nautilus_icon_canvas_item_get_max_text_width (NautilusIconCanvasItem *item) } void -nautilus_icon_canvas_item_set_entire_text (NautilusIconCanvasItem *item, - gboolean entire_text) +nautilus_canvas_item_set_entire_text (NautilusCanvasItem *item, + gboolean entire_text) { if (item->details->entire_text != entire_text) { item->details->entire_text = entire_text; - nautilus_icon_canvas_item_invalidate_label_size (item); + nautilus_canvas_item_invalidate_label_size (item); eel_canvas_item_request_update (EEL_CANVAS_ITEM (item)); } } -/* Class initialization function for the icon canvas item. */ +/* Class initialization function for the canvas canvas item. */ static void -nautilus_icon_canvas_item_class_init (NautilusIconCanvasItemClass *class) +nautilus_canvas_item_class_init (NautilusCanvasItemClass *class) { GObjectClass *object_class; EelCanvasItemClass *item_class; @@ -2001,94 +2001,94 @@ nautilus_icon_canvas_item_class_init (NautilusIconCanvasItemClass *class) object_class = G_OBJECT_CLASS (class); item_class = EEL_CANVAS_ITEM_CLASS (class); - object_class->finalize = nautilus_icon_canvas_item_finalize; - object_class->set_property = nautilus_icon_canvas_item_set_property; - object_class->get_property = nautilus_icon_canvas_item_get_property; + object_class->finalize = nautilus_canvas_item_finalize; + object_class->set_property = nautilus_canvas_item_set_property; + object_class->get_property = nautilus_canvas_item_get_property; g_object_class_install_property ( - object_class, - PROP_EDITABLE_TEXT, - g_param_spec_string ("editable_text", - "editable text", - "the editable label", - "", G_PARAM_READWRITE)); + object_class, + PROP_EDITABLE_TEXT, + g_param_spec_string ("editable_text", + "editable text", + "the editable label", + "", G_PARAM_READWRITE)); g_object_class_install_property ( - object_class, - PROP_ADDITIONAL_TEXT, - g_param_spec_string ("additional_text", - "additional text", - "some more text", - "", G_PARAM_READWRITE)); + object_class, + PROP_ADDITIONAL_TEXT, + g_param_spec_string ("additional_text", + "additional text", + "some more text", + "", G_PARAM_READWRITE)); g_object_class_install_property ( - object_class, - PROP_HIGHLIGHTED_FOR_SELECTION, - g_param_spec_boolean ("highlighted_for_selection", - "highlighted for selection", - "whether we are highlighted for a selection", - FALSE, G_PARAM_READWRITE)); + object_class, + PROP_HIGHLIGHTED_FOR_SELECTION, + g_param_spec_boolean ("highlighted_for_selection", + "highlighted for selection", + "whether we are highlighted for a selection", + FALSE, G_PARAM_READWRITE)); g_object_class_install_property ( - object_class, - PROP_HIGHLIGHTED_AS_KEYBOARD_FOCUS, - g_param_spec_boolean ("highlighted_as_keyboard_focus", - "highlighted as keyboard focus", - "whether we are highlighted to render keyboard focus", - FALSE, G_PARAM_READWRITE)); + object_class, + PROP_HIGHLIGHTED_AS_KEYBOARD_FOCUS, + g_param_spec_boolean ("highlighted_as_keyboard_focus", + "highlighted as keyboard focus", + "whether we are highlighted to render keyboard focus", + FALSE, G_PARAM_READWRITE)); g_object_class_install_property ( - object_class, - PROP_HIGHLIGHTED_FOR_DROP, - g_param_spec_boolean ("highlighted_for_drop", - "highlighted for drop", - "whether we are highlighted for a D&D drop", - FALSE, G_PARAM_READWRITE)); + object_class, + PROP_HIGHLIGHTED_FOR_DROP, + g_param_spec_boolean ("highlighted_for_drop", + "highlighted for drop", + "whether we are highlighted for a D&D drop", + FALSE, G_PARAM_READWRITE)); g_object_class_install_property ( - object_class, - PROP_HIGHLIGHTED_FOR_CLIPBOARD, - g_param_spec_boolean ("highlighted_for_clipboard", - "highlighted for clipboard", - "whether we are highlighted for a clipboard paste (after we have been cut)", - FALSE, G_PARAM_READWRITE)); - - item_class->update = nautilus_icon_canvas_item_update; - item_class->draw = nautilus_icon_canvas_item_draw; - item_class->point = nautilus_icon_canvas_item_point; - item_class->translate = nautilus_icon_canvas_item_translate; - item_class->bounds = nautilus_icon_canvas_item_bounds; - item_class->event = nautilus_icon_canvas_item_event; + object_class, + PROP_HIGHLIGHTED_FOR_CLIPBOARD, + g_param_spec_boolean ("highlighted_for_clipboard", + "highlighted for clipboard", + "whether we are highlighted for a clipboard paste (after we have been cut)", + FALSE, G_PARAM_READWRITE)); + + item_class->update = nautilus_canvas_item_update; + item_class->draw = nautilus_canvas_item_draw; + item_class->point = nautilus_canvas_item_point; + item_class->translate = nautilus_canvas_item_translate; + item_class->bounds = nautilus_canvas_item_bounds; + item_class->event = nautilus_canvas_item_event; atk_registry_set_factory_type (atk_get_default_registry (), - NAUTILUS_TYPE_ICON_CANVAS_ITEM, - nautilus_icon_canvas_item_accessible_factory_get_type ()); + NAUTILUS_TYPE_CANVAS_ITEM, + nautilus_canvas_item_accessible_factory_get_type ()); - g_type_class_add_private (class, sizeof (NautilusIconCanvasItemDetails)); + g_type_class_add_private (class, sizeof (NautilusCanvasItemDetails)); } static GailTextUtil * -nautilus_icon_canvas_item_get_text (GObject *text) +nautilus_canvas_item_get_text (GObject *text) { - return NAUTILUS_ICON_CANVAS_ITEM (text)->details->text_util; + return NAUTILUS_CANVAS_ITEM (text)->details->text_util; } static void -nautilus_icon_canvas_item_text_interface_init (EelAccessibleTextIface *iface) +nautilus_canvas_item_text_interface_init (EelAccessibleTextIface *iface) { - iface->get_text = nautilus_icon_canvas_item_get_text; + iface->get_text = nautilus_canvas_item_get_text; } /* ============================= a11y interfaces =========================== */ -static const char *nautilus_icon_canvas_item_accessible_action_names[] = { +static const char *nautilus_canvas_item_accessible_action_names[] = { "open", "menu", NULL }; -static const char *nautilus_icon_canvas_item_accessible_action_descriptions[] = { +static const char *nautilus_canvas_item_accessible_action_descriptions[] = { "Open item", "Popup context menu", NULL @@ -2104,38 +2104,38 @@ typedef struct { char *action_descriptions[LAST_ACTION]; char *image_description; char *description; -} NautilusIconCanvasItemAccessiblePrivate; +} NautilusCanvasItemAccessiblePrivate; typedef struct { - NautilusIconCanvasItem *item; + NautilusCanvasItem *item; gint action_number; -} NautilusIconCanvasItemAccessibleActionContext; +} NautilusCanvasItemAccessibleActionContext; typedef struct { EelCanvasItemAccessible parent; - NautilusIconCanvasItemAccessiblePrivate *priv; -} NautilusIconCanvasItemAccessible; + NautilusCanvasItemAccessiblePrivate *priv; +} NautilusCanvasItemAccessible; typedef struct { EelCanvasItemAccessibleClass parent_class; -} NautilusIconCanvasItemAccessibleClass; +} NautilusCanvasItemAccessibleClass; -#define GET_ACCESSIBLE_PRIV(o) ((NautilusIconCanvasItemAccessible *) o)->priv; +#define GET_ACCESSIBLE_PRIV(o) ((NautilusCanvasItemAccessible *) o)->priv; /* accessible AtkAction interface */ static gboolean -nautilus_icon_canvas_item_accessible_idle_do_action (gpointer data) +nautilus_canvas_item_accessible_idle_do_action (gpointer data) { - NautilusIconCanvasItem *item; - NautilusIconCanvasItemAccessibleActionContext *ctx; - NautilusIcon *icon; - NautilusIconContainer *container; + NautilusCanvasItem *item; + NautilusCanvasItemAccessibleActionContext *ctx; + NautilusCanvasIcon *icon; + NautilusCanvasContainer *container; GList* selection; GList file_list; GdkEventButton button_event = { 0 }; gint action_number; - container = NAUTILUS_ICON_CONTAINER (data); + container = NAUTILUS_CANVAS_CONTAINER (data); container->details->a11y_item_action_idle_handler = 0; while (!g_queue_is_empty (container->details->a11y_item_action_queue)) { ctx = g_queue_pop_head (container->details->a11y_item_action_queue); @@ -2152,7 +2152,7 @@ nautilus_icon_canvas_item_accessible_idle_do_action (gpointer data) g_signal_emit_by_name (container, "activate", &file_list); break; case ACTION_MENU: - selection = nautilus_icon_container_get_selection (container); + selection = nautilus_canvas_container_get_selection (container); if (selection == NULL || g_list_length (selection) != 1 || selection->data != icon->data) { @@ -2171,37 +2171,37 @@ nautilus_icon_canvas_item_accessible_idle_do_action (gpointer data) } static gboolean -nautilus_icon_canvas_item_accessible_do_action (AtkAction *accessible, - int i) +nautilus_canvas_item_accessible_do_action (AtkAction *accessible, + int i) { - NautilusIconCanvasItem *item; - NautilusIconCanvasItemAccessibleActionContext *ctx; - NautilusIconContainer *container; + NautilusCanvasItem *item; + NautilusCanvasItemAccessibleActionContext *ctx; + NautilusCanvasContainer *container; g_assert (i < LAST_ACTION); - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); if (!item) { return FALSE; } - container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); + container = NAUTILUS_CANVAS_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); switch (i) { case ACTION_OPEN: case ACTION_MENU: if (container->details->a11y_item_action_queue == NULL) { container->details->a11y_item_action_queue = g_queue_new (); } - ctx = g_new (NautilusIconCanvasItemAccessibleActionContext, 1); + ctx = g_new (NautilusCanvasItemAccessibleActionContext, 1); ctx->action_number = i; ctx->item = item; g_queue_push_head (container->details->a11y_item_action_queue, ctx); if (container->details->a11y_item_action_idle_handler == 0) { - container->details->a11y_item_action_idle_handler = g_idle_add (nautilus_icon_canvas_item_accessible_idle_do_action, container); + container->details->a11y_item_action_idle_handler = g_idle_add (nautilus_canvas_item_accessible_idle_do_action, container); } break; default : - g_warning ("Invalid action passed to NautilusIconCanvasItemAccessible::do_action"); + g_warning ("Invalid action passed to NautilusCanvasItemAccessible::do_action"); return FALSE; } @@ -2209,16 +2209,16 @@ nautilus_icon_canvas_item_accessible_do_action (AtkAction *accessible, } static int -nautilus_icon_canvas_item_accessible_get_n_actions (AtkAction *accessible) +nautilus_canvas_item_accessible_get_n_actions (AtkAction *accessible) { return LAST_ACTION; } static const char * -nautilus_icon_canvas_item_accessible_action_get_description (AtkAction *accessible, - int i) +nautilus_canvas_item_accessible_action_get_description (AtkAction *accessible, + int i) { - NautilusIconCanvasItemAccessiblePrivate *priv; + NautilusCanvasItemAccessiblePrivate *priv; g_assert (i < LAST_ACTION); @@ -2227,21 +2227,21 @@ nautilus_icon_canvas_item_accessible_action_get_description (AtkAction *accessib if (priv->action_descriptions[i]) { return priv->action_descriptions[i]; } else { - return nautilus_icon_canvas_item_accessible_action_descriptions[i]; + return nautilus_canvas_item_accessible_action_descriptions[i]; } } static const char * -nautilus_icon_canvas_item_accessible_action_get_name (AtkAction *accessible, int i) +nautilus_canvas_item_accessible_action_get_name (AtkAction *accessible, int i) { g_assert (i < LAST_ACTION); - return nautilus_icon_canvas_item_accessible_action_names[i]; + return nautilus_canvas_item_accessible_action_names[i]; } static const char * -nautilus_icon_canvas_item_accessible_action_get_keybinding (AtkAction *accessible, - int i) +nautilus_canvas_item_accessible_action_get_keybinding (AtkAction *accessible, + int i) { g_assert (i < LAST_ACTION); @@ -2249,11 +2249,11 @@ nautilus_icon_canvas_item_accessible_action_get_keybinding (AtkAction *accessibl } static gboolean -nautilus_icon_canvas_item_accessible_action_set_description (AtkAction *accessible, - int i, - const char *description) +nautilus_canvas_item_accessible_action_set_description (AtkAction *accessible, + int i, + const char *description) { - NautilusIconCanvasItemAccessiblePrivate *priv; + NautilusCanvasItemAccessiblePrivate *priv; g_assert (i < LAST_ACTION); @@ -2268,26 +2268,26 @@ nautilus_icon_canvas_item_accessible_action_set_description (AtkAction *accessib } static void -nautilus_icon_canvas_item_accessible_action_interface_init (AtkActionIface *iface) +nautilus_canvas_item_accessible_action_interface_init (AtkActionIface *iface) { - iface->do_action = nautilus_icon_canvas_item_accessible_do_action; - iface->get_n_actions = nautilus_icon_canvas_item_accessible_get_n_actions; - iface->get_description = nautilus_icon_canvas_item_accessible_action_get_description; - iface->get_keybinding = nautilus_icon_canvas_item_accessible_action_get_keybinding; - iface->get_name = nautilus_icon_canvas_item_accessible_action_get_name; - iface->set_description = nautilus_icon_canvas_item_accessible_action_set_description; + iface->do_action = nautilus_canvas_item_accessible_do_action; + iface->get_n_actions = nautilus_canvas_item_accessible_get_n_actions; + iface->get_description = nautilus_canvas_item_accessible_action_get_description; + iface->get_keybinding = nautilus_canvas_item_accessible_action_get_keybinding; + iface->get_name = nautilus_canvas_item_accessible_action_get_name; + iface->set_description = nautilus_canvas_item_accessible_action_set_description; } static const gchar * -nautilus_icon_canvas_item_accessible_get_name (AtkObject *accessible) +nautilus_canvas_item_accessible_get_name (AtkObject *accessible) { - NautilusIconCanvasItem *item; + NautilusCanvasItem *item; if (accessible->name) { return accessible->name; } - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); if (!item) { return NULL; } @@ -2295,11 +2295,11 @@ nautilus_icon_canvas_item_accessible_get_name (AtkObject *accessible) } static const gchar* -nautilus_icon_canvas_item_accessible_get_description (AtkObject *accessible) +nautilus_canvas_item_accessible_get_description (AtkObject *accessible) { - NautilusIconCanvasItem *item; + NautilusCanvasItem *item; - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); if (!item) { return NULL; } @@ -2308,11 +2308,11 @@ nautilus_icon_canvas_item_accessible_get_description (AtkObject *accessible) } static AtkObject * -nautilus_icon_canvas_item_accessible_get_parent (AtkObject *accessible) +nautilus_canvas_item_accessible_get_parent (AtkObject *accessible) { - NautilusIconCanvasItem *item; + NautilusCanvasItem *item; - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); if (!item) { return NULL; } @@ -2321,20 +2321,20 @@ nautilus_icon_canvas_item_accessible_get_parent (AtkObject *accessible) } static int -nautilus_icon_canvas_item_accessible_get_index_in_parent (AtkObject *accessible) +nautilus_canvas_item_accessible_get_index_in_parent (AtkObject *accessible) { - NautilusIconCanvasItem *item; - NautilusIconContainer *container; + NautilusCanvasItem *item; + NautilusCanvasContainer *container; GList *l; - NautilusIcon *icon; + NautilusCanvasIcon *icon; int i; - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); if (!item) { return -1; } - container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); + container = NAUTILUS_CANVAS_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); l = container->details->icons; i = 0; @@ -2353,12 +2353,12 @@ nautilus_icon_canvas_item_accessible_get_index_in_parent (AtkObject *accessible) } static const gchar * -nautilus_icon_canvas_item_accessible_get_image_description (AtkImage *image) +nautilus_canvas_item_accessible_get_image_description (AtkImage *image) { - NautilusIconCanvasItemAccessiblePrivate *priv; - NautilusIconCanvasItem *item; - NautilusIcon *icon; - NautilusIconContainer *container; + NautilusCanvasItemAccessiblePrivate *priv; + NautilusCanvasItem *item; + NautilusCanvasIcon *icon; + NautilusCanvasContainer *container; char *description; priv = GET_ACCESSIBLE_PRIV (image); @@ -2366,13 +2366,13 @@ nautilus_icon_canvas_item_accessible_get_image_description (AtkImage *image) if (priv->image_description) { return priv->image_description; } else { - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (image))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (image))); if (item == NULL) { return NULL; } icon = item->user_data; - container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); - description = nautilus_icon_container_get_icon_description (container, icon->data); + container = NAUTILUS_CANVAS_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); + description = nautilus_canvas_container_get_icon_description (container, icon->data); g_free (priv->description); priv->description = description; return priv->description; @@ -2380,14 +2380,14 @@ nautilus_icon_canvas_item_accessible_get_image_description (AtkImage *image) } static void -nautilus_icon_canvas_item_accessible_get_image_size - (AtkImage *image, - gint *width, - gint *height) +nautilus_canvas_item_accessible_get_image_size +(AtkImage *image, + gint *width, + gint *height) { - NautilusIconCanvasItem *item; + NautilusCanvasItem *item; - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (image))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (image))); if (!item || !item->details->pixbuf) { *width = *height = 0; @@ -2398,32 +2398,32 @@ nautilus_icon_canvas_item_accessible_get_image_size } static void -nautilus_icon_canvas_item_accessible_get_image_position - (AtkImage *image, - gint *x, - gint *y, - AtkCoordType coord_type) +nautilus_canvas_item_accessible_get_image_position +(AtkImage *image, + gint *x, + gint *y, + AtkCoordType coord_type) { - NautilusIconCanvasItem *item; + NautilusCanvasItem *item; gint x_offset, y_offset, itmp; - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (image))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (image))); if (!item) { return; } - if (!item->details->canvas_rect.x0 && !item->details->canvas_rect.x1) { + if (!item->details->icon_rect.x0 && !item->details->icon_rect.x1) { return; } else { x_offset = 0; y_offset = 0; if (item->details->text_width) { - itmp = item->details->canvas_rect.x0 - - item->details->text_rect.x0; + itmp = item->details->icon_rect.x0 - + item->details->text_rect.x0; if (itmp > x_offset) { x_offset = itmp; } - itmp = item->details->canvas_rect.y0 - - item->details->text_rect.y0; + itmp = item->details->icon_rect.y0 - + item->details->text_rect.y0; if (itmp > y_offset) { y_offset = itmp; } @@ -2435,10 +2435,10 @@ nautilus_icon_canvas_item_accessible_get_image_position } static gboolean -nautilus_icon_canvas_item_accessible_set_image_description (AtkImage *image, - const gchar *description) +nautilus_canvas_item_accessible_set_image_description (AtkImage *image, + const gchar *description) { - NautilusIconCanvasItemAccessiblePrivate *priv; + NautilusCanvasItemAccessiblePrivate *priv; priv = GET_ACCESSIBLE_PRIV (image); @@ -2449,29 +2449,29 @@ nautilus_icon_canvas_item_accessible_set_image_description (AtkImage *image, } static void -nautilus_icon_canvas_item_accessible_image_interface_init (AtkImageIface *iface) +nautilus_canvas_item_accessible_image_interface_init (AtkImageIface *iface) { - iface->get_image_description = nautilus_icon_canvas_item_accessible_get_image_description; - iface->set_image_description = nautilus_icon_canvas_item_accessible_set_image_description; - iface->get_image_size = nautilus_icon_canvas_item_accessible_get_image_size; - iface->get_image_position = nautilus_icon_canvas_item_accessible_get_image_position; + iface->get_image_description = nautilus_canvas_item_accessible_get_image_description; + iface->set_image_description = nautilus_canvas_item_accessible_set_image_description; + iface->get_image_size = nautilus_canvas_item_accessible_get_image_size; + iface->get_image_position = nautilus_canvas_item_accessible_get_image_position; } /* accessible text interface */ static gint -nautilus_icon_canvas_item_accessible_get_offset_at_point (AtkText *text, - gint x, - gint y, - AtkCoordType coords) +nautilus_canvas_item_accessible_get_offset_at_point (AtkText *text, + gint x, + gint y, + AtkCoordType coords) { gint real_x, real_y, real_width, real_height; - NautilusIconCanvasItem *item; + NautilusCanvasItem *item; gint editable_height; gint offset = 0; gint index; PangoLayout *layout, *editable_layout, *additional_layout; PangoRectangle rect0; - char *icon_text; + char *canvas_text; gboolean have_editable; gboolean have_additional; gint text_offset; @@ -2482,13 +2482,13 @@ nautilus_icon_canvas_item_accessible_get_offset_at_point (AtkText *text, x -= real_x; y -= real_y; - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text))); if (item->details->pixbuf) { y -= gdk_pixbuf_get_height (item->details->pixbuf); } have_editable = item->details->editable_text != NULL && - item->details->editable_text[0] != '\0'; + item->details->editable_text[0] != '\0'; have_additional = item->details->additional_text != NULL &&item->details->additional_text[0] != '\0'; editable_layout = NULL; @@ -2502,17 +2502,17 @@ nautilus_icon_canvas_item_accessible_get_offset_at_point (AtkText *text, prepare_pango_layout_for_draw (item, editable_layout); additional_layout = get_label_layout (&item->details->additional_text_layout, item, item->details->additional_text); layout = additional_layout; - icon_text = item->details->additional_text; + canvas_text = item->details->additional_text; y -= editable_height + LABEL_LINE_SPACING; } else { layout = editable_layout; - icon_text = item->details->editable_text; + canvas_text = item->details->editable_text; } } else if (have_additional) { additional_layout = get_label_layout (&item->details->additional_text_layout, item, item->details->additional_text); prepare_pango_layout_for_draw (item, additional_layout); layout = additional_layout; - icon_text = item->details->additional_text; + canvas_text = item->details->additional_text; } else { return 0; } @@ -2544,9 +2544,9 @@ nautilus_icon_canvas_item_accessible_get_offset_at_point (AtkText *text, } } if (index == -1) { - offset = g_utf8_strlen (icon_text, -1); + offset = g_utf8_strlen (canvas_text, -1); } else { - offset = g_utf8_pointer_to_offset (icon_text, icon_text + index); + offset = g_utf8_pointer_to_offset (canvas_text, canvas_text + index); } if (layout == additional_layout) { offset += g_utf8_strlen (item->details->editable_text, -1); @@ -2564,19 +2564,19 @@ nautilus_icon_canvas_item_accessible_get_offset_at_point (AtkText *text, } static void -nautilus_icon_canvas_item_accessible_get_character_extents (AtkText *text, - gint offset, - gint *x, - gint *y, - gint *width, - gint *height, - AtkCoordType coords) +nautilus_canvas_item_accessible_get_character_extents (AtkText *text, + gint offset, + gint *x, + gint *y, + gint *width, + gint *height, + AtkCoordType coords) { gint pos_x, pos_y; gint len, byte_offset; gint editable_height; - gchar *icon_text; - NautilusIconCanvasItem *item; + gchar *canvas_text; + NautilusCanvasItem *item; PangoLayout *layout, *editable_layout, *additional_layout; PangoRectangle rect; PangoRectangle rect0; @@ -2584,14 +2584,14 @@ nautilus_icon_canvas_item_accessible_get_character_extents (AtkText *text, gint text_offset; atk_component_get_position (ATK_COMPONENT (text), &pos_x, &pos_y, coords); - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (text))); if (item->details->pixbuf) { pos_y += gdk_pixbuf_get_height (item->details->pixbuf); } have_editable = item->details->editable_text != NULL && - item->details->editable_text[0] != '\0'; + item->details->editable_text[0] != '\0'; if (have_editable) { len = g_utf8_strlen (item->details->editable_text, -1); } else { @@ -2602,11 +2602,11 @@ nautilus_icon_canvas_item_accessible_get_character_extents (AtkText *text, additional_layout = get_label_layout (&item->details->additional_text_layout, item, item->details->additional_text); if (offset < len) { - icon_text = item->details->editable_text; + canvas_text = item->details->editable_text; layout = editable_layout; } else { offset -= len; - icon_text = item->details->additional_text; + canvas_text = item->details->additional_text; layout = additional_layout; pos_y += LABEL_LINE_SPACING; if (have_editable) { @@ -2614,7 +2614,7 @@ nautilus_icon_canvas_item_accessible_get_character_extents (AtkText *text, pos_y += editable_height; } } - byte_offset = g_utf8_offset_to_pointer (icon_text, offset) - icon_text; + byte_offset = g_utf8_offset_to_pointer (canvas_text, offset) - canvas_text; pango_layout_index_to_pos (layout, byte_offset, &rect); text_offset = 0; if (have_editable) { @@ -2642,7 +2642,7 @@ nautilus_icon_canvas_item_accessible_get_character_extents (AtkText *text, } static void -nautilus_icon_canvas_item_accessible_text_interface_init (AtkTextIface *iface) +nautilus_canvas_item_accessible_text_interface_init (AtkTextIface *iface) { iface->get_text = eel_accessibility_text_get_text; iface->get_character_at_offset = eel_accessibility_text_get_character_at_offset; @@ -2650,40 +2650,40 @@ nautilus_icon_canvas_item_accessible_text_interface_init (AtkTextIface *iface) iface->get_text_at_offset = eel_accessibility_text_get_text_at_offset; iface->get_text_after_offset = eel_accessibility_text_get_text_after_offset; iface->get_character_count = eel_accessibility_text_get_character_count; - iface->get_character_extents = nautilus_icon_canvas_item_accessible_get_character_extents; - iface->get_offset_at_point = nautilus_icon_canvas_item_accessible_get_offset_at_point; + iface->get_character_extents = nautilus_canvas_item_accessible_get_character_extents; + iface->get_offset_at_point = nautilus_canvas_item_accessible_get_offset_at_point; } -static GType nautilus_icon_canvas_item_accessible_get_type (void); +static GType nautilus_canvas_item_accessible_get_type (void); -G_DEFINE_TYPE_WITH_CODE (NautilusIconCanvasItemAccessible, - nautilus_icon_canvas_item_accessible, +G_DEFINE_TYPE_WITH_CODE (NautilusCanvasItemAccessible, + nautilus_canvas_item_accessible, eel_canvas_item_accessible_get_type (), G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, - nautilus_icon_canvas_item_accessible_image_interface_init) + nautilus_canvas_item_accessible_image_interface_init) G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, - nautilus_icon_canvas_item_accessible_text_interface_init) + nautilus_canvas_item_accessible_text_interface_init) G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, - nautilus_icon_canvas_item_accessible_action_interface_init)); + nautilus_canvas_item_accessible_action_interface_init)); static AtkStateSet* -nautilus_icon_canvas_item_accessible_ref_state_set (AtkObject *accessible) +nautilus_canvas_item_accessible_ref_state_set (AtkObject *accessible) { AtkStateSet *state_set; - NautilusIconCanvasItem *item; - NautilusIconContainer *container; - NautilusIcon *icon; + NautilusCanvasItem *item; + NautilusCanvasContainer *container; + NautilusCanvasIcon *icon; GList *l; gboolean one_item_selected; - state_set = ATK_OBJECT_CLASS (nautilus_icon_canvas_item_accessible_parent_class)->ref_state_set (accessible); + state_set = ATK_OBJECT_CLASS (nautilus_canvas_item_accessible_parent_class)->ref_state_set (accessible); - item = NAUTILUS_ICON_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); + item = NAUTILUS_CANVAS_ITEM (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible))); if (!item) { atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT); return state_set; } - container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); + container = NAUTILUS_CANVAS_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); if (item->details->is_highlighted_as_keyboard_focus) { atk_state_set_add_state (state_set, ATK_STATE_FOCUSED); } else if (!container->details->keyboard_focus) { @@ -2716,9 +2716,9 @@ nautilus_icon_canvas_item_accessible_ref_state_set (AtkObject *accessible) } static void -nautilus_icon_canvas_item_accessible_finalize (GObject *object) +nautilus_canvas_item_accessible_finalize (GObject *object) { - NautilusIconCanvasItemAccessiblePrivate *priv; + NautilusCanvasItemAccessiblePrivate *priv; int i; priv = GET_ACCESSIBLE_PRIV (object); @@ -2729,59 +2729,59 @@ nautilus_icon_canvas_item_accessible_finalize (GObject *object) g_free (priv->image_description); g_free (priv->description); - G_OBJECT_CLASS (nautilus_icon_canvas_item_accessible_parent_class)->finalize (object); + G_OBJECT_CLASS (nautilus_canvas_item_accessible_parent_class)->finalize (object); } static void -nautilus_icon_canvas_item_accessible_initialize (AtkObject *accessible, - gpointer widget) +nautilus_canvas_item_accessible_initialize (AtkObject *accessible, + gpointer widget) { - ATK_OBJECT_CLASS (nautilus_icon_canvas_item_accessible_parent_class)->initialize (accessible, widget); + ATK_OBJECT_CLASS (nautilus_canvas_item_accessible_parent_class)->initialize (accessible, widget); - atk_object_set_role (accessible, ATK_ROLE_ICON); + atk_object_set_role (accessible, ATK_ROLE_CANVAS); } static void -nautilus_icon_canvas_item_accessible_class_init (NautilusIconCanvasItemAccessibleClass *klass) +nautilus_canvas_item_accessible_class_init (NautilusCanvasItemAccessibleClass *klass) { AtkObjectClass *aclass = ATK_OBJECT_CLASS (klass); GObjectClass *oclass = G_OBJECT_CLASS (klass); - oclass->finalize = nautilus_icon_canvas_item_accessible_finalize; + oclass->finalize = nautilus_canvas_item_accessible_finalize; - aclass->initialize = nautilus_icon_canvas_item_accessible_initialize; + aclass->initialize = nautilus_canvas_item_accessible_initialize; - aclass->get_name = nautilus_icon_canvas_item_accessible_get_name; - aclass->get_description = nautilus_icon_canvas_item_accessible_get_description; - aclass->get_parent = nautilus_icon_canvas_item_accessible_get_parent; - aclass->get_index_in_parent = nautilus_icon_canvas_item_accessible_get_index_in_parent; - aclass->ref_state_set = nautilus_icon_canvas_item_accessible_ref_state_set; + aclass->get_name = nautilus_canvas_item_accessible_get_name; + aclass->get_description = nautilus_canvas_item_accessible_get_description; + aclass->get_parent = nautilus_canvas_item_accessible_get_parent; + aclass->get_index_in_parent = nautilus_canvas_item_accessible_get_index_in_parent; + aclass->ref_state_set = nautilus_canvas_item_accessible_ref_state_set; - g_type_class_add_private (klass, sizeof (NautilusIconCanvasItemAccessiblePrivate)); + g_type_class_add_private (klass, sizeof (NautilusCanvasItemAccessiblePrivate)); } static void -nautilus_icon_canvas_item_accessible_init (NautilusIconCanvasItemAccessible *self) +nautilus_canvas_item_accessible_init (NautilusCanvasItemAccessible *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, nautilus_icon_canvas_item_accessible_get_type (), - NautilusIconCanvasItemAccessiblePrivate); + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, nautilus_canvas_item_accessible_get_type (), + NautilusCanvasItemAccessiblePrivate); } /* dummy typedef */ -typedef AtkObjectFactory NautilusIconCanvasItemAccessibleFactory; -typedef AtkObjectFactoryClass NautilusIconCanvasItemAccessibleFactoryClass; +typedef AtkObjectFactory NautilusCanvasItemAccessibleFactory; +typedef AtkObjectFactoryClass NautilusCanvasItemAccessibleFactoryClass; -G_DEFINE_TYPE (NautilusIconCanvasItemAccessibleFactory, nautilus_icon_canvas_item_accessible_factory, +G_DEFINE_TYPE (NautilusCanvasItemAccessibleFactory, nautilus_canvas_item_accessible_factory, ATK_TYPE_OBJECT_FACTORY); static AtkObject * -nautilus_icon_canvas_item_accessible_factory_create_accessible (GObject *for_object) +nautilus_canvas_item_accessible_factory_create_accessible (GObject *for_object) { AtkObject *accessible; - NautilusIconCanvasItem *item; + NautilusCanvasItem *item; GString *item_text; - item = NAUTILUS_ICON_CANVAS_ITEM (for_object); + item = NAUTILUS_CANVAS_ITEM (for_object); g_assert (item != NULL); item_text = g_string_new (NULL); @@ -2797,26 +2797,26 @@ nautilus_icon_canvas_item_accessible_factory_create_accessible (GObject *for_obj item_text->str); g_string_free (item_text, TRUE); - accessible = g_object_new (nautilus_icon_canvas_item_accessible_get_type (), NULL); + accessible = g_object_new (nautilus_canvas_item_accessible_get_type (), NULL); atk_object_initialize (accessible, for_object); return accessible; } static GType -nautilus_icon_canvas_item_accessible_factory_get_accessible_type (void) +nautilus_canvas_item_accessible_factory_get_accessible_type (void) { - return nautilus_icon_canvas_item_accessible_get_type (); + return nautilus_canvas_item_accessible_get_type (); } static void -nautilus_icon_canvas_item_accessible_factory_init (NautilusIconCanvasItemAccessibleFactory *self) +nautilus_canvas_item_accessible_factory_init (NautilusCanvasItemAccessibleFactory *self) { } static void -nautilus_icon_canvas_item_accessible_factory_class_init (NautilusIconCanvasItemAccessibleFactoryClass *klass) +nautilus_canvas_item_accessible_factory_class_init (NautilusCanvasItemAccessibleFactoryClass *klass) { - klass->create_accessible = nautilus_icon_canvas_item_accessible_factory_create_accessible; - klass->get_accessible_type = nautilus_icon_canvas_item_accessible_factory_get_accessible_type; + klass->create_accessible = nautilus_canvas_item_accessible_factory_create_accessible; + klass->get_accessible_type = nautilus_canvas_item_accessible_factory_get_accessible_type; } diff --git a/libnautilus-private/nautilus-canvas-item.h b/libnautilus-private/nautilus-canvas-item.h new file mode 100644 index 000000000..2c9e51106 --- /dev/null +++ b/libnautilus-private/nautilus-canvas-item.h @@ -0,0 +1,115 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* Nautilus - Canvas item class for canvas container. + * + * Copyright (C) 2000 Eazel, Inc. + * + * Author: Andy Hertzfeld <andy@eazel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NAUTILUS_CANVAS_ITEM_H +#define NAUTILUS_CANVAS_ITEM_H + +#include <eel/eel-canvas.h> +#include <eel/eel-art-extensions.h> + +G_BEGIN_DECLS + +#define NAUTILUS_TYPE_CANVAS_ITEM nautilus_canvas_item_get_type() +#define NAUTILUS_CANVAS_ITEM(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_CANVAS_ITEM, NautilusCanvasItem)) +#define NAUTILUS_CANVAS_ITEM_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CANVAS_ITEM, NautilusCanvasItemClass)) +#define NAUTILUS_IS_CANVAS_ITEM(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_CANVAS_ITEM)) +#define NAUTILUS_IS_CANVAS_ITEM_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_CANVAS_ITEM)) +#define NAUTILUS_CANVAS_ITEM_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_CANVAS_ITEM, NautilusCanvasItemClass)) + +typedef struct NautilusCanvasItem NautilusCanvasItem; +typedef struct NautilusCanvasItemClass NautilusCanvasItemClass; +typedef struct NautilusCanvasItemDetails NautilusCanvasItemDetails; + +struct NautilusCanvasItem { + EelCanvasItem item; + NautilusCanvasItemDetails *details; + gpointer user_data; +}; + +struct NautilusCanvasItemClass { + EelCanvasItemClass parent_class; +}; + +/* not namespaced due to their length */ +typedef enum { + BOUNDS_USAGE_FOR_LAYOUT, + BOUNDS_USAGE_FOR_ENTIRE_ITEM, + BOUNDS_USAGE_FOR_DISPLAY +} NautilusCanvasItemBoundsUsage; + +/* GObject */ +GType nautilus_canvas_item_get_type (void); + +/* attributes */ +void nautilus_canvas_item_set_image (NautilusCanvasItem *item, + GdkPixbuf *image); +cairo_surface_t* nautilus_canvas_item_get_drag_surface (NautilusCanvasItem *item); +void nautilus_canvas_item_set_emblems (NautilusCanvasItem *item, + GList *emblem_pixbufs); +void nautilus_canvas_item_set_show_stretch_handles (NautilusCanvasItem *item, + gboolean show_stretch_handles); +void nautilus_canvas_item_set_attach_points (NautilusCanvasItem *item, + GdkPoint *attach_points, + int n_attach_points); +void nautilus_canvas_item_set_embedded_text_rect (NautilusCanvasItem *item, + const GdkRectangle *text_rect); +void nautilus_canvas_item_set_embedded_text (NautilusCanvasItem *item, + const char *text); +double nautilus_canvas_item_get_max_text_width (NautilusCanvasItem *item); +const char *nautilus_canvas_item_get_editable_text (NautilusCanvasItem *canvas_item); +void nautilus_canvas_item_set_renaming (NautilusCanvasItem *canvas_item, + gboolean state); + +/* geometry and hit testing */ +gboolean nautilus_canvas_item_hit_test_rectangle (NautilusCanvasItem *item, + EelIRect canvas_rect); +gboolean nautilus_canvas_item_hit_test_stretch_handles (NautilusCanvasItem *item, + gdouble world_x, + gdouble world_y, + GtkCornerType *corner); +void nautilus_canvas_item_invalidate_label (NautilusCanvasItem *item); +void nautilus_canvas_item_invalidate_label_size (NautilusCanvasItem *item); +EelDRect nautilus_canvas_item_get_icon_rectangle (const NautilusCanvasItem *item); +EelDRect nautilus_canvas_item_get_text_rectangle (NautilusCanvasItem *item, + gboolean for_layout); +void nautilus_canvas_item_get_bounds_for_layout (NautilusCanvasItem *item, + double *x1, double *y1, double *x2, double *y2); +void nautilus_canvas_item_get_bounds_for_entire_item (NautilusCanvasItem *item, + double *x1, double *y1, double *x2, double *y2); +void nautilus_canvas_item_update_bounds (NautilusCanvasItem *item, + double i2w_dx, double i2w_dy); +void nautilus_canvas_item_set_is_visible (NautilusCanvasItem *item, + gboolean visible); +/* whether the entire label text must be visible at all times */ +void nautilus_canvas_item_set_entire_text (NautilusCanvasItem *canvas_item, + gboolean entire_text); + +G_END_DECLS + +#endif /* NAUTILUS_CANVAS_ITEM_H */ diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-canvas-private.h index e68970316..92977330e 100644 --- a/libnautilus-private/nautilus-icon-private.h +++ b/libnautilus-private/nautilus-canvas-private.h @@ -1,5 +1,5 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* gnome-icon-container-private.h +/* gnome-canvas-container-private.h Copyright (C) 1999, 2000 Free Software Foundation Copyright (C) 2000 Eazel, Inc. @@ -22,22 +22,22 @@ Author: Ettore Perazzoli <ettore@gnu.org> */ -#ifndef NAUTILUS_ICON_CONTAINER_PRIVATE_H -#define NAUTILUS_ICON_CONTAINER_PRIVATE_H +#ifndef NAUTILUS_CANVAS_CONTAINER_PRIVATE_H +#define NAUTILUS_CANVAS_CONTAINER_PRIVATE_H #include <eel/eel-glib-extensions.h> -#include <libnautilus-private/nautilus-icon-canvas-item.h> -#include <libnautilus-private/nautilus-icon-container.h> -#include <libnautilus-private/nautilus-icon-dnd.h> +#include <libnautilus-private/nautilus-canvas-item.h> +#include <libnautilus-private/nautilus-canvas-container.h> +#include <libnautilus-private/nautilus-canvas-dnd.h> /* An Icon. */ typedef struct { /* Object represented by this icon. */ - NautilusIconData *data; + NautilusCanvasIconData *data; /* Canvas item for the icon. */ - NautilusIconCanvasItem *item; + NautilusCanvasItem *item; /* X/Y coordinates. */ double x, y; @@ -66,10 +66,10 @@ typedef struct { eel_boolean_bit is_monitored : 1; eel_boolean_bit has_lazy_position : 1; -} NautilusIcon; +} NautilusCanvasIcon; -/* Private NautilusIconContainer members. */ +/* Private NautilusCanvasContainer members. */ typedef struct { gboolean active; @@ -84,7 +84,7 @@ typedef struct { EelDRect prev_rect; int last_adj_x; int last_adj_y; -} NautilusIconRubberbandInfo; +} NautilusCanvasRubberbandInfo; typedef enum { DRAG_STATE_INITIAL, @@ -118,33 +118,33 @@ enum { LAST_LABEL_COLOR }; -struct NautilusIconContainerDetails { +struct NautilusCanvasContainerDetails { /* List of icons. */ GList *icons; GList *new_icons; GHashTable *icon_set; /* Current icon for keyboard navigation. */ - NautilusIcon *keyboard_focus; - NautilusIcon *keyboard_rubberband_start; + NautilusCanvasIcon *keyboard_focus; + NautilusCanvasIcon *keyboard_rubberband_start; /* Current icon with stretch handles, so we have only one. */ - NautilusIcon *stretch_icon; + NautilusCanvasIcon *stretch_icon; double stretch_initial_x, stretch_initial_y; guint stretch_initial_size; /* Last highlighted drop target. */ - NautilusIcon *drop_target; + NautilusCanvasIcon *drop_target; /* Rubberbanding status. */ - NautilusIconRubberbandInfo rubberband_info; + NautilusCanvasRubberbandInfo rubberband_info; /* Timeout used to make a selected icon fully visible after a short * period of time. (The timeout is needed to make sure * double-clicking still works.) */ guint keyboard_icon_reveal_timer_id; - NautilusIcon *keyboard_icon_to_reveal; + NautilusCanvasIcon *keyboard_icon_to_reveal; /* Used to coalesce selection changed signals in some cases */ guint selection_changed_id; @@ -152,19 +152,19 @@ struct NautilusIconContainerDetails { /* If a request is made to reveal an unpositioned icon we remember * it and reveal it once it gets positioned (in relayout). */ - NautilusIcon *pending_icon_to_reveal; + NautilusCanvasIcon *pending_icon_to_reveal; /* If a request is made to rename an unpositioned icon we remember * it and start renaming it once it gets positioned (in relayout). */ - NautilusIcon *pending_icon_to_rename; + NautilusCanvasIcon *pending_icon_to_rename; /* Remembered information about the start of the current event. */ guint32 button_down_time; /* Drag state. Valid only if drag_button is non-zero. */ guint drag_button; - NautilusIcon *drag_icon; + NautilusCanvasIcon *drag_icon; int drag_x, drag_y; DragState drag_state; gboolean drag_started; @@ -172,10 +172,10 @@ struct NautilusIconContainerDetails { gboolean drag_allow_moves; gboolean icon_selected_on_button_down; - NautilusIcon *double_click_icon[2]; /* Both clicks in a double click need to be on the same icon */ + NautilusCanvasIcon *double_click_icon[2]; /* Both clicks in a double click need to be on the same icon */ guint double_click_button[2]; - NautilusIcon *range_selection_base_icon; + NautilusCanvasIcon *range_selection_base_icon; /* Renaming Details */ gboolean renaming; @@ -192,7 +192,7 @@ struct NautilusIconContainerDetails { guint align_idle_id; /* DnD info. */ - NautilusIconDndInfo *dnd_info; + NautilusCanvasDndInfo *dnd_info; /* zoom level */ int zoom_level; @@ -211,10 +211,10 @@ struct NautilusIconContainerDetails { gboolean auto_layout; /* Layout mode */ - NautilusIconLayoutMode layout_mode; + NautilusCanvasLayoutMode layout_mode; /* Label position */ - NautilusIconLabelPosition label_position; + NautilusCanvasLabelPosition label_position; /* Should the container keep icons aligned to a grid */ gboolean keep_aligned; @@ -261,28 +261,28 @@ struct NautilusIconContainerDetails { }; /* Private functions shared by mutiple files. */ -NautilusIcon *nautilus_icon_container_get_icon_by_uri (NautilusIconContainer *container, - const char *uri); -void nautilus_icon_container_move_icon (NautilusIconContainer *container, - NautilusIcon *icon, - int x, - int y, - double scale, - gboolean raise, - gboolean snap, - gboolean update_position); -void nautilus_icon_container_select_list_unselect_others (NautilusIconContainer *container, - GList *icons); -char * nautilus_icon_container_get_icon_uri (NautilusIconContainer *container, - NautilusIcon *icon); -char * nautilus_icon_container_get_icon_drop_target_uri (NautilusIconContainer *container, - NautilusIcon *icon); -void nautilus_icon_container_update_icon (NautilusIconContainer *container, - NautilusIcon *icon); -gboolean nautilus_icon_container_has_stored_icon_positions (NautilusIconContainer *container); -gboolean nautilus_icon_container_scroll (NautilusIconContainer *container, - int delta_x, - int delta_y); -void nautilus_icon_container_update_scroll_region (NautilusIconContainer *container); - -#endif /* NAUTILUS_ICON_CONTAINER_PRIVATE_H */ +NautilusCanvasIcon *nautilus_canvas_container_get_icon_by_uri (NautilusCanvasContainer *container, + const char *uri); +void nautilus_canvas_container_move_icon (NautilusCanvasContainer *container, + NautilusCanvasIcon *icon, + int x, + int y, + double scale, + gboolean raise, + gboolean snap, + gboolean update_position); +void nautilus_canvas_container_select_list_unselect_others (NautilusCanvasContainer *container, + GList *icons); +char * nautilus_canvas_container_get_icon_uri (NautilusCanvasContainer *container, + NautilusCanvasIcon *canvas); +char * nautilus_canvas_container_get_icon_drop_target_uri (NautilusCanvasContainer *container, + NautilusCanvasIcon *canvas); +void nautilus_canvas_container_update_icon (NautilusCanvasContainer *container, + NautilusCanvasIcon *canvas); +gboolean nautilus_canvas_container_has_stored_icon_positions (NautilusCanvasContainer *container); +gboolean nautilus_canvas_container_scroll (NautilusCanvasContainer *container, + int delta_x, + int delta_y); +void nautilus_canvas_container_update_scroll_region (NautilusCanvasContainer *container); + +#endif /* NAUTILUS_CANVAS_CONTAINER_PRIVATE_H */ diff --git a/libnautilus-private/nautilus-debug.c b/libnautilus-private/nautilus-debug.c index a51443199..9297b8950 100644 --- a/libnautilus-private/nautilus-debug.c +++ b/libnautilus-private/nautilus-debug.c @@ -42,8 +42,8 @@ static GDebugKey keys[] = { { "DBus", NAUTILUS_DEBUG_DBUS }, { "DirectoryView", NAUTILUS_DEBUG_DIRECTORY_VIEW }, { "File", NAUTILUS_DEBUG_FILE }, - { "IconContainer", NAUTILUS_DEBUG_ICON_CONTAINER }, - { "IconView", NAUTILUS_DEBUG_ICON_VIEW }, + { "CanvasContainer", NAUTILUS_DEBUG_CANVAS_CONTAINER }, + { "IconView", NAUTILUS_DEBUG_CANVAS_VIEW }, { "ListView", NAUTILUS_DEBUG_LIST_VIEW }, { "Mime", NAUTILUS_DEBUG_MIME }, { "Places", NAUTILUS_DEBUG_PLACES }, diff --git a/libnautilus-private/nautilus-debug.h b/libnautilus-private/nautilus-debug.h index 8eb869362..f1c8b2881 100644 --- a/libnautilus-private/nautilus-debug.h +++ b/libnautilus-private/nautilus-debug.h @@ -38,8 +38,8 @@ typedef enum { NAUTILUS_DEBUG_DBUS = 1 << 3, NAUTILUS_DEBUG_DIRECTORY_VIEW = 1 << 4, NAUTILUS_DEBUG_FILE = 1 << 5, - NAUTILUS_DEBUG_ICON_CONTAINER = 1 << 6, - NAUTILUS_DEBUG_ICON_VIEW = 1 << 7, + NAUTILUS_DEBUG_CANVAS_CONTAINER = 1 << 6, + NAUTILUS_DEBUG_CANVAS_VIEW = 1 << 7, NAUTILUS_DEBUG_LIST_VIEW = 1 << 8, NAUTILUS_DEBUG_MIME = 1 << 9, NAUTILUS_DEBUG_PLACES = 1 << 10, diff --git a/libnautilus-private/nautilus-desktop-background.c b/libnautilus-private/nautilus-desktop-background.c index f7b4312e5..6c1033df5 100644 --- a/libnautilus-private/nautilus-desktop-background.c +++ b/libnautilus-private/nautilus-desktop-background.c @@ -549,7 +549,7 @@ nautilus_desktop_background_class_init (NautilusDesktopBackgroundClass *klass) pspec = g_param_spec_object ("widget", "The widget for this background", "The widget that gets its background set", - NAUTILUS_TYPE_ICON_CONTAINER, + NAUTILUS_TYPE_CANVAS_CONTAINER, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_WIDGET, pspec); @@ -591,7 +591,7 @@ nautilus_desktop_background_receive_dropped_background_image (NautilusDesktopBac } NautilusDesktopBackground * -nautilus_desktop_background_new (NautilusIconContainer *container) +nautilus_desktop_background_new (NautilusCanvasContainer *container) { return g_object_new (NAUTILUS_TYPE_DESKTOP_BACKGROUND, "widget", container, diff --git a/libnautilus-private/nautilus-desktop-background.h b/libnautilus-private/nautilus-desktop-background.h index 8b9926f50..aa306ba26 100644 --- a/libnautilus-private/nautilus-desktop-background.h +++ b/libnautilus-private/nautilus-desktop-background.h @@ -31,7 +31,7 @@ #include <gtk/gtk.h> -#include "nautilus-icon-container.h" +#include "nautilus-canvas-container.h" typedef struct NautilusDesktopBackground NautilusDesktopBackground; typedef struct NautilusDesktopBackgroundClass NautilusDesktopBackgroundClass; @@ -49,7 +49,7 @@ typedef struct NautilusDesktopBackgroundClass NautilusDesktopBackgroundClass; (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_DESKTOP_BACKGROUND, NautilusDesktopBackgroundClass)) GType nautilus_desktop_background_get_type (void); -NautilusDesktopBackground * nautilus_desktop_background_new (NautilusIconContainer *container); +NautilusDesktopBackground * nautilus_desktop_background_new (NautilusCanvasContainer *container); void nautilus_desktop_background_receive_dropped_background_image (NautilusDesktopBackground *self, const gchar *image_uri); diff --git a/libnautilus-private/nautilus-icon-canvas-item.h b/libnautilus-private/nautilus-icon-canvas-item.h deleted file mode 100644 index 4e84983e8..000000000 --- a/libnautilus-private/nautilus-icon-canvas-item.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* Nautilus - Icon canvas item class for icon container. - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef NAUTILUS_ICON_CANVAS_ITEM_H -#define NAUTILUS_ICON_CANVAS_ITEM_H - -#include <eel/eel-canvas.h> -#include <eel/eel-art-extensions.h> - -G_BEGIN_DECLS - -#define NAUTILUS_TYPE_ICON_CANVAS_ITEM nautilus_icon_canvas_item_get_type() -#define NAUTILUS_ICON_CANVAS_ITEM(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_ICON_CANVAS_ITEM, NautilusIconCanvasItem)) -#define NAUTILUS_ICON_CANVAS_ITEM_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ICON_CANVAS_ITEM, NautilusIconCanvasItemClass)) -#define NAUTILUS_IS_ICON_CANVAS_ITEM(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_ICON_CANVAS_ITEM)) -#define NAUTILUS_IS_ICON_CANVAS_ITEM_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ICON_CANVAS_ITEM)) -#define NAUTILUS_ICON_CANVAS_ITEM_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_ICON_CANVAS_ITEM, NautilusIconCanvasItemClass)) - -typedef struct NautilusIconCanvasItem NautilusIconCanvasItem; -typedef struct NautilusIconCanvasItemClass NautilusIconCanvasItemClass; -typedef struct NautilusIconCanvasItemDetails NautilusIconCanvasItemDetails; - -struct NautilusIconCanvasItem { - EelCanvasItem item; - NautilusIconCanvasItemDetails *details; - gpointer user_data; -}; - -struct NautilusIconCanvasItemClass { - EelCanvasItemClass parent_class; -}; - -/* not namespaced due to their length */ -typedef enum { - BOUNDS_USAGE_FOR_LAYOUT, - BOUNDS_USAGE_FOR_ENTIRE_ITEM, - BOUNDS_USAGE_FOR_DISPLAY -} NautilusIconCanvasItemBoundsUsage; - -/* GObject */ -GType nautilus_icon_canvas_item_get_type (void); - -/* attributes */ -void nautilus_icon_canvas_item_set_image (NautilusIconCanvasItem *item, - GdkPixbuf *image); -cairo_surface_t* nautilus_icon_canvas_item_get_drag_surface (NautilusIconCanvasItem *item); -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, - GdkPoint *attach_points, - int n_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, - gboolean state); - -/* geometry and hit testing */ -gboolean nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item, - EelIRect canvas_rect); -gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item, - gdouble world_x, - gdouble world_y, - GtkCornerType *corner); -void nautilus_icon_canvas_item_invalidate_label (NautilusIconCanvasItem *item); -void nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item); -EelDRect nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item); -EelDRect nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item, - gboolean for_layout); -void nautilus_icon_canvas_item_get_bounds_for_layout (NautilusIconCanvasItem *item, - double *x1, double *y1, double *x2, double *y2); -void nautilus_icon_canvas_item_get_bounds_for_entire_item (NautilusIconCanvasItem *item, - double *x1, double *y1, double *x2, double *y2); -void nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item, - double i2w_dx, double i2w_dy); -void nautilus_icon_canvas_item_set_is_visible (NautilusIconCanvasItem *item, - gboolean visible); -/* whether the entire label text must be visible at all times */ -void nautilus_icon_canvas_item_set_entire_text (NautilusIconCanvasItem *icon_item, - gboolean entire_text); - -G_END_DECLS - -#endif /* NAUTILUS_ICON_CANVAS_ITEM_H */ diff --git a/libnautilus-private/nautilus-icon-container.h b/libnautilus-private/nautilus-icon-container.h deleted file mode 100644 index 6ae2eaefa..000000000 --- a/libnautilus-private/nautilus-icon-container.h +++ /dev/null @@ -1,357 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* gnome-icon-container.h - Icon container widget. - - Copyright (C) 1999, 2000 Free Software Foundation - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Ettore Perazzoli <ettore@gnu.org>, Darin Adler <darin@bentspoon.com> -*/ - -#ifndef NAUTILUS_ICON_CONTAINER_H -#define NAUTILUS_ICON_CONTAINER_H - -#include <eel/eel-canvas.h> -#include <libnautilus-private/nautilus-icon-info.h> - -#define NAUTILUS_TYPE_ICON_CONTAINER nautilus_icon_container_get_type() -#define NAUTILUS_ICON_CONTAINER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_ICON_CONTAINER, NautilusIconContainer)) -#define NAUTILUS_ICON_CONTAINER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ICON_CONTAINER, NautilusIconContainerClass)) -#define NAUTILUS_IS_ICON_CONTAINER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_ICON_CONTAINER)) -#define NAUTILUS_IS_ICON_CONTAINER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ICON_CONTAINER)) -#define NAUTILUS_ICON_CONTAINER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_ICON_CONTAINER, NautilusIconContainerClass)) - - -#define NAUTILUS_ICON_CONTAINER_ICON_DATA(pointer) \ - ((NautilusIconData *) (pointer)) - -typedef struct NautilusIconData NautilusIconData; - -typedef void (* NautilusIconCallback) (NautilusIconData *icon_data, - gpointer callback_data); - -typedef struct { - int x; - int y; - double scale; -} NautilusIconPosition; - -typedef enum { - NAUTILUS_ICON_LAYOUT_L_R_T_B, - NAUTILUS_ICON_LAYOUT_R_L_T_B, - NAUTILUS_ICON_LAYOUT_T_B_L_R, - NAUTILUS_ICON_LAYOUT_T_B_R_L -} NautilusIconLayoutMode; - -typedef enum { - NAUTILUS_ICON_LABEL_POSITION_UNDER, -} NautilusIconLabelPosition; - -#define NAUTILUS_ICON_CONTAINER_TYPESELECT_FLUSH_DELAY 1000000 - -typedef struct NautilusIconContainerDetails NautilusIconContainerDetails; - -typedef struct { - EelCanvas canvas; - NautilusIconContainerDetails *details; -} NautilusIconContainer; - -typedef struct { - EelCanvasClass parent_slot; - - /* Operations on the container. */ - int (* button_press) (NautilusIconContainer *container, - GdkEventButton *event); - void (* context_click_background) (NautilusIconContainer *container, - GdkEventButton *event); - void (* middle_click) (NautilusIconContainer *container, - GdkEventButton *event); - - /* Operations on icons. */ - void (* activate) (NautilusIconContainer *container, - NautilusIconData *data); - void (* activate_alternate) (NautilusIconContainer *container, - NautilusIconData *data); - void (* activate_previewer) (NautilusIconContainer *container, - GList *files, - GArray *locations); - void (* context_click_selection) (NautilusIconContainer *container, - GdkEventButton *event); - void (* move_copy_items) (NautilusIconContainer *container, - const GList *item_uris, - GdkPoint *relative_item_points, - const char *target_uri, - GdkDragAction action, - int x, - int y); - void (* handle_netscape_url) (NautilusIconContainer *container, - const char *url, - const char *target_uri, - GdkDragAction action, - int x, - int y); - void (* handle_uri_list) (NautilusIconContainer *container, - const char *uri_list, - const char *target_uri, - GdkDragAction action, - int x, - int y); - void (* handle_text) (NautilusIconContainer *container, - const char *text, - const char *target_uri, - GdkDragAction action, - int x, - int y); - void (* handle_raw) (NautilusIconContainer *container, - char *raw_data, - int length, - const char *target_uri, - const char *direct_save_uri, - GdkDragAction action, - int x, - int y); - - /* Queries on the container for subclass/client. - * These must be implemented. The default "do nothing" is not good enough. - */ - char * (* get_container_uri) (NautilusIconContainer *container); - - /* Queries on icons for subclass/client. - * These must be implemented. The default "do nothing" is not - * good enough, these are _not_ signals. - */ - NautilusIconInfo *(* get_icon_images) (NautilusIconContainer *container, - NautilusIconData *data, - int icon_size, - char **embedded_text, - gboolean for_drag_accept, - gboolean need_large_embeddded_text, - gboolean *embedded_text_needs_loading, - gboolean *has_window_open); - void (* get_icon_text) (NautilusIconContainer *container, - NautilusIconData *data, - char **editable_text, - char **additional_text, - gboolean include_invisible); - char * (* get_icon_description) (NautilusIconContainer *container, - NautilusIconData *data); - int (* compare_icons) (NautilusIconContainer *container, - NautilusIconData *icon_a, - NautilusIconData *icon_b); - int (* compare_icons_by_name) (NautilusIconContainer *container, - NautilusIconData *icon_a, - NautilusIconData *icon_b); - void (* freeze_updates) (NautilusIconContainer *container); - void (* unfreeze_updates) (NautilusIconContainer *container); - void (* start_monitor_top_left) (NautilusIconContainer *container, - NautilusIconData *data, - gconstpointer client, - gboolean large_text); - void (* stop_monitor_top_left) (NautilusIconContainer *container, - NautilusIconData *data, - gconstpointer client); - void (* prioritize_thumbnailing) (NautilusIconContainer *container, - NautilusIconData *data); - - /* Queries on icons for subclass/client. - * These must be implemented => These are signals ! - * The default "do nothing" is not good enough. - */ - gboolean (* can_accept_item) (NautilusIconContainer *container, - NautilusIconData *target, - const char *item_uri); - gboolean (* get_stored_icon_position) (NautilusIconContainer *container, - NautilusIconData *data, - NautilusIconPosition *position); - char * (* get_icon_uri) (NautilusIconContainer *container, - NautilusIconData *data); - char * (* get_icon_drop_target_uri) (NautilusIconContainer *container, - NautilusIconData *data); - - /* If icon data is NULL, the layout timestamp of the container should be retrieved. - * That is the time when the container displayed a fully loaded directory with - * all icon positions assigned. - * - * If icon data is not NULL, the position timestamp of the icon should be retrieved. - * That is the time when the file (i.e. icon data payload) was last displayed in a - * fully loaded directory with all icon positions assigned. - */ - gboolean (* get_stored_layout_timestamp) (NautilusIconContainer *container, - NautilusIconData *data, - time_t *time); - /* If icon data is NULL, the layout timestamp of the container should be stored. - * If icon data is not NULL, the position timestamp of the container should be stored. - */ - gboolean (* store_layout_timestamp) (NautilusIconContainer *container, - NautilusIconData *data, - const time_t *time); - - /* Notifications for the whole container. */ - void (* band_select_started) (NautilusIconContainer *container); - void (* band_select_ended) (NautilusIconContainer *container); - void (* selection_changed) (NautilusIconContainer *container); - void (* layout_changed) (NautilusIconContainer *container); - - /* Notifications for icons. */ - void (* icon_position_changed) (NautilusIconContainer *container, - NautilusIconData *data, - const NautilusIconPosition *position); - void (* icon_rename_started) (NautilusIconContainer *container, - GtkWidget *renaming_widget); - void (* icon_rename_ended) (NautilusIconContainer *container, - NautilusIconData *data, - const char *text); - void (* icon_stretch_started) (NautilusIconContainer *container, - NautilusIconData *data); - void (* icon_stretch_ended) (NautilusIconContainer *container, - NautilusIconData *data); - int (* preview) (NautilusIconContainer *container, - NautilusIconData *data, - gboolean start_flag); - void (* icon_added) (NautilusIconContainer *container, - NautilusIconData *data); - void (* icon_removed) (NautilusIconContainer *container, - NautilusIconData *data); - void (* cleared) (NautilusIconContainer *container); - gboolean (* start_interactive_search) (NautilusIconContainer *container); -} NautilusIconContainerClass; - -/* GtkObject */ -GType nautilus_icon_container_get_type (void); -GtkWidget * nautilus_icon_container_new (void); - - -/* adding, removing, and managing icons */ -void nautilus_icon_container_clear (NautilusIconContainer *view); -gboolean nautilus_icon_container_add (NautilusIconContainer *view, - NautilusIconData *data); -void nautilus_icon_container_layout_now (NautilusIconContainer *container); -gboolean nautilus_icon_container_remove (NautilusIconContainer *view, - NautilusIconData *data); -void nautilus_icon_container_for_each (NautilusIconContainer *view, - NautilusIconCallback callback, - gpointer callback_data); -void nautilus_icon_container_request_update (NautilusIconContainer *view, - NautilusIconData *data); -void nautilus_icon_container_request_update_all (NautilusIconContainer *container); -void nautilus_icon_container_reveal (NautilusIconContainer *container, - NautilusIconData *data); -gboolean nautilus_icon_container_is_empty (NautilusIconContainer *container); -NautilusIconData *nautilus_icon_container_get_first_visible_icon (NautilusIconContainer *container); -void nautilus_icon_container_scroll_to_icon (NautilusIconContainer *container, - NautilusIconData *data); - -void nautilus_icon_container_begin_loading (NautilusIconContainer *container); -void nautilus_icon_container_end_loading (NautilusIconContainer *container, - gboolean all_icons_added); - -/* control the layout */ -gboolean nautilus_icon_container_is_auto_layout (NautilusIconContainer *container); -void nautilus_icon_container_set_auto_layout (NautilusIconContainer *container, - gboolean auto_layout); - -gboolean nautilus_icon_container_is_keep_aligned (NautilusIconContainer *container); -void nautilus_icon_container_set_keep_aligned (NautilusIconContainer *container, - gboolean keep_aligned); -void nautilus_icon_container_set_layout_mode (NautilusIconContainer *container, - NautilusIconLayoutMode mode); -void nautilus_icon_container_set_label_position (NautilusIconContainer *container, - NautilusIconLabelPosition pos); -void nautilus_icon_container_sort (NautilusIconContainer *container); -void nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container); - -int nautilus_icon_container_get_max_layout_lines (NautilusIconContainer *container); -int nautilus_icon_container_get_max_layout_lines_for_pango (NautilusIconContainer *container); - -void nautilus_icon_container_set_highlighted_for_clipboard (NautilusIconContainer *container, - GList *clipboard_icon_data); - -/* operations on all icons */ -void nautilus_icon_container_unselect_all (NautilusIconContainer *view); -void nautilus_icon_container_select_all (NautilusIconContainer *view); - - -/* operations on the selection */ -GList * nautilus_icon_container_get_selection (NautilusIconContainer *view); -void nautilus_icon_container_invert_selection (NautilusIconContainer *view); -void nautilus_icon_container_set_selection (NautilusIconContainer *view, - GList *selection); -GArray * nautilus_icon_container_get_selected_icon_locations (NautilusIconContainer *view); -gboolean nautilus_icon_container_has_stretch_handles (NautilusIconContainer *container); -gboolean nautilus_icon_container_is_stretched (NautilusIconContainer *container); -void nautilus_icon_container_show_stretch_handles (NautilusIconContainer *container); -void nautilus_icon_container_unstretch (NautilusIconContainer *container); -void nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container, - gboolean select_all); - -/* options */ -NautilusZoomLevel nautilus_icon_container_get_zoom_level (NautilusIconContainer *view); -void nautilus_icon_container_set_zoom_level (NautilusIconContainer *view, - int new_zoom_level); -void nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container, - gboolean single_click_mode); -void nautilus_icon_container_enable_linger_selection (NautilusIconContainer *view, - gboolean enable); -gboolean nautilus_icon_container_get_is_fixed_size (NautilusIconContainer *container); -void nautilus_icon_container_set_is_fixed_size (NautilusIconContainer *container, - gboolean is_fixed_size); -gboolean nautilus_icon_container_get_is_desktop (NautilusIconContainer *container); -void nautilus_icon_container_set_is_desktop (NautilusIconContainer *container, - gboolean is_desktop); -void nautilus_icon_container_reset_scroll_region (NautilusIconContainer *container); -void nautilus_icon_container_set_font (NautilusIconContainer *container, - const char *font); -void nautilus_icon_container_set_margins (NautilusIconContainer *container, - int left_margin, - int right_margin, - int top_margin, - int bottom_margin); -void nautilus_icon_container_set_use_drop_shadows (NautilusIconContainer *container, - gboolean use_drop_shadows); -char* nautilus_icon_container_get_icon_description (NautilusIconContainer *container, - NautilusIconData *data); -gboolean nautilus_icon_container_get_allow_moves (NautilusIconContainer *container); -void nautilus_icon_container_set_allow_moves (NautilusIconContainer *container, - gboolean allow_moves); - -gboolean nautilus_icon_container_is_layout_rtl (NautilusIconContainer *container); -gboolean nautilus_icon_container_is_layout_vertical (NautilusIconContainer *container); - -gboolean nautilus_icon_container_get_store_layout_timestamps (NautilusIconContainer *container); -void nautilus_icon_container_set_store_layout_timestamps (NautilusIconContainer *container, - gboolean store_layout); - -void nautilus_icon_container_widget_to_file_operation_position (NautilusIconContainer *container, - GdkPoint *position); - -#define CANVAS_WIDTH(container,allocation) ((allocation.width \ - - container->details->left_margin \ - - container->details->right_margin) \ - / EEL_CANVAS (container)->pixels_per_unit) - -#define CANVAS_HEIGHT(container,allocation) ((allocation.height \ - - container->details->top_margin \ - - container->details->bottom_margin) \ - / EEL_CANVAS (container)->pixels_per_unit) - -#endif /* NAUTILUS_ICON_CONTAINER_H */ diff --git a/libnautilus-private/nautilus-lib-self-check-functions.h b/libnautilus-private/nautilus-lib-self-check-functions.h index 7a376ee86..b2f971c96 100644 --- a/libnautilus-private/nautilus-lib-self-check-functions.h +++ b/libnautilus-private/nautilus-lib-self-check-functions.h @@ -43,7 +43,7 @@ void nautilus_run_lib_self_checks (void); macro (nautilus_self_check_file_operations) \ macro (nautilus_self_check_directory) \ macro (nautilus_self_check_file) \ - macro (nautilus_self_check_icon_container) \ + macro (nautilus_self_check_canvas_container) \ /* Add new self-check functions to the list above this line. */ /* Generate prototypes for all the functions. */ diff --git a/libnautilus-private/nautilus-tree-view-drag-dest.c b/libnautilus-private/nautilus-tree-view-drag-dest.c index f857add89..f41230108 100644 --- a/libnautilus-private/nautilus-tree-view-drag-dest.c +++ b/libnautilus-private/nautilus-tree-view-drag-dest.c @@ -34,7 +34,6 @@ #include "nautilus-file-dnd.h" #include "nautilus-file-changes-queue.h" -#include "nautilus-icon-dnd.h" #include "nautilus-link.h" #include <gtk/gtk.h> diff --git a/po/POTFILES.in b/po/POTFILES.in index 3dda68dd6..cc622fde8 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -30,9 +30,9 @@ libnautilus-private/nautilus-file-operations.c libnautilus-private/nautilus-file-undo-operations.c libnautilus-private/nautilus-file-utilities.c libnautilus-private/nautilus-global-preferences.c -libnautilus-private/nautilus-icon-canvas-item.c -libnautilus-private/nautilus-icon-container.c -libnautilus-private/nautilus-icon-dnd.c +libnautilus-private/nautilus-canvas-item.c +libnautilus-private/nautilus-canvas-container.c +libnautilus-private/nautilus-canvas-dnd.c libnautilus-private/nautilus-mime-application-chooser.c libnautilus-private/nautilus-program-choosing.c libnautilus-private/nautilus-progress-info.c @@ -50,7 +50,7 @@ src/nautilus-bookmarks-window.c [type: gettext/glade]src/nautilus-bookmarks-window.ui src/nautilus-connect-server-dialog.c src/nautilus-connect-server-dialog-main.c -src/nautilus-desktop-icon-view.c +src/nautilus-desktop-canvas-view.c src/nautilus-desktop-icon-view-ui.xml src/nautilus-desktop-item-properties.c src/nautilus-desktop-window.c @@ -58,8 +58,8 @@ src/nautilus-directory-view-ui.xml src/nautilus-error-reporting.c src/nautilus-file-management-properties.c [type: gettext/glade]src/nautilus-file-management-properties.ui -src/nautilus-icon-view.c -src/nautilus-icon-view-container.c +src/nautilus-canvas-view.c +src/nautilus-canvas-view-container.c src/nautilus-icon-view-ui.xml src/nautilus-image-properties-page.c src/nautilus-list-model.c diff --git a/src/Makefile.am b/src/Makefile.am index f7a012090..086d5bd26 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -85,13 +85,17 @@ nautilus_SOURCES = \ nautilus-bookmark-list.h \ nautilus-bookmarks-window.c \ nautilus-bookmarks-window.h \ + nautilus-canvas-view.c \ + nautilus-canvas-view.h \ + nautilus-canvas-view-container.c \ + nautilus-canvas-view-container.h \ nautilus-connect-server-dialog.c \ nautilus-connect-server-dialog.h \ nautilus-connect-server-dialog-nonmain.c \ nautilus-connect-server-operation.c \ nautilus-connect-server-operation.h \ - nautilus-desktop-icon-view.c \ - nautilus-desktop-icon-view.h \ + nautilus-desktop-canvas-view.c \ + nautilus-desktop-canvas-view.h \ nautilus-desktop-item-properties.c \ nautilus-desktop-item-properties.h \ nautilus-desktop-window.c \ @@ -104,10 +108,6 @@ nautilus_SOURCES = \ nautilus-floating-bar.h \ nautilus-freedesktop-dbus.c \ nautilus-freedesktop-dbus.h \ - nautilus-icon-view.c \ - nautilus-icon-view.h \ - nautilus-icon-view-container.c \ - nautilus-icon-view-container.h \ nautilus-image-properties-page.c \ nautilus-image-properties-page.h \ nautilus-list-model.c \ diff --git a/src/nautilus-application.c b/src/nautilus-application.c index a8bd7f9d8..5bdc78862 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -36,11 +36,11 @@ #include "nautilus-bookmarks-window.h" #include "nautilus-connect-server-dialog.h" -#include "nautilus-desktop-icon-view.h" +#include "nautilus-desktop-canvas-view.h" #include "nautilus-desktop-window.h" #include "nautilus-file-management-properties.h" #include "nautilus-freedesktop-dbus.h" -#include "nautilus-icon-view.h" +#include "nautilus-canvas-view.h" #include "nautilus-image-properties-page.h" #include "nautilus-list-view.h" #include "nautilus-previewer.h" @@ -1353,8 +1353,8 @@ nautilus_application_startup (GApplication *app) nautilus_global_preferences_init (); /* register views */ - nautilus_icon_view_register (); - nautilus_desktop_icon_view_register (); + nautilus_canvas_view_register (); + nautilus_desktop_canvas_view_register (); nautilus_list_view_register (); #if ENABLE_EMPTY_VIEW nautilus_empty_view_register (); diff --git a/src/nautilus-icon-view-container.c b/src/nautilus-canvas-view-container.c index 256fd2bdc..94dc7bedf 100644 --- a/src/nautilus-icon-view-container.c +++ b/src/nautilus-canvas-view-container.c @@ -23,7 +23,7 @@ */ #include <config.h> -#include "nautilus-icon-view-container.h" +#include "nautilus-canvas-view-container.h" #include <string.h> #include <glib/gi18n.h> @@ -37,20 +37,20 @@ #define ICON_TEXT_ATTRIBUTES_NUM_ITEMS 3 #define ICON_TEXT_ATTRIBUTES_DEFAULT_TOKENS "size,date_modified,type" -G_DEFINE_TYPE (NautilusIconViewContainer, nautilus_icon_view_container, NAUTILUS_TYPE_ICON_CONTAINER); +G_DEFINE_TYPE (NautilusCanvasViewContainer, nautilus_canvas_view_container, NAUTILUS_TYPE_CANVAS_CONTAINER); static GQuark attribute_none_q; -static NautilusIconView * -get_icon_view (NautilusIconContainer *container) +static NautilusCanvasView * +get_canvas_view (NautilusCanvasContainer *container) { /* Type unsafe comparison for performance */ - return ((NautilusIconViewContainer *)container)->view; + return ((NautilusCanvasViewContainer *)container)->view; } static NautilusIconInfo * -nautilus_icon_view_container_get_icon_images (NautilusIconContainer *container, - NautilusIconData *data, +nautilus_canvas_view_container_get_icon_images (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, int size, char **embedded_text, gboolean for_drag_accept, @@ -58,7 +58,7 @@ nautilus_icon_view_container_get_icon_images (NautilusIconContainer *container, gboolean *embedded_text_needs_loading, gboolean *has_window_open) { - NautilusIconView *icon_view; + NautilusCanvasView *canvas_view; NautilusFile *file; gboolean use_embedding; NautilusFileIconFlags flags; @@ -71,8 +71,8 @@ nautilus_icon_view_container_get_icon_images (NautilusIconContainer *container, file = (NautilusFile *) data; g_assert (NAUTILUS_IS_FILE (file)); - icon_view = get_icon_view (container); - g_return_val_if_fail (icon_view != NULL, NULL); + canvas_view = get_canvas_view (container); + g_return_val_if_fail (canvas_view != NULL, NULL); use_embedding = FALSE; if (embedded_text) { @@ -126,8 +126,8 @@ nautilus_icon_view_container_get_icon_images (NautilusIconContainer *container, } static char * -nautilus_icon_view_container_get_icon_description (NautilusIconContainer *container, - NautilusIconData *data) +nautilus_canvas_view_container_get_icon_description (NautilusCanvasContainer *container, + NautilusCanvasIconData *data) { NautilusFile *file; char *mime_type; @@ -147,8 +147,8 @@ nautilus_icon_view_container_get_icon_description (NautilusIconContainer *contai } static void -nautilus_icon_view_container_start_monitor_top_left (NautilusIconContainer *container, - NautilusIconData *data, +nautilus_canvas_view_container_start_monitor_top_left (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, gconstpointer client, gboolean large_text) { @@ -167,8 +167,8 @@ nautilus_icon_view_container_start_monitor_top_left (NautilusIconContainer *cont } static void -nautilus_icon_view_container_stop_monitor_top_left (NautilusIconContainer *container, - NautilusIconData *data, +nautilus_canvas_view_container_stop_monitor_top_left (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, gconstpointer client) { NautilusFile *file; @@ -181,8 +181,8 @@ nautilus_icon_view_container_stop_monitor_top_left (NautilusIconContainer *conta } static void -nautilus_icon_view_container_prioritize_thumbnailing (NautilusIconContainer *container, - NautilusIconData *data) +nautilus_canvas_view_container_prioritize_thumbnailing (NautilusCanvasContainer *container, + NautilusCanvasIconData *data) { NautilusFile *file; char *uri; @@ -225,7 +225,7 @@ update_auto_strv_as_quarks (GSettings *settings, * beneath icons. */ static GQuark * -nautilus_icon_view_container_get_icon_text_attributes_from_preferences (void) +nautilus_canvas_view_container_get_icon_text_attributes_from_preferences (void) { static GQuark *attributes = NULL; @@ -280,16 +280,16 @@ quarkv_length (GQuark *attributes) } /** - * nautilus_icon_view_get_icon_text_attribute_names: + * nautilus_canvas_view_get_icon_text_attribute_names: * * Get a list representing which text attributes should be displayed * beneath an icon. The result is dependent on zoom level and possibly * user configuration. Don't free the result. - * @view: NautilusIconView to query. + * @view: NautilusCanvasView to query. * **/ static GQuark * -nautilus_icon_view_container_get_icon_text_attribute_names (NautilusIconContainer *container, +nautilus_canvas_view_container_get_icon_text_attribute_names (NautilusCanvasContainer *container, int *len) { GQuark *attributes; @@ -305,9 +305,9 @@ nautilus_icon_view_container_get_icon_text_attribute_names (NautilusIconContaine 3 /* NAUTILUS_ZOOM_LEVEL_LARGEST */ }; - piece_count = pieces_by_level[nautilus_icon_container_get_zoom_level (container)]; + piece_count = pieces_by_level[nautilus_canvas_container_get_zoom_level (container)]; - attributes = nautilus_icon_view_container_get_icon_text_attributes_from_preferences (); + attributes = nautilus_canvas_view_container_get_icon_text_attributes_from_preferences (); *len = MIN (piece_count, quarkv_length (attributes)); @@ -318,8 +318,8 @@ nautilus_icon_view_container_get_icon_text_attribute_names (NautilusIconContaine * part below that is not editable. */ static void -nautilus_icon_view_container_get_icon_text (NautilusIconContainer *container, - NautilusIconData *data, +nautilus_canvas_view_container_get_icon_text (NautilusCanvasContainer *container, + NautilusCanvasIconData *data, char **editable_text, char **additional_text, gboolean include_invisible) @@ -327,7 +327,7 @@ nautilus_icon_view_container_get_icon_text (NautilusIconContainer *container, GQuark *attributes; char *text_array[4]; int i, j, num_attributes; - NautilusIconView *icon_view; + NautilusCanvasView *canvas_view; NautilusFile *file; gboolean use_additional; @@ -335,13 +335,13 @@ nautilus_icon_view_container_get_icon_text (NautilusIconContainer *container, g_assert (NAUTILUS_IS_FILE (file)); g_assert (editable_text != NULL); - icon_view = get_icon_view (container); - g_return_if_fail (icon_view != NULL); + canvas_view = get_canvas_view (container); + g_return_if_fail (canvas_view != NULL); use_additional = (additional_text != NULL); /* In the smallest zoom mode, no text is drawn. */ - if (nautilus_icon_container_get_zoom_level (container) == NAUTILUS_ZOOM_LEVEL_SMALLEST && + if (nautilus_canvas_container_get_zoom_level (container) == NAUTILUS_ZOOM_LEVEL_SMALLEST && !include_invisible) { *editable_text = NULL; } else { @@ -362,7 +362,7 @@ nautilus_icon_view_container_get_icon_text (NautilusIconContainer *container, } /* Find out what attributes go below each icon. */ - attributes = nautilus_icon_view_container_get_icon_text_attribute_names (container, + attributes = nautilus_canvas_view_container_get_icon_text_attribute_names (container, &num_attributes); /* Get the attributes. */ @@ -443,9 +443,9 @@ get_sort_category (NautilusFile *file) } static int -fm_desktop_icon_container_icons_compare (NautilusIconContainer *container, - NautilusIconData *data_a, - NautilusIconData *data_b) +fm_desktop_canvas_container_icons_compare (NautilusCanvasContainer *container, + NautilusCanvasIconData *data_a, + NautilusCanvasIconData *data_b) { NautilusFile *file_a; NautilusFile *file_b; @@ -455,7 +455,7 @@ fm_desktop_icon_container_icons_compare (NautilusIconContainer *container, file_a = (NautilusFile *) data_a; file_b = (NautilusFile *) data_b; - directory_view = NAUTILUS_VIEW (NAUTILUS_ICON_VIEW_CONTAINER (container)->view); + directory_view = NAUTILUS_VIEW (NAUTILUS_CANVAS_VIEW_CONTAINER (container)->view); g_return_val_if_fail (directory_view != NULL, 0); category_a = get_sort_category (file_a); @@ -476,30 +476,30 @@ fm_desktop_icon_container_icons_compare (NautilusIconContainer *container, } static int -nautilus_icon_view_container_compare_icons (NautilusIconContainer *container, - NautilusIconData *icon_a, - NautilusIconData *icon_b) +nautilus_canvas_view_container_compare_icons (NautilusCanvasContainer *container, + NautilusCanvasIconData *icon_a, + NautilusCanvasIconData *icon_b) { - NautilusIconView *icon_view; + NautilusCanvasView *canvas_view; - icon_view = get_icon_view (container); - g_return_val_if_fail (icon_view != NULL, 0); + canvas_view = get_canvas_view (container); + g_return_val_if_fail (canvas_view != NULL, 0); - if (NAUTILUS_ICON_VIEW_CONTAINER (container)->sort_for_desktop) { - return fm_desktop_icon_container_icons_compare + if (NAUTILUS_CANVAS_VIEW_CONTAINER (container)->sort_for_desktop) { + return fm_desktop_canvas_container_icons_compare (container, icon_a, icon_b); } /* Type unsafe comparisons for performance */ - return nautilus_icon_view_compare_files (icon_view, + return nautilus_canvas_view_compare_files (canvas_view, (NautilusFile *)icon_a, (NautilusFile *)icon_b); } static int -nautilus_icon_view_container_compare_icons_by_name (NautilusIconContainer *container, - NautilusIconData *icon_a, - NautilusIconData *icon_b) +nautilus_canvas_view_container_compare_icons_by_name (NautilusCanvasContainer *container, + NautilusCanvasIconData *icon_a, + NautilusCanvasIconData *icon_b) { return nautilus_file_compare_for_sort (NAUTILUS_FILE (icon_a), @@ -509,77 +509,77 @@ nautilus_icon_view_container_compare_icons_by_name (NautilusIconContainer *conta } static void -nautilus_icon_view_container_freeze_updates (NautilusIconContainer *container) +nautilus_canvas_view_container_freeze_updates (NautilusCanvasContainer *container) { - NautilusIconView *icon_view; - icon_view = get_icon_view (container); - g_return_if_fail (icon_view != NULL); - nautilus_view_freeze_updates (NAUTILUS_VIEW (icon_view)); + NautilusCanvasView *canvas_view; + canvas_view = get_canvas_view (container); + g_return_if_fail (canvas_view != NULL); + nautilus_view_freeze_updates (NAUTILUS_VIEW (canvas_view)); } static void -nautilus_icon_view_container_unfreeze_updates (NautilusIconContainer *container) +nautilus_canvas_view_container_unfreeze_updates (NautilusCanvasContainer *container) { - NautilusIconView *icon_view; - icon_view = get_icon_view (container); - g_return_if_fail (icon_view != NULL); - nautilus_view_unfreeze_updates (NAUTILUS_VIEW (icon_view)); + NautilusCanvasView *canvas_view; + canvas_view = get_canvas_view (container); + g_return_if_fail (canvas_view != NULL); + nautilus_view_unfreeze_updates (NAUTILUS_VIEW (canvas_view)); } static void -nautilus_icon_view_container_class_init (NautilusIconViewContainerClass *klass) +nautilus_canvas_view_container_class_init (NautilusCanvasViewContainerClass *klass) { - NautilusIconContainerClass *ic_class; + NautilusCanvasContainerClass *ic_class; ic_class = &klass->parent_class; attribute_none_q = g_quark_from_static_string ("none"); - ic_class->get_icon_text = nautilus_icon_view_container_get_icon_text; - ic_class->get_icon_images = nautilus_icon_view_container_get_icon_images; - ic_class->get_icon_description = nautilus_icon_view_container_get_icon_description; - ic_class->start_monitor_top_left = nautilus_icon_view_container_start_monitor_top_left; - ic_class->stop_monitor_top_left = nautilus_icon_view_container_stop_monitor_top_left; - ic_class->prioritize_thumbnailing = nautilus_icon_view_container_prioritize_thumbnailing; - - ic_class->compare_icons = nautilus_icon_view_container_compare_icons; - ic_class->compare_icons_by_name = nautilus_icon_view_container_compare_icons_by_name; - ic_class->freeze_updates = nautilus_icon_view_container_freeze_updates; - ic_class->unfreeze_updates = nautilus_icon_view_container_unfreeze_updates; + ic_class->get_icon_text = nautilus_canvas_view_container_get_icon_text; + ic_class->get_icon_images = nautilus_canvas_view_container_get_icon_images; + ic_class->get_icon_description = nautilus_canvas_view_container_get_icon_description; + ic_class->start_monitor_top_left = nautilus_canvas_view_container_start_monitor_top_left; + ic_class->stop_monitor_top_left = nautilus_canvas_view_container_stop_monitor_top_left; + ic_class->prioritize_thumbnailing = nautilus_canvas_view_container_prioritize_thumbnailing; + + ic_class->compare_icons = nautilus_canvas_view_container_compare_icons; + ic_class->compare_icons_by_name = nautilus_canvas_view_container_compare_icons_by_name; + ic_class->freeze_updates = nautilus_canvas_view_container_freeze_updates; + ic_class->unfreeze_updates = nautilus_canvas_view_container_unfreeze_updates; } static void -nautilus_icon_view_container_init (NautilusIconViewContainer *icon_container) +nautilus_canvas_view_container_init (NautilusCanvasViewContainer *canvas_container) { - gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (icon_container)), + gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (canvas_container)), GTK_STYLE_CLASS_VIEW); } -NautilusIconContainer * -nautilus_icon_view_container_construct (NautilusIconViewContainer *icon_container, NautilusIconView *view) +NautilusCanvasContainer * +nautilus_canvas_view_container_construct (NautilusCanvasViewContainer *canvas_container, NautilusCanvasView *view) { AtkObject *atk_obj; - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), NULL); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), NULL); - icon_container->view = view; - atk_obj = gtk_widget_get_accessible (GTK_WIDGET (icon_container)); - atk_object_set_name (atk_obj, _("Icon View")); + canvas_container->view = view; + atk_obj = gtk_widget_get_accessible (GTK_WIDGET (canvas_container)); + atk_object_set_name (atk_obj, _("Canvas View")); - return NAUTILUS_ICON_CONTAINER (icon_container); + return NAUTILUS_CANVAS_CONTAINER (canvas_container); } -NautilusIconContainer * -nautilus_icon_view_container_new (NautilusIconView *view) +NautilusCanvasContainer * +nautilus_canvas_view_container_new (NautilusCanvasView *view) { - return nautilus_icon_view_container_construct - (g_object_new (NAUTILUS_TYPE_ICON_VIEW_CONTAINER, NULL), + return nautilus_canvas_view_container_construct + (g_object_new (NAUTILUS_TYPE_CANVAS_VIEW_CONTAINER, NULL), view); } void -nautilus_icon_view_container_set_sort_desktop (NautilusIconViewContainer *container, +nautilus_canvas_view_container_set_sort_desktop (NautilusCanvasViewContainer *container, gboolean desktop) { container->sort_for_desktop = desktop; diff --git a/src/nautilus-canvas-view-container.h b/src/nautilus-canvas-view-container.h new file mode 100644 index 000000000..6677d74b3 --- /dev/null +++ b/src/nautilus-canvas-view-container.h @@ -0,0 +1,67 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* fm-icon-container.h - the container widget for file manager icons + + Copyright (C) 2002 Sun Microsystems, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Author: Michael Meeks <michael@ximian.com> +*/ + +#ifndef NAUTILUS_CANVAS_VIEW_CONTAINER_H +#define NAUTILUS_CANVAS_VIEW_CONTAINER_H + +#include "nautilus-canvas-view.h" + +#include <libnautilus-private/nautilus-canvas-container.h> + +typedef struct NautilusCanvasViewContainer NautilusCanvasViewContainer; +typedef struct NautilusCanvasViewContainerClass NautilusCanvasViewContainerClass; + +#define NAUTILUS_TYPE_CANVAS_VIEW_CONTAINER nautilus_canvas_view_container_get_type() +#define NAUTILUS_CANVAS_VIEW_CONTAINER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_CANVAS_VIEW_CONTAINER, NautilusCanvasViewContainer)) +#define NAUTILUS_CANVAS_VIEW_CONTAINER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CANVAS_VIEW_CONTAINER, NautilusCanvasViewContainerClass)) +#define NAUTILUS_IS_CANVAS_VIEW_CONTAINER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_CANVAS_VIEW_CONTAINER)) +#define NAUTILUS_IS_CANVAS_VIEW_CONTAINER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_CANVAS_VIEW_CONTAINER)) +#define NAUTILUS_CANVAS_VIEW_CONTAINER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_CANVAS_VIEW_CONTAINER, NautilusCanvasViewContainerClass)) + +typedef struct NautilusCanvasViewContainerDetails NautilusCanvasViewContainerDetails; + +struct NautilusCanvasViewContainer { + NautilusCanvasContainer parent; + + NautilusCanvasView *view; + gboolean sort_for_desktop; +}; + +struct NautilusCanvasViewContainerClass { + NautilusCanvasContainerClass parent_class; +}; + +GType nautilus_canvas_view_container_get_type (void); +NautilusCanvasContainer *nautilus_canvas_view_container_construct (NautilusCanvasViewContainer *canvas_container, + NautilusCanvasView *view); +NautilusCanvasContainer *nautilus_canvas_view_container_new (NautilusCanvasView *view); +void nautilus_canvas_view_container_set_sort_desktop (NautilusCanvasViewContainer *container, + gboolean desktop); + +#endif /* NAUTILUS_CANVAS_VIEW_CONTAINER_H */ diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c new file mode 100644 index 000000000..e4ac264e7 --- /dev/null +++ b/src/nautilus-canvas-view.c @@ -0,0 +1,2475 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* fm-canvas-view.c - implementation of canvas view of directory. + + Copyright (C) 2000, 2001 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: John Sullivan <sullivan@eazel.com> +*/ + +#include <config.h> + +#include "nautilus-canvas-view.h" + +#include "nautilus-actions.h" +#include "nautilus-canvas-view-container.h" +#include "nautilus-desktop-canvas-view.h" +#include "nautilus-error-reporting.h" +#include "nautilus-view-dnd.h" +#include "nautilus-view-factory.h" + +#include <stdlib.h> +#include <eel/eel-vfs-extensions.h> +#include <errno.h> +#include <fcntl.h> +#include <gtk/gtk.h> +#include <glib/gi18n.h> +#include <gio/gio.h> +#include <libnautilus-private/nautilus-clipboard-monitor.h> +#include <libnautilus-private/nautilus-directory.h> +#include <libnautilus-private/nautilus-dnd.h> +#include <libnautilus-private/nautilus-file-dnd.h> +#include <libnautilus-private/nautilus-file-utilities.h> +#include <libnautilus-private/nautilus-ui-utilities.h> +#include <libnautilus-private/nautilus-global-preferences.h> +#include <libnautilus-private/nautilus-canvas-container.h> +#include <libnautilus-private/nautilus-canvas-dnd.h> +#include <libnautilus-private/nautilus-link.h> +#include <libnautilus-private/nautilus-metadata.h> +#include <libnautilus-private/nautilus-clipboard.h> +#include <libnautilus-private/nautilus-desktop-icon-file.h> + +#define DEBUG_FLAG NAUTILUS_DEBUG_CANVAS_VIEW +#include <libnautilus-private/nautilus-debug.h> + +#include <locale.h> +#include <signal.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> + +#define POPUP_PATH_CANVAS_APPEARANCE "/selection/Canvas Appearance Items" + +enum +{ + PROP_SUPPORTS_AUTO_LAYOUT = 1, + PROP_SUPPORTS_SCALING, + PROP_SUPPORTS_KEEP_ALIGNED, + NUM_PROPERTIES +}; + +static GParamSpec *properties[NUM_PROPERTIES] = { NULL, }; + +typedef struct { + const NautilusFileSortType sort_type; + const char *metadata_text; + const char *action; + const char *menu_label; + const char *menu_hint; +} SortCriterion; + +typedef enum { + MENU_ITEM_TYPE_STANDARD, + MENU_ITEM_TYPE_CHECK, + MENU_ITEM_TYPE_RADIO, + MENU_ITEM_TYPE_TREE +} MenuItemType; + +struct NautilusCanvasViewDetails +{ + GList *icons_not_positioned; + + guint react_to_canvas_change_idle_id; + + const SortCriterion *sort; + gboolean sort_reversed; + + GtkActionGroup *canvas_action_group; + guint canvas_merge_id; + + gboolean filter_by_screen; + int num_screens; + + gulong clipboard_handler_id; + + GtkWidget *canvas_container; + + gboolean supports_auto_layout; + gboolean supports_scaling; + gboolean supports_keep_aligned; +}; + + +/* Note that the first item in this list is the default sort, + * and that the items show up in the menu in the order they + * appear in this list. + */ +static const SortCriterion sort_criteria[] = { + { + NAUTILUS_FILE_SORT_BY_DISPLAY_NAME, + "name", + "Sort by Name", + N_("by _Name"), + N_("Keep icons sorted by name in rows") + }, + { + NAUTILUS_FILE_SORT_BY_SIZE, + "size", + "Sort by Size", + N_("by _Size"), + N_("Keep icons sorted by size in rows") + }, + { + NAUTILUS_FILE_SORT_BY_TYPE, + "type", + "Sort by Type", + N_("by _Type"), + N_("Keep icons sorted by type in rows") + }, + { + NAUTILUS_FILE_SORT_BY_MTIME, + "modification date", + "Sort by Modification Date", + N_("by Modification _Date"), + N_("Keep icons sorted by modification date in rows") + }, + { + NAUTILUS_FILE_SORT_BY_TRASHED_TIME, + "trashed", + "Sort by Trash Time", + N_("by T_rash Time"), + N_("Keep icons sorted by trash time in rows") + } +}; + +static void nautilus_canvas_view_set_directory_sort_by (NautilusCanvasView *canvas_view, + NautilusFile *file, + const char *sort_by); +static void nautilus_canvas_view_set_zoom_level (NautilusCanvasView *view, + NautilusZoomLevel new_level, + gboolean always_emit); +static void nautilus_canvas_view_update_click_mode (NautilusCanvasView *canvas_view); +static gboolean nautilus_canvas_view_supports_scaling (NautilusCanvasView *canvas_view); +static void nautilus_canvas_view_reveal_selection (NautilusView *view); +static const SortCriterion *get_sort_criterion_by_sort_type (NautilusFileSortType sort_type); +static void set_sort_criterion_by_sort_type (NautilusCanvasView *canvas_view, + NautilusFileSortType sort_type); +static gboolean set_sort_reversed (NautilusCanvasView *canvas_view, + gboolean new_value, + gboolean set_metadata); +static void switch_to_manual_layout (NautilusCanvasView *view); +static void update_layout_menus (NautilusCanvasView *view); +static NautilusFileSortType get_default_sort_order (NautilusFile *file, + gboolean *reversed); +static void nautilus_canvas_view_clear (NautilusView *view); + +G_DEFINE_TYPE (NautilusCanvasView, nautilus_canvas_view, NAUTILUS_TYPE_VIEW); + +static void +nautilus_canvas_view_destroy (GtkWidget *object) +{ + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (object); + + nautilus_canvas_view_clear (NAUTILUS_VIEW (object)); + + if (canvas_view->details->react_to_canvas_change_idle_id != 0) { + g_source_remove (canvas_view->details->react_to_canvas_change_idle_id); + canvas_view->details->react_to_canvas_change_idle_id = 0; + } + + if (canvas_view->details->clipboard_handler_id != 0) { + g_signal_handler_disconnect (nautilus_clipboard_monitor_get (), + canvas_view->details->clipboard_handler_id); + canvas_view->details->clipboard_handler_id = 0; + } + + if (canvas_view->details->icons_not_positioned) { + nautilus_file_list_free (canvas_view->details->icons_not_positioned); + canvas_view->details->icons_not_positioned = NULL; + } + + GTK_WIDGET_CLASS (nautilus_canvas_view_parent_class)->destroy (object); +} + +static NautilusCanvasContainer * +get_canvas_container (NautilusCanvasView *canvas_view) +{ + return NAUTILUS_CANVAS_CONTAINER (canvas_view->details->canvas_container); +} + +NautilusCanvasContainer * +nautilus_canvas_view_get_canvas_container (NautilusCanvasView *canvas_view) +{ + return get_canvas_container (canvas_view); +} + +static gboolean +nautilus_canvas_view_supports_manual_layout (NautilusCanvasView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), FALSE); + + return TRUE; +} + +static gboolean +get_stored_icon_position_callback (NautilusCanvasContainer *container, + NautilusFile *file, + NautilusCanvasPosition *position, + NautilusCanvasView *canvas_view) +{ + char *position_string, *scale_string; + gboolean position_good; + char c; + + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); + g_assert (NAUTILUS_IS_FILE (file)); + g_assert (position != NULL); + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + + if (!nautilus_canvas_view_supports_manual_layout (canvas_view)) { + return FALSE; + } + + /* Get the current position of this canvas from the metadata. */ + position_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_ICON_POSITION, ""); + position_good = sscanf + (position_string, " %d , %d %c", + &position->x, &position->y, &c) == 2; + g_free (position_string); + + /* If it is the desktop directory, maybe the gnome-libs metadata has information about it */ + + /* Disable scaling if not on the desktop */ + if (nautilus_canvas_view_supports_scaling (canvas_view)) { + /* Get the scale of the canvas from the metadata. */ + scale_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_ICON_SCALE, "1"); + position->scale = g_ascii_strtod (scale_string, NULL); + if (errno != 0) { + position->scale = 1.0; + } + + g_free (scale_string); + } else { + position->scale = 1.0; + } + + return position_good; +} + +static void +real_set_sort_criterion (NautilusCanvasView *canvas_view, + const SortCriterion *sort, + gboolean clear, + gboolean set_metadata) +{ + NautilusFile *file; + + file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view)); + + if (clear) { + nautilus_file_set_metadata (file, + NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY, NULL, NULL); + nautilus_file_set_metadata (file, + NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_REVERSED, NULL, NULL); + canvas_view->details->sort = + get_sort_criterion_by_sort_type (get_default_sort_order + (file, &canvas_view->details->sort_reversed)); + } else if (set_metadata) { + /* Store the new sort setting. */ + nautilus_canvas_view_set_directory_sort_by (canvas_view, + file, + sort->metadata_text); + } + + /* Update the layout menus to match the new sort setting. */ + update_layout_menus (canvas_view); +} + +static void +set_sort_criterion (NautilusCanvasView *canvas_view, + const SortCriterion *sort, + gboolean set_metadata) +{ + if (sort == NULL || + canvas_view->details->sort == sort) { + return; + } + + canvas_view->details->sort = sort; + + real_set_sort_criterion (canvas_view, sort, FALSE, set_metadata); +} + +static void +clear_sort_criterion (NautilusCanvasView *canvas_view) +{ + real_set_sort_criterion (canvas_view, NULL, TRUE, TRUE); +} + +static void +action_stretch_callback (GtkAction *action, + gpointer callback_data) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (callback_data)); + + nautilus_canvas_container_show_stretch_handles + (get_canvas_container (NAUTILUS_CANVAS_VIEW (callback_data))); +} + +static void +action_unstretch_callback (GtkAction *action, + gpointer callback_data) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (callback_data)); + + nautilus_canvas_container_unstretch + (get_canvas_container (NAUTILUS_CANVAS_VIEW (callback_data))); +} + +static void +nautilus_canvas_view_clean_up (NautilusCanvasView *canvas_view) +{ + NautilusCanvasContainer *canvas_container; + gboolean saved_sort_reversed; + + canvas_container = get_canvas_container (canvas_view); + + /* Hardwire Clean Up to always be by name, in forward order */ + saved_sort_reversed = canvas_view->details->sort_reversed; + + set_sort_reversed (canvas_view, FALSE, FALSE); + set_sort_criterion (canvas_view, &sort_criteria[0], FALSE); + + nautilus_canvas_container_sort (canvas_container); + nautilus_canvas_container_freeze_icon_positions (canvas_container); + + set_sort_reversed (canvas_view, saved_sort_reversed, FALSE); +} + +static void +action_clean_up_callback (GtkAction *action, gpointer callback_data) +{ + nautilus_canvas_view_clean_up (NAUTILUS_CANVAS_VIEW (callback_data)); +} + +static gboolean +nautilus_canvas_view_using_auto_layout (NautilusCanvasView *canvas_view) +{ + return nautilus_canvas_container_is_auto_layout + (get_canvas_container (canvas_view)); +} + +static void +action_sort_radio_callback (GtkAction *action, + GtkRadioAction *current, + NautilusCanvasView *view) +{ + NautilusFileSortType sort_type; + + sort_type = gtk_radio_action_get_current_value (current); + + /* Note that id might be a toggle item. + * Ignore non-sort ids so that they don't cause sorting. + */ + if (sort_type == NAUTILUS_FILE_SORT_NONE) { + switch_to_manual_layout (view); + } else { + set_sort_criterion_by_sort_type (view, sort_type); + } +} + +static void +list_covers (NautilusCanvasIconData *data, gpointer callback_data) +{ + GSList **file_list; + + file_list = callback_data; + + *file_list = g_slist_prepend (*file_list, data); +} + +static void +unref_cover (NautilusCanvasIconData *data, gpointer callback_data) +{ + nautilus_file_unref (NAUTILUS_FILE (data)); +} + +static void +nautilus_canvas_view_clear (NautilusView *view) +{ + NautilusCanvasContainer *canvas_container; + GSList *file_list; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view)); + + canvas_container = get_canvas_container (NAUTILUS_CANVAS_VIEW (view)); + if (!canvas_container) + return; + + /* Clear away the existing icons. */ + file_list = NULL; + nautilus_canvas_container_for_each (canvas_container, list_covers, &file_list); + nautilus_canvas_container_clear (canvas_container); + g_slist_foreach (file_list, (GFunc)unref_cover, NULL); + g_slist_free (file_list); +} + +static gboolean +should_show_file_on_screen (NautilusView *view, NautilusFile *file) +{ + char *screen_string; + int screen_num; + NautilusCanvasView *canvas_view; + GdkScreen *screen; + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + + if (!nautilus_view_should_show_file (view, file)) { + return FALSE; + } + + /* Get the screen for this canvas from the metadata. */ + screen_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_SCREEN, "0"); + screen_num = atoi (screen_string); + g_free (screen_string); + screen = gtk_widget_get_screen (GTK_WIDGET (view)); + + if (screen_num != gdk_screen_get_number (screen) && + (screen_num < canvas_view->details->num_screens || + gdk_screen_get_number (screen) > 0)) { + return FALSE; + } + + return TRUE; +} + +static void +nautilus_canvas_view_remove_file (NautilusView *view, NautilusFile *file, NautilusDirectory *directory) +{ + NautilusCanvasView *canvas_view; + + /* This used to assert that 'directory == nautilus_view_get_model (view)', but that + * resulted in a lot of crash reports (bug #352592). I don't see how that trace happens. + * It seems that somehow we get a files_changed event sent to the view from a directory + * that isn't the model, but the code disables the monitor and signal callback handlers when + * changing directories. Maybe we can get some more information when this happens. + * Further discussion in bug #368178. + */ + if (directory != nautilus_view_get_model (view)) { + char *file_uri, *dir_uri, *model_uri; + file_uri = nautilus_file_get_uri (file); + dir_uri = nautilus_directory_get_uri (directory); + model_uri = nautilus_directory_get_uri (nautilus_view_get_model (view)); + g_warning ("nautilus_canvas_view_remove_file() - directory not canvas view model, shouldn't happen.\n" + "file: %p:%s, dir: %p:%s, model: %p:%s, view loading: %d\n" + "If you see this, please add this info to http://bugzilla.gnome.org/show_bug.cgi?id=368178", + file, file_uri, directory, dir_uri, nautilus_view_get_model (view), model_uri, nautilus_view_get_loading (view)); + g_free (file_uri); + g_free (dir_uri); + g_free (model_uri); + } + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + + if (nautilus_canvas_container_remove (get_canvas_container (canvas_view), + NAUTILUS_CANVAS_ICON_DATA (file))) { + nautilus_file_unref (file); + } +} + +static void +nautilus_canvas_view_add_file (NautilusView *view, NautilusFile *file, NautilusDirectory *directory) +{ + NautilusCanvasView *canvas_view; + NautilusCanvasContainer *canvas_container; + + g_assert (directory == nautilus_view_get_model (view)); + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + canvas_container = get_canvas_container (canvas_view); + + if (canvas_view->details->filter_by_screen && + !should_show_file_on_screen (view, file)) { + return; + } + + /* Reset scroll region for the first canvas added when loading a directory. */ + if (nautilus_view_get_loading (view) && nautilus_canvas_container_is_empty (canvas_container)) { + nautilus_canvas_container_reset_scroll_region (canvas_container); + } + + if (nautilus_canvas_container_add (canvas_container, + NAUTILUS_CANVAS_ICON_DATA (file))) { + nautilus_file_ref (file); + } +} + +static void +nautilus_canvas_view_file_changed (NautilusView *view, NautilusFile *file, NautilusDirectory *directory) +{ + NautilusCanvasView *canvas_view; + + g_assert (directory == nautilus_view_get_model (view)); + + g_return_if_fail (view != NULL); + canvas_view = NAUTILUS_CANVAS_VIEW (view); + + if (!canvas_view->details->filter_by_screen) { + nautilus_canvas_container_request_update + (get_canvas_container (canvas_view), + NAUTILUS_CANVAS_ICON_DATA (file)); + return; + } + + if (!should_show_file_on_screen (view, file)) { + nautilus_canvas_view_remove_file (view, file, directory); + } else { + + nautilus_canvas_container_request_update + (get_canvas_container (canvas_view), + NAUTILUS_CANVAS_ICON_DATA (file)); + } +} + +static gboolean +nautilus_canvas_view_supports_auto_layout (NautilusCanvasView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), FALSE); + + return view->details->supports_auto_layout; +} + +static gboolean +nautilus_canvas_view_supports_scaling (NautilusCanvasView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), FALSE); + + return view->details->supports_scaling; +} + +static gboolean +nautilus_canvas_view_supports_keep_aligned (NautilusCanvasView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), FALSE); + + return view->details->supports_keep_aligned; +} + +static void +update_layout_menus (NautilusCanvasView *view) +{ + gboolean is_auto_layout; + GtkAction *action; + const char *action_name; + NautilusFile *file; + + if (view->details->canvas_action_group == NULL) { + return; + } + + is_auto_layout = nautilus_canvas_view_using_auto_layout (view); + file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (view)); + + if (nautilus_canvas_view_supports_auto_layout (view)) { + /* Mark sort criterion. */ + action_name = is_auto_layout ? view->details->sort->action : NAUTILUS_ACTION_MANUAL_LAYOUT; + action = gtk_action_group_get_action (view->details->canvas_action_group, + action_name); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); + + action = gtk_action_group_get_action (view->details->canvas_action_group, + NAUTILUS_ACTION_REVERSED_ORDER); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + view->details->sort_reversed); + gtk_action_set_sensitive (action, is_auto_layout); + + action = gtk_action_group_get_action (view->details->canvas_action_group, + NAUTILUS_ACTION_SORT_TRASH_TIME); + + if (file != NULL && nautilus_file_is_in_trash (file)) { + gtk_action_set_visible (action, TRUE); + } else { + gtk_action_set_visible (action, FALSE); + } + } + + action = gtk_action_group_get_action (view->details->canvas_action_group, + NAUTILUS_ACTION_MANUAL_LAYOUT); + gtk_action_set_visible (action, + nautilus_canvas_view_supports_manual_layout (view)); + + /* Clean Up is only relevant for manual layout */ + action = gtk_action_group_get_action (view->details->canvas_action_group, + NAUTILUS_ACTION_CLEAN_UP); + gtk_action_set_sensitive (action, !is_auto_layout); + + if (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view)) { + gtk_action_set_label (action, _("_Organize Desktop by Name")); + } + + action = gtk_action_group_get_action (view->details->canvas_action_group, + NAUTILUS_ACTION_KEEP_ALIGNED); + gtk_action_set_visible (action, + nautilus_canvas_view_supports_keep_aligned (view)); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), + nautilus_canvas_container_is_keep_aligned (get_canvas_container (view))); + gtk_action_set_sensitive (action, !is_auto_layout); +} + + +static char * +nautilus_canvas_view_get_directory_sort_by (NautilusCanvasView *canvas_view, + NautilusFile *file) +{ + const SortCriterion *default_sort_criterion; + + if (!nautilus_canvas_view_supports_auto_layout (canvas_view)) { + return g_strdup ("name"); + } + + default_sort_criterion = get_sort_criterion_by_sort_type (get_default_sort_order (file, NULL)); + g_return_val_if_fail (default_sort_criterion != NULL, NULL); + + return nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY, + default_sort_criterion->metadata_text); +} + +static NautilusFileSortType +get_default_sort_order (NautilusFile *file, gboolean *reversed) +{ + NautilusFileSortType retval, default_sort_order; + gboolean default_sort_in_reverse_order; + + default_sort_order = g_settings_get_enum (nautilus_preferences, + NAUTILUS_PREFERENCES_DEFAULT_SORT_ORDER); + default_sort_in_reverse_order = g_settings_get_boolean (nautilus_preferences, + NAUTILUS_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER); + + retval = nautilus_file_get_default_sort_type (file, reversed); + + if (retval == NAUTILUS_FILE_SORT_NONE) { + + if (reversed != NULL) { + *reversed = default_sort_in_reverse_order; + } + + retval = CLAMP (default_sort_order, NAUTILUS_FILE_SORT_BY_DISPLAY_NAME, + NAUTILUS_FILE_SORT_BY_MTIME); + } + + return retval; +} + +static void +nautilus_canvas_view_set_directory_sort_by (NautilusCanvasView *canvas_view, + NautilusFile *file, + const char *sort_by) +{ + const SortCriterion *default_sort_criterion; + + if (!nautilus_canvas_view_supports_auto_layout (canvas_view)) { + return; + } + + default_sort_criterion = get_sort_criterion_by_sort_type (get_default_sort_order (file, NULL)); + g_return_if_fail (default_sort_criterion != NULL); + + nautilus_file_set_metadata + (file, NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY, + default_sort_criterion->metadata_text, + sort_by); +} + +static gboolean +nautilus_canvas_view_get_directory_sort_reversed (NautilusCanvasView *canvas_view, + NautilusFile *file) +{ + gboolean reversed; + + if (!nautilus_canvas_view_supports_auto_layout (canvas_view)) { + return FALSE; + } + + get_default_sort_order (file, &reversed); + return nautilus_file_get_boolean_metadata + (file, + NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_REVERSED, + reversed); +} + +static void +nautilus_canvas_view_set_directory_sort_reversed (NautilusCanvasView *canvas_view, + NautilusFile *file, + gboolean sort_reversed) +{ + gboolean reversed; + + if (!nautilus_canvas_view_supports_auto_layout (canvas_view)) { + return; + } + + get_default_sort_order (file, &reversed); + nautilus_file_set_boolean_metadata + (file, + NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_REVERSED, + reversed, sort_reversed); +} + +static gboolean +get_default_directory_keep_aligned (void) +{ + return TRUE; +} + +static gboolean +nautilus_canvas_view_get_directory_keep_aligned (NautilusCanvasView *canvas_view, + NautilusFile *file) +{ + if (!nautilus_canvas_view_supports_keep_aligned (canvas_view)) { + return FALSE; + } + + return nautilus_file_get_boolean_metadata + (file, + NAUTILUS_METADATA_KEY_ICON_VIEW_KEEP_ALIGNED, + get_default_directory_keep_aligned ()); +} + +static void +nautilus_canvas_view_set_directory_keep_aligned (NautilusCanvasView *canvas_view, + NautilusFile *file, + gboolean keep_aligned) +{ + if (!nautilus_canvas_view_supports_keep_aligned (canvas_view)) { + return; + } + + nautilus_file_set_boolean_metadata + (file, NAUTILUS_METADATA_KEY_ICON_VIEW_KEEP_ALIGNED, + get_default_directory_keep_aligned (), + keep_aligned); +} + +static gboolean +nautilus_canvas_view_get_directory_auto_layout (NautilusCanvasView *canvas_view, + NautilusFile *file) +{ + if (!nautilus_canvas_view_supports_auto_layout (canvas_view)) { + return FALSE; + } + + if (!nautilus_canvas_view_supports_manual_layout (canvas_view)) { + return TRUE; + } + + return nautilus_file_get_boolean_metadata + (file, NAUTILUS_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT, TRUE); +} + +static void +nautilus_canvas_view_set_directory_auto_layout (NautilusCanvasView *canvas_view, + NautilusFile *file, + gboolean auto_layout) +{ + if (!nautilus_canvas_view_supports_auto_layout (canvas_view) || + !nautilus_canvas_view_supports_manual_layout (canvas_view)) { + return; + } + + nautilus_file_set_boolean_metadata + (file, NAUTILUS_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT, + TRUE, + auto_layout); +} + +static gboolean +set_sort_reversed (NautilusCanvasView *canvas_view, + gboolean new_value, + gboolean set_metadata) +{ + if (canvas_view->details->sort_reversed == new_value) { + return FALSE; + } + canvas_view->details->sort_reversed = new_value; + + if (set_metadata) { + /* Store the new sort setting. */ + nautilus_canvas_view_set_directory_sort_reversed (canvas_view, nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view)), new_value); + } + + /* Update the layout menus to match the new sort-order setting. */ + update_layout_menus (canvas_view); + + return TRUE; +} + +static const SortCriterion * +get_sort_criterion_by_metadata_text (const char *metadata_text) +{ + guint i; + + /* Figure out what the new sort setting should be. */ + for (i = 0; i < G_N_ELEMENTS (sort_criteria); i++) { + if (strcmp (sort_criteria[i].metadata_text, metadata_text) == 0) { + return &sort_criteria[i]; + } + } + return NULL; +} + +static const SortCriterion * +get_sort_criterion_by_sort_type (NautilusFileSortType sort_type) +{ + guint i; + + /* Figure out what the new sort setting should be. */ + for (i = 0; i < G_N_ELEMENTS (sort_criteria); i++) { + if (sort_type == sort_criteria[i].sort_type) { + return &sort_criteria[i]; + } + } + + return &sort_criteria[0]; +} + +#define DEFAULT_ZOOM_LEVEL(canvas_view) default_zoom_level + +static NautilusZoomLevel +get_default_zoom_level (NautilusCanvasView *canvas_view) +{ + NautilusZoomLevel default_zoom_level; + + default_zoom_level = g_settings_get_enum (nautilus_icon_view_preferences, + NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL); + + return CLAMP (DEFAULT_ZOOM_LEVEL(canvas_view), NAUTILUS_ZOOM_LEVEL_SMALLEST, NAUTILUS_ZOOM_LEVEL_LARGEST); +} + +static void +nautilus_canvas_view_begin_loading (NautilusView *view) +{ + NautilusCanvasView *canvas_view; + GtkWidget *canvas_container; + NautilusFile *file; + int level; + char *sort_name, *uri; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view)); + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + file = nautilus_view_get_directory_as_file (view); + uri = nautilus_file_get_uri (file); + canvas_container = GTK_WIDGET (get_canvas_container (canvas_view)); + + nautilus_canvas_container_begin_loading (NAUTILUS_CANVAS_CONTAINER (canvas_container)); + + nautilus_canvas_container_set_allow_moves (NAUTILUS_CANVAS_CONTAINER (canvas_container), + !eel_uri_is_search (uri)); + + g_free (uri); + + /* Set up the zoom level from the metadata. */ + if (nautilus_view_supports_zooming (NAUTILUS_VIEW (canvas_view))) { + level = nautilus_file_get_integer_metadata (file, + NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL, + get_default_zoom_level (canvas_view)); + nautilus_canvas_view_set_zoom_level (canvas_view, level, TRUE); + } + + /* Set the sort mode. + * It's OK not to resort the icons because the + * container doesn't have any icons at this point. + */ + sort_name = nautilus_canvas_view_get_directory_sort_by (canvas_view, file); + set_sort_criterion (canvas_view, get_sort_criterion_by_metadata_text (sort_name), FALSE); + g_free (sort_name); + + /* Set the sort direction from the metadata. */ + set_sort_reversed (canvas_view, nautilus_canvas_view_get_directory_sort_reversed (canvas_view, file), FALSE); + + nautilus_canvas_container_set_keep_aligned + (get_canvas_container (canvas_view), + nautilus_canvas_view_get_directory_keep_aligned (canvas_view, file)); + + /* We must set auto-layout last, because it invokes the layout_changed + * callback, which works incorrectly if the other layout criteria are + * not already set up properly (see bug 6500, e.g.) + */ + nautilus_canvas_container_set_auto_layout + (get_canvas_container (canvas_view), + nautilus_canvas_view_get_directory_auto_layout (canvas_view, file)); + + /* e.g. keep aligned may have changed */ + update_layout_menus (canvas_view); +} + +static void +canvas_view_notify_clipboard_info (NautilusClipboardMonitor *monitor, + NautilusClipboardInfo *info, + NautilusCanvasView *canvas_view) +{ + GList *icon_data; + + icon_data = NULL; + if (info && info->cut) { + icon_data = info->files; + } + + nautilus_canvas_container_set_highlighted_for_clipboard ( + get_canvas_container (canvas_view), icon_data); +} + +static void +nautilus_canvas_view_end_loading (NautilusView *view, + gboolean all_files_seen) +{ + NautilusCanvasView *canvas_view; + GtkWidget *canvas_container; + NautilusClipboardMonitor *monitor; + NautilusClipboardInfo *info; + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + + canvas_container = GTK_WIDGET (get_canvas_container (canvas_view)); + nautilus_canvas_container_end_loading (NAUTILUS_CANVAS_CONTAINER (canvas_container), all_files_seen); + + monitor = nautilus_clipboard_monitor_get (); + info = nautilus_clipboard_monitor_get_clipboard_info (monitor); + + canvas_view_notify_clipboard_info (monitor, info, canvas_view); +} + +static NautilusZoomLevel +nautilus_canvas_view_get_zoom_level (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), NAUTILUS_ZOOM_LEVEL_STANDARD); + + return nautilus_canvas_container_get_zoom_level (get_canvas_container (NAUTILUS_CANVAS_VIEW (view))); +} + +static void +nautilus_canvas_view_set_zoom_level (NautilusCanvasView *view, + NautilusZoomLevel new_level, + gboolean always_emit) +{ + NautilusCanvasContainer *canvas_container; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view)); + g_return_if_fail (new_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST && + new_level <= NAUTILUS_ZOOM_LEVEL_LARGEST); + + canvas_container = get_canvas_container (view); + if (nautilus_canvas_container_get_zoom_level (canvas_container) == new_level) { + if (always_emit) { + g_signal_emit_by_name (view, "zoom_level_changed"); + } + return; + } + + nautilus_file_set_integer_metadata + (nautilus_view_get_directory_as_file (NAUTILUS_VIEW (view)), + NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL, + get_default_zoom_level (view), + new_level); + + nautilus_canvas_container_set_zoom_level (canvas_container, new_level); + + g_signal_emit_by_name (view, "zoom_level_changed"); + + if (nautilus_view_get_active (NAUTILUS_VIEW (view))) { + nautilus_view_update_menus (NAUTILUS_VIEW (view)); + } +} + +static void +nautilus_canvas_view_bump_zoom_level (NautilusView *view, int zoom_increment) +{ + NautilusZoomLevel new_level; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view)); + + new_level = nautilus_canvas_view_get_zoom_level (view) + zoom_increment; + + if (new_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST && + new_level <= NAUTILUS_ZOOM_LEVEL_LARGEST) { + nautilus_view_zoom_to_level (view, new_level); + } +} + +static void +nautilus_canvas_view_zoom_to_level (NautilusView *view, + NautilusZoomLevel zoom_level) +{ + NautilusCanvasView *canvas_view; + + g_assert (NAUTILUS_IS_CANVAS_VIEW (view)); + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + nautilus_canvas_view_set_zoom_level (canvas_view, zoom_level, FALSE); +} + +static void +nautilus_canvas_view_restore_default_zoom_level (NautilusView *view) +{ + NautilusCanvasView *canvas_view; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view)); + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + nautilus_view_zoom_to_level + (view, get_default_zoom_level (canvas_view)); +} + +static gboolean +nautilus_canvas_view_can_zoom_in (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), FALSE); + + return nautilus_canvas_view_get_zoom_level (view) + < NAUTILUS_ZOOM_LEVEL_LARGEST; +} + +static gboolean +nautilus_canvas_view_can_zoom_out (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), FALSE); + + return nautilus_canvas_view_get_zoom_level (view) + > NAUTILUS_ZOOM_LEVEL_SMALLEST; +} + +static gboolean +nautilus_canvas_view_is_empty (NautilusView *view) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (view)); + + return nautilus_canvas_container_is_empty + (get_canvas_container (NAUTILUS_CANVAS_VIEW (view))); +} + +static GList * +nautilus_canvas_view_get_selection (NautilusView *view) +{ + GList *list; + + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), NULL); + + list = nautilus_canvas_container_get_selection + (get_canvas_container (NAUTILUS_CANVAS_VIEW (view))); + nautilus_file_list_ref (list); + return list; +} + +static void +count_item (NautilusCanvasIconData *icon_data, + gpointer callback_data) +{ + guint *count; + + count = callback_data; + (*count)++; +} + +static guint +nautilus_canvas_view_get_item_count (NautilusView *view) +{ + guint count; + + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), 0); + + count = 0; + + nautilus_canvas_container_for_each + (get_canvas_container (NAUTILUS_CANVAS_VIEW (view)), + count_item, &count); + + return count; +} + +static void +set_sort_criterion_by_sort_type (NautilusCanvasView *canvas_view, + NautilusFileSortType sort_type) +{ + const SortCriterion *sort; + + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + + sort = get_sort_criterion_by_sort_type (sort_type); + g_return_if_fail (sort != NULL); + + if (sort == canvas_view->details->sort + && nautilus_canvas_view_using_auto_layout (canvas_view)) { + return; + } + + set_sort_criterion (canvas_view, sort, TRUE); + nautilus_canvas_container_sort (get_canvas_container (canvas_view)); + nautilus_canvas_view_reveal_selection (NAUTILUS_VIEW (canvas_view)); +} + + +static void +action_reversed_order_callback (GtkAction *action, + gpointer user_data) +{ + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (user_data); + + if (set_sort_reversed (canvas_view, + gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)), + TRUE)) { + nautilus_canvas_container_sort (get_canvas_container (canvas_view)); + nautilus_canvas_view_reveal_selection (NAUTILUS_VIEW (canvas_view)); + } +} + +static void +action_keep_aligned_callback (GtkAction *action, + gpointer user_data) +{ + NautilusCanvasView *canvas_view; + NautilusFile *file; + gboolean keep_aligned; + + canvas_view = NAUTILUS_CANVAS_VIEW (user_data); + + keep_aligned = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); + + file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view)); + nautilus_canvas_view_set_directory_keep_aligned (canvas_view, + file, + keep_aligned); + + nautilus_canvas_container_set_keep_aligned (get_canvas_container (canvas_view), + keep_aligned); +} + +static void +switch_to_manual_layout (NautilusCanvasView *canvas_view) +{ + if (!nautilus_canvas_view_using_auto_layout (canvas_view)) { + return; + } + + canvas_view->details->sort = &sort_criteria[0]; + + nautilus_canvas_container_set_auto_layout + (get_canvas_container (canvas_view), FALSE); +} + +static void +layout_changed_callback (NautilusCanvasContainer *container, + NautilusCanvasView *canvas_view) +{ + NautilusFile *file; + + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + g_assert (container == get_canvas_container (canvas_view)); + + file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view)); + + if (file != NULL) { + nautilus_canvas_view_set_directory_auto_layout + (canvas_view, + file, + nautilus_canvas_view_using_auto_layout (canvas_view)); + } + + update_layout_menus (canvas_view); +} + +static gboolean +nautilus_canvas_view_can_rename_file (NautilusView *view, NautilusFile *file) +{ + if (!(nautilus_canvas_view_get_zoom_level (view) > NAUTILUS_ZOOM_LEVEL_SMALLEST)) { + return FALSE; + } + + return NAUTILUS_VIEW_CLASS(nautilus_canvas_view_parent_class)->can_rename_file (view, file); +} + +static void +nautilus_canvas_view_start_renaming_file (NautilusView *view, + NautilusFile *file, + gboolean select_all) +{ + /* call parent class to make sure the right canvas is selected */ + NAUTILUS_VIEW_CLASS(nautilus_canvas_view_parent_class)->start_renaming_file (view, file, select_all); + + /* start renaming */ + nautilus_canvas_container_start_renaming_selected_item + (get_canvas_container (NAUTILUS_CANVAS_VIEW (view)), select_all); +} + +static const GtkActionEntry canvas_view_entries[] = { + /* name, stock id, label */ { "Arrange Items", NULL, N_("Arran_ge Items") }, + /* name, stock id */ { "Stretch", NULL, + /* label, accelerator */ N_("Resize Canvas..."), NULL, + /* tooltip */ N_("Make the selected canvas resizable"), + G_CALLBACK (action_stretch_callback) }, + /* name, stock id */ { "Unstretch", NULL, + /* label, accelerator */ N_("Restore Icons' Original Si_zes"), NULL, + /* tooltip */ N_("Restore each selected canvas to its original size"), + G_CALLBACK (action_unstretch_callback) }, + /* name, stock id */ { "Clean Up", NULL, + /* label, accelerator */ N_("_Organize by Name"), NULL, + /* tooltip */ N_("Reposition icons to better fit in the window and avoid overlapping"), + G_CALLBACK (action_clean_up_callback) }, +}; + +static const GtkToggleActionEntry canvas_view_toggle_entries[] = { + /* name, stock id */ { "Reversed Order", NULL, + /* label, accelerator */ N_("Re_versed Order"), NULL, + /* tooltip */ N_("Display icons in the opposite order"), + G_CALLBACK (action_reversed_order_callback), + 0 }, + /* name, stock id */ { "Keep Aligned", NULL, + /* label, accelerator */ N_("_Keep Aligned"), NULL, + /* tooltip */ N_("Keep icons lined up on a grid"), + G_CALLBACK (action_keep_aligned_callback), + 0 }, +}; + +static const GtkRadioActionEntry arrange_radio_entries[] = { + { "Manual Layout", NULL, + N_("_Manually"), NULL, + N_("Leave icons wherever they are dropped"), + NAUTILUS_FILE_SORT_NONE }, + { "Sort by Name", NULL, + N_("By _Name"), NULL, + N_("Keep icons sorted by name in rows"), + NAUTILUS_FILE_SORT_BY_DISPLAY_NAME }, + { "Sort by Size", NULL, + N_("By _Size"), NULL, + N_("Keep icons sorted by size in rows"), + NAUTILUS_FILE_SORT_BY_SIZE }, + { "Sort by Type", NULL, + N_("By _Type"), NULL, + N_("Keep icons sorted by type in rows"), + NAUTILUS_FILE_SORT_BY_TYPE }, + { "Sort by Modification Date", NULL, + N_("By Modification _Date"), NULL, + N_("Keep icons sorted by modification date in rows"), + NAUTILUS_FILE_SORT_BY_MTIME }, + { "Sort by Trash Time", NULL, + N_("By T_rash Time"), NULL, + N_("Keep icons sorted by trash time in rows"), + NAUTILUS_FILE_SORT_BY_TRASHED_TIME }, +}; + +static void +nautilus_canvas_view_merge_menus (NautilusView *view) +{ + NautilusCanvasView *canvas_view; + GtkUIManager *ui_manager; + GtkActionGroup *action_group; + GtkAction *action; + + g_assert (NAUTILUS_IS_CANVAS_VIEW (view)); + + NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->merge_menus (view); + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + + ui_manager = nautilus_view_get_ui_manager (NAUTILUS_VIEW (canvas_view)); + + action_group = gtk_action_group_new ("CanvasViewActions"); + gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); + canvas_view->details->canvas_action_group = action_group; + gtk_action_group_add_actions (action_group, + canvas_view_entries, G_N_ELEMENTS (canvas_view_entries), + canvas_view); + gtk_action_group_add_toggle_actions (action_group, + canvas_view_toggle_entries, G_N_ELEMENTS (canvas_view_toggle_entries), + canvas_view); + gtk_action_group_add_radio_actions (action_group, + arrange_radio_entries, + G_N_ELEMENTS (arrange_radio_entries), + -1, + G_CALLBACK (action_sort_radio_callback), + canvas_view); + + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + g_object_unref (action_group); /* owned by ui manager */ + + canvas_view->details->canvas_merge_id = + gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-canvas-view-ui.xml", NULL); + + /* Do one-time state-setting here; context-dependent state-setting + * is done in update_menus. + */ + if (!nautilus_canvas_view_supports_auto_layout (canvas_view)) { + action = gtk_action_group_get_action (action_group, + NAUTILUS_ACTION_ARRANGE_ITEMS); + gtk_action_set_visible (action, FALSE); + } + + if (nautilus_canvas_view_supports_scaling (canvas_view)) { + gtk_ui_manager_add_ui (ui_manager, + canvas_view->details->canvas_merge_id, + POPUP_PATH_CANVAS_APPEARANCE, + NAUTILUS_ACTION_STRETCH, + NAUTILUS_ACTION_STRETCH, + GTK_UI_MANAGER_MENUITEM, + FALSE); + gtk_ui_manager_add_ui (ui_manager, + canvas_view->details->canvas_merge_id, + POPUP_PATH_CANVAS_APPEARANCE, + NAUTILUS_ACTION_UNSTRETCH, + NAUTILUS_ACTION_UNSTRETCH, + GTK_UI_MANAGER_MENUITEM, + FALSE); + } + + update_layout_menus (canvas_view); +} + +static void +nautilus_canvas_view_unmerge_menus (NautilusView *view) +{ + NautilusCanvasView *canvas_view; + GtkUIManager *ui_manager; + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + + NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->unmerge_menus (view); + + ui_manager = nautilus_view_get_ui_manager (view); + if (ui_manager != NULL) { + nautilus_ui_unmerge_ui (ui_manager, + &canvas_view->details->canvas_merge_id, + &canvas_view->details->canvas_action_group); + } +} + +static void +nautilus_canvas_view_update_menus (NautilusView *view) +{ + NautilusCanvasView *canvas_view; + int selection_count; + GtkAction *action; + NautilusCanvasContainer *canvas_container; + gboolean editable; + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + + NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->update_menus(view); + + selection_count = nautilus_view_get_selection_count (view); + canvas_container = get_canvas_container (canvas_view); + + action = gtk_action_group_get_action (canvas_view->details->canvas_action_group, + NAUTILUS_ACTION_STRETCH); + gtk_action_set_sensitive (action, + selection_count == 1 + && canvas_container != NULL + && !nautilus_canvas_container_has_stretch_handles (canvas_container)); + + gtk_action_set_visible (action, + nautilus_canvas_view_supports_scaling (canvas_view)); + + action = gtk_action_group_get_action (canvas_view->details->canvas_action_group, + NAUTILUS_ACTION_UNSTRETCH); + g_object_set (action, "label", + (selection_count > 1) + ? _("Restore Icons' Original Si_zes") + : _("Restore Canvas's Original Si_ze"), + NULL); + gtk_action_set_sensitive (action, + canvas_container != NULL + && nautilus_canvas_container_is_stretched (canvas_container)); + + gtk_action_set_visible (action, + nautilus_canvas_view_supports_scaling (canvas_view)); + + editable = nautilus_view_is_editable (view); + action = gtk_action_group_get_action (canvas_view->details->canvas_action_group, + NAUTILUS_ACTION_MANUAL_LAYOUT); + gtk_action_set_sensitive (action, editable); +} + +static void +nautilus_canvas_view_reset_to_defaults (NautilusView *view) +{ + NautilusCanvasContainer *canvas_container; + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + canvas_container = get_canvas_container (canvas_view); + + clear_sort_criterion (canvas_view); + nautilus_canvas_container_set_keep_aligned + (canvas_container, get_default_directory_keep_aligned ()); + + nautilus_canvas_container_sort (canvas_container); + + update_layout_menus (canvas_view); + + nautilus_canvas_view_restore_default_zoom_level (view); +} + +static void +nautilus_canvas_view_select_all (NautilusView *view) +{ + NautilusCanvasContainer *canvas_container; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view)); + + canvas_container = get_canvas_container (NAUTILUS_CANVAS_VIEW (view)); + nautilus_canvas_container_select_all (canvas_container); +} + +static void +nautilus_canvas_view_reveal_selection (NautilusView *view) +{ + GList *selection; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view)); + + selection = nautilus_view_get_selection (view); + + /* Make sure at least one of the selected items is scrolled into view */ + if (selection != NULL) { + nautilus_canvas_container_reveal + (get_canvas_container (NAUTILUS_CANVAS_VIEW (view)), + selection->data); + } + + nautilus_file_list_free (selection); +} + +static GArray * +nautilus_canvas_view_get_selected_icon_locations (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), NULL); + + return nautilus_canvas_container_get_selected_icon_locations + (get_canvas_container (NAUTILUS_CANVAS_VIEW (view))); +} + + +static void +nautilus_canvas_view_set_selection (NautilusView *view, GList *selection) +{ + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view)); + + nautilus_canvas_container_set_selection + (get_canvas_container (NAUTILUS_CANVAS_VIEW (view)), selection); +} + +static void +nautilus_canvas_view_invert_selection (NautilusView *view) +{ + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view)); + + nautilus_canvas_container_invert_selection + (get_canvas_container (NAUTILUS_CANVAS_VIEW (view))); +} + +static gboolean +nautilus_canvas_view_using_manual_layout (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), FALSE); + + return !nautilus_canvas_view_using_auto_layout (NAUTILUS_CANVAS_VIEW (view)); +} + +static void +nautilus_canvas_view_widget_to_file_operation_position (NautilusView *view, + GdkPoint *position) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (view)); + + nautilus_canvas_container_widget_to_file_operation_position + (get_canvas_container (NAUTILUS_CANVAS_VIEW (view)), position); +} + +static void +canvas_container_activate_callback (NautilusCanvasContainer *container, + GList *file_list, + NautilusCanvasView *canvas_view) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + g_assert (container == get_canvas_container (canvas_view)); + + nautilus_view_activate_files (NAUTILUS_VIEW (canvas_view), + file_list, + 0, TRUE); +} + +static void +canvas_container_activate_previewer_callback (NautilusCanvasContainer *container, + GList *file_list, + GArray *locations, + NautilusCanvasView *canvas_view) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + g_assert (container == get_canvas_container (canvas_view)); + + nautilus_view_preview_files (NAUTILUS_VIEW (canvas_view), + file_list, locations); +} + +/* this is called in one of these cases: + * - we activate with enter holding shift + * - we activate with space holding shift + * - we double click an canvas holding shift + * - we middle click an canvas + * + * If we don't open in new windows by default, the behavior should be + * - middle click, shift + activate -> open in new tab + * - shift + double click -> open in new window + * + * If we open in new windows by default, the behaviour should be + * - middle click, or shift + activate, or shift + double-click -> close parent + */ +static void +canvas_container_activate_alternate_callback (NautilusCanvasContainer *container, + GList *file_list, + NautilusCanvasView *canvas_view) +{ + GdkEvent *event; + GdkEventButton *button_event; + GdkEventKey *key_event; + gboolean open_in_tab, open_in_window, close_behind; + NautilusWindowOpenFlags flags; + + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + g_assert (container == get_canvas_container (canvas_view)); + + flags = 0; + event = gtk_get_current_event (); + open_in_tab = FALSE; + open_in_window = FALSE; + close_behind = FALSE; + + if (g_settings_get_boolean (nautilus_preferences, + NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) { + if (event->type == GDK_BUTTON_PRESS || + event->type == GDK_BUTTON_RELEASE || + event->type == GDK_2BUTTON_PRESS || + event->type == GDK_3BUTTON_PRESS) { + button_event = (GdkEventButton *) event; + open_in_window = ((button_event->state & GDK_SHIFT_MASK) != 0); + open_in_tab = !open_in_window; + } else if (event->type == GDK_KEY_PRESS || + event->type == GDK_KEY_RELEASE) { + key_event = (GdkEventKey *) event; + open_in_tab = ((key_event->state & GDK_SHIFT_MASK) != 0); + } + } else { + close_behind = TRUE; + } + + if (open_in_tab) { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB; + } + + if (open_in_window) { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; + } + + if (close_behind) { + flags |= NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND; + } + + DEBUG ("Activate alternate, open in tab %d, close behind %d, new window %d\n", + open_in_tab, close_behind, open_in_window); + + nautilus_view_activate_files (NAUTILUS_VIEW (canvas_view), + file_list, + flags, + TRUE); +} + +static void +band_select_started_callback (NautilusCanvasContainer *container, + NautilusCanvasView *canvas_view) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + g_assert (container == get_canvas_container (canvas_view)); + + nautilus_view_start_batching_selection_changes (NAUTILUS_VIEW (canvas_view)); +} + +static void +band_select_ended_callback (NautilusCanvasContainer *container, + NautilusCanvasView *canvas_view) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + g_assert (container == get_canvas_container (canvas_view)); + + nautilus_view_stop_batching_selection_changes (NAUTILUS_VIEW (canvas_view)); +} + +int +nautilus_canvas_view_compare_files (NautilusCanvasView *canvas_view, + NautilusFile *a, + NautilusFile *b) +{ + return nautilus_file_compare_for_sort + (a, b, canvas_view->details->sort->sort_type, + /* Use type-unsafe cast for performance */ + nautilus_view_should_sort_directories_first ((NautilusView *)canvas_view), + canvas_view->details->sort_reversed); +} + +static int +compare_files (NautilusView *canvas_view, + NautilusFile *a, + NautilusFile *b) +{ + return nautilus_canvas_view_compare_files ((NautilusCanvasView *)canvas_view, a, b); +} + + +void +nautilus_canvas_view_filter_by_screen (NautilusCanvasView *canvas_view, + gboolean filter) +{ + canvas_view->details->filter_by_screen = filter; + canvas_view->details->num_screens = gdk_display_get_n_screens (gtk_widget_get_display (GTK_WIDGET (canvas_view))); +} + +static void +nautilus_canvas_view_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen) +{ + NautilusView *view; + GList *files, *l; + NautilusFile *file; + NautilusDirectory *directory; + NautilusCanvasContainer *canvas_container; + + if (GTK_WIDGET_CLASS (nautilus_canvas_view_parent_class)->screen_changed) { + GTK_WIDGET_CLASS (nautilus_canvas_view_parent_class)->screen_changed (widget, previous_screen); + } + + view = NAUTILUS_VIEW (widget); + if (NAUTILUS_CANVAS_VIEW (view)->details->filter_by_screen) { + canvas_container = get_canvas_container (NAUTILUS_CANVAS_VIEW (view)); + + directory = nautilus_view_get_model (view); + files = nautilus_directory_get_file_list (directory); + + for (l = files; l != NULL; l = l->next) { + file = l->data; + + if (!should_show_file_on_screen (view, file)) { + nautilus_canvas_view_remove_file (view, file, directory); + } else { + if (nautilus_canvas_container_add (canvas_container, + NAUTILUS_CANVAS_ICON_DATA (file))) { + nautilus_file_ref (file); + } + } + } + + nautilus_file_list_unref (files); + g_list_free (files); + } +} + +static void +selection_changed_callback (NautilusCanvasContainer *container, + NautilusCanvasView *canvas_view) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + g_assert (container == get_canvas_container (canvas_view)); + + nautilus_view_notify_selection_changed (NAUTILUS_VIEW (canvas_view)); +} + +static void +canvas_container_context_click_selection_callback (NautilusCanvasContainer *container, + GdkEventButton *event, + NautilusCanvasView *canvas_view) +{ + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + + nautilus_view_pop_up_selection_context_menu + (NAUTILUS_VIEW (canvas_view), event); +} + +static void +canvas_container_context_click_background_callback (NautilusCanvasContainer *container, + GdkEventButton *event, + NautilusCanvasView *canvas_view) +{ + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + + nautilus_view_pop_up_background_context_menu + (NAUTILUS_VIEW (canvas_view), event); +} + +static gboolean +nautilus_canvas_view_react_to_canvas_change_idle_callback (gpointer data) +{ + NautilusCanvasView *canvas_view; + + g_assert (NAUTILUS_IS_CANVAS_VIEW (data)); + + canvas_view = NAUTILUS_CANVAS_VIEW (data); + canvas_view->details->react_to_canvas_change_idle_id = 0; + + /* Rebuild the menus since some of them (e.g. Restore Stretched Icons) + * may be different now. + */ + nautilus_view_update_menus (NAUTILUS_VIEW (canvas_view)); + + /* Don't call this again (unless rescheduled) */ + return FALSE; +} + +static void +icon_position_changed_callback (NautilusCanvasContainer *container, + NautilusFile *file, + const NautilusCanvasPosition *position, + NautilusCanvasView *canvas_view) +{ + char *position_string; + char scale_string[G_ASCII_DTOSTR_BUF_SIZE]; + + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + g_assert (container == get_canvas_container (canvas_view)); + g_assert (NAUTILUS_IS_FILE (file)); + + /* Schedule updating menus for the next idle. Doing it directly here + * noticeably slows down canvas stretching. The other work here to + * store the canvas position and scale does not seem to noticeably + * slow down canvas stretching. It would be trickier to move to an + * idle call, because we'd have to keep track of potentially multiple + * sets of file/geometry info. + */ + if (nautilus_view_get_active (NAUTILUS_VIEW (canvas_view)) && + canvas_view->details->react_to_canvas_change_idle_id == 0) { + canvas_view->details->react_to_canvas_change_idle_id + = g_idle_add (nautilus_canvas_view_react_to_canvas_change_idle_callback, + canvas_view); + } + + /* Store the new position of the canvas in the metadata. */ + if (!nautilus_canvas_view_using_auto_layout (canvas_view)) { + position_string = g_strdup_printf + ("%d,%d", position->x, position->y); + nautilus_file_set_metadata + (file, NAUTILUS_METADATA_KEY_ICON_POSITION, + NULL, position_string); + g_free (position_string); + } + + + g_ascii_dtostr (scale_string, sizeof (scale_string), position->scale); + nautilus_file_set_metadata + (file, NAUTILUS_METADATA_KEY_ICON_SCALE, + "1.0", scale_string); +} + +/* Attempt to change the filename to the new text. Notify user if operation fails. */ +static void +icon_rename_ended_cb (NautilusCanvasContainer *container, + NautilusFile *file, + const char *new_name, + NautilusCanvasView *canvas_view) +{ + g_assert (NAUTILUS_IS_FILE (file)); + + nautilus_view_set_is_renaming (NAUTILUS_VIEW (canvas_view), FALSE); + + /* Don't allow a rename with an empty string. Revert to original + * without notifying the user. + */ + if ((new_name == NULL) || (new_name[0] == '\0')) { + return; + } + + nautilus_rename_file (file, new_name, NULL, NULL); +} + +static void +icon_rename_started_cb (NautilusCanvasContainer *container, + GtkWidget *widget, + gpointer callback_data) +{ + NautilusView *directory_view; + + directory_view = NAUTILUS_VIEW (callback_data); + nautilus_clipboard_set_up_editable + (GTK_EDITABLE (widget), + nautilus_view_get_ui_manager (directory_view), + FALSE); +} + +static char * +get_icon_uri_callback (NautilusCanvasContainer *container, + NautilusFile *file, + NautilusCanvasView *canvas_view) +{ + g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container)); + g_assert (NAUTILUS_IS_FILE (file)); + g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view)); + + return nautilus_file_get_uri (file); +} + +static char * +get_icon_drop_target_uri_callback (NautilusCanvasContainer *container, + NautilusFile *file, + NautilusCanvasView *canvas_view) +{ + g_return_val_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (container), NULL); + g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL); + g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (canvas_view), NULL); + + return nautilus_file_get_drop_target_uri (file); +} + +/* Preferences changed callbacks */ +static void +nautilus_canvas_view_click_policy_changed (NautilusView *directory_view) +{ + g_assert (NAUTILUS_IS_CANVAS_VIEW (directory_view)); + + nautilus_canvas_view_update_click_mode (NAUTILUS_CANVAS_VIEW (directory_view)); +} + +static void +image_display_policy_changed_callback (gpointer callback_data) +{ + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (callback_data); + + nautilus_canvas_container_request_update_all (get_canvas_container (canvas_view)); +} + +static void +text_attribute_names_changed_callback (gpointer callback_data) +{ + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (callback_data); + + nautilus_canvas_container_request_update_all (get_canvas_container (canvas_view)); +} + +static void +default_sort_order_changed_callback (gpointer callback_data) +{ + NautilusCanvasView *canvas_view; + NautilusFile *file; + char *sort_name; + NautilusCanvasContainer *canvas_container; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (callback_data)); + + canvas_view = NAUTILUS_CANVAS_VIEW (callback_data); + + file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view)); + sort_name = nautilus_canvas_view_get_directory_sort_by (canvas_view, file); + set_sort_criterion (canvas_view, get_sort_criterion_by_metadata_text (sort_name), FALSE); + g_free (sort_name); + + canvas_container = get_canvas_container (canvas_view); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (canvas_container)); + + nautilus_canvas_container_request_update_all (canvas_container); +} + +static void +default_sort_in_reverse_order_changed_callback (gpointer callback_data) +{ + NautilusCanvasView *canvas_view; + NautilusFile *file; + NautilusCanvasContainer *canvas_container; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (callback_data)); + + canvas_view = NAUTILUS_CANVAS_VIEW (callback_data); + + file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view)); + set_sort_reversed (canvas_view, nautilus_canvas_view_get_directory_sort_reversed (canvas_view, file), FALSE); + canvas_container = get_canvas_container (canvas_view); + g_return_if_fail (NAUTILUS_IS_CANVAS_CONTAINER (canvas_container)); + + nautilus_canvas_container_request_update_all (canvas_container); +} + +static void +default_zoom_level_changed_callback (gpointer callback_data) +{ + NautilusCanvasView *canvas_view; + NautilusFile *file; + int level; + + g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (callback_data)); + + canvas_view = NAUTILUS_CANVAS_VIEW (callback_data); + + if (nautilus_view_supports_zooming (NAUTILUS_VIEW (canvas_view))) { + file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (canvas_view)); + + level = nautilus_file_get_integer_metadata (file, + NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL, + get_default_zoom_level (canvas_view)); + + nautilus_view_zoom_to_level (NAUTILUS_VIEW (canvas_view), level); + } +} + +static void +nautilus_canvas_view_sort_directories_first_changed (NautilusView *directory_view) +{ + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (directory_view); + + if (nautilus_canvas_view_using_auto_layout (canvas_view)) { + nautilus_canvas_container_sort + (get_canvas_container (canvas_view)); + } +} + +static gboolean +canvas_view_can_accept_item (NautilusCanvasContainer *container, + NautilusFile *target_item, + const char *item_uri, + NautilusView *view) +{ + return nautilus_drag_can_accept_item (target_item, item_uri); +} + +static char * +canvas_view_get_container_uri (NautilusCanvasContainer *container, + NautilusView *view) +{ + return nautilus_view_get_uri (view); +} + +static void +canvas_view_move_copy_items (NautilusCanvasContainer *container, + const GList *item_uris, + GArray *relative_item_points, + const char *target_dir, + int copy_action, + int x, int y, + NautilusView *view) +{ + nautilus_clipboard_clear_if_colliding_uris (GTK_WIDGET (view), + item_uris, + nautilus_view_get_copied_files_atom (view)); + nautilus_view_move_copy_items (view, item_uris, relative_item_points, target_dir, + copy_action, x, y); +} + +static void +nautilus_canvas_view_update_click_mode (NautilusCanvasView *canvas_view) +{ + NautilusCanvasContainer *canvas_container; + int click_mode; + + canvas_container = get_canvas_container (canvas_view); + g_assert (canvas_container != NULL); + + click_mode = g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_CLICK_POLICY); + + nautilus_canvas_container_set_single_click_mode (canvas_container, + click_mode == NAUTILUS_CLICK_POLICY_SINGLE); +} + +static gboolean +get_stored_layout_timestamp (NautilusCanvasContainer *container, + NautilusCanvasIconData *icon_data, + time_t *timestamp, + NautilusCanvasView *view) +{ + NautilusFile *file; + NautilusDirectory *directory; + + if (icon_data == NULL) { + directory = nautilus_view_get_model (NAUTILUS_VIEW (view)); + if (directory == NULL) { + return FALSE; + } + + file = nautilus_directory_get_corresponding_file (directory); + *timestamp = nautilus_file_get_time_metadata (file, + NAUTILUS_METADATA_KEY_ICON_VIEW_LAYOUT_TIMESTAMP); + nautilus_file_unref (file); + } else { + *timestamp = nautilus_file_get_time_metadata (NAUTILUS_FILE (icon_data), + NAUTILUS_METADATA_KEY_ICON_POSITION_TIMESTAMP); + } + + return TRUE; +} + +static gboolean +store_layout_timestamp (NautilusCanvasContainer *container, + NautilusCanvasIconData *icon_data, + const time_t *timestamp, + NautilusCanvasView *view) +{ + NautilusFile *file; + NautilusDirectory *directory; + + if (icon_data == NULL) { + directory = nautilus_view_get_model (NAUTILUS_VIEW (view)); + if (directory == NULL) { + return FALSE; + } + + file = nautilus_directory_get_corresponding_file (directory); + nautilus_file_set_time_metadata (file, + NAUTILUS_METADATA_KEY_ICON_VIEW_LAYOUT_TIMESTAMP, + (time_t) *timestamp); + nautilus_file_unref (file); + } else { + nautilus_file_set_time_metadata (NAUTILUS_FILE (icon_data), + NAUTILUS_METADATA_KEY_ICON_POSITION_TIMESTAMP, + (time_t) *timestamp); + } + + return TRUE; +} + +static gboolean +focus_in_event_callback (GtkWidget *widget, GdkEventFocus *event, gpointer user_data) +{ + NautilusWindowSlot *slot; + NautilusCanvasView *canvas_view = NAUTILUS_CANVAS_VIEW (user_data); + + /* make the corresponding slot (and the window that contains it) active */ + slot = nautilus_view_get_nautilus_window_slot (NAUTILUS_VIEW (canvas_view)); + nautilus_window_slot_make_hosting_window_active (slot); + + return FALSE; +} + +static NautilusCanvasContainer * +create_canvas_container (NautilusCanvasView *canvas_view) +{ + NautilusCanvasContainer *canvas_container; + + canvas_container = nautilus_canvas_view_container_new (canvas_view); + canvas_view->details->canvas_container = GTK_WIDGET (canvas_container); + g_object_add_weak_pointer (G_OBJECT (canvas_container), + (gpointer *) &canvas_view->details->canvas_container); + + gtk_widget_set_can_focus (GTK_WIDGET (canvas_container), TRUE); + + g_signal_connect_object (canvas_container, "focus_in_event", + G_CALLBACK (focus_in_event_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "activate", + G_CALLBACK (canvas_container_activate_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "activate_alternate", + G_CALLBACK (canvas_container_activate_alternate_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "activate_previewer", + G_CALLBACK (canvas_container_activate_previewer_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "band_select_started", + G_CALLBACK (band_select_started_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "band_select_ended", + G_CALLBACK (band_select_ended_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "context_click_selection", + G_CALLBACK (canvas_container_context_click_selection_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "context_click_background", + G_CALLBACK (canvas_container_context_click_background_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "icon_position_changed", + G_CALLBACK (icon_position_changed_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "selection_changed", + G_CALLBACK (selection_changed_callback), canvas_view, 0); + /* FIXME: many of these should move into fm-canvas-container as virtual methods */ + g_signal_connect_object (canvas_container, "get_icon_uri", + G_CALLBACK (get_icon_uri_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "get_icon_drop_target_uri", + G_CALLBACK (get_icon_drop_target_uri_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "move_copy_items", + G_CALLBACK (canvas_view_move_copy_items), canvas_view, 0); + g_signal_connect_object (canvas_container, "get_container_uri", + G_CALLBACK (canvas_view_get_container_uri), canvas_view, 0); + g_signal_connect_object (canvas_container, "can_accept_item", + G_CALLBACK (canvas_view_can_accept_item), canvas_view, 0); + g_signal_connect_object (canvas_container, "get_stored_icon_position", + G_CALLBACK (get_stored_icon_position_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "layout_changed", + G_CALLBACK (layout_changed_callback), canvas_view, 0); + g_signal_connect_object (canvas_container, "icon_rename_started", + G_CALLBACK (icon_rename_started_cb), canvas_view, 0); + g_signal_connect_object (canvas_container, "icon_rename_ended", + G_CALLBACK (icon_rename_ended_cb), canvas_view, 0); + g_signal_connect_object (canvas_container, "icon_stretch_started", + G_CALLBACK (nautilus_view_update_menus), canvas_view, + G_CONNECT_SWAPPED); + g_signal_connect_object (canvas_container, "icon_stretch_ended", + G_CALLBACK (nautilus_view_update_menus), canvas_view, + G_CONNECT_SWAPPED); + + g_signal_connect_object (canvas_container, "get_stored_layout_timestamp", + G_CALLBACK (get_stored_layout_timestamp), canvas_view, 0); + g_signal_connect_object (canvas_container, "store_layout_timestamp", + G_CALLBACK (store_layout_timestamp), canvas_view, 0); + + gtk_container_add (GTK_CONTAINER (canvas_view), + GTK_WIDGET (canvas_container)); + + nautilus_canvas_view_update_click_mode (canvas_view); + + gtk_widget_show (GTK_WIDGET (canvas_container)); + + return canvas_container; +} + +/* Handles an URL received from Mozilla */ +static void +canvas_view_handle_netscape_url (NautilusCanvasContainer *container, const char *encoded_url, + const char *target_uri, + GdkDragAction action, int x, int y, NautilusCanvasView *view) +{ + nautilus_view_handle_netscape_url_drop (NAUTILUS_VIEW (view), + encoded_url, target_uri, action, x, y); +} + +static void +canvas_view_handle_uri_list (NautilusCanvasContainer *container, const char *item_uris, + const char *target_uri, + GdkDragAction action, int x, int y, NautilusCanvasView *view) +{ + nautilus_view_handle_uri_list_drop (NAUTILUS_VIEW (view), + item_uris, target_uri, action, x, y); +} + +static void +canvas_view_handle_text (NautilusCanvasContainer *container, const char *text, + const char *target_uri, + GdkDragAction action, int x, int y, NautilusCanvasView *view) +{ + nautilus_view_handle_text_drop (NAUTILUS_VIEW (view), + text, target_uri, action, x, y); +} + +static void +canvas_view_handle_raw (NautilusCanvasContainer *container, const char *raw_data, + int length, const char *target_uri, const char *direct_save_uri, + GdkDragAction action, int x, int y, NautilusCanvasView *view) +{ + nautilus_view_handle_raw_drop (NAUTILUS_VIEW (view), + raw_data, length, target_uri, direct_save_uri, action, x, y); +} + +static char * +canvas_view_get_first_visible_file (NautilusView *view) +{ + NautilusFile *file; + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + + file = NAUTILUS_FILE (nautilus_canvas_container_get_first_visible_icon (get_canvas_container (canvas_view))); + + if (file) { + return nautilus_file_get_uri (file); + } + + return NULL; +} + +static void +canvas_view_scroll_to_file (NautilusView *view, + const char *uri) +{ + NautilusFile *file; + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (view); + + if (uri != NULL) { + /* Only if existing, since we don't want to add the file to + the directory if it has been removed since then */ + file = nautilus_file_get_existing_by_uri (uri); + if (file != NULL) { + nautilus_canvas_container_scroll_to_canvas (get_canvas_container (canvas_view), + NAUTILUS_CANVAS_ICON_DATA (file)); + nautilus_file_unref (file); + } + } +} + +static const char * +nautilus_canvas_view_get_id (NautilusView *view) +{ + return NAUTILUS_CANVAS_VIEW_ID; +} + +static void +nautilus_canvas_view_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (object); + + switch (prop_id) { + case PROP_SUPPORTS_AUTO_LAYOUT: + canvas_view->details->supports_auto_layout = g_value_get_boolean (value); + break; + case PROP_SUPPORTS_SCALING: + canvas_view->details->supports_scaling = g_value_get_boolean (value); + break; + case PROP_SUPPORTS_KEEP_ALIGNED: + canvas_view->details->supports_keep_aligned = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nautilus_canvas_view_finalize (GObject *object) +{ + NautilusCanvasView *canvas_view; + + canvas_view = NAUTILUS_CANVAS_VIEW (object); + + g_free (canvas_view->details); + + g_signal_handlers_disconnect_by_func (nautilus_preferences, + default_sort_order_changed_callback, + canvas_view); + g_signal_handlers_disconnect_by_func (nautilus_preferences, + default_sort_in_reverse_order_changed_callback, + canvas_view); + g_signal_handlers_disconnect_by_func (nautilus_preferences, + image_display_policy_changed_callback, + canvas_view); + + g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences, + default_zoom_level_changed_callback, + canvas_view); + g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences, + text_attribute_names_changed_callback, + canvas_view); + + G_OBJECT_CLASS (nautilus_canvas_view_parent_class)->finalize (object); +} + +static void +nautilus_canvas_view_class_init (NautilusCanvasViewClass *klass) +{ + NautilusViewClass *nautilus_view_class; + GObjectClass *oclass; + + nautilus_view_class = NAUTILUS_VIEW_CLASS (klass); + oclass = G_OBJECT_CLASS (klass); + + oclass->set_property = nautilus_canvas_view_set_property; + oclass->finalize = nautilus_canvas_view_finalize; + + GTK_WIDGET_CLASS (klass)->destroy = nautilus_canvas_view_destroy; + GTK_WIDGET_CLASS (klass)->screen_changed = nautilus_canvas_view_screen_changed; + + nautilus_view_class->add_file = nautilus_canvas_view_add_file; + nautilus_view_class->begin_loading = nautilus_canvas_view_begin_loading; + nautilus_view_class->bump_zoom_level = nautilus_canvas_view_bump_zoom_level; + nautilus_view_class->can_rename_file = nautilus_canvas_view_can_rename_file; + nautilus_view_class->can_zoom_in = nautilus_canvas_view_can_zoom_in; + nautilus_view_class->can_zoom_out = nautilus_canvas_view_can_zoom_out; + nautilus_view_class->clear = nautilus_canvas_view_clear; + nautilus_view_class->end_loading = nautilus_canvas_view_end_loading; + nautilus_view_class->file_changed = nautilus_canvas_view_file_changed; + nautilus_view_class->get_selected_icon_locations = nautilus_canvas_view_get_selected_icon_locations; + nautilus_view_class->get_selection = nautilus_canvas_view_get_selection; + nautilus_view_class->get_selection_for_file_transfer = nautilus_canvas_view_get_selection; + nautilus_view_class->get_item_count = nautilus_canvas_view_get_item_count; + nautilus_view_class->is_empty = nautilus_canvas_view_is_empty; + nautilus_view_class->remove_file = nautilus_canvas_view_remove_file; + nautilus_view_class->reset_to_defaults = nautilus_canvas_view_reset_to_defaults; + nautilus_view_class->restore_default_zoom_level = nautilus_canvas_view_restore_default_zoom_level; + nautilus_view_class->reveal_selection = nautilus_canvas_view_reveal_selection; + nautilus_view_class->select_all = nautilus_canvas_view_select_all; + nautilus_view_class->set_selection = nautilus_canvas_view_set_selection; + nautilus_view_class->invert_selection = nautilus_canvas_view_invert_selection; + nautilus_view_class->compare_files = compare_files; + nautilus_view_class->zoom_to_level = nautilus_canvas_view_zoom_to_level; + nautilus_view_class->get_zoom_level = nautilus_canvas_view_get_zoom_level; + nautilus_view_class->click_policy_changed = nautilus_canvas_view_click_policy_changed; + nautilus_view_class->merge_menus = nautilus_canvas_view_merge_menus; + nautilus_view_class->unmerge_menus = nautilus_canvas_view_unmerge_menus; + nautilus_view_class->sort_directories_first_changed = nautilus_canvas_view_sort_directories_first_changed; + nautilus_view_class->start_renaming_file = nautilus_canvas_view_start_renaming_file; + nautilus_view_class->update_menus = nautilus_canvas_view_update_menus; + nautilus_view_class->using_manual_layout = nautilus_canvas_view_using_manual_layout; + nautilus_view_class->widget_to_file_operation_position = nautilus_canvas_view_widget_to_file_operation_position; + nautilus_view_class->get_view_id = nautilus_canvas_view_get_id; + nautilus_view_class->get_first_visible_file = canvas_view_get_first_visible_file; + nautilus_view_class->scroll_to_file = canvas_view_scroll_to_file; + + properties[PROP_SUPPORTS_AUTO_LAYOUT] = + g_param_spec_boolean ("supports-auto-layout", + "Supports auto layout", + "Whether this view supports auto layout", + TRUE, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY); + properties[PROP_SUPPORTS_SCALING] = + g_param_spec_boolean ("supports-scaling", + "Supports scaling", + "Whether this view supports scaling", + FALSE, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY); + properties[PROP_SUPPORTS_KEEP_ALIGNED] = + g_param_spec_boolean ("supports-keep-aligned", + "Supports keep aligned", + "Whether this view supports keep aligned", + FALSE, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY); + + g_object_class_install_properties (oclass, NUM_PROPERTIES, properties); +} + +static void +nautilus_canvas_view_init (NautilusCanvasView *canvas_view) +{ + NautilusCanvasContainer *canvas_container; + + g_return_if_fail (gtk_bin_get_child (GTK_BIN (canvas_view)) == NULL); + + canvas_view->details = g_new0 (NautilusCanvasViewDetails, 1); + canvas_view->details->sort = &sort_criteria[0]; + canvas_view->details->filter_by_screen = FALSE; + + canvas_container = create_canvas_container (canvas_view); + + /* Set our default layout mode */ + nautilus_canvas_container_set_layout_mode (canvas_container, + gtk_widget_get_direction (GTK_WIDGET(canvas_container)) == GTK_TEXT_DIR_RTL ? + NAUTILUS_CANVAS_LAYOUT_R_L_T_B : + NAUTILUS_CANVAS_LAYOUT_L_R_T_B); + + g_signal_connect_swapped (nautilus_preferences, + "changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_ORDER, + G_CALLBACK (default_sort_order_changed_callback), + canvas_view); + g_signal_connect_swapped (nautilus_preferences, + "changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER, + G_CALLBACK (default_sort_in_reverse_order_changed_callback), + canvas_view); + g_signal_connect_swapped (nautilus_preferences, + "changed::" NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, + G_CALLBACK (image_display_policy_changed_callback), + canvas_view); + + g_signal_connect_swapped (nautilus_icon_view_preferences, + "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL, + G_CALLBACK (default_zoom_level_changed_callback), + canvas_view); + g_signal_connect_swapped (nautilus_icon_view_preferences, + "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS, + G_CALLBACK (text_attribute_names_changed_callback), + canvas_view); + + g_signal_connect_object (get_canvas_container (canvas_view), "handle_netscape_url", + G_CALLBACK (canvas_view_handle_netscape_url), canvas_view, 0); + g_signal_connect_object (get_canvas_container (canvas_view), "handle_uri_list", + G_CALLBACK (canvas_view_handle_uri_list), canvas_view, 0); + g_signal_connect_object (get_canvas_container (canvas_view), "handle_text", + G_CALLBACK (canvas_view_handle_text), canvas_view, 0); + g_signal_connect_object (get_canvas_container (canvas_view), "handle_raw", + G_CALLBACK (canvas_view_handle_raw), canvas_view, 0); + + canvas_view->details->clipboard_handler_id = + g_signal_connect (nautilus_clipboard_monitor_get (), + "clipboard_info", + G_CALLBACK (canvas_view_notify_clipboard_info), canvas_view); +} + +static NautilusView * +nautilus_canvas_view_create (NautilusWindowSlot *slot) +{ + NautilusCanvasView *view; + + view = g_object_new (NAUTILUS_TYPE_CANVAS_VIEW, + "window-slot", slot, + NULL); + return NAUTILUS_VIEW (view); +} + +static gboolean +nautilus_canvas_view_supports_uri (const char *uri, + GFileType file_type, + const char *mime_type) +{ + if (file_type == G_FILE_TYPE_DIRECTORY) { + return TRUE; + } + if (strcmp (mime_type, NAUTILUS_SAVED_SEARCH_MIMETYPE) == 0){ + return TRUE; + } + if (g_str_has_prefix (uri, "trash:")) { + return TRUE; + } + if (g_str_has_prefix (uri, EEL_SEARCH_URI)) { + return TRUE; + } + + return FALSE; +} + +#define TRANSLATE_VIEW_INFO(view_info) \ + view_info.view_combo_label = _(view_info.view_combo_label); \ + view_info.view_menu_label_with_mnemonic = _(view_info.view_menu_label_with_mnemonic); \ + view_info.error_label = _(view_info.error_label); \ + view_info.startup_error_label = _(view_info.startup_error_label); \ + view_info.display_location_label = _(view_info.display_location_label); \ + + +static NautilusViewInfo nautilus_canvas_view = { + NAUTILUS_CANVAS_VIEW_ID, + /* translators: this is used in the view selection dropdown + * of navigation windows and in the preferences dialog */ + N_("Icon View"), + /* translators: this is used in the view menu */ + N_("_Icons"), + N_("The icon view encountered an error."), + N_("The icon view encountered an error while starting up."), + N_("Display this location with the canvas view."), + nautilus_canvas_view_create, + nautilus_canvas_view_supports_uri +}; + +void +nautilus_canvas_view_register (void) +{ + TRANSLATE_VIEW_INFO (nautilus_canvas_view) + nautilus_view_factory_register (&nautilus_canvas_view); +} + diff --git a/src/nautilus-canvas-view.h b/src/nautilus-canvas-view.h new file mode 100644 index 000000000..c1bec5eca --- /dev/null +++ b/src/nautilus-canvas-view.h @@ -0,0 +1,72 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-canvas-view.h - interface for canvas view of directory. + * + * Copyright (C) 2000 Eazel, Inc. + * + * The Gnome Library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * The Gnome Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with the Gnome Library; see the file COPYING.LIB. If not, + * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: John Sullivan <sullivan@eazel.com> + * + */ + +#ifndef NAUTILUS_CANVAS_VIEW_H +#define NAUTILUS_CANVAS_VIEW_H + +#include "nautilus-view.h" +#include "libnautilus-private/nautilus-canvas-container.h" + +typedef struct NautilusCanvasView NautilusCanvasView; +typedef struct NautilusCanvasViewClass NautilusCanvasViewClass; + +#define NAUTILUS_TYPE_CANVAS_VIEW nautilus_canvas_view_get_type() +#define NAUTILUS_CANVAS_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_CANVAS_VIEW, NautilusCanvasView)) +#define NAUTILUS_CANVAS_VIEW_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CANVAS_VIEW, NautilusCanvasViewClass)) +#define NAUTILUS_IS_CANVAS_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_CANVAS_VIEW)) +#define NAUTILUS_IS_CANVAS_VIEW_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_CANVAS_VIEW)) +#define NAUTILUS_CANVAS_VIEW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_CANVAS_VIEW, NautilusCanvasViewClass)) + +#define NAUTILUS_CANVAS_VIEW_ID "OAFIID:Nautilus_File_Manager_Canvas_View" + +typedef struct NautilusCanvasViewDetails NautilusCanvasViewDetails; + +struct NautilusCanvasView { + NautilusView parent; + NautilusCanvasViewDetails *details; +}; + +struct NautilusCanvasViewClass { + NautilusViewClass parent_class; +}; + +/* GObject support */ +GType nautilus_canvas_view_get_type (void); +int nautilus_canvas_view_compare_files (NautilusCanvasView *canvas_view, + NautilusFile *a, + NautilusFile *b); +void nautilus_canvas_view_filter_by_screen (NautilusCanvasView *canvas_view, + gboolean filter); + +void nautilus_canvas_view_register (void); + +NautilusCanvasContainer * nautilus_canvas_view_get_canvas_container (NautilusCanvasView *view); + +#endif /* NAUTILUS_CANVAS_VIEW_H */ diff --git a/src/nautilus-desktop-icon-view.c b/src/nautilus-desktop-canvas-view.c index 1729510e7..409967a7a 100644 --- a/src/nautilus-desktop-icon-view.c +++ b/src/nautilus-desktop-canvas-view.c @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* fm-desktop-icon-view.c - implementation of icon view for managing the desktop. +/* nautilus-desktop-canvas-view.c - implementation of canvas view for managing the desktop. Copyright (C) 2000, 2001 Eazel, Inc.mou @@ -26,10 +26,10 @@ #include <config.h> -#include "nautilus-desktop-icon-view.h" +#include "nautilus-desktop-canvas-view.h" #include "nautilus-actions.h" -#include "nautilus-icon-view-container.h" +#include "nautilus-canvas-view-container.h" #include "nautilus-view-factory.h" #include "nautilus-view.h" @@ -65,7 +65,7 @@ /* Timeout to check the desktop directory for updates */ #define RESCAN_TIMEOUT 4 -struct NautilusDesktopIconViewDetails +struct NautilusDesktopCanvasViewDetails { GdkWindow *root_window; GtkActionGroup *desktop_action_group; @@ -83,18 +83,18 @@ struct NautilusDesktopIconViewDetails static void default_zoom_level_changed (gpointer user_data); static void real_merge_menus (NautilusView *view); static void real_update_menus (NautilusView *view); -static void nautilus_desktop_icon_view_update_icon_container_fonts (NautilusDesktopIconView *view); +static void nautilus_desktop_canvas_view_update_canvas_container_fonts (NautilusDesktopCanvasView *view); static void font_changed_callback (gpointer callback_data); -G_DEFINE_TYPE (NautilusDesktopIconView, nautilus_desktop_icon_view, NAUTILUS_TYPE_ICON_VIEW) +G_DEFINE_TYPE (NautilusDesktopCanvasView, nautilus_desktop_canvas_view, NAUTILUS_TYPE_CANVAS_VIEW) static char *desktop_directory; static time_t desktop_dir_modify_time; -#define get_icon_container(w) nautilus_icon_view_get_icon_container(NAUTILUS_ICON_VIEW (w)) +#define get_canvas_container(w) nautilus_canvas_view_get_canvas_container(NAUTILUS_CANVAS_VIEW (w)) static void -icon_container_set_workarea (NautilusIconContainer *icon_container, +canvas_container_set_workarea (NautilusCanvasContainer *canvas_container, GdkScreen *screen, long *workareas, int n_items) @@ -123,12 +123,12 @@ icon_container_set_workarea (NautilusIconContainer *icon_container, bottom = MAX (bottom, screen_height - height - y); } - nautilus_icon_container_set_margins (icon_container, + nautilus_canvas_container_set_margins (canvas_container, left, right, top, bottom); } static void -net_workarea_changed (NautilusDesktopIconView *icon_view, +net_workarea_changed (NautilusDesktopCanvasView *canvas_view, GdkWindow *window) { long *nworkareas = NULL; @@ -136,12 +136,12 @@ net_workarea_changed (NautilusDesktopIconView *icon_view, GdkAtom type_returned; int format_returned; int length_returned; - NautilusIconContainer *icon_container; + NautilusCanvasContainer *canvas_container; GdkScreen *screen; - g_return_if_fail (NAUTILUS_IS_DESKTOP_ICON_VIEW (icon_view)); + g_return_if_fail (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (canvas_view)); - icon_container = get_icon_container (icon_view); + canvas_container = get_canvas_container (canvas_view); /* Find the number of desktops so we know how long the * workareas array is going to be (each desktop will have four @@ -194,13 +194,13 @@ net_workarea_changed (NautilusDesktopIconView *icon_view, || ((*nworkareas) * 4 * sizeof(long)) != length_returned || format_returned != 32) { g_warning("Can not determine workarea, guessing at layout"); - nautilus_icon_container_set_margins (icon_container, + nautilus_canvas_container_set_margins (canvas_container, 0, 0, 0, 0); } else { screen = gdk_window_get_screen (window); - icon_container_set_workarea - (icon_container, screen, workareas, length_returned / sizeof (long)); + canvas_container_set_workarea + (canvas_container, screen, workareas, length_returned / sizeof (long)); } if (nworkareas != NULL) @@ -211,19 +211,19 @@ net_workarea_changed (NautilusDesktopIconView *icon_view, } static GdkFilterReturn -desktop_icon_view_property_filter (GdkXEvent *gdk_xevent, +desktop_canvas_view_property_filter (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) { XEvent *xevent = gdk_xevent; - NautilusDesktopIconView *icon_view; + NautilusDesktopCanvasView *canvas_view; - icon_view = NAUTILUS_DESKTOP_ICON_VIEW (data); + canvas_view = NAUTILUS_DESKTOP_CANVAS_VIEW (data); switch (xevent->type) { case PropertyNotify: if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("_NET_WORKAREA")) - net_workarea_changed (icon_view, event->any.window); + net_workarea_changed (canvas_view, event->any.window); break; default: break; @@ -235,92 +235,92 @@ desktop_icon_view_property_filter (GdkXEvent *gdk_xevent, static void real_begin_loading (NautilusView *object) { - NautilusIconContainer *icon_container; - NautilusDesktopIconView *view; + NautilusCanvasContainer *canvas_container; + NautilusDesktopCanvasView *view; - view = NAUTILUS_DESKTOP_ICON_VIEW (object); + view = NAUTILUS_DESKTOP_CANVAS_VIEW (object); - icon_container = get_icon_container (view); + canvas_container = get_canvas_container (view); if (view->details->background == NULL) { - view->details->background = nautilus_desktop_background_new (icon_container); + view->details->background = nautilus_desktop_background_new (canvas_container); } - NAUTILUS_VIEW_CLASS (nautilus_desktop_icon_view_parent_class)->begin_loading (object); + NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->begin_loading (object); } static const char * real_get_id (NautilusView *view) { - return NAUTILUS_DESKTOP_ICON_VIEW_ID; + return NAUTILUS_DESKTOP_CANVAS_VIEW_ID; } static void -nautilus_desktop_icon_view_dispose (GObject *object) +nautilus_desktop_canvas_view_dispose (GObject *object) { - NautilusDesktopIconView *icon_view; + NautilusDesktopCanvasView *canvas_view; GtkUIManager *ui_manager; - icon_view = NAUTILUS_DESKTOP_ICON_VIEW (object); + canvas_view = NAUTILUS_DESKTOP_CANVAS_VIEW (object); /* Remove desktop rescan timeout. */ - if (icon_view->details->reload_desktop_timeout != 0) { - g_source_remove (icon_view->details->reload_desktop_timeout); - icon_view->details->reload_desktop_timeout = 0; + if (canvas_view->details->reload_desktop_timeout != 0) { + g_source_remove (canvas_view->details->reload_desktop_timeout); + canvas_view->details->reload_desktop_timeout = 0; } - ui_manager = nautilus_view_get_ui_manager (NAUTILUS_VIEW (icon_view)); + ui_manager = nautilus_view_get_ui_manager (NAUTILUS_VIEW (canvas_view)); if (ui_manager != NULL) { nautilus_ui_unmerge_ui (ui_manager, - &icon_view->details->desktop_merge_id, - &icon_view->details->desktop_action_group); + &canvas_view->details->desktop_merge_id, + &canvas_view->details->desktop_action_group); } g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences, default_zoom_level_changed, - icon_view); + canvas_view); g_signal_handlers_disconnect_by_func (nautilus_preferences, font_changed_callback, - icon_view); + canvas_view); g_signal_handlers_disconnect_by_func (gnome_lockdown_preferences, nautilus_view_update_menus, - icon_view); + canvas_view); - if (icon_view->details->background != NULL) { - g_object_unref (icon_view->details->background); - icon_view->details->background = NULL; + if (canvas_view->details->background != NULL) { + g_object_unref (canvas_view->details->background); + canvas_view->details->background = NULL; } - G_OBJECT_CLASS (nautilus_desktop_icon_view_parent_class)->dispose (object); + G_OBJECT_CLASS (nautilus_desktop_canvas_view_parent_class)->dispose (object); } static void -nautilus_desktop_icon_view_class_init (NautilusDesktopIconViewClass *class) +nautilus_desktop_canvas_view_class_init (NautilusDesktopCanvasViewClass *class) { NautilusViewClass *vclass; vclass = NAUTILUS_VIEW_CLASS (class); - G_OBJECT_CLASS (class)->dispose = nautilus_desktop_icon_view_dispose; + G_OBJECT_CLASS (class)->dispose = nautilus_desktop_canvas_view_dispose; vclass->begin_loading = real_begin_loading; vclass->merge_menus = real_merge_menus; vclass->update_menus = real_update_menus; vclass->get_view_id = real_get_id; - g_type_class_add_private (class, sizeof (NautilusDesktopIconViewDetails)); + g_type_class_add_private (class, sizeof (NautilusDesktopCanvasViewDetails)); } static void -nautilus_desktop_icon_view_handle_middle_click (NautilusIconContainer *icon_container, +nautilus_desktop_canvas_view_handle_middle_click (NautilusCanvasContainer *canvas_container, GdkEventButton *event, - NautilusDesktopIconView *desktop_icon_view) + NautilusDesktopCanvasView *desktop_canvas_view) { XButtonEvent x_event; GdkDevice *keyboard = NULL, *pointer = NULL, *cur; GdkDeviceManager *manager; GList *list, *l; - manager = gdk_display_get_device_manager (gtk_widget_get_display (GTK_WIDGET (icon_container))); + manager = gdk_display_get_device_manager (gtk_widget_get_display (GTK_WIDGET (canvas_container))); list = gdk_device_manager_list_devices (manager, GDK_DEVICE_TYPE_MASTER); for (l = list; l != NULL; l = l->next) { @@ -357,7 +357,7 @@ nautilus_desktop_icon_view_handle_middle_click (NautilusIconContainer *icon_cont /* Stop the event because we don't want anyone else dealing with it. */ gdk_flush (); - g_signal_stop_emission_by_name (icon_container, "middle_click"); + g_signal_stop_emission_by_name (canvas_container, "middle_click"); /* build an X event to represent the middle click. */ x_event.type = ButtonPress; @@ -381,25 +381,25 @@ nautilus_desktop_icon_view_handle_middle_click (NautilusIconContainer *icon_cont } static void -unrealized_callback (GtkWidget *widget, NautilusDesktopIconView *desktop_icon_view) +unrealized_callback (GtkWidget *widget, NautilusDesktopCanvasView *desktop_canvas_view) { - g_return_if_fail (desktop_icon_view->details->root_window != NULL); + g_return_if_fail (desktop_canvas_view->details->root_window != NULL); /* Remove the property filter */ - gdk_window_remove_filter (desktop_icon_view->details->root_window, - desktop_icon_view_property_filter, - desktop_icon_view); - desktop_icon_view->details->root_window = NULL; + gdk_window_remove_filter (desktop_canvas_view->details->root_window, + desktop_canvas_view_property_filter, + desktop_canvas_view); + desktop_canvas_view->details->root_window = NULL; } static void -realized_callback (GtkWidget *widget, NautilusDesktopIconView *desktop_icon_view) +realized_callback (GtkWidget *widget, NautilusDesktopCanvasView *desktop_canvas_view) { GdkWindow *root_window; GdkScreen *screen; GtkAllocation allocation; - g_return_if_fail (desktop_icon_view->details->root_window == NULL); + g_return_if_fail (desktop_canvas_view->details->root_window == NULL); screen = gtk_widget_get_screen (widget); @@ -413,21 +413,21 @@ realized_callback (GtkWidget *widget, NautilusDesktopIconView *desktop_icon_view allocation.y = 0; allocation.width = gdk_screen_get_width (screen); allocation.height = gdk_screen_get_height (screen); - gtk_widget_size_allocate (GTK_WIDGET(get_icon_container(desktop_icon_view)), + gtk_widget_size_allocate (GTK_WIDGET(get_canvas_container(desktop_canvas_view)), &allocation); root_window = gdk_screen_get_root_window (screen); - desktop_icon_view->details->root_window = root_window; + desktop_canvas_view->details->root_window = root_window; /* Read out the workarea geometry and update the icon container accordingly */ - net_workarea_changed (desktop_icon_view, root_window); + net_workarea_changed (desktop_canvas_view, root_window); /* Setup the property filter */ gdk_window_set_events (root_window, GDK_PROPERTY_CHANGE_MASK); gdk_window_add_filter (root_window, - desktop_icon_view_property_filter, - desktop_icon_view); + desktop_canvas_view_property_filter, + desktop_canvas_view); } static NautilusZoomLevel @@ -445,23 +445,23 @@ static void default_zoom_level_changed (gpointer user_data) { NautilusZoomLevel new_level; - NautilusDesktopIconView *desktop_icon_view; + NautilusDesktopCanvasView *desktop_canvas_view; - desktop_icon_view = NAUTILUS_DESKTOP_ICON_VIEW (user_data); + desktop_canvas_view = NAUTILUS_DESKTOP_CANVAS_VIEW (user_data); new_level = get_default_zoom_level (); - nautilus_icon_container_set_zoom_level (get_icon_container (desktop_icon_view), + nautilus_canvas_container_set_zoom_level (get_canvas_container (desktop_canvas_view), new_level); } static gboolean do_desktop_rescan (gpointer data) { - NautilusDesktopIconView *desktop_icon_view; + NautilusDesktopCanvasView *desktop_canvas_view; struct stat buf; - desktop_icon_view = NAUTILUS_DESKTOP_ICON_VIEW (data); - if (desktop_icon_view->details->pending_rescan) { + desktop_canvas_view = NAUTILUS_DESKTOP_CANVAS_VIEW (data); + if (desktop_canvas_view->details->pending_rescan) { return TRUE; } @@ -473,21 +473,21 @@ do_desktop_rescan (gpointer data) return TRUE; } - desktop_icon_view->details->pending_rescan = TRUE; + desktop_canvas_view->details->pending_rescan = TRUE; nautilus_directory_force_reload - (nautilus_view_get_model (NAUTILUS_VIEW (desktop_icon_view))); + (nautilus_view_get_model (NAUTILUS_VIEW (desktop_canvas_view))); return TRUE; } static void done_loading (NautilusDirectory *model, - NautilusDesktopIconView *desktop_icon_view) + NautilusDesktopCanvasView *desktop_canvas_view) { struct stat buf; - desktop_icon_view->details->pending_rescan = FALSE; + desktop_canvas_view->details->pending_rescan = FALSE; if (stat (desktop_directory, &buf) == -1) { return; } @@ -496,135 +496,135 @@ done_loading (NautilusDirectory *model, } /* This function is used because the NautilusDirectory model does not - * exist always in the desktop_icon_view, so we wait until it has been + * exist always in the desktop_canvas_view, so we wait until it has been * instantiated. */ static void -delayed_init (NautilusDesktopIconView *desktop_icon_view) +delayed_init (NautilusDesktopCanvasView *desktop_canvas_view) { /* Keep track of the load time. */ - g_signal_connect_object (nautilus_view_get_model (NAUTILUS_VIEW (desktop_icon_view)), + g_signal_connect_object (nautilus_view_get_model (NAUTILUS_VIEW (desktop_canvas_view)), "done_loading", - G_CALLBACK (done_loading), desktop_icon_view, 0); + G_CALLBACK (done_loading), desktop_canvas_view, 0); /* Monitor desktop directory. */ - desktop_icon_view->details->reload_desktop_timeout = - g_timeout_add_seconds (RESCAN_TIMEOUT, do_desktop_rescan, desktop_icon_view); + desktop_canvas_view->details->reload_desktop_timeout = + g_timeout_add_seconds (RESCAN_TIMEOUT, do_desktop_rescan, desktop_canvas_view); - g_signal_handler_disconnect (desktop_icon_view, - desktop_icon_view->details->delayed_init_signal); + g_signal_handler_disconnect (desktop_canvas_view, + desktop_canvas_view->details->delayed_init_signal); - desktop_icon_view->details->delayed_init_signal = 0; + desktop_canvas_view->details->delayed_init_signal = 0; } static void font_changed_callback (gpointer callback_data) { - g_return_if_fail (NAUTILUS_IS_DESKTOP_ICON_VIEW (callback_data)); + g_return_if_fail (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (callback_data)); - nautilus_desktop_icon_view_update_icon_container_fonts (NAUTILUS_DESKTOP_ICON_VIEW (callback_data)); + nautilus_desktop_canvas_view_update_canvas_container_fonts (NAUTILUS_DESKTOP_CANVAS_VIEW (callback_data)); } static void -nautilus_desktop_icon_view_update_icon_container_fonts (NautilusDesktopIconView *icon_view) +nautilus_desktop_canvas_view_update_canvas_container_fonts (NautilusDesktopCanvasView *canvas_view) { - NautilusIconContainer *icon_container; + NautilusCanvasContainer *canvas_container; char *font; - icon_container = get_icon_container (icon_view); - g_assert (icon_container != NULL); + canvas_container = get_canvas_container (canvas_view); + g_assert (canvas_container != NULL); font = g_settings_get_string (nautilus_desktop_preferences, NAUTILUS_PREFERENCES_DESKTOP_FONT); - nautilus_icon_container_set_font (icon_container, font); + nautilus_canvas_container_set_font (canvas_container, font); g_free (font); } static void -nautilus_desktop_icon_view_init (NautilusDesktopIconView *desktop_icon_view) +nautilus_desktop_canvas_view_init (NautilusDesktopCanvasView *desktop_canvas_view) { - NautilusIconContainer *icon_container; + NautilusCanvasContainer *canvas_container; GtkAllocation allocation; GtkAdjustment *hadj, *vadj; - desktop_icon_view->details = G_TYPE_INSTANCE_GET_PRIVATE (desktop_icon_view, - NAUTILUS_TYPE_DESKTOP_ICON_VIEW, - NautilusDesktopIconViewDetails); + desktop_canvas_view->details = G_TYPE_INSTANCE_GET_PRIVATE (desktop_canvas_view, + NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW, + NautilusDesktopCanvasViewDetails); if (desktop_directory == NULL) { desktop_directory = nautilus_get_desktop_directory (); } - nautilus_icon_view_filter_by_screen (NAUTILUS_ICON_VIEW (desktop_icon_view), TRUE); - icon_container = get_icon_container (desktop_icon_view); - nautilus_icon_container_set_use_drop_shadows (icon_container, TRUE); - nautilus_icon_view_container_set_sort_desktop (NAUTILUS_ICON_VIEW_CONTAINER (icon_container), TRUE); + nautilus_canvas_view_filter_by_screen (NAUTILUS_CANVAS_VIEW (desktop_canvas_view), TRUE); + canvas_container = get_canvas_container (desktop_canvas_view); + nautilus_canvas_container_set_use_drop_shadows (canvas_container, TRUE); + nautilus_canvas_view_container_set_sort_desktop (NAUTILUS_CANVAS_VIEW_CONTAINER (canvas_container), TRUE); /* Do a reload on the desktop if we don't have FAM, a smarter * way to keep track of the items on the desktop. */ if (!nautilus_monitor_active ()) { - desktop_icon_view->details->delayed_init_signal = g_signal_connect_object - (desktop_icon_view, "begin_loading", - G_CALLBACK (delayed_init), desktop_icon_view, 0); + desktop_canvas_view->details->delayed_init_signal = g_signal_connect_object + (desktop_canvas_view, "begin_loading", + G_CALLBACK (delayed_init), desktop_canvas_view, 0); } - nautilus_icon_container_set_is_fixed_size (icon_container, TRUE); - nautilus_icon_container_set_is_desktop (icon_container, TRUE); - nautilus_icon_container_set_store_layout_timestamps (icon_container, TRUE); + nautilus_canvas_container_set_is_fixed_size (canvas_container, TRUE); + nautilus_canvas_container_set_is_desktop (canvas_container, TRUE); + nautilus_canvas_container_set_store_layout_timestamps (canvas_container, TRUE); /* Set allocation to be at 0, 0 */ - gtk_widget_get_allocation (GTK_WIDGET (icon_container), &allocation); + gtk_widget_get_allocation (GTK_WIDGET (canvas_container), &allocation); allocation.x = 0; allocation.y = 0; - gtk_widget_set_allocation (GTK_WIDGET (icon_container), &allocation); + gtk_widget_set_allocation (GTK_WIDGET (canvas_container), &allocation); - gtk_widget_queue_resize (GTK_WIDGET (icon_container)); + gtk_widget_queue_resize (GTK_WIDGET (canvas_container)); - hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (icon_container)); - vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (icon_container)); + hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas_container)); + vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas_container)); gtk_adjustment_set_value (hadj, 0); gtk_adjustment_set_value (vadj, 0); nautilus_view_ignore_hidden_file_preferences - (NAUTILUS_VIEW (desktop_icon_view)); + (NAUTILUS_VIEW (desktop_canvas_view)); - nautilus_view_set_show_foreign (NAUTILUS_VIEW (desktop_icon_view), + nautilus_view_set_show_foreign (NAUTILUS_VIEW (desktop_canvas_view), FALSE); /* Set our default layout mode */ - nautilus_icon_container_set_layout_mode (icon_container, - gtk_widget_get_direction (GTK_WIDGET(icon_container)) == GTK_TEXT_DIR_RTL ? - NAUTILUS_ICON_LAYOUT_T_B_R_L : - NAUTILUS_ICON_LAYOUT_T_B_L_R); - - g_signal_connect_object (icon_container, "middle_click", - G_CALLBACK (nautilus_desktop_icon_view_handle_middle_click), desktop_icon_view, 0); - g_signal_connect_object (desktop_icon_view, "realize", - G_CALLBACK (realized_callback), desktop_icon_view, 0); - g_signal_connect_object (desktop_icon_view, "unrealize", - G_CALLBACK (unrealized_callback), desktop_icon_view, 0); + nautilus_canvas_container_set_layout_mode (canvas_container, + gtk_widget_get_direction (GTK_WIDGET(canvas_container)) == GTK_TEXT_DIR_RTL ? + NAUTILUS_CANVAS_LAYOUT_T_B_R_L : + NAUTILUS_CANVAS_LAYOUT_T_B_L_R); + + g_signal_connect_object (canvas_container, "middle_click", + G_CALLBACK (nautilus_desktop_canvas_view_handle_middle_click), desktop_canvas_view, 0); + g_signal_connect_object (desktop_canvas_view, "realize", + G_CALLBACK (realized_callback), desktop_canvas_view, 0); + g_signal_connect_object (desktop_canvas_view, "unrealize", + G_CALLBACK (unrealized_callback), desktop_canvas_view, 0); g_signal_connect_swapped (nautilus_icon_view_preferences, "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL, G_CALLBACK (default_zoom_level_changed), - desktop_icon_view); + desktop_canvas_view); g_signal_connect_swapped (nautilus_desktop_preferences, "changed::" NAUTILUS_PREFERENCES_DESKTOP_FONT, G_CALLBACK (font_changed_callback), - desktop_icon_view); + desktop_canvas_view); - default_zoom_level_changed (desktop_icon_view); - nautilus_desktop_icon_view_update_icon_container_fonts (desktop_icon_view); + default_zoom_level_changed (desktop_canvas_view); + nautilus_desktop_canvas_view_update_canvas_container_fonts (desktop_canvas_view); g_signal_connect_swapped (gnome_lockdown_preferences, "changed::" NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE, G_CALLBACK (nautilus_view_update_menus), - desktop_icon_view); + desktop_canvas_view); } static void @@ -680,16 +680,16 @@ trash_link_is_selection (NautilusView *view) static void real_update_menus (NautilusView *view) { - NautilusDesktopIconView *desktop_view; + NautilusDesktopCanvasView *desktop_view; char *label; gboolean include_empty_trash; GtkAction *action; - g_assert (NAUTILUS_IS_DESKTOP_ICON_VIEW (view)); + g_assert (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view)); - NAUTILUS_VIEW_CLASS (nautilus_desktop_icon_view_parent_class)->update_menus (view); + NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->update_menus (view); - desktop_view = NAUTILUS_DESKTOP_ICON_VIEW (view); + desktop_view = NAUTILUS_DESKTOP_CANVAS_VIEW (view); /* Empty Trash */ include_empty_trash = trash_link_is_selection (view); @@ -726,13 +726,13 @@ static const GtkActionEntry desktop_view_entries[] = { static void real_merge_menus (NautilusView *view) { - NautilusDesktopIconView *desktop_view; + NautilusDesktopCanvasView *desktop_view; GtkUIManager *ui_manager; GtkActionGroup *action_group; - NAUTILUS_VIEW_CLASS (nautilus_desktop_icon_view_parent_class)->merge_menus (view); + NAUTILUS_VIEW_CLASS (nautilus_desktop_canvas_view_parent_class)->merge_menus (view); - desktop_view = NAUTILUS_DESKTOP_ICON_VIEW (view); + desktop_view = NAUTILUS_DESKTOP_CANVAS_VIEW (view); ui_manager = nautilus_view_get_ui_manager (view); @@ -747,15 +747,15 @@ real_merge_menus (NautilusView *view) g_object_unref (action_group); /* owned by ui manager */ desktop_view->details->desktop_merge_id = - gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-desktop-icon-view-ui.xml", NULL); + gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-desktop-canvas-view-ui.xml", NULL); } static NautilusView * -nautilus_desktop_icon_view_create (NautilusWindowSlot *slot) +nautilus_desktop_canvas_view_create (NautilusWindowSlot *slot) { - NautilusIconView *view; + NautilusCanvasView *view; - view = g_object_new (NAUTILUS_TYPE_DESKTOP_ICON_VIEW, + view = g_object_new (NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW, "window-slot", slot, "supports-zooming", FALSE, "supports-auto-layout", FALSE, @@ -766,7 +766,7 @@ nautilus_desktop_icon_view_create (NautilusWindowSlot *slot) } static gboolean -nautilus_desktop_icon_view_supports_uri (const char *uri, +nautilus_desktop_canvas_view_supports_uri (const char *uri, GFileType file_type, const char *mime_type) { @@ -777,22 +777,22 @@ nautilus_desktop_icon_view_supports_uri (const char *uri, return FALSE; } -static NautilusViewInfo nautilus_desktop_icon_view = { - NAUTILUS_DESKTOP_ICON_VIEW_ID, +static NautilusViewInfo nautilus_desktop_canvas_view = { + NAUTILUS_DESKTOP_CANVAS_VIEW_ID, "Desktop View", "_Desktop", N_("The desktop view encountered an error."), N_("The desktop view encountered an error while starting up."), "Display this location with the desktop view.", - nautilus_desktop_icon_view_create, - nautilus_desktop_icon_view_supports_uri + nautilus_desktop_canvas_view_create, + nautilus_desktop_canvas_view_supports_uri }; void -nautilus_desktop_icon_view_register (void) +nautilus_desktop_canvas_view_register (void) { - nautilus_desktop_icon_view.error_label = _(nautilus_desktop_icon_view.error_label); - nautilus_desktop_icon_view.startup_error_label = _(nautilus_desktop_icon_view.startup_error_label); + nautilus_desktop_canvas_view.error_label = _(nautilus_desktop_canvas_view.error_label); + nautilus_desktop_canvas_view.startup_error_label = _(nautilus_desktop_canvas_view.startup_error_label); - nautilus_view_factory_register (&nautilus_desktop_icon_view); + nautilus_view_factory_register (&nautilus_desktop_canvas_view); } diff --git a/src/nautilus-desktop-canvas-view.h b/src/nautilus-desktop-canvas-view.h new file mode 100644 index 000000000..725851c31 --- /dev/null +++ b/src/nautilus-desktop-canvas-view.h @@ -0,0 +1,58 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* fm-icon-view.h - interface for icon view of directory. + + Copyright (C) 2000 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Mike Engber <engber@eazel.com> +*/ + +#ifndef NAUTILUS_DESKTOP_CANVAS_VIEW_H +#define NAUTILUS_DESKTOP_CANVAS_VIEW_H + +#include "nautilus-canvas-view.h" + +#define NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW nautilus_desktop_canvas_view_get_type() +#define NAUTILUS_DESKTOP_CANVAS_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW, NautilusDesktopCanvasView)) +#define NAUTILUS_DESKTOP_CANVAS_VIEW_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW, NautilusDesktopCanvasViewClass)) +#define NAUTILUS_IS_DESKTOP_CANVAS_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW)) +#define NAUTILUS_IS_DESKTOP_CANVAS_VIEW_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW)) +#define NAUTILUS_DESKTOP_CANVAS_VIEW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_DESKTOP_CANVAS_VIEW, NautilusDesktopCanvasViewClass)) + +#define NAUTILUS_DESKTOP_CANVAS_VIEW_ID "OAFIID:Nautilus_File_Manager_Desktop_Canvas_View" + +typedef struct NautilusDesktopCanvasViewDetails NautilusDesktopCanvasViewDetails; +typedef struct { + NautilusCanvasView parent; + NautilusDesktopCanvasViewDetails *details; +} NautilusDesktopCanvasView; + +typedef struct { + NautilusCanvasViewClass parent_class; +} NautilusDesktopCanvasViewClass; + +/* GObject support */ +GType nautilus_desktop_canvas_view_get_type (void); +void nautilus_desktop_canvas_view_register (void); + +#endif /* NAUTILUS_DESKTOP_CANVAS_VIEW_H */ diff --git a/src/nautilus-desktop-icon-view.h b/src/nautilus-desktop-icon-view.h deleted file mode 100644 index e7a766b42..000000000 --- a/src/nautilus-desktop-icon-view.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* fm-icon-view.h - interface for icon view of directory. - - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Mike Engber <engber@eazel.com> -*/ - -#ifndef NAUTILUS_DESKTOP_ICON_VIEW_H -#define NAUTILUS_DESKTOP_ICON_VIEW_H - -#include "nautilus-icon-view.h" - -#define NAUTILUS_TYPE_DESKTOP_ICON_VIEW nautilus_desktop_icon_view_get_type() -#define NAUTILUS_DESKTOP_ICON_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_DESKTOP_ICON_VIEW, NautilusDesktopIconView)) -#define NAUTILUS_DESKTOP_ICON_VIEW_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_DESKTOP_ICON_VIEW, NautilusDesktopIconViewClass)) -#define NAUTILUS_IS_DESKTOP_ICON_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_DESKTOP_ICON_VIEW)) -#define NAUTILUS_IS_DESKTOP_ICON_VIEW_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DESKTOP_ICON_VIEW)) -#define NAUTILUS_DESKTOP_ICON_VIEW_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_DESKTOP_ICON_VIEW, NautilusDesktopIconViewClass)) - -#define NAUTILUS_DESKTOP_ICON_VIEW_ID "OAFIID:Nautilus_File_Manager_Desktop_Icon_View" - -typedef struct NautilusDesktopIconViewDetails NautilusDesktopIconViewDetails; -typedef struct { - NautilusIconView parent; - NautilusDesktopIconViewDetails *details; -} NautilusDesktopIconView; - -typedef struct { - NautilusIconViewClass parent_class; -} NautilusDesktopIconViewClass; - -/* GObject support */ -GType nautilus_desktop_icon_view_get_type (void); -void nautilus_desktop_icon_view_register (void); - -#endif /* NAUTILUS_DESKTOP_ICON_VIEW_H */ diff --git a/src/nautilus-icon-view-container.h b/src/nautilus-icon-view-container.h deleted file mode 100644 index 1946e3509..000000000 --- a/src/nautilus-icon-view-container.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* fm-icon-container.h - the container widget for file manager icons - - Copyright (C) 2002 Sun Microsystems, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Michael Meeks <michael@ximian.com> -*/ - -#ifndef NAUTILUS_ICON_VIEW_CONTAINER_H -#define NAUTILUS_ICON_VIEW_CONTAINER_H - -#include "nautilus-icon-view.h" - -#include <libnautilus-private/nautilus-icon-container.h> - -typedef struct NautilusIconViewContainer NautilusIconViewContainer; -typedef struct NautilusIconViewContainerClass NautilusIconViewContainerClass; - -#define NAUTILUS_TYPE_ICON_VIEW_CONTAINER nautilus_icon_view_container_get_type() -#define NAUTILUS_ICON_VIEW_CONTAINER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_ICON_VIEW_CONTAINER, NautilusIconViewContainer)) -#define NAUTILUS_ICON_VIEW_CONTAINER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ICON_VIEW_CONTAINER, NautilusIconViewContainerClass)) -#define NAUTILUS_IS_ICON_VIEW_CONTAINER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_ICON_VIEW_CONTAINER)) -#define NAUTILUS_IS_ICON_VIEW_CONTAINER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ICON_VIEW_CONTAINER)) -#define NAUTILUS_ICON_VIEW_CONTAINER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_ICON_VIEW_CONTAINER, NautilusIconViewContainerClass)) - -typedef struct NautilusIconViewContainerDetails NautilusIconViewContainerDetails; - -struct NautilusIconViewContainer { - NautilusIconContainer parent; - - NautilusIconView *view; - gboolean sort_for_desktop; -}; - -struct NautilusIconViewContainerClass { - NautilusIconContainerClass parent_class; -}; - -GType nautilus_icon_view_container_get_type (void); -NautilusIconContainer *nautilus_icon_view_container_construct (NautilusIconViewContainer *icon_container, - NautilusIconView *view); -NautilusIconContainer *nautilus_icon_view_container_new (NautilusIconView *view); -void nautilus_icon_view_container_set_sort_desktop (NautilusIconViewContainer *container, - gboolean desktop); - -#endif /* NAUTILUS_ICON_VIEW_CONTAINER_H */ diff --git a/src/nautilus-icon-view.c b/src/nautilus-icon-view.c deleted file mode 100644 index 99cfa6391..000000000 --- a/src/nautilus-icon-view.c +++ /dev/null @@ -1,2475 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* fm-icon-view.c - implementation of icon view of directory. - - Copyright (C) 2000, 2001 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: John Sullivan <sullivan@eazel.com> -*/ - -#include <config.h> - -#include "nautilus-icon-view.h" - -#include "nautilus-actions.h" -#include "nautilus-icon-view-container.h" -#include "nautilus-desktop-icon-view.h" -#include "nautilus-error-reporting.h" -#include "nautilus-view-dnd.h" -#include "nautilus-view-factory.h" - -#include <stdlib.h> -#include <eel/eel-vfs-extensions.h> -#include <errno.h> -#include <fcntl.h> -#include <gtk/gtk.h> -#include <glib/gi18n.h> -#include <gio/gio.h> -#include <libnautilus-private/nautilus-clipboard-monitor.h> -#include <libnautilus-private/nautilus-directory.h> -#include <libnautilus-private/nautilus-dnd.h> -#include <libnautilus-private/nautilus-file-dnd.h> -#include <libnautilus-private/nautilus-file-utilities.h> -#include <libnautilus-private/nautilus-ui-utilities.h> -#include <libnautilus-private/nautilus-global-preferences.h> -#include <libnautilus-private/nautilus-icon-container.h> -#include <libnautilus-private/nautilus-icon-dnd.h> -#include <libnautilus-private/nautilus-link.h> -#include <libnautilus-private/nautilus-metadata.h> -#include <libnautilus-private/nautilus-clipboard.h> -#include <libnautilus-private/nautilus-desktop-icon-file.h> - -#define DEBUG_FLAG NAUTILUS_DEBUG_ICON_VIEW -#include <libnautilus-private/nautilus-debug.h> - -#include <locale.h> -#include <signal.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> - -#define POPUP_PATH_ICON_APPEARANCE "/selection/Icon Appearance Items" - -enum -{ - PROP_SUPPORTS_AUTO_LAYOUT = 1, - PROP_SUPPORTS_SCALING, - PROP_SUPPORTS_KEEP_ALIGNED, - NUM_PROPERTIES -}; - -static GParamSpec *properties[NUM_PROPERTIES] = { NULL, }; - -typedef struct { - const NautilusFileSortType sort_type; - const char *metadata_text; - const char *action; - const char *menu_label; - const char *menu_hint; -} SortCriterion; - -typedef enum { - MENU_ITEM_TYPE_STANDARD, - MENU_ITEM_TYPE_CHECK, - MENU_ITEM_TYPE_RADIO, - MENU_ITEM_TYPE_TREE -} MenuItemType; - -struct NautilusIconViewDetails -{ - GList *icons_not_positioned; - - guint react_to_icon_change_idle_id; - - const SortCriterion *sort; - gboolean sort_reversed; - - GtkActionGroup *icon_action_group; - guint icon_merge_id; - - gboolean filter_by_screen; - int num_screens; - - gulong clipboard_handler_id; - - GtkWidget *icon_container; - - gboolean supports_auto_layout; - gboolean supports_scaling; - gboolean supports_keep_aligned; -}; - - -/* Note that the first item in this list is the default sort, - * and that the items show up in the menu in the order they - * appear in this list. - */ -static const SortCriterion sort_criteria[] = { - { - NAUTILUS_FILE_SORT_BY_DISPLAY_NAME, - "name", - "Sort by Name", - N_("by _Name"), - N_("Keep icons sorted by name in rows") - }, - { - NAUTILUS_FILE_SORT_BY_SIZE, - "size", - "Sort by Size", - N_("by _Size"), - N_("Keep icons sorted by size in rows") - }, - { - NAUTILUS_FILE_SORT_BY_TYPE, - "type", - "Sort by Type", - N_("by _Type"), - N_("Keep icons sorted by type in rows") - }, - { - NAUTILUS_FILE_SORT_BY_MTIME, - "modification date", - "Sort by Modification Date", - N_("by Modification _Date"), - N_("Keep icons sorted by modification date in rows") - }, - { - NAUTILUS_FILE_SORT_BY_TRASHED_TIME, - "trashed", - "Sort by Trash Time", - N_("by T_rash Time"), - N_("Keep icons sorted by trash time in rows") - } -}; - -static void nautilus_icon_view_set_directory_sort_by (NautilusIconView *icon_view, - NautilusFile *file, - const char *sort_by); -static void nautilus_icon_view_set_zoom_level (NautilusIconView *view, - NautilusZoomLevel new_level, - gboolean always_emit); -static void nautilus_icon_view_update_click_mode (NautilusIconView *icon_view); -static gboolean nautilus_icon_view_supports_scaling (NautilusIconView *icon_view); -static void nautilus_icon_view_reveal_selection (NautilusView *view); -static const SortCriterion *get_sort_criterion_by_sort_type (NautilusFileSortType sort_type); -static void set_sort_criterion_by_sort_type (NautilusIconView *icon_view, - NautilusFileSortType sort_type); -static gboolean set_sort_reversed (NautilusIconView *icon_view, - gboolean new_value, - gboolean set_metadata); -static void switch_to_manual_layout (NautilusIconView *view); -static void update_layout_menus (NautilusIconView *view); -static NautilusFileSortType get_default_sort_order (NautilusFile *file, - gboolean *reversed); -static void nautilus_icon_view_clear (NautilusView *view); - -G_DEFINE_TYPE (NautilusIconView, nautilus_icon_view, NAUTILUS_TYPE_VIEW); - -static void -nautilus_icon_view_destroy (GtkWidget *object) -{ - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (object); - - nautilus_icon_view_clear (NAUTILUS_VIEW (object)); - - if (icon_view->details->react_to_icon_change_idle_id != 0) { - g_source_remove (icon_view->details->react_to_icon_change_idle_id); - icon_view->details->react_to_icon_change_idle_id = 0; - } - - if (icon_view->details->clipboard_handler_id != 0) { - g_signal_handler_disconnect (nautilus_clipboard_monitor_get (), - icon_view->details->clipboard_handler_id); - icon_view->details->clipboard_handler_id = 0; - } - - if (icon_view->details->icons_not_positioned) { - nautilus_file_list_free (icon_view->details->icons_not_positioned); - icon_view->details->icons_not_positioned = NULL; - } - - GTK_WIDGET_CLASS (nautilus_icon_view_parent_class)->destroy (object); -} - -static NautilusIconContainer * -get_icon_container (NautilusIconView *icon_view) -{ - return NAUTILUS_ICON_CONTAINER (icon_view->details->icon_container); -} - -NautilusIconContainer * -nautilus_icon_view_get_icon_container (NautilusIconView *icon_view) -{ - return get_icon_container (icon_view); -} - -static gboolean -nautilus_icon_view_supports_manual_layout (NautilusIconView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), FALSE); - - return TRUE; -} - -static gboolean -get_stored_icon_position_callback (NautilusIconContainer *container, - NautilusFile *file, - NautilusIconPosition *position, - NautilusIconView *icon_view) -{ - char *position_string, *scale_string; - gboolean position_good; - char c; - - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); - g_assert (NAUTILUS_IS_FILE (file)); - g_assert (position != NULL); - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - - if (!nautilus_icon_view_supports_manual_layout (icon_view)) { - return FALSE; - } - - /* Get the current position of this icon from the metadata. */ - position_string = nautilus_file_get_metadata - (file, NAUTILUS_METADATA_KEY_ICON_POSITION, ""); - position_good = sscanf - (position_string, " %d , %d %c", - &position->x, &position->y, &c) == 2; - g_free (position_string); - - /* If it is the desktop directory, maybe the gnome-libs metadata has information about it */ - - /* Disable scaling if not on the desktop */ - if (nautilus_icon_view_supports_scaling (icon_view)) { - /* Get the scale of the icon from the metadata. */ - scale_string = nautilus_file_get_metadata - (file, NAUTILUS_METADATA_KEY_ICON_SCALE, "1"); - position->scale = g_ascii_strtod (scale_string, NULL); - if (errno != 0) { - position->scale = 1.0; - } - - g_free (scale_string); - } else { - position->scale = 1.0; - } - - return position_good; -} - -static void -real_set_sort_criterion (NautilusIconView *icon_view, - const SortCriterion *sort, - gboolean clear, - gboolean set_metadata) -{ - NautilusFile *file; - - file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (icon_view)); - - if (clear) { - nautilus_file_set_metadata (file, - NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY, NULL, NULL); - nautilus_file_set_metadata (file, - NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_REVERSED, NULL, NULL); - icon_view->details->sort = - get_sort_criterion_by_sort_type (get_default_sort_order - (file, &icon_view->details->sort_reversed)); - } else if (set_metadata) { - /* Store the new sort setting. */ - nautilus_icon_view_set_directory_sort_by (icon_view, - file, - sort->metadata_text); - } - - /* Update the layout menus to match the new sort setting. */ - update_layout_menus (icon_view); -} - -static void -set_sort_criterion (NautilusIconView *icon_view, - const SortCriterion *sort, - gboolean set_metadata) -{ - if (sort == NULL || - icon_view->details->sort == sort) { - return; - } - - icon_view->details->sort = sort; - - real_set_sort_criterion (icon_view, sort, FALSE, set_metadata); -} - -static void -clear_sort_criterion (NautilusIconView *icon_view) -{ - real_set_sort_criterion (icon_view, NULL, TRUE, TRUE); -} - -static void -action_stretch_callback (GtkAction *action, - gpointer callback_data) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (callback_data)); - - nautilus_icon_container_show_stretch_handles - (get_icon_container (NAUTILUS_ICON_VIEW (callback_data))); -} - -static void -action_unstretch_callback (GtkAction *action, - gpointer callback_data) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (callback_data)); - - nautilus_icon_container_unstretch - (get_icon_container (NAUTILUS_ICON_VIEW (callback_data))); -} - -static void -nautilus_icon_view_clean_up (NautilusIconView *icon_view) -{ - NautilusIconContainer *icon_container; - gboolean saved_sort_reversed; - - icon_container = get_icon_container (icon_view); - - /* Hardwire Clean Up to always be by name, in forward order */ - saved_sort_reversed = icon_view->details->sort_reversed; - - set_sort_reversed (icon_view, FALSE, FALSE); - set_sort_criterion (icon_view, &sort_criteria[0], FALSE); - - nautilus_icon_container_sort (icon_container); - nautilus_icon_container_freeze_icon_positions (icon_container); - - set_sort_reversed (icon_view, saved_sort_reversed, FALSE); -} - -static void -action_clean_up_callback (GtkAction *action, gpointer callback_data) -{ - nautilus_icon_view_clean_up (NAUTILUS_ICON_VIEW (callback_data)); -} - -static gboolean -nautilus_icon_view_using_auto_layout (NautilusIconView *icon_view) -{ - return nautilus_icon_container_is_auto_layout - (get_icon_container (icon_view)); -} - -static void -action_sort_radio_callback (GtkAction *action, - GtkRadioAction *current, - NautilusIconView *view) -{ - NautilusFileSortType sort_type; - - sort_type = gtk_radio_action_get_current_value (current); - - /* Note that id might be a toggle item. - * Ignore non-sort ids so that they don't cause sorting. - */ - if (sort_type == NAUTILUS_FILE_SORT_NONE) { - switch_to_manual_layout (view); - } else { - set_sort_criterion_by_sort_type (view, sort_type); - } -} - -static void -list_covers (NautilusIconData *data, gpointer callback_data) -{ - GSList **file_list; - - file_list = callback_data; - - *file_list = g_slist_prepend (*file_list, data); -} - -static void -unref_cover (NautilusIconData *data, gpointer callback_data) -{ - nautilus_file_unref (NAUTILUS_FILE (data)); -} - -static void -nautilus_icon_view_clear (NautilusView *view) -{ - NautilusIconContainer *icon_container; - GSList *file_list; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (view)); - - icon_container = get_icon_container (NAUTILUS_ICON_VIEW (view)); - if (!icon_container) - return; - - /* Clear away the existing icons. */ - file_list = NULL; - nautilus_icon_container_for_each (icon_container, list_covers, &file_list); - nautilus_icon_container_clear (icon_container); - g_slist_foreach (file_list, (GFunc)unref_cover, NULL); - g_slist_free (file_list); -} - -static gboolean -should_show_file_on_screen (NautilusView *view, NautilusFile *file) -{ - char *screen_string; - int screen_num; - NautilusIconView *icon_view; - GdkScreen *screen; - - icon_view = NAUTILUS_ICON_VIEW (view); - - if (!nautilus_view_should_show_file (view, file)) { - return FALSE; - } - - /* Get the screen for this icon from the metadata. */ - screen_string = nautilus_file_get_metadata - (file, NAUTILUS_METADATA_KEY_SCREEN, "0"); - screen_num = atoi (screen_string); - g_free (screen_string); - screen = gtk_widget_get_screen (GTK_WIDGET (view)); - - if (screen_num != gdk_screen_get_number (screen) && - (screen_num < icon_view->details->num_screens || - gdk_screen_get_number (screen) > 0)) { - return FALSE; - } - - return TRUE; -} - -static void -nautilus_icon_view_remove_file (NautilusView *view, NautilusFile *file, NautilusDirectory *directory) -{ - NautilusIconView *icon_view; - - /* This used to assert that 'directory == nautilus_view_get_model (view)', but that - * resulted in a lot of crash reports (bug #352592). I don't see how that trace happens. - * It seems that somehow we get a files_changed event sent to the view from a directory - * that isn't the model, but the code disables the monitor and signal callback handlers when - * changing directories. Maybe we can get some more information when this happens. - * Further discussion in bug #368178. - */ - if (directory != nautilus_view_get_model (view)) { - char *file_uri, *dir_uri, *model_uri; - file_uri = nautilus_file_get_uri (file); - dir_uri = nautilus_directory_get_uri (directory); - model_uri = nautilus_directory_get_uri (nautilus_view_get_model (view)); - g_warning ("nautilus_icon_view_remove_file() - directory not icon view model, shouldn't happen.\n" - "file: %p:%s, dir: %p:%s, model: %p:%s, view loading: %d\n" - "If you see this, please add this info to http://bugzilla.gnome.org/show_bug.cgi?id=368178", - file, file_uri, directory, dir_uri, nautilus_view_get_model (view), model_uri, nautilus_view_get_loading (view)); - g_free (file_uri); - g_free (dir_uri); - g_free (model_uri); - } - - icon_view = NAUTILUS_ICON_VIEW (view); - - if (nautilus_icon_container_remove (get_icon_container (icon_view), - NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) { - nautilus_file_unref (file); - } -} - -static void -nautilus_icon_view_add_file (NautilusView *view, NautilusFile *file, NautilusDirectory *directory) -{ - NautilusIconView *icon_view; - NautilusIconContainer *icon_container; - - g_assert (directory == nautilus_view_get_model (view)); - - icon_view = NAUTILUS_ICON_VIEW (view); - icon_container = get_icon_container (icon_view); - - if (icon_view->details->filter_by_screen && - !should_show_file_on_screen (view, file)) { - return; - } - - /* Reset scroll region for the first icon added when loading a directory. */ - if (nautilus_view_get_loading (view) && nautilus_icon_container_is_empty (icon_container)) { - nautilus_icon_container_reset_scroll_region (icon_container); - } - - if (nautilus_icon_container_add (icon_container, - NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) { - nautilus_file_ref (file); - } -} - -static void -nautilus_icon_view_file_changed (NautilusView *view, NautilusFile *file, NautilusDirectory *directory) -{ - NautilusIconView *icon_view; - - g_assert (directory == nautilus_view_get_model (view)); - - g_return_if_fail (view != NULL); - icon_view = NAUTILUS_ICON_VIEW (view); - - if (!icon_view->details->filter_by_screen) { - nautilus_icon_container_request_update - (get_icon_container (icon_view), - NAUTILUS_ICON_CONTAINER_ICON_DATA (file)); - return; - } - - if (!should_show_file_on_screen (view, file)) { - nautilus_icon_view_remove_file (view, file, directory); - } else { - - nautilus_icon_container_request_update - (get_icon_container (icon_view), - NAUTILUS_ICON_CONTAINER_ICON_DATA (file)); - } -} - -static gboolean -nautilus_icon_view_supports_auto_layout (NautilusIconView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), FALSE); - - return view->details->supports_auto_layout; -} - -static gboolean -nautilus_icon_view_supports_scaling (NautilusIconView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), FALSE); - - return view->details->supports_scaling; -} - -static gboolean -nautilus_icon_view_supports_keep_aligned (NautilusIconView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), FALSE); - - return view->details->supports_keep_aligned; -} - -static void -update_layout_menus (NautilusIconView *view) -{ - gboolean is_auto_layout; - GtkAction *action; - const char *action_name; - NautilusFile *file; - - if (view->details->icon_action_group == NULL) { - return; - } - - is_auto_layout = nautilus_icon_view_using_auto_layout (view); - file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (view)); - - if (nautilus_icon_view_supports_auto_layout (view)) { - /* Mark sort criterion. */ - action_name = is_auto_layout ? view->details->sort->action : NAUTILUS_ACTION_MANUAL_LAYOUT; - action = gtk_action_group_get_action (view->details->icon_action_group, - action_name); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); - - action = gtk_action_group_get_action (view->details->icon_action_group, - NAUTILUS_ACTION_REVERSED_ORDER); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), - view->details->sort_reversed); - gtk_action_set_sensitive (action, is_auto_layout); - - action = gtk_action_group_get_action (view->details->icon_action_group, - NAUTILUS_ACTION_SORT_TRASH_TIME); - - if (file != NULL && nautilus_file_is_in_trash (file)) { - gtk_action_set_visible (action, TRUE); - } else { - gtk_action_set_visible (action, FALSE); - } - } - - action = gtk_action_group_get_action (view->details->icon_action_group, - NAUTILUS_ACTION_MANUAL_LAYOUT); - gtk_action_set_visible (action, - nautilus_icon_view_supports_manual_layout (view)); - - /* Clean Up is only relevant for manual layout */ - action = gtk_action_group_get_action (view->details->icon_action_group, - NAUTILUS_ACTION_CLEAN_UP); - gtk_action_set_sensitive (action, !is_auto_layout); - - if (NAUTILUS_IS_DESKTOP_ICON_VIEW (view)) { - gtk_action_set_label (action, _("_Organize Desktop by Name")); - } - - action = gtk_action_group_get_action (view->details->icon_action_group, - NAUTILUS_ACTION_KEEP_ALIGNED); - gtk_action_set_visible (action, - nautilus_icon_view_supports_keep_aligned (view)); - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), - nautilus_icon_container_is_keep_aligned (get_icon_container (view))); - gtk_action_set_sensitive (action, !is_auto_layout); -} - - -static char * -nautilus_icon_view_get_directory_sort_by (NautilusIconView *icon_view, - NautilusFile *file) -{ - const SortCriterion *default_sort_criterion; - - if (!nautilus_icon_view_supports_auto_layout (icon_view)) { - return g_strdup ("name"); - } - - default_sort_criterion = get_sort_criterion_by_sort_type (get_default_sort_order (file, NULL)); - g_return_val_if_fail (default_sort_criterion != NULL, NULL); - - return nautilus_file_get_metadata - (file, NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY, - default_sort_criterion->metadata_text); -} - -static NautilusFileSortType -get_default_sort_order (NautilusFile *file, gboolean *reversed) -{ - NautilusFileSortType retval, default_sort_order; - gboolean default_sort_in_reverse_order; - - default_sort_order = g_settings_get_enum (nautilus_preferences, - NAUTILUS_PREFERENCES_DEFAULT_SORT_ORDER); - default_sort_in_reverse_order = g_settings_get_boolean (nautilus_preferences, - NAUTILUS_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER); - - retval = nautilus_file_get_default_sort_type (file, reversed); - - if (retval == NAUTILUS_FILE_SORT_NONE) { - - if (reversed != NULL) { - *reversed = default_sort_in_reverse_order; - } - - retval = CLAMP (default_sort_order, NAUTILUS_FILE_SORT_BY_DISPLAY_NAME, - NAUTILUS_FILE_SORT_BY_MTIME); - } - - return retval; -} - -static void -nautilus_icon_view_set_directory_sort_by (NautilusIconView *icon_view, - NautilusFile *file, - const char *sort_by) -{ - const SortCriterion *default_sort_criterion; - - if (!nautilus_icon_view_supports_auto_layout (icon_view)) { - return; - } - - default_sort_criterion = get_sort_criterion_by_sort_type (get_default_sort_order (file, NULL)); - g_return_if_fail (default_sort_criterion != NULL); - - nautilus_file_set_metadata - (file, NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY, - default_sort_criterion->metadata_text, - sort_by); -} - -static gboolean -nautilus_icon_view_get_directory_sort_reversed (NautilusIconView *icon_view, - NautilusFile *file) -{ - gboolean reversed; - - if (!nautilus_icon_view_supports_auto_layout (icon_view)) { - return FALSE; - } - - get_default_sort_order (file, &reversed); - return nautilus_file_get_boolean_metadata - (file, - NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_REVERSED, - reversed); -} - -static void -nautilus_icon_view_set_directory_sort_reversed (NautilusIconView *icon_view, - NautilusFile *file, - gboolean sort_reversed) -{ - gboolean reversed; - - if (!nautilus_icon_view_supports_auto_layout (icon_view)) { - return; - } - - get_default_sort_order (file, &reversed); - nautilus_file_set_boolean_metadata - (file, - NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_REVERSED, - reversed, sort_reversed); -} - -static gboolean -get_default_directory_keep_aligned (void) -{ - return TRUE; -} - -static gboolean -nautilus_icon_view_get_directory_keep_aligned (NautilusIconView *icon_view, - NautilusFile *file) -{ - if (!nautilus_icon_view_supports_keep_aligned (icon_view)) { - return FALSE; - } - - return nautilus_file_get_boolean_metadata - (file, - NAUTILUS_METADATA_KEY_ICON_VIEW_KEEP_ALIGNED, - get_default_directory_keep_aligned ()); -} - -static void -nautilus_icon_view_set_directory_keep_aligned (NautilusIconView *icon_view, - NautilusFile *file, - gboolean keep_aligned) -{ - if (!nautilus_icon_view_supports_keep_aligned (icon_view)) { - return; - } - - nautilus_file_set_boolean_metadata - (file, NAUTILUS_METADATA_KEY_ICON_VIEW_KEEP_ALIGNED, - get_default_directory_keep_aligned (), - keep_aligned); -} - -static gboolean -nautilus_icon_view_get_directory_auto_layout (NautilusIconView *icon_view, - NautilusFile *file) -{ - if (!nautilus_icon_view_supports_auto_layout (icon_view)) { - return FALSE; - } - - if (!nautilus_icon_view_supports_manual_layout (icon_view)) { - return TRUE; - } - - return nautilus_file_get_boolean_metadata - (file, NAUTILUS_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT, TRUE); -} - -static void -nautilus_icon_view_set_directory_auto_layout (NautilusIconView *icon_view, - NautilusFile *file, - gboolean auto_layout) -{ - if (!nautilus_icon_view_supports_auto_layout (icon_view) || - !nautilus_icon_view_supports_manual_layout (icon_view)) { - return; - } - - nautilus_file_set_boolean_metadata - (file, NAUTILUS_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT, - TRUE, - auto_layout); -} - -static gboolean -set_sort_reversed (NautilusIconView *icon_view, - gboolean new_value, - gboolean set_metadata) -{ - if (icon_view->details->sort_reversed == new_value) { - return FALSE; - } - icon_view->details->sort_reversed = new_value; - - if (set_metadata) { - /* Store the new sort setting. */ - nautilus_icon_view_set_directory_sort_reversed (icon_view, nautilus_view_get_directory_as_file (NAUTILUS_VIEW (icon_view)), new_value); - } - - /* Update the layout menus to match the new sort-order setting. */ - update_layout_menus (icon_view); - - return TRUE; -} - -static const SortCriterion * -get_sort_criterion_by_metadata_text (const char *metadata_text) -{ - guint i; - - /* Figure out what the new sort setting should be. */ - for (i = 0; i < G_N_ELEMENTS (sort_criteria); i++) { - if (strcmp (sort_criteria[i].metadata_text, metadata_text) == 0) { - return &sort_criteria[i]; - } - } - return NULL; -} - -static const SortCriterion * -get_sort_criterion_by_sort_type (NautilusFileSortType sort_type) -{ - guint i; - - /* Figure out what the new sort setting should be. */ - for (i = 0; i < G_N_ELEMENTS (sort_criteria); i++) { - if (sort_type == sort_criteria[i].sort_type) { - return &sort_criteria[i]; - } - } - - return &sort_criteria[0]; -} - -#define DEFAULT_ZOOM_LEVEL(icon_view) default_zoom_level - -static NautilusZoomLevel -get_default_zoom_level (NautilusIconView *icon_view) -{ - NautilusZoomLevel default_zoom_level; - - default_zoom_level = g_settings_get_enum (nautilus_icon_view_preferences, - NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL); - - return CLAMP (DEFAULT_ZOOM_LEVEL(icon_view), NAUTILUS_ZOOM_LEVEL_SMALLEST, NAUTILUS_ZOOM_LEVEL_LARGEST); -} - -static void -nautilus_icon_view_begin_loading (NautilusView *view) -{ - NautilusIconView *icon_view; - GtkWidget *icon_container; - NautilusFile *file; - int level; - char *sort_name, *uri; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (view)); - - icon_view = NAUTILUS_ICON_VIEW (view); - file = nautilus_view_get_directory_as_file (view); - uri = nautilus_file_get_uri (file); - icon_container = GTK_WIDGET (get_icon_container (icon_view)); - - nautilus_icon_container_begin_loading (NAUTILUS_ICON_CONTAINER (icon_container)); - - nautilus_icon_container_set_allow_moves (NAUTILUS_ICON_CONTAINER (icon_container), - !eel_uri_is_search (uri)); - - g_free (uri); - - /* Set up the zoom level from the metadata. */ - if (nautilus_view_supports_zooming (NAUTILUS_VIEW (icon_view))) { - level = nautilus_file_get_integer_metadata (file, - NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL, - get_default_zoom_level (icon_view)); - nautilus_icon_view_set_zoom_level (icon_view, level, TRUE); - } - - /* Set the sort mode. - * It's OK not to resort the icons because the - * container doesn't have any icons at this point. - */ - sort_name = nautilus_icon_view_get_directory_sort_by (icon_view, file); - set_sort_criterion (icon_view, get_sort_criterion_by_metadata_text (sort_name), FALSE); - g_free (sort_name); - - /* Set the sort direction from the metadata. */ - set_sort_reversed (icon_view, nautilus_icon_view_get_directory_sort_reversed (icon_view, file), FALSE); - - nautilus_icon_container_set_keep_aligned - (get_icon_container (icon_view), - nautilus_icon_view_get_directory_keep_aligned (icon_view, file)); - - /* We must set auto-layout last, because it invokes the layout_changed - * callback, which works incorrectly if the other layout criteria are - * not already set up properly (see bug 6500, e.g.) - */ - nautilus_icon_container_set_auto_layout - (get_icon_container (icon_view), - nautilus_icon_view_get_directory_auto_layout (icon_view, file)); - - /* e.g. keep aligned may have changed */ - update_layout_menus (icon_view); -} - -static void -icon_view_notify_clipboard_info (NautilusClipboardMonitor *monitor, - NautilusClipboardInfo *info, - NautilusIconView *icon_view) -{ - GList *icon_data; - - icon_data = NULL; - if (info && info->cut) { - icon_data = info->files; - } - - nautilus_icon_container_set_highlighted_for_clipboard ( - get_icon_container (icon_view), icon_data); -} - -static void -nautilus_icon_view_end_loading (NautilusView *view, - gboolean all_files_seen) -{ - NautilusIconView *icon_view; - GtkWidget *icon_container; - NautilusClipboardMonitor *monitor; - NautilusClipboardInfo *info; - - icon_view = NAUTILUS_ICON_VIEW (view); - - icon_container = GTK_WIDGET (get_icon_container (icon_view)); - nautilus_icon_container_end_loading (NAUTILUS_ICON_CONTAINER (icon_container), all_files_seen); - - monitor = nautilus_clipboard_monitor_get (); - info = nautilus_clipboard_monitor_get_clipboard_info (monitor); - - icon_view_notify_clipboard_info (monitor, info, icon_view); -} - -static NautilusZoomLevel -nautilus_icon_view_get_zoom_level (NautilusView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), NAUTILUS_ZOOM_LEVEL_STANDARD); - - return nautilus_icon_container_get_zoom_level (get_icon_container (NAUTILUS_ICON_VIEW (view))); -} - -static void -nautilus_icon_view_set_zoom_level (NautilusIconView *view, - NautilusZoomLevel new_level, - gboolean always_emit) -{ - NautilusIconContainer *icon_container; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (view)); - g_return_if_fail (new_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST && - new_level <= NAUTILUS_ZOOM_LEVEL_LARGEST); - - icon_container = get_icon_container (view); - if (nautilus_icon_container_get_zoom_level (icon_container) == new_level) { - if (always_emit) { - g_signal_emit_by_name (view, "zoom_level_changed"); - } - return; - } - - nautilus_file_set_integer_metadata - (nautilus_view_get_directory_as_file (NAUTILUS_VIEW (view)), - NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL, - get_default_zoom_level (view), - new_level); - - nautilus_icon_container_set_zoom_level (icon_container, new_level); - - g_signal_emit_by_name (view, "zoom_level_changed"); - - if (nautilus_view_get_active (NAUTILUS_VIEW (view))) { - nautilus_view_update_menus (NAUTILUS_VIEW (view)); - } -} - -static void -nautilus_icon_view_bump_zoom_level (NautilusView *view, int zoom_increment) -{ - NautilusZoomLevel new_level; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (view)); - - new_level = nautilus_icon_view_get_zoom_level (view) + zoom_increment; - - if (new_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST && - new_level <= NAUTILUS_ZOOM_LEVEL_LARGEST) { - nautilus_view_zoom_to_level (view, new_level); - } -} - -static void -nautilus_icon_view_zoom_to_level (NautilusView *view, - NautilusZoomLevel zoom_level) -{ - NautilusIconView *icon_view; - - g_assert (NAUTILUS_IS_ICON_VIEW (view)); - - icon_view = NAUTILUS_ICON_VIEW (view); - nautilus_icon_view_set_zoom_level (icon_view, zoom_level, FALSE); -} - -static void -nautilus_icon_view_restore_default_zoom_level (NautilusView *view) -{ - NautilusIconView *icon_view; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (view)); - - icon_view = NAUTILUS_ICON_VIEW (view); - nautilus_view_zoom_to_level - (view, get_default_zoom_level (icon_view)); -} - -static gboolean -nautilus_icon_view_can_zoom_in (NautilusView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), FALSE); - - return nautilus_icon_view_get_zoom_level (view) - < NAUTILUS_ZOOM_LEVEL_LARGEST; -} - -static gboolean -nautilus_icon_view_can_zoom_out (NautilusView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), FALSE); - - return nautilus_icon_view_get_zoom_level (view) - > NAUTILUS_ZOOM_LEVEL_SMALLEST; -} - -static gboolean -nautilus_icon_view_is_empty (NautilusView *view) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (view)); - - return nautilus_icon_container_is_empty - (get_icon_container (NAUTILUS_ICON_VIEW (view))); -} - -static GList * -nautilus_icon_view_get_selection (NautilusView *view) -{ - GList *list; - - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), NULL); - - list = nautilus_icon_container_get_selection - (get_icon_container (NAUTILUS_ICON_VIEW (view))); - nautilus_file_list_ref (list); - return list; -} - -static void -count_item (NautilusIconData *icon_data, - gpointer callback_data) -{ - guint *count; - - count = callback_data; - (*count)++; -} - -static guint -nautilus_icon_view_get_item_count (NautilusView *view) -{ - guint count; - - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), 0); - - count = 0; - - nautilus_icon_container_for_each - (get_icon_container (NAUTILUS_ICON_VIEW (view)), - count_item, &count); - - return count; -} - -static void -set_sort_criterion_by_sort_type (NautilusIconView *icon_view, - NautilusFileSortType sort_type) -{ - const SortCriterion *sort; - - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - - sort = get_sort_criterion_by_sort_type (sort_type); - g_return_if_fail (sort != NULL); - - if (sort == icon_view->details->sort - && nautilus_icon_view_using_auto_layout (icon_view)) { - return; - } - - set_sort_criterion (icon_view, sort, TRUE); - nautilus_icon_container_sort (get_icon_container (icon_view)); - nautilus_icon_view_reveal_selection (NAUTILUS_VIEW (icon_view)); -} - - -static void -action_reversed_order_callback (GtkAction *action, - gpointer user_data) -{ - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (user_data); - - if (set_sort_reversed (icon_view, - gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)), - TRUE)) { - nautilus_icon_container_sort (get_icon_container (icon_view)); - nautilus_icon_view_reveal_selection (NAUTILUS_VIEW (icon_view)); - } -} - -static void -action_keep_aligned_callback (GtkAction *action, - gpointer user_data) -{ - NautilusIconView *icon_view; - NautilusFile *file; - gboolean keep_aligned; - - icon_view = NAUTILUS_ICON_VIEW (user_data); - - keep_aligned = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); - - file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (icon_view)); - nautilus_icon_view_set_directory_keep_aligned (icon_view, - file, - keep_aligned); - - nautilus_icon_container_set_keep_aligned (get_icon_container (icon_view), - keep_aligned); -} - -static void -switch_to_manual_layout (NautilusIconView *icon_view) -{ - if (!nautilus_icon_view_using_auto_layout (icon_view)) { - return; - } - - icon_view->details->sort = &sort_criteria[0]; - - nautilus_icon_container_set_auto_layout - (get_icon_container (icon_view), FALSE); -} - -static void -layout_changed_callback (NautilusIconContainer *container, - NautilusIconView *icon_view) -{ - NautilusFile *file; - - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - g_assert (container == get_icon_container (icon_view)); - - file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (icon_view)); - - if (file != NULL) { - nautilus_icon_view_set_directory_auto_layout - (icon_view, - file, - nautilus_icon_view_using_auto_layout (icon_view)); - } - - update_layout_menus (icon_view); -} - -static gboolean -nautilus_icon_view_can_rename_file (NautilusView *view, NautilusFile *file) -{ - if (!(nautilus_icon_view_get_zoom_level (view) > NAUTILUS_ZOOM_LEVEL_SMALLEST)) { - return FALSE; - } - - return NAUTILUS_VIEW_CLASS(nautilus_icon_view_parent_class)->can_rename_file (view, file); -} - -static void -nautilus_icon_view_start_renaming_file (NautilusView *view, - NautilusFile *file, - gboolean select_all) -{ - /* call parent class to make sure the right icon is selected */ - NAUTILUS_VIEW_CLASS(nautilus_icon_view_parent_class)->start_renaming_file (view, file, select_all); - - /* start renaming */ - nautilus_icon_container_start_renaming_selected_item - (get_icon_container (NAUTILUS_ICON_VIEW (view)), select_all); -} - -static const GtkActionEntry icon_view_entries[] = { - /* name, stock id, label */ { "Arrange Items", NULL, N_("Arran_ge Items") }, - /* name, stock id */ { "Stretch", NULL, - /* label, accelerator */ N_("Resize Icon..."), NULL, - /* tooltip */ N_("Make the selected icon resizable"), - G_CALLBACK (action_stretch_callback) }, - /* name, stock id */ { "Unstretch", NULL, - /* label, accelerator */ N_("Restore Icons' Original Si_zes"), NULL, - /* tooltip */ N_("Restore each selected icon to its original size"), - G_CALLBACK (action_unstretch_callback) }, - /* name, stock id */ { "Clean Up", NULL, - /* label, accelerator */ N_("_Organize by Name"), NULL, - /* tooltip */ N_("Reposition icons to better fit in the window and avoid overlapping"), - G_CALLBACK (action_clean_up_callback) }, -}; - -static const GtkToggleActionEntry icon_view_toggle_entries[] = { - /* name, stock id */ { "Reversed Order", NULL, - /* label, accelerator */ N_("Re_versed Order"), NULL, - /* tooltip */ N_("Display icons in the opposite order"), - G_CALLBACK (action_reversed_order_callback), - 0 }, - /* name, stock id */ { "Keep Aligned", NULL, - /* label, accelerator */ N_("_Keep Aligned"), NULL, - /* tooltip */ N_("Keep icons lined up on a grid"), - G_CALLBACK (action_keep_aligned_callback), - 0 }, -}; - -static const GtkRadioActionEntry arrange_radio_entries[] = { - { "Manual Layout", NULL, - N_("_Manually"), NULL, - N_("Leave icons wherever they are dropped"), - NAUTILUS_FILE_SORT_NONE }, - { "Sort by Name", NULL, - N_("By _Name"), NULL, - N_("Keep icons sorted by name in rows"), - NAUTILUS_FILE_SORT_BY_DISPLAY_NAME }, - { "Sort by Size", NULL, - N_("By _Size"), NULL, - N_("Keep icons sorted by size in rows"), - NAUTILUS_FILE_SORT_BY_SIZE }, - { "Sort by Type", NULL, - N_("By _Type"), NULL, - N_("Keep icons sorted by type in rows"), - NAUTILUS_FILE_SORT_BY_TYPE }, - { "Sort by Modification Date", NULL, - N_("By Modification _Date"), NULL, - N_("Keep icons sorted by modification date in rows"), - NAUTILUS_FILE_SORT_BY_MTIME }, - { "Sort by Trash Time", NULL, - N_("By T_rash Time"), NULL, - N_("Keep icons sorted by trash time in rows"), - NAUTILUS_FILE_SORT_BY_TRASHED_TIME }, -}; - -static void -nautilus_icon_view_merge_menus (NautilusView *view) -{ - NautilusIconView *icon_view; - GtkUIManager *ui_manager; - GtkActionGroup *action_group; - GtkAction *action; - - g_assert (NAUTILUS_IS_ICON_VIEW (view)); - - NAUTILUS_VIEW_CLASS (nautilus_icon_view_parent_class)->merge_menus (view); - - icon_view = NAUTILUS_ICON_VIEW (view); - - ui_manager = nautilus_view_get_ui_manager (NAUTILUS_VIEW (icon_view)); - - action_group = gtk_action_group_new ("IconViewActions"); - gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); - icon_view->details->icon_action_group = action_group; - gtk_action_group_add_actions (action_group, - icon_view_entries, G_N_ELEMENTS (icon_view_entries), - icon_view); - gtk_action_group_add_toggle_actions (action_group, - icon_view_toggle_entries, G_N_ELEMENTS (icon_view_toggle_entries), - icon_view); - gtk_action_group_add_radio_actions (action_group, - arrange_radio_entries, - G_N_ELEMENTS (arrange_radio_entries), - -1, - G_CALLBACK (action_sort_radio_callback), - icon_view); - - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - g_object_unref (action_group); /* owned by ui manager */ - - icon_view->details->icon_merge_id = - gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-icon-view-ui.xml", NULL); - - /* Do one-time state-setting here; context-dependent state-setting - * is done in update_menus. - */ - if (!nautilus_icon_view_supports_auto_layout (icon_view)) { - action = gtk_action_group_get_action (action_group, - NAUTILUS_ACTION_ARRANGE_ITEMS); - gtk_action_set_visible (action, FALSE); - } - - if (nautilus_icon_view_supports_scaling (icon_view)) { - gtk_ui_manager_add_ui (ui_manager, - icon_view->details->icon_merge_id, - POPUP_PATH_ICON_APPEARANCE, - NAUTILUS_ACTION_STRETCH, - NAUTILUS_ACTION_STRETCH, - GTK_UI_MANAGER_MENUITEM, - FALSE); - gtk_ui_manager_add_ui (ui_manager, - icon_view->details->icon_merge_id, - POPUP_PATH_ICON_APPEARANCE, - NAUTILUS_ACTION_UNSTRETCH, - NAUTILUS_ACTION_UNSTRETCH, - GTK_UI_MANAGER_MENUITEM, - FALSE); - } - - update_layout_menus (icon_view); -} - -static void -nautilus_icon_view_unmerge_menus (NautilusView *view) -{ - NautilusIconView *icon_view; - GtkUIManager *ui_manager; - - icon_view = NAUTILUS_ICON_VIEW (view); - - NAUTILUS_VIEW_CLASS (nautilus_icon_view_parent_class)->unmerge_menus (view); - - ui_manager = nautilus_view_get_ui_manager (view); - if (ui_manager != NULL) { - nautilus_ui_unmerge_ui (ui_manager, - &icon_view->details->icon_merge_id, - &icon_view->details->icon_action_group); - } -} - -static void -nautilus_icon_view_update_menus (NautilusView *view) -{ - NautilusIconView *icon_view; - int selection_count; - GtkAction *action; - NautilusIconContainer *icon_container; - gboolean editable; - - icon_view = NAUTILUS_ICON_VIEW (view); - - NAUTILUS_VIEW_CLASS (nautilus_icon_view_parent_class)->update_menus(view); - - selection_count = nautilus_view_get_selection_count (view); - icon_container = get_icon_container (icon_view); - - action = gtk_action_group_get_action (icon_view->details->icon_action_group, - NAUTILUS_ACTION_STRETCH); - gtk_action_set_sensitive (action, - selection_count == 1 - && icon_container != NULL - && !nautilus_icon_container_has_stretch_handles (icon_container)); - - gtk_action_set_visible (action, - nautilus_icon_view_supports_scaling (icon_view)); - - action = gtk_action_group_get_action (icon_view->details->icon_action_group, - NAUTILUS_ACTION_UNSTRETCH); - g_object_set (action, "label", - (selection_count > 1) - ? _("Restore Icons' Original Si_zes") - : _("Restore Icon's Original Si_ze"), - NULL); - gtk_action_set_sensitive (action, - icon_container != NULL - && nautilus_icon_container_is_stretched (icon_container)); - - gtk_action_set_visible (action, - nautilus_icon_view_supports_scaling (icon_view)); - - editable = nautilus_view_is_editable (view); - action = gtk_action_group_get_action (icon_view->details->icon_action_group, - NAUTILUS_ACTION_MANUAL_LAYOUT); - gtk_action_set_sensitive (action, editable); -} - -static void -nautilus_icon_view_reset_to_defaults (NautilusView *view) -{ - NautilusIconContainer *icon_container; - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (view); - icon_container = get_icon_container (icon_view); - - clear_sort_criterion (icon_view); - nautilus_icon_container_set_keep_aligned - (icon_container, get_default_directory_keep_aligned ()); - - nautilus_icon_container_sort (icon_container); - - update_layout_menus (icon_view); - - nautilus_icon_view_restore_default_zoom_level (view); -} - -static void -nautilus_icon_view_select_all (NautilusView *view) -{ - NautilusIconContainer *icon_container; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (view)); - - icon_container = get_icon_container (NAUTILUS_ICON_VIEW (view)); - nautilus_icon_container_select_all (icon_container); -} - -static void -nautilus_icon_view_reveal_selection (NautilusView *view) -{ - GList *selection; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (view)); - - selection = nautilus_view_get_selection (view); - - /* Make sure at least one of the selected items is scrolled into view */ - if (selection != NULL) { - nautilus_icon_container_reveal - (get_icon_container (NAUTILUS_ICON_VIEW (view)), - selection->data); - } - - nautilus_file_list_free (selection); -} - -static GArray * -nautilus_icon_view_get_selected_icon_locations (NautilusView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), NULL); - - return nautilus_icon_container_get_selected_icon_locations - (get_icon_container (NAUTILUS_ICON_VIEW (view))); -} - - -static void -nautilus_icon_view_set_selection (NautilusView *view, GList *selection) -{ - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (view)); - - nautilus_icon_container_set_selection - (get_icon_container (NAUTILUS_ICON_VIEW (view)), selection); -} - -static void -nautilus_icon_view_invert_selection (NautilusView *view) -{ - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (view)); - - nautilus_icon_container_invert_selection - (get_icon_container (NAUTILUS_ICON_VIEW (view))); -} - -static gboolean -nautilus_icon_view_using_manual_layout (NautilusView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (view), FALSE); - - return !nautilus_icon_view_using_auto_layout (NAUTILUS_ICON_VIEW (view)); -} - -static void -nautilus_icon_view_widget_to_file_operation_position (NautilusView *view, - GdkPoint *position) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (view)); - - nautilus_icon_container_widget_to_file_operation_position - (get_icon_container (NAUTILUS_ICON_VIEW (view)), position); -} - -static void -icon_container_activate_callback (NautilusIconContainer *container, - GList *file_list, - NautilusIconView *icon_view) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - g_assert (container == get_icon_container (icon_view)); - - nautilus_view_activate_files (NAUTILUS_VIEW (icon_view), - file_list, - 0, TRUE); -} - -static void -icon_container_activate_previewer_callback (NautilusIconContainer *container, - GList *file_list, - GArray *locations, - NautilusIconView *icon_view) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - g_assert (container == get_icon_container (icon_view)); - - nautilus_view_preview_files (NAUTILUS_VIEW (icon_view), - file_list, locations); -} - -/* this is called in one of these cases: - * - we activate with enter holding shift - * - we activate with space holding shift - * - we double click an icon holding shift - * - we middle click an icon - * - * If we don't open in new windows by default, the behavior should be - * - middle click, shift + activate -> open in new tab - * - shift + double click -> open in new window - * - * If we open in new windows by default, the behaviour should be - * - middle click, or shift + activate, or shift + double-click -> close parent - */ -static void -icon_container_activate_alternate_callback (NautilusIconContainer *container, - GList *file_list, - NautilusIconView *icon_view) -{ - GdkEvent *event; - GdkEventButton *button_event; - GdkEventKey *key_event; - gboolean open_in_tab, open_in_window, close_behind; - NautilusWindowOpenFlags flags; - - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - g_assert (container == get_icon_container (icon_view)); - - flags = 0; - event = gtk_get_current_event (); - open_in_tab = FALSE; - open_in_window = FALSE; - close_behind = FALSE; - - if (g_settings_get_boolean (nautilus_preferences, - NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) { - if (event->type == GDK_BUTTON_PRESS || - event->type == GDK_BUTTON_RELEASE || - event->type == GDK_2BUTTON_PRESS || - event->type == GDK_3BUTTON_PRESS) { - button_event = (GdkEventButton *) event; - open_in_window = ((button_event->state & GDK_SHIFT_MASK) != 0); - open_in_tab = !open_in_window; - } else if (event->type == GDK_KEY_PRESS || - event->type == GDK_KEY_RELEASE) { - key_event = (GdkEventKey *) event; - open_in_tab = ((key_event->state & GDK_SHIFT_MASK) != 0); - } - } else { - close_behind = TRUE; - } - - if (open_in_tab) { - flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB; - } - - if (open_in_window) { - flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW; - } - - if (close_behind) { - flags |= NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND; - } - - DEBUG ("Activate alternate, open in tab %d, close behind %d, new window %d\n", - open_in_tab, close_behind, open_in_window); - - nautilus_view_activate_files (NAUTILUS_VIEW (icon_view), - file_list, - flags, - TRUE); -} - -static void -band_select_started_callback (NautilusIconContainer *container, - NautilusIconView *icon_view) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - g_assert (container == get_icon_container (icon_view)); - - nautilus_view_start_batching_selection_changes (NAUTILUS_VIEW (icon_view)); -} - -static void -band_select_ended_callback (NautilusIconContainer *container, - NautilusIconView *icon_view) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - g_assert (container == get_icon_container (icon_view)); - - nautilus_view_stop_batching_selection_changes (NAUTILUS_VIEW (icon_view)); -} - -int -nautilus_icon_view_compare_files (NautilusIconView *icon_view, - NautilusFile *a, - NautilusFile *b) -{ - return nautilus_file_compare_for_sort - (a, b, icon_view->details->sort->sort_type, - /* Use type-unsafe cast for performance */ - nautilus_view_should_sort_directories_first ((NautilusView *)icon_view), - icon_view->details->sort_reversed); -} - -static int -compare_files (NautilusView *icon_view, - NautilusFile *a, - NautilusFile *b) -{ - return nautilus_icon_view_compare_files ((NautilusIconView *)icon_view, a, b); -} - - -void -nautilus_icon_view_filter_by_screen (NautilusIconView *icon_view, - gboolean filter) -{ - icon_view->details->filter_by_screen = filter; - icon_view->details->num_screens = gdk_display_get_n_screens (gtk_widget_get_display (GTK_WIDGET (icon_view))); -} - -static void -nautilus_icon_view_screen_changed (GtkWidget *widget, - GdkScreen *previous_screen) -{ - NautilusView *view; - GList *files, *l; - NautilusFile *file; - NautilusDirectory *directory; - NautilusIconContainer *icon_container; - - if (GTK_WIDGET_CLASS (nautilus_icon_view_parent_class)->screen_changed) { - GTK_WIDGET_CLASS (nautilus_icon_view_parent_class)->screen_changed (widget, previous_screen); - } - - view = NAUTILUS_VIEW (widget); - if (NAUTILUS_ICON_VIEW (view)->details->filter_by_screen) { - icon_container = get_icon_container (NAUTILUS_ICON_VIEW (view)); - - directory = nautilus_view_get_model (view); - files = nautilus_directory_get_file_list (directory); - - for (l = files; l != NULL; l = l->next) { - file = l->data; - - if (!should_show_file_on_screen (view, file)) { - nautilus_icon_view_remove_file (view, file, directory); - } else { - if (nautilus_icon_container_add (icon_container, - NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) { - nautilus_file_ref (file); - } - } - } - - nautilus_file_list_unref (files); - g_list_free (files); - } -} - -static void -selection_changed_callback (NautilusIconContainer *container, - NautilusIconView *icon_view) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - g_assert (container == get_icon_container (icon_view)); - - nautilus_view_notify_selection_changed (NAUTILUS_VIEW (icon_view)); -} - -static void -icon_container_context_click_selection_callback (NautilusIconContainer *container, - GdkEventButton *event, - NautilusIconView *icon_view) -{ - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - - nautilus_view_pop_up_selection_context_menu - (NAUTILUS_VIEW (icon_view), event); -} - -static void -icon_container_context_click_background_callback (NautilusIconContainer *container, - GdkEventButton *event, - NautilusIconView *icon_view) -{ - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - - nautilus_view_pop_up_background_context_menu - (NAUTILUS_VIEW (icon_view), event); -} - -static gboolean -nautilus_icon_view_react_to_icon_change_idle_callback (gpointer data) -{ - NautilusIconView *icon_view; - - g_assert (NAUTILUS_IS_ICON_VIEW (data)); - - icon_view = NAUTILUS_ICON_VIEW (data); - icon_view->details->react_to_icon_change_idle_id = 0; - - /* Rebuild the menus since some of them (e.g. Restore Stretched Icons) - * may be different now. - */ - nautilus_view_update_menus (NAUTILUS_VIEW (icon_view)); - - /* Don't call this again (unless rescheduled) */ - return FALSE; -} - -static void -icon_position_changed_callback (NautilusIconContainer *container, - NautilusFile *file, - const NautilusIconPosition *position, - NautilusIconView *icon_view) -{ - char *position_string; - char scale_string[G_ASCII_DTOSTR_BUF_SIZE]; - - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - g_assert (container == get_icon_container (icon_view)); - g_assert (NAUTILUS_IS_FILE (file)); - - /* Schedule updating menus for the next idle. Doing it directly here - * noticeably slows down icon stretching. The other work here to - * store the icon position and scale does not seem to noticeably - * slow down icon stretching. It would be trickier to move to an - * idle call, because we'd have to keep track of potentially multiple - * sets of file/geometry info. - */ - if (nautilus_view_get_active (NAUTILUS_VIEW (icon_view)) && - icon_view->details->react_to_icon_change_idle_id == 0) { - icon_view->details->react_to_icon_change_idle_id - = g_idle_add (nautilus_icon_view_react_to_icon_change_idle_callback, - icon_view); - } - - /* Store the new position of the icon in the metadata. */ - if (!nautilus_icon_view_using_auto_layout (icon_view)) { - position_string = g_strdup_printf - ("%d,%d", position->x, position->y); - nautilus_file_set_metadata - (file, NAUTILUS_METADATA_KEY_ICON_POSITION, - NULL, position_string); - g_free (position_string); - } - - - g_ascii_dtostr (scale_string, sizeof (scale_string), position->scale); - nautilus_file_set_metadata - (file, NAUTILUS_METADATA_KEY_ICON_SCALE, - "1.0", scale_string); -} - -/* Attempt to change the filename to the new text. Notify user if operation fails. */ -static void -icon_rename_ended_cb (NautilusIconContainer *container, - NautilusFile *file, - const char *new_name, - NautilusIconView *icon_view) -{ - g_assert (NAUTILUS_IS_FILE (file)); - - nautilus_view_set_is_renaming (NAUTILUS_VIEW (icon_view), FALSE); - - /* Don't allow a rename with an empty string. Revert to original - * without notifying the user. - */ - if ((new_name == NULL) || (new_name[0] == '\0')) { - return; - } - - nautilus_rename_file (file, new_name, NULL, NULL); -} - -static void -icon_rename_started_cb (NautilusIconContainer *container, - GtkWidget *widget, - gpointer callback_data) -{ - NautilusView *directory_view; - - directory_view = NAUTILUS_VIEW (callback_data); - nautilus_clipboard_set_up_editable - (GTK_EDITABLE (widget), - nautilus_view_get_ui_manager (directory_view), - FALSE); -} - -static char * -get_icon_uri_callback (NautilusIconContainer *container, - NautilusFile *file, - NautilusIconView *icon_view) -{ - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); - g_assert (NAUTILUS_IS_FILE (file)); - g_assert (NAUTILUS_IS_ICON_VIEW (icon_view)); - - return nautilus_file_get_uri (file); -} - -static char * -get_icon_drop_target_uri_callback (NautilusIconContainer *container, - NautilusFile *file, - NautilusIconView *icon_view) -{ - g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (container), NULL); - g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL); - g_return_val_if_fail (NAUTILUS_IS_ICON_VIEW (icon_view), NULL); - - return nautilus_file_get_drop_target_uri (file); -} - -/* Preferences changed callbacks */ -static void -nautilus_icon_view_click_policy_changed (NautilusView *directory_view) -{ - g_assert (NAUTILUS_IS_ICON_VIEW (directory_view)); - - nautilus_icon_view_update_click_mode (NAUTILUS_ICON_VIEW (directory_view)); -} - -static void -image_display_policy_changed_callback (gpointer callback_data) -{ - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (callback_data); - - nautilus_icon_container_request_update_all (get_icon_container (icon_view)); -} - -static void -text_attribute_names_changed_callback (gpointer callback_data) -{ - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (callback_data); - - nautilus_icon_container_request_update_all (get_icon_container (icon_view)); -} - -static void -default_sort_order_changed_callback (gpointer callback_data) -{ - NautilusIconView *icon_view; - NautilusFile *file; - char *sort_name; - NautilusIconContainer *icon_container; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (callback_data)); - - icon_view = NAUTILUS_ICON_VIEW (callback_data); - - file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (icon_view)); - sort_name = nautilus_icon_view_get_directory_sort_by (icon_view, file); - set_sort_criterion (icon_view, get_sort_criterion_by_metadata_text (sort_name), FALSE); - g_free (sort_name); - - icon_container = get_icon_container (icon_view); - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (icon_container)); - - nautilus_icon_container_request_update_all (icon_container); -} - -static void -default_sort_in_reverse_order_changed_callback (gpointer callback_data) -{ - NautilusIconView *icon_view; - NautilusFile *file; - NautilusIconContainer *icon_container; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (callback_data)); - - icon_view = NAUTILUS_ICON_VIEW (callback_data); - - file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (icon_view)); - set_sort_reversed (icon_view, nautilus_icon_view_get_directory_sort_reversed (icon_view, file), FALSE); - icon_container = get_icon_container (icon_view); - g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (icon_container)); - - nautilus_icon_container_request_update_all (icon_container); -} - -static void -default_zoom_level_changed_callback (gpointer callback_data) -{ - NautilusIconView *icon_view; - NautilusFile *file; - int level; - - g_return_if_fail (NAUTILUS_IS_ICON_VIEW (callback_data)); - - icon_view = NAUTILUS_ICON_VIEW (callback_data); - - if (nautilus_view_supports_zooming (NAUTILUS_VIEW (icon_view))) { - file = nautilus_view_get_directory_as_file (NAUTILUS_VIEW (icon_view)); - - level = nautilus_file_get_integer_metadata (file, - NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL, - get_default_zoom_level (icon_view)); - - nautilus_view_zoom_to_level (NAUTILUS_VIEW (icon_view), level); - } -} - -static void -nautilus_icon_view_sort_directories_first_changed (NautilusView *directory_view) -{ - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (directory_view); - - if (nautilus_icon_view_using_auto_layout (icon_view)) { - nautilus_icon_container_sort - (get_icon_container (icon_view)); - } -} - -static gboolean -icon_view_can_accept_item (NautilusIconContainer *container, - NautilusFile *target_item, - const char *item_uri, - NautilusView *view) -{ - return nautilus_drag_can_accept_item (target_item, item_uri); -} - -static char * -icon_view_get_container_uri (NautilusIconContainer *container, - NautilusView *view) -{ - return nautilus_view_get_uri (view); -} - -static void -icon_view_move_copy_items (NautilusIconContainer *container, - const GList *item_uris, - GArray *relative_item_points, - const char *target_dir, - int copy_action, - int x, int y, - NautilusView *view) -{ - nautilus_clipboard_clear_if_colliding_uris (GTK_WIDGET (view), - item_uris, - nautilus_view_get_copied_files_atom (view)); - nautilus_view_move_copy_items (view, item_uris, relative_item_points, target_dir, - copy_action, x, y); -} - -static void -nautilus_icon_view_update_click_mode (NautilusIconView *icon_view) -{ - NautilusIconContainer *icon_container; - int click_mode; - - icon_container = get_icon_container (icon_view); - g_assert (icon_container != NULL); - - click_mode = g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_CLICK_POLICY); - - nautilus_icon_container_set_single_click_mode (icon_container, - click_mode == NAUTILUS_CLICK_POLICY_SINGLE); -} - -static gboolean -get_stored_layout_timestamp (NautilusIconContainer *container, - NautilusIconData *icon_data, - time_t *timestamp, - NautilusIconView *view) -{ - NautilusFile *file; - NautilusDirectory *directory; - - if (icon_data == NULL) { - directory = nautilus_view_get_model (NAUTILUS_VIEW (view)); - if (directory == NULL) { - return FALSE; - } - - file = nautilus_directory_get_corresponding_file (directory); - *timestamp = nautilus_file_get_time_metadata (file, - NAUTILUS_METADATA_KEY_ICON_VIEW_LAYOUT_TIMESTAMP); - nautilus_file_unref (file); - } else { - *timestamp = nautilus_file_get_time_metadata (NAUTILUS_FILE (icon_data), - NAUTILUS_METADATA_KEY_ICON_POSITION_TIMESTAMP); - } - - return TRUE; -} - -static gboolean -store_layout_timestamp (NautilusIconContainer *container, - NautilusIconData *icon_data, - const time_t *timestamp, - NautilusIconView *view) -{ - NautilusFile *file; - NautilusDirectory *directory; - - if (icon_data == NULL) { - directory = nautilus_view_get_model (NAUTILUS_VIEW (view)); - if (directory == NULL) { - return FALSE; - } - - file = nautilus_directory_get_corresponding_file (directory); - nautilus_file_set_time_metadata (file, - NAUTILUS_METADATA_KEY_ICON_VIEW_LAYOUT_TIMESTAMP, - (time_t) *timestamp); - nautilus_file_unref (file); - } else { - nautilus_file_set_time_metadata (NAUTILUS_FILE (icon_data), - NAUTILUS_METADATA_KEY_ICON_POSITION_TIMESTAMP, - (time_t) *timestamp); - } - - return TRUE; -} - -static gboolean -focus_in_event_callback (GtkWidget *widget, GdkEventFocus *event, gpointer user_data) -{ - NautilusWindowSlot *slot; - NautilusIconView *icon_view = NAUTILUS_ICON_VIEW (user_data); - - /* make the corresponding slot (and the window that contains it) active */ - slot = nautilus_view_get_nautilus_window_slot (NAUTILUS_VIEW (icon_view)); - nautilus_window_slot_make_hosting_window_active (slot); - - return FALSE; -} - -static NautilusIconContainer * -create_icon_container (NautilusIconView *icon_view) -{ - NautilusIconContainer *icon_container; - - icon_container = nautilus_icon_view_container_new (icon_view); - icon_view->details->icon_container = GTK_WIDGET (icon_container); - g_object_add_weak_pointer (G_OBJECT (icon_container), - (gpointer *) &icon_view->details->icon_container); - - gtk_widget_set_can_focus (GTK_WIDGET (icon_container), TRUE); - - g_signal_connect_object (icon_container, "focus_in_event", - G_CALLBACK (focus_in_event_callback), icon_view, 0); - g_signal_connect_object (icon_container, "activate", - G_CALLBACK (icon_container_activate_callback), icon_view, 0); - g_signal_connect_object (icon_container, "activate_alternate", - G_CALLBACK (icon_container_activate_alternate_callback), icon_view, 0); - g_signal_connect_object (icon_container, "activate_previewer", - G_CALLBACK (icon_container_activate_previewer_callback), icon_view, 0); - g_signal_connect_object (icon_container, "band_select_started", - G_CALLBACK (band_select_started_callback), icon_view, 0); - g_signal_connect_object (icon_container, "band_select_ended", - G_CALLBACK (band_select_ended_callback), icon_view, 0); - g_signal_connect_object (icon_container, "context_click_selection", - G_CALLBACK (icon_container_context_click_selection_callback), icon_view, 0); - g_signal_connect_object (icon_container, "context_click_background", - G_CALLBACK (icon_container_context_click_background_callback), icon_view, 0); - g_signal_connect_object (icon_container, "icon_position_changed", - G_CALLBACK (icon_position_changed_callback), icon_view, 0); - g_signal_connect_object (icon_container, "selection_changed", - G_CALLBACK (selection_changed_callback), icon_view, 0); - /* FIXME: many of these should move into fm-icon-container as virtual methods */ - g_signal_connect_object (icon_container, "get_icon_uri", - G_CALLBACK (get_icon_uri_callback), icon_view, 0); - g_signal_connect_object (icon_container, "get_icon_drop_target_uri", - G_CALLBACK (get_icon_drop_target_uri_callback), icon_view, 0); - g_signal_connect_object (icon_container, "move_copy_items", - G_CALLBACK (icon_view_move_copy_items), icon_view, 0); - g_signal_connect_object (icon_container, "get_container_uri", - G_CALLBACK (icon_view_get_container_uri), icon_view, 0); - g_signal_connect_object (icon_container, "can_accept_item", - G_CALLBACK (icon_view_can_accept_item), icon_view, 0); - g_signal_connect_object (icon_container, "get_stored_icon_position", - G_CALLBACK (get_stored_icon_position_callback), icon_view, 0); - g_signal_connect_object (icon_container, "layout_changed", - G_CALLBACK (layout_changed_callback), icon_view, 0); - g_signal_connect_object (icon_container, "icon_rename_started", - G_CALLBACK (icon_rename_started_cb), icon_view, 0); - g_signal_connect_object (icon_container, "icon_rename_ended", - G_CALLBACK (icon_rename_ended_cb), icon_view, 0); - g_signal_connect_object (icon_container, "icon_stretch_started", - G_CALLBACK (nautilus_view_update_menus), icon_view, - G_CONNECT_SWAPPED); - g_signal_connect_object (icon_container, "icon_stretch_ended", - G_CALLBACK (nautilus_view_update_menus), icon_view, - G_CONNECT_SWAPPED); - - g_signal_connect_object (icon_container, "get_stored_layout_timestamp", - G_CALLBACK (get_stored_layout_timestamp), icon_view, 0); - g_signal_connect_object (icon_container, "store_layout_timestamp", - G_CALLBACK (store_layout_timestamp), icon_view, 0); - - gtk_container_add (GTK_CONTAINER (icon_view), - GTK_WIDGET (icon_container)); - - nautilus_icon_view_update_click_mode (icon_view); - - gtk_widget_show (GTK_WIDGET (icon_container)); - - return icon_container; -} - -/* Handles an URL received from Mozilla */ -static void -icon_view_handle_netscape_url (NautilusIconContainer *container, const char *encoded_url, - const char *target_uri, - GdkDragAction action, int x, int y, NautilusIconView *view) -{ - nautilus_view_handle_netscape_url_drop (NAUTILUS_VIEW (view), - encoded_url, target_uri, action, x, y); -} - -static void -icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_uris, - const char *target_uri, - GdkDragAction action, int x, int y, NautilusIconView *view) -{ - nautilus_view_handle_uri_list_drop (NAUTILUS_VIEW (view), - item_uris, target_uri, action, x, y); -} - -static void -icon_view_handle_text (NautilusIconContainer *container, const char *text, - const char *target_uri, - GdkDragAction action, int x, int y, NautilusIconView *view) -{ - nautilus_view_handle_text_drop (NAUTILUS_VIEW (view), - text, target_uri, action, x, y); -} - -static void -icon_view_handle_raw (NautilusIconContainer *container, const char *raw_data, - int length, const char *target_uri, const char *direct_save_uri, - GdkDragAction action, int x, int y, NautilusIconView *view) -{ - nautilus_view_handle_raw_drop (NAUTILUS_VIEW (view), - raw_data, length, target_uri, direct_save_uri, action, x, y); -} - -static char * -icon_view_get_first_visible_file (NautilusView *view) -{ - NautilusFile *file; - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (view); - - file = NAUTILUS_FILE (nautilus_icon_container_get_first_visible_icon (get_icon_container (icon_view))); - - if (file) { - return nautilus_file_get_uri (file); - } - - return NULL; -} - -static void -icon_view_scroll_to_file (NautilusView *view, - const char *uri) -{ - NautilusFile *file; - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (view); - - if (uri != NULL) { - /* Only if existing, since we don't want to add the file to - the directory if it has been removed since then */ - file = nautilus_file_get_existing_by_uri (uri); - if (file != NULL) { - nautilus_icon_container_scroll_to_icon (get_icon_container (icon_view), - NAUTILUS_ICON_CONTAINER_ICON_DATA (file)); - nautilus_file_unref (file); - } - } -} - -static const char * -nautilus_icon_view_get_id (NautilusView *view) -{ - return NAUTILUS_ICON_VIEW_ID; -} - -static void -nautilus_icon_view_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (object); - - switch (prop_id) { - case PROP_SUPPORTS_AUTO_LAYOUT: - icon_view->details->supports_auto_layout = g_value_get_boolean (value); - break; - case PROP_SUPPORTS_SCALING: - icon_view->details->supports_scaling = g_value_get_boolean (value); - break; - case PROP_SUPPORTS_KEEP_ALIGNED: - icon_view->details->supports_keep_aligned = g_value_get_boolean (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -nautilus_icon_view_finalize (GObject *object) -{ - NautilusIconView *icon_view; - - icon_view = NAUTILUS_ICON_VIEW (object); - - g_free (icon_view->details); - - g_signal_handlers_disconnect_by_func (nautilus_preferences, - default_sort_order_changed_callback, - icon_view); - g_signal_handlers_disconnect_by_func (nautilus_preferences, - default_sort_in_reverse_order_changed_callback, - icon_view); - g_signal_handlers_disconnect_by_func (nautilus_preferences, - image_display_policy_changed_callback, - icon_view); - - g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences, - default_zoom_level_changed_callback, - icon_view); - g_signal_handlers_disconnect_by_func (nautilus_icon_view_preferences, - text_attribute_names_changed_callback, - icon_view); - - G_OBJECT_CLASS (nautilus_icon_view_parent_class)->finalize (object); -} - -static void -nautilus_icon_view_class_init (NautilusIconViewClass *klass) -{ - NautilusViewClass *nautilus_view_class; - GObjectClass *oclass; - - nautilus_view_class = NAUTILUS_VIEW_CLASS (klass); - oclass = G_OBJECT_CLASS (klass); - - oclass->set_property = nautilus_icon_view_set_property; - oclass->finalize = nautilus_icon_view_finalize; - - GTK_WIDGET_CLASS (klass)->destroy = nautilus_icon_view_destroy; - GTK_WIDGET_CLASS (klass)->screen_changed = nautilus_icon_view_screen_changed; - - nautilus_view_class->add_file = nautilus_icon_view_add_file; - nautilus_view_class->begin_loading = nautilus_icon_view_begin_loading; - nautilus_view_class->bump_zoom_level = nautilus_icon_view_bump_zoom_level; - nautilus_view_class->can_rename_file = nautilus_icon_view_can_rename_file; - nautilus_view_class->can_zoom_in = nautilus_icon_view_can_zoom_in; - nautilus_view_class->can_zoom_out = nautilus_icon_view_can_zoom_out; - nautilus_view_class->clear = nautilus_icon_view_clear; - nautilus_view_class->end_loading = nautilus_icon_view_end_loading; - nautilus_view_class->file_changed = nautilus_icon_view_file_changed; - nautilus_view_class->get_selected_icon_locations = nautilus_icon_view_get_selected_icon_locations; - nautilus_view_class->get_selection = nautilus_icon_view_get_selection; - nautilus_view_class->get_selection_for_file_transfer = nautilus_icon_view_get_selection; - nautilus_view_class->get_item_count = nautilus_icon_view_get_item_count; - nautilus_view_class->is_empty = nautilus_icon_view_is_empty; - nautilus_view_class->remove_file = nautilus_icon_view_remove_file; - nautilus_view_class->reset_to_defaults = nautilus_icon_view_reset_to_defaults; - nautilus_view_class->restore_default_zoom_level = nautilus_icon_view_restore_default_zoom_level; - nautilus_view_class->reveal_selection = nautilus_icon_view_reveal_selection; - nautilus_view_class->select_all = nautilus_icon_view_select_all; - nautilus_view_class->set_selection = nautilus_icon_view_set_selection; - nautilus_view_class->invert_selection = nautilus_icon_view_invert_selection; - nautilus_view_class->compare_files = compare_files; - nautilus_view_class->zoom_to_level = nautilus_icon_view_zoom_to_level; - nautilus_view_class->get_zoom_level = nautilus_icon_view_get_zoom_level; - nautilus_view_class->click_policy_changed = nautilus_icon_view_click_policy_changed; - nautilus_view_class->merge_menus = nautilus_icon_view_merge_menus; - nautilus_view_class->unmerge_menus = nautilus_icon_view_unmerge_menus; - nautilus_view_class->sort_directories_first_changed = nautilus_icon_view_sort_directories_first_changed; - nautilus_view_class->start_renaming_file = nautilus_icon_view_start_renaming_file; - nautilus_view_class->update_menus = nautilus_icon_view_update_menus; - nautilus_view_class->using_manual_layout = nautilus_icon_view_using_manual_layout; - nautilus_view_class->widget_to_file_operation_position = nautilus_icon_view_widget_to_file_operation_position; - nautilus_view_class->get_view_id = nautilus_icon_view_get_id; - nautilus_view_class->get_first_visible_file = icon_view_get_first_visible_file; - nautilus_view_class->scroll_to_file = icon_view_scroll_to_file; - - properties[PROP_SUPPORTS_AUTO_LAYOUT] = - g_param_spec_boolean ("supports-auto-layout", - "Supports auto layout", - "Whether this view supports auto layout", - TRUE, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY); - properties[PROP_SUPPORTS_SCALING] = - g_param_spec_boolean ("supports-scaling", - "Supports scaling", - "Whether this view supports scaling", - FALSE, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY); - properties[PROP_SUPPORTS_KEEP_ALIGNED] = - g_param_spec_boolean ("supports-keep-aligned", - "Supports keep aligned", - "Whether this view supports keep aligned", - FALSE, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY); - - g_object_class_install_properties (oclass, NUM_PROPERTIES, properties); -} - -static void -nautilus_icon_view_init (NautilusIconView *icon_view) -{ - NautilusIconContainer *icon_container; - - g_return_if_fail (gtk_bin_get_child (GTK_BIN (icon_view)) == NULL); - - icon_view->details = g_new0 (NautilusIconViewDetails, 1); - icon_view->details->sort = &sort_criteria[0]; - icon_view->details->filter_by_screen = FALSE; - - icon_container = create_icon_container (icon_view); - - /* Set our default layout mode */ - nautilus_icon_container_set_layout_mode (icon_container, - gtk_widget_get_direction (GTK_WIDGET(icon_container)) == GTK_TEXT_DIR_RTL ? - NAUTILUS_ICON_LAYOUT_R_L_T_B : - NAUTILUS_ICON_LAYOUT_L_R_T_B); - - g_signal_connect_swapped (nautilus_preferences, - "changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_ORDER, - G_CALLBACK (default_sort_order_changed_callback), - icon_view); - g_signal_connect_swapped (nautilus_preferences, - "changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER, - G_CALLBACK (default_sort_in_reverse_order_changed_callback), - icon_view); - g_signal_connect_swapped (nautilus_preferences, - "changed::" NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, - G_CALLBACK (image_display_policy_changed_callback), - icon_view); - - g_signal_connect_swapped (nautilus_icon_view_preferences, - "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL, - G_CALLBACK (default_zoom_level_changed_callback), - icon_view); - g_signal_connect_swapped (nautilus_icon_view_preferences, - "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS, - G_CALLBACK (text_attribute_names_changed_callback), - icon_view); - - g_signal_connect_object (get_icon_container (icon_view), "handle_netscape_url", - G_CALLBACK (icon_view_handle_netscape_url), icon_view, 0); - g_signal_connect_object (get_icon_container (icon_view), "handle_uri_list", - G_CALLBACK (icon_view_handle_uri_list), icon_view, 0); - g_signal_connect_object (get_icon_container (icon_view), "handle_text", - G_CALLBACK (icon_view_handle_text), icon_view, 0); - g_signal_connect_object (get_icon_container (icon_view), "handle_raw", - G_CALLBACK (icon_view_handle_raw), icon_view, 0); - - icon_view->details->clipboard_handler_id = - g_signal_connect (nautilus_clipboard_monitor_get (), - "clipboard_info", - G_CALLBACK (icon_view_notify_clipboard_info), icon_view); -} - -static NautilusView * -nautilus_icon_view_create (NautilusWindowSlot *slot) -{ - NautilusIconView *view; - - view = g_object_new (NAUTILUS_TYPE_ICON_VIEW, - "window-slot", slot, - NULL); - return NAUTILUS_VIEW (view); -} - -static gboolean -nautilus_icon_view_supports_uri (const char *uri, - GFileType file_type, - const char *mime_type) -{ - if (file_type == G_FILE_TYPE_DIRECTORY) { - return TRUE; - } - if (strcmp (mime_type, NAUTILUS_SAVED_SEARCH_MIMETYPE) == 0){ - return TRUE; - } - if (g_str_has_prefix (uri, "trash:")) { - return TRUE; - } - if (g_str_has_prefix (uri, EEL_SEARCH_URI)) { - return TRUE; - } - - return FALSE; -} - -#define TRANSLATE_VIEW_INFO(view_info) \ - view_info.view_combo_label = _(view_info.view_combo_label); \ - view_info.view_menu_label_with_mnemonic = _(view_info.view_menu_label_with_mnemonic); \ - view_info.error_label = _(view_info.error_label); \ - view_info.startup_error_label = _(view_info.startup_error_label); \ - view_info.display_location_label = _(view_info.display_location_label); \ - - -static NautilusViewInfo nautilus_icon_view = { - NAUTILUS_ICON_VIEW_ID, - /* translators: this is used in the view selection dropdown - * of navigation windows and in the preferences dialog */ - N_("Icon View"), - /* translators: this is used in the view menu */ - N_("_Icons"), - N_("The icon view encountered an error."), - N_("The icon view encountered an error while starting up."), - N_("Display this location with the icon view."), - nautilus_icon_view_create, - nautilus_icon_view_supports_uri -}; - -void -nautilus_icon_view_register (void) -{ - TRANSLATE_VIEW_INFO (nautilus_icon_view) - nautilus_view_factory_register (&nautilus_icon_view); -} - diff --git a/src/nautilus-icon-view.h b/src/nautilus-icon-view.h deleted file mode 100644 index af82f19dd..000000000 --- a/src/nautilus-icon-view.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-icon-view.h - interface for icon view of directory. - * - * Copyright (C) 2000 Eazel, Inc. - * - * The Gnome Library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * The Gnome Library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Gnome Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: John Sullivan <sullivan@eazel.com> - * - */ - -#ifndef NAUTILUS_ICON_VIEW_H -#define NAUTILUS_ICON_VIEW_H - -#include "nautilus-view.h" - -typedef struct NautilusIconView NautilusIconView; -typedef struct NautilusIconViewClass NautilusIconViewClass; - -#define NAUTILUS_TYPE_ICON_VIEW nautilus_icon_view_get_type() -#define NAUTILUS_ICON_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_ICON_VIEW, NautilusIconView)) -#define NAUTILUS_ICON_VIEW_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ICON_VIEW, NautilusIconViewClass)) -#define NAUTILUS_IS_ICON_VIEW(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_ICON_VIEW)) -#define NAUTILUS_IS_ICON_VIEW_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ICON_VIEW)) -#define NAUTILUS_ICON_VIEW_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_ICON_VIEW, NautilusIconViewClass)) - -#define NAUTILUS_ICON_VIEW_ID "OAFIID:Nautilus_File_Manager_Icon_View" - -typedef struct NautilusIconViewDetails NautilusIconViewDetails; - -struct NautilusIconView { - NautilusView parent; - NautilusIconViewDetails *details; -}; - -struct NautilusIconViewClass { - NautilusViewClass parent_class; -}; - -/* GObject support */ -GType nautilus_icon_view_get_type (void); -int nautilus_icon_view_compare_files (NautilusIconView *icon_view, - NautilusFile *a, - NautilusFile *b); -void nautilus_icon_view_filter_by_screen (NautilusIconView *icon_view, - gboolean filter); - -void nautilus_icon_view_register (void); - -NautilusIconContainer * nautilus_icon_view_get_icon_container (NautilusIconView *view); - -#endif /* NAUTILUS_ICON_VIEW_H */ diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index 0eef1a882..a0be4f916 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -52,7 +52,6 @@ #include <libnautilus-private/nautilus-file-utilities.h> #include <libnautilus-private/nautilus-ui-utilities.h> #include <libnautilus-private/nautilus-global-preferences.h> -#include <libnautilus-private/nautilus-icon-dnd.h> #include <libnautilus-private/nautilus-metadata.h> #include <libnautilus-private/nautilus-module.h> #include <libnautilus-private/nautilus-tree-view-drag-dest.h> diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c index 91363f8ae..3193761cf 100644 --- a/src/nautilus-location-bar.c +++ b/src/nautilus-location-bar.c @@ -43,7 +43,6 @@ #include <eel/eel-vfs-extensions.h> #include <gtk/gtk.h> #include <glib/gi18n.h> -#include <libnautilus-private/nautilus-icon-dnd.h> #include <libnautilus-private/nautilus-clipboard.h> #include <stdio.h> #include <string.h> diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c index 8ec64a7c1..ded954552 100644 --- a/src/nautilus-location-entry.c +++ b/src/nautilus-location-entry.c @@ -41,7 +41,6 @@ #include <gio/gio.h> #include <libnautilus-private/nautilus-file-utilities.h> #include <libnautilus-private/nautilus-entry.h> -#include <libnautilus-private/nautilus-icon-dnd.h> #include <libnautilus-private/nautilus-clipboard.h> #include <stdio.h> #include <string.h> diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c index 1d89517c4..c6d3e7df5 100644 --- a/src/nautilus-pathbar.c +++ b/src/nautilus-pathbar.c @@ -32,7 +32,6 @@ #include <libnautilus-private/nautilus-global-preferences.h> #include <libnautilus-private/nautilus-icon-names.h> #include <libnautilus-private/nautilus-trash-monitor.h> -#include <libnautilus-private/nautilus-icon-dnd.h> #include "nautilus-window-slot-dnd.h" diff --git a/src/nautilus-view-dnd.c b/src/nautilus-view-dnd.c index eb5080dff..610664541 100644 --- a/src/nautilus-view-dnd.c +++ b/src/nautilus-view-dnd.c @@ -31,7 +31,6 @@ #include "nautilus-view-dnd.h" -#include "nautilus-desktop-icon-view.h" #include "nautilus-view.h" #include <eel/eel-stock-dialogs.h> diff --git a/src/nautilus-view.c b/src/nautilus-view.c index 8fbb0cf73..47c6a7aa5 100644 --- a/src/nautilus-view.c +++ b/src/nautilus-view.c @@ -32,7 +32,7 @@ #include "nautilus-view.h" #include "nautilus-actions.h" -#include "nautilus-desktop-icon-view.h" +#include "nautilus-desktop-canvas-view.h" #include "nautilus-error-reporting.h" #include "nautilus-list-view.h" #include "nautilus-mime-actions.h" @@ -8745,7 +8745,7 @@ real_update_menus (NautilusView *view) show_open_alternate = file_list_all_are_folders (selection) && selection_count > 0 && g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER) && - !NAUTILUS_IS_DESKTOP_ICON_VIEW (view); + !NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view); action = gtk_action_group_get_action (view->details->dir_action_group, NAUTILUS_ACTION_OPEN_ALTERNATE); @@ -8849,7 +8849,7 @@ real_update_menus (NautilusView *view) selection_count), NULL); - show_properties = (!NAUTILUS_IS_DESKTOP_ICON_VIEW (view) || selection_count > 0); + show_properties = (!NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view) || selection_count > 0); action = gtk_action_group_get_action (view->details->dir_action_group, NAUTILUS_ACTION_PROPERTIES); @@ -9740,7 +9740,7 @@ window_slots_changed (NautilusWindow *window, * border. */ if (g_list_length (slots) > 1 || - NAUTILUS_IS_DESKTOP_ICON_VIEW (view)) { + NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view)) { gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view), GTK_SHADOW_NONE); } else { gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view), GTK_SHADOW_IN); diff --git a/src/nautilus-view.h b/src/nautilus-view.h index a208e18ab..9ba3f96d1 100644 --- a/src/nautilus-view.h +++ b/src/nautilus-view.h @@ -33,7 +33,6 @@ #include <libnautilus-private/nautilus-directory.h> #include <libnautilus-private/nautilus-file.h> -#include <libnautilus-private/nautilus-icon-container.h> #include <libnautilus-private/nautilus-link.h> typedef struct NautilusView NautilusView; |