summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcaja-private/caja-icon-container.c17
-rw-r--r--libcaja-private/caja-icon-container.h3
-rw-r--r--libcaja-private/caja-icon-private.h3
-rw-r--r--libcaja-private/caja-metadata.c1
-rw-r--r--libcaja-private/caja-metadata.h1
-rw-r--r--src/file-manager/caja-icon-view-ui.xml2
-rw-r--r--src/file-manager/fm-actions.h1
-rw-r--r--src/file-manager/fm-icon-view.c75
8 files changed, 102 insertions, 1 deletions
diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c
index 31a326af..a8d9b603 100644
--- a/libcaja-private/caja-icon-container.c
+++ b/libcaja-private/caja-icon-container.c
@@ -2610,7 +2610,7 @@ caja_icon_container_move_icon (CajaIconContainer *container,
}
}
- if (!details->auto_layout)
+ if (!details->auto_layout && !details->lock_icons_position)
{
if (details->keep_aligned && snap)
{
@@ -8688,6 +8688,12 @@ caja_icon_container_is_keep_aligned (CajaIconContainer *container)
return container->details->keep_aligned;
}
+gboolean
+caja_icon_container_is_lock_icons_position (CajaIconContainer *container)
+{
+ return container->details->lock_icons_position;
+}
+
static gboolean
align_icons_callback (gpointer callback_data)
{
@@ -8741,6 +8747,15 @@ caja_icon_container_set_keep_aligned (CajaIconContainer *container,
}
void
+caja_icon_container_set_lock_icons_position (CajaIconContainer *container,
+ gboolean lock_icons_position)
+{
+ g_return_if_fail (CAJA_IS_ICON_CONTAINER (container));
+
+ container->details->lock_icons_position = lock_icons_position;
+}
+
+void
caja_icon_container_set_layout_mode (CajaIconContainer *container,
CajaIconLayoutMode mode)
{
diff --git a/libcaja-private/caja-icon-container.h b/libcaja-private/caja-icon-container.h
index 2bc03818..0280e848 100644
--- a/libcaja-private/caja-icon-container.h
+++ b/libcaja-private/caja-icon-container.h
@@ -281,6 +281,9 @@ void caja_icon_container_set_tighter_layout (CajaIconCon
gboolean caja_icon_container_is_keep_aligned (CajaIconContainer *container);
void caja_icon_container_set_keep_aligned (CajaIconContainer *container,
gboolean keep_aligned);
+gboolean caja_icon_container_is_lock_icons_position (CajaIconContainer *container);
+void caja_icon_container_set_lock_icons_position (CajaIconContainer *container,
+ gboolean lock_icons_position);
void caja_icon_container_set_layout_mode (CajaIconContainer *container,
CajaIconLayoutMode mode);
void caja_icon_container_set_label_position (CajaIconContainer *container,
diff --git a/libcaja-private/caja-icon-private.h b/libcaja-private/caja-icon-private.h
index 6d1657d5..80d53234 100644
--- a/libcaja-private/caja-icon-private.h
+++ b/libcaja-private/caja-icon-private.h
@@ -238,6 +238,9 @@ struct CajaIconContainerDetails
/* Should the container keep icons aligned to a grid */
gboolean keep_aligned;
+ /* Should the container not allow manual icon position */
+ gboolean lock_icons_position;
+
/* Set to TRUE after first allocation has been done */
gboolean has_been_allocated;
diff --git a/libcaja-private/caja-metadata.c b/libcaja-private/caja-metadata.c
index da831f8b..c7c62e86 100644
--- a/libcaja-private/caja-metadata.c
+++ b/libcaja-private/caja-metadata.c
@@ -35,6 +35,7 @@ static char *used_metadata_names[] =
CAJA_METADATA_KEY_ICON_VIEW_SORT_BY,
CAJA_METADATA_KEY_ICON_VIEW_SORT_REVERSED,
CAJA_METADATA_KEY_ICON_VIEW_KEEP_ALIGNED,
+ CAJA_METADATA_KEY_ICON_VIEW_LOCK_ICONS_POSITION,
CAJA_METADATA_KEY_ICON_VIEW_LAYOUT_TIMESTAMP,
CAJA_METADATA_KEY_LIST_VIEW_ZOOM_LEVEL,
CAJA_METADATA_KEY_LIST_VIEW_SORT_COLUMN,
diff --git a/libcaja-private/caja-metadata.h b/libcaja-private/caja-metadata.h
index 34ac7ac7..e953b78e 100644
--- a/libcaja-private/caja-metadata.h
+++ b/libcaja-private/caja-metadata.h
@@ -45,6 +45,7 @@
#define CAJA_METADATA_KEY_ICON_VIEW_SORT_BY "caja-icon-view-sort-by"
#define CAJA_METADATA_KEY_ICON_VIEW_SORT_REVERSED "caja-icon-view-sort-reversed"
#define CAJA_METADATA_KEY_ICON_VIEW_KEEP_ALIGNED "caja-icon-view-keep-aligned"
+#define CAJA_METADATA_KEY_ICON_VIEW_LOCK_ICONS_POSITION "caja-icon-view-lock-icons-position"
#define CAJA_METADATA_KEY_ICON_VIEW_LAYOUT_TIMESTAMP "caja-icon-view-layout-timestamp"
#define CAJA_METADATA_KEY_LIST_VIEW_ZOOM_LEVEL "caja-list-view-zoom-level"
diff --git a/src/file-manager/caja-icon-view-ui.xml b/src/file-manager/caja-icon-view-ui.xml
index b2c9eefa..8ac19e33 100644
--- a/src/file-manager/caja-icon-view-ui.xml
+++ b/src/file-manager/caja-icon-view-ui.xml
@@ -26,6 +26,7 @@
</menu>
<menuitem name="Clean Up" action="Clean Up"/>
<menuitem name="Keep Aligned" action="Keep Aligned"/>
+ <menuitem name="Lock Icons Position" action="Lock Icons Position"/>
</placeholder>
</menu>
@@ -51,6 +52,7 @@
</menu>
<menuitem name="Clean Up" action="Clean Up"/>
<menuitem name="Keep Aligned" action="Keep Aligned"/>
+ <menuitem name="Lock Icons Position" action="Lock Icons Position"/>
</placeholder>
</placeholder>
</popup>
diff --git a/src/file-manager/fm-actions.h b/src/file-manager/fm-actions.h
index 5d333168..450dec76 100644
--- a/src/file-manager/fm-actions.h
+++ b/src/file-manager/fm-actions.h
@@ -101,6 +101,7 @@
#define FM_ACTION_REVERSED_ORDER "Reversed Order"
#define FM_ACTION_CLEAN_UP "Clean Up"
#define FM_ACTION_KEEP_ALIGNED "Keep Aligned"
+#define FM_ACTION_LOCK_ICON_POSITION "Lock Icons Position"
#define FM_ACTION_ARRANGE_ITEMS "Arrange Items"
#define FM_ACTION_STRETCH "Stretch"
#define FM_ACTION_UNSTRETCH "Unstretch"
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index c553b98c..adeba93d 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -801,6 +801,12 @@ update_layout_menus (FMIconView *view)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
caja_icon_container_is_keep_aligned (get_icon_container (view)));
gtk_action_set_sensitive (action, !is_auto_layout);
+
+ action = gtk_action_group_get_action (view->details->icon_action_group,
+ FM_ACTION_LOCK_ICON_POSITION);
+ gtk_action_set_visible (action, !is_auto_layout);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ caja_icon_container_is_lock_icons_position (get_icon_container (view)));
G_GNUC_END_IGNORE_DEPRECATIONS;
}
@@ -991,6 +997,43 @@ fm_icon_view_set_directory_keep_aligned (FMIconView *icon_view,
}
static gboolean
+get_default_directory_lock_icons_position (void)
+{
+ return FALSE;
+}
+
+static gboolean
+fm_icon_view_get_directory_lock_icons_position (FMIconView *icon_view,
+ CajaFile *file)
+{
+ if (!fm_icon_view_supports_manual_layout (icon_view))
+ {
+ return FALSE;
+ }
+
+ return caja_file_get_boolean_metadata
+ (file,
+ CAJA_METADATA_KEY_ICON_VIEW_LOCK_ICONS_POSITION,
+ get_default_directory_lock_icons_position ());
+}
+
+static void
+fm_icon_view_set_directory_lock_icons_position (FMIconView *icon_view,
+ CajaFile *file,
+ gboolean lock_icons_position)
+{
+ if (!fm_icon_view_supports_manual_layout (icon_view))
+ {
+ return;
+ }
+
+ caja_file_set_boolean_metadata
+ (file, CAJA_METADATA_KEY_ICON_VIEW_LOCK_ICONS_POSITION,
+ get_default_directory_lock_icons_position (),
+ lock_icons_position);
+}
+
+static gboolean
fm_icon_view_get_directory_auto_layout (FMIconView *icon_view,
CajaFile *file)
{
@@ -1350,6 +1393,9 @@ fm_icon_view_begin_loading (FMDirectoryView *view)
caja_icon_container_set_keep_aligned
(get_icon_container (icon_view),
fm_icon_view_get_directory_keep_aligned (icon_view, file));
+ caja_icon_container_set_lock_icons_position
+ (get_icon_container (icon_view),
+ fm_icon_view_get_directory_lock_icons_position (icon_view, file));
caja_icon_container_set_tighter_layout
(get_icon_container (icon_view),
fm_icon_view_get_directory_tighter_layout (icon_view, file));
@@ -1641,6 +1687,27 @@ action_keep_aligned_callback (GtkAction *action,
}
static void
+action_lock_icons_position_callback (GtkAction *action,
+ gpointer user_data)
+{
+ FMIconView *icon_view;
+ CajaFile *file;
+ gboolean lock_icons_position;
+
+ icon_view = FM_ICON_VIEW (user_data);
+
+ lock_icons_position = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+
+ file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (icon_view));
+ fm_icon_view_set_directory_lock_icons_position (icon_view,
+ file,
+ lock_icons_position);
+
+ caja_icon_container_set_lock_icons_position (get_icon_container (icon_view),
+ lock_icons_position);
+}
+
+static void
switch_to_manual_layout (FMIconView *icon_view)
{
if (!fm_icon_view_using_auto_layout (icon_view))
@@ -1742,6 +1809,12 @@ static const GtkToggleActionEntry icon_view_toggle_entries[] =
G_CALLBACK (action_keep_aligned_callback),
0
},
+ /* name, stock id */ { "Lock Icons Position", NULL,
+ /* label, accelerator */ N_("_Lock Icons Position"), NULL,
+ /* tooltip */ N_("Prevent repositioning icons"),
+ G_CALLBACK (action_lock_icons_position_callback),
+ 0
+ },
};
static const GtkRadioActionEntry arrange_radio_entries[] =
@@ -1963,6 +2036,8 @@ fm_icon_view_reset_to_defaults (FMDirectoryView *view)
clear_sort_criterion (icon_view);
caja_icon_container_set_keep_aligned
(icon_container, get_default_directory_keep_aligned ());
+ caja_icon_container_set_lock_icons_position
+ (icon_container, get_default_directory_lock_icons_position ());
caja_icon_container_set_tighter_layout
(icon_container, get_default_directory_tighter_layout ());