summaryrefslogtreecommitdiff
path: root/src/file-manager
diff options
context:
space:
mode:
Diffstat (limited to 'src/file-manager')
-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
3 files changed, 78 insertions, 0 deletions
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 ());