Commit 3bb16943 authored by Dave Camp's avatar Dave Camp Committed by Dave Camp

Implemented a "Keep Aligned" mode on the desktop, that snaps icons to a

2003-05-03  Dave Camp  <dave@ximian.com>

	* libnautilus-private/nautilus-icon-container.c: (icon_set_size),
	(icon_toggle_selected), (snap_position),
	(compare_icons_by_position), (placement_grid_new),
	(placement_grid_free), (placement_grid_position_is_free),
	(placement_grid_mark), (canvas_position_to_grid_position),
	(placement_grid_mark_icon), (find_empty_location), (align_icons),
	(lay_down_icons_tblr), (nautilus_icon_container_move_icon),
	(destroy), (update_stretch_at_idle), (undo_stretching),
	(nautilus_icon_container_unstretch),
	(nautilus_icon_container_is_keep_aligned), (align_icons_callback),
	(unschedule_align_icons), (schedule_align_icons),
	(nautilus_icon_container_set_keep_aligned):
	* libnautilus-private/nautilus-icon-container.h:
	* libnautilus-private/nautilus-icon-dnd.c: (handle_local_move):
	* libnautilus-private/nautilus-icon-private.h:
	* libnautilus-private/nautilus-metadata.h:
	* src/file-manager/fm-desktop-icon-view.c:
	(fm_desktop_icon_view_class_init), (real_supports_auto_layout),
	(real_supports_keep_aligned):
	* src/file-manager/fm-icon-view.c:
	(fm_icon_view_supports_keep_aligned), (update_layout_menus),
	(get_default_directory_keep_aligned),
	(fm_icon_view_get_directory_keep_aligned),
	(fm_icon_view_set_directory_keep_aligned),
	(real_supports_keep_aligned), (fm_icon_view_begin_loading),
	(keep_aligned_state_changed_callback), (fm_icon_view_merge_menus),
	(fm_icon_view_reset_to_defaults), (fm_icon_view_class_init):
	* src/file-manager/fm-icon-view.h:
	* src/file-manager/nautilus-icon-view-ui.xml:
	Implemented a "Keep Aligned" mode on the desktop, that snaps icons
	to a grid.
parent 2dbe9bfa
2003-05-03 Dave Camp <dave@ximian.com>
* libnautilus-private/nautilus-icon-container.c: (icon_set_size),
(icon_toggle_selected), (snap_position),
(compare_icons_by_position), (placement_grid_new),
(placement_grid_free), (placement_grid_position_is_free),
(placement_grid_mark), (canvas_position_to_grid_position),
(placement_grid_mark_icon), (find_empty_location), (align_icons),
(lay_down_icons_tblr), (nautilus_icon_container_move_icon),
(destroy), (update_stretch_at_idle), (undo_stretching),
(nautilus_icon_container_unstretch),
(nautilus_icon_container_is_keep_aligned), (align_icons_callback),
(unschedule_align_icons), (schedule_align_icons),
(nautilus_icon_container_set_keep_aligned):
* libnautilus-private/nautilus-icon-container.h:
* libnautilus-private/nautilus-icon-dnd.c: (handle_local_move):
* libnautilus-private/nautilus-icon-private.h:
* libnautilus-private/nautilus-metadata.h:
* src/file-manager/fm-desktop-icon-view.c:
(fm_desktop_icon_view_class_init), (real_supports_auto_layout),
(real_supports_keep_aligned):
* src/file-manager/fm-icon-view.c:
(fm_icon_view_supports_keep_aligned), (update_layout_menus),
(get_default_directory_keep_aligned),
(fm_icon_view_get_directory_keep_aligned),
(fm_icon_view_set_directory_keep_aligned),
(real_supports_keep_aligned), (fm_icon_view_begin_loading),
(keep_aligned_state_changed_callback), (fm_icon_view_merge_menus),
(fm_icon_view_reset_to_defaults), (fm_icon_view_class_init):
* src/file-manager/fm-icon-view.h:
* src/file-manager/nautilus-icon-view-ui.xml:
Implemented a "Keep Aligned" mode on the desktop, that snaps icons
to a grid.
2003-05-03 Masahiro Sakai <sakai@tom.sfc.keio.ac.jp>
* configure.in: Call AC_LIBTOOL_WIN32_DLL which is necessary for
......
......@@ -205,6 +205,10 @@ void nautilus_icon_container_set_auto_layout (Nautilu
gboolean nautilus_icon_container_is_tighter_layout (NautilusIconContainer *container);
void nautilus_icon_container_set_tighter_layout (NautilusIconContainer *container,
gboolean tighter_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_sort (NautilusIconContainer *container);
......
......@@ -811,7 +811,7 @@ handle_local_move (NautilusIconContainer *container,
(container, icon,
world_x + item->icon_x, world_y + item->icon_y,
icon->scale_x, icon->scale_y,
TRUE, TRUE);
TRUE, TRUE, TRUE);
}
moved_icons = g_list_prepend (moved_icons, icon);
}
......
......@@ -177,6 +177,9 @@ struct NautilusIconContainerDetails {
/* Idle handler for stretch code */
guint stretch_idle_id;
/* Align idle id */
guint align_idle_id;
/* DnD info. */
NautilusIconDndInfo *dnd_info;
......@@ -215,7 +218,10 @@ struct NautilusIconContainerDetails {
/* Layout mode */
NautilusIconLayoutMode layout_mode;
/* Set to TRUE after first allocation has been done */
/* Should the container keep icons aligned to a grid */
gboolean keep_aligned;
/* Set to TRUE after first allocation has been done */
gboolean has_been_allocated;
/* Is the container fixed or resizable */
......@@ -252,6 +258,7 @@ void nautilus_icon_container_move_icon (NautilusIconC
double scale_x,
double scale_y,
gboolean raise,
gboolean snap,
gboolean update_position);
void nautilus_icon_container_select_list_unselect_others (NautilusIconContainer *container,
GList *icons);
......
......@@ -53,6 +53,7 @@
#define NAUTILUS_METADATA_KEY_ICON_VIEW_TIGHTER_LAYOUT "icon_view_tighter_layout"
#define NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_BY "icon_view_sort_by"
#define NAUTILUS_METADATA_KEY_ICON_VIEW_SORT_REVERSED "icon_view_sort_reversed"
#define NAUTILUS_METADATA_KEY_ICON_VIEW_KEEP_ALIGNED "icon_view_keep_aligned"
#define NAUTILUS_METADATA_KEY_LIST_VIEW_ZOOM_LEVEL "list_view_zoom_level"
#define NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN "list_view_sort_column"
......
......@@ -121,6 +121,7 @@ static void volume_unmounted_callback (NautilusVolum
FMDesktopIconView *icon_view);
static void update_desktop_directory (UpdateType type);
static gboolean real_supports_auto_layout (FMIconView *view);
static gboolean real_supports_keep_aligned (FMIconView *view);
static void real_merge_menus (FMDirectoryView *view);
static void real_update_menus (FMDirectoryView *view);
static gboolean real_supports_zooming (FMDirectoryView *view);
......@@ -300,6 +301,7 @@ fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class)
FM_DIRECTORY_VIEW_CLASS (class)->supports_zooming = real_supports_zooming;
FM_ICON_VIEW_CLASS (class)->supports_auto_layout = real_supports_auto_layout;
FM_ICON_VIEW_CLASS (class)->supports_keep_aligned = real_supports_keep_aligned;
}
static void
......@@ -1472,6 +1474,12 @@ real_supports_auto_layout (FMIconView *view)
return FALSE;
}
static gboolean
real_supports_keep_aligned (FMIconView *view)
{
return TRUE;
}
static gboolean
real_supports_zooming (FMDirectoryView *view)
{
......
......@@ -98,10 +98,12 @@
#define COMMAND_TIGHTER_LAYOUT "/commands/Tighter Layout"
#define COMMAND_SORT_REVERSED "/commands/Reversed Order"
#define COMMAND_CLEAN_UP "/commands/Clean Up"
#define COMMAND_KEEP_ALIGNED "/commands/Keep Aligned"
#define ID_MANUAL_LAYOUT "Manual Layout"
#define ID_TIGHTER_LAYOUT "Tighter Layout"
#define ID_SORT_REVERSED "Reversed Order"
#define ID_KEEP_ALIGNED "Keep Aligned"
typedef struct {
NautilusFileSortType sort_type;
......@@ -578,6 +580,16 @@ fm_icon_view_supports_auto_layout (FMIconView *view)
supports_auto_layout, (view));
}
static gboolean
fm_icon_view_supports_keep_aligned (FMIconView *view)
{
g_return_val_if_fail (FM_IS_ICON_VIEW (view), FALSE);
return EEL_CALL_METHOD_WITH_RETURN_VALUE
(FM_ICON_VIEW_CLASS, view,
supports_keep_aligned, (view));
}
static void
update_layout_menus (FMIconView *view)
{
......@@ -617,6 +629,18 @@ update_layout_menus (FMIconView *view)
nautilus_bonobo_set_sensitive
(view->details->ui, COMMAND_CLEAN_UP, !is_auto_layout);
nautilus_bonobo_set_hidden (view->details->ui,
COMMAND_KEEP_ALIGNED,
!fm_icon_view_supports_keep_aligned (view));
nautilus_bonobo_set_toggle_state
(view->details->ui, COMMAND_KEEP_ALIGNED,
nautilus_icon_container_is_keep_aligned (get_icon_container (view)));
nautilus_bonobo_set_sensitive
(view->details->ui, COMMAND_KEEP_ALIGNED, !is_auto_layout);
bonobo_ui_component_thaw (view->details->ui, NULL);
}
......@@ -753,6 +777,41 @@ fm_icon_view_real_set_directory_sort_reversed (FMIconView *icon_view,
sort_reversed);
}
static gboolean
get_default_directory_keep_aligned (void)
{
return TRUE;
}
static gboolean
fm_icon_view_get_directory_keep_aligned (FMIconView *icon_view,
NautilusFile *file)
{
if (!fm_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
fm_icon_view_set_directory_keep_aligned (FMIconView *icon_view,
NautilusFile *file,
gboolean keep_aligned)
{
if (!fm_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);
}
/* maintainence of auto layout boolean */
static gboolean default_directory_manual_layout = FALSE;
......@@ -879,6 +938,14 @@ real_supports_auto_layout (FMIconView *view)
return TRUE;
}
static gboolean
real_supports_keep_aligned (FMIconView *view)
{
g_return_val_if_fail (FM_IS_ICON_VIEW (view), FALSE);
return FALSE;
}
static gboolean
set_sort_reversed (FMIconView *icon_view, gboolean new_value)
{
......@@ -1005,6 +1072,9 @@ fm_icon_view_begin_loading (FMDirectoryView *view)
/* Set the sort direction from the metadata. */
set_sort_reversed (icon_view, fm_icon_view_get_directory_sort_reversed (icon_view, file));
nautilus_icon_container_set_keep_aligned
(get_icon_container (icon_view),
fm_icon_view_get_directory_keep_aligned (icon_view, file));
nautilus_icon_container_set_tighter_layout
(get_icon_container (icon_view),
fm_icon_view_get_directory_tighter_layout (icon_view, file));
......@@ -1286,6 +1356,37 @@ sort_reversed_state_changed_callback (BonoboUIComponent *component,
}
}
static void
keep_aligned_state_changed_callback (BonoboUIComponent *component,
const char *path,
Bonobo_UIComponent_EventType type,
const char *state,
gpointer user_data)
{
FMIconView *icon_view;
NautilusFile *file;
gboolean keep_aligned;
g_assert (strcmp (path, ID_KEEP_ALIGNED) == 0);
icon_view = FM_ICON_VIEW (user_data);
if (strcmp (state, "") == 0) {
/* State goes blank when component is removed; ignore this. */
return;
}
keep_aligned = strcmp (state, "1") == 0 ? TRUE : FALSE;
file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (icon_view));
fm_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 (FMIconView *icon_view)
{
......@@ -1393,6 +1494,7 @@ fm_icon_view_merge_menus (FMDirectoryView *view)
bonobo_ui_component_add_listener (icon_view->details->ui, ID_TIGHTER_LAYOUT, tighter_layout_state_changed_callback, view);
bonobo_ui_component_add_listener (icon_view->details->ui, ID_SORT_REVERSED, sort_reversed_state_changed_callback, view);
bonobo_ui_component_add_listener (icon_view->details->ui, ID_KEEP_ALIGNED, keep_aligned_state_changed_callback, view);
icon_view->details->menus_ready = TRUE;
bonobo_ui_component_freeze (icon_view->details->ui, NULL);
......@@ -1472,6 +1574,8 @@ fm_icon_view_reset_to_defaults (FMDirectoryView *view)
set_sort_criterion (icon_view, get_sort_criterion_by_sort_type (get_default_sort_order ()));
set_sort_reversed (icon_view, get_default_sort_in_reverse_order ());
nautilus_icon_container_set_keep_aligned
(icon_container, get_default_directory_keep_aligned ());
nautilus_icon_container_set_tighter_layout
(icon_container, get_default_directory_tighter_layout ());
......@@ -2520,6 +2624,7 @@ fm_icon_view_class_init (FMIconViewClass *klass)
klass->clean_up = fm_icon_view_real_clean_up;
klass->supports_auto_layout = real_supports_auto_layout;
klass->supports_keep_aligned = real_supports_keep_aligned;
klass->get_directory_auto_layout = fm_icon_view_real_get_directory_auto_layout;
klass->get_directory_sort_by = fm_icon_view_real_get_directory_sort_by;
klass->get_directory_sort_reversed = fm_icon_view_real_get_directory_sort_reversed;
......
......@@ -84,6 +84,12 @@ struct FMIconViewClass {
*/
gboolean (* supports_auto_layout) (FMIconView *view);
/* supports_auto_layout is a function pointer that subclasses may
* override to control whether snap-to-grid mode
* should be enabled. The default implementation returns FALSE.
*/
gboolean (* supports_keep_aligned) (FMIconView *view);
};
/* GObject support */
......
......@@ -24,6 +24,9 @@
<cmd name="Sort by Emblems"
_label="By _Emblems"
_tip="Keep icons sorted by emblems in rows"/>
<cmd name="Keep Aligned"
_label="_Keep Aligned"
_tip="Keep icons lined up on a grid"/>
<cmd name="Tighter Layout"
_label="Compact _Layout"
_tip="Toggle using a tighter layout scheme"/>
......@@ -78,6 +81,9 @@
</submenu>
<menuitem name="Clean Up"
verb="Clean Up"/>
<menuitem name="Keep Aligned"
id="Keep Aligned"
type="toggle"/>
</placeholder>
</submenu>
......@@ -108,6 +114,7 @@
id="Sort by Emblems"/>
</placeholder>
<separator/>
<menuitem name="Tighter Layout"
id="Tighter Layout"
type="toggle"/>
......@@ -115,7 +122,11 @@
id="Reversed Order"
type="toggle"/>
</submenu>
<menuitem name="Clean Up" verb="Clean Up"/>
<menuitem name="Keep Aligned"
id="Keep Aligned"
type="toggle"/>
</placeholder>
</placeholder>
</popup>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment