1 --- caja-1.28.0/src/file-manager/caja-directory-view-ui.xml.orig 2024-02-20 01:30:36.000000000 +0100
2 +++ caja-1.28.0/src/file-manager/caja-directory-view-ui.xml 2024-02-26 08:42:41.083540685 +0100
4 <menuitem name="Duplicate" action="Duplicate"/>
5 <menuitem name="Create Link" action="Create Link"/>
6 <menuitem name="Rename" action="Rename"/>
7 + <menuitem name="Restore to" action="Restore to"/>
8 + <menuitem name="Snapshot now" action="Snap Now"/>
9 + <menuitem name="Scanning...." action="View Snap"/>
10 <menu action="CopyToMenu">
11 <menuitem name="Copy to next pane" action="Copy to next pane"/>
12 <menuitem name="Copy to Home" action="Copy to Home"/>
14 <placeholder name="File Actions">
15 <menuitem name="Create Link" action="Create Link"/>
16 <menuitem name="Rename" action="Rename"/>
17 + <menuitem name="Restore to" action="Restore to"/>
18 + <menuitem name="Snapshot now" action="Snap Now"/>
19 + <menuitem name="Scanning...." action="View Snap"/>
20 <menu action="CopyToMenu">
21 <menuitem name="Copy to next pane" action="Copy to next pane"/>
22 <menuitem name="Copy to Home" action="Copy to Home"/>
25 <separator name="Location After Clipboard Separator"/>
26 <placeholder name="Dangerous File Actions">
27 + <menuitem name="Restore" action="Restore"/>
28 <menuitem name="Trash" action="LocationTrash"/>
29 <menuitem name="Delete" action="LocationDelete"/>
30 <menuitem name="Restore From Trash" action="LocationRestoreFromTrash"/>
31 --- caja-1.28.0/src/file-manager/fm-actions.h.orig 2024-02-20 01:30:36.000000000 +0100
32 +++ caja-1.28.0/src/file-manager/fm-actions.h 2024-02-26 08:42:41.083717777 +0100
34 #define FM_ACTION_NEW_LAUNCHER "New Launcher"
35 #define FM_ACTION_NEW_LAUNCHER_DESKTOP "New Launcher Desktop"
36 #define FM_ACTION_RENAME "Rename"
37 +#define FM_ACTION_RESTORE_TO "Restore to"
38 +#define FM_ACTION_HAS_SNAPSHOT "View Snap"
39 +#define FM_ACTION_SNAP_NOW "Snap Now"
40 #define FM_ACTION_DUPLICATE "Duplicate"
41 #define FM_ACTION_CREATE_LINK "Create Link"
42 #define FM_ACTION_SELECT_ALL "Select All"
43 --- caja-1.28.0/src/file-manager/fm-directory-view.c.orig 2024-02-20 01:30:36.000000000 +0100
44 +++ caja-1.28.0/src/file-manager/fm-directory-view.c 2024-02-26 08:42:41.084993364 +0100
45 @@ -1002,6 +1002,77 @@
50 +action_snap_now (GtkAction *action,
51 + gpointer callback_data)
53 + FMDirectoryView *view = FM_DIRECTORY_VIEW (callback_data);
54 + GList *selection = fm_directory_view_get_selection_for_file_transfer (view);
55 + GFile *file = caja_file_get_location (CAJA_FILE (selection->data));
56 + char *path = g_file_get_path (file);
57 + char *fs = ts_get_zfs_filesystem (path);
58 + char *cmd = g_strdup_printf ("/usr/lib/time-slider-snapshot '%s' '%s'", path, fs);
59 + mate_gdk_spawn_command_line_on_screen (gtk_widget_get_screen (GTK_WIDGET (callback_data)),
65 + g_object_unref (file);
69 +action_restore_to_desktop_callback (GtkAction *action,
70 + gpointer callback_data)
72 + GList *locations = NULL;
74 + FMDirectoryView *view = FM_DIRECTORY_VIEW (callback_data);
75 + char *desktop_directory = caja_get_desktop_directory_uri();
76 + GList *selection = fm_directory_view_get_selection_for_file_transfer (view);
78 + if (selection == NULL)
81 + if (desktop_directory == NULL)
85 + for (node = selection; node != NULL; node = node->next)
87 + locations = g_list_prepend (locations,
88 + caja_file_get_uri ((CajaFile *) node->data));
91 + fm_directory_view_move_copy_items (locations, NULL, desktop_directory,
92 + GDK_ACTION_COPY, 0, 0, view);
94 + caja_file_list_free (selection);
98 +action_show_snapshot_versions_callback (GtkAction *action,
99 + gpointer callback_data)
101 + FMDirectoryView *view = FM_DIRECTORY_VIEW (callback_data);
102 + GList *selection = fm_directory_view_get_selection_for_file_transfer (view);
103 + GFile *file = caja_file_get_location (CAJA_FILE (selection->data));
104 + char *dir = caja_file_get_snapshot_dir (CAJA_FILE (selection->data));
105 + char *file_path = g_file_get_path (file);
106 + char real_file_path [PATH_MAX + 1];
107 + if (ts_realpath (file_path, real_file_path))
109 + char *cmd = g_strdup_printf ("/usr/lib/time-slider-version '%s' '%s'", dir,
111 + mate_gdk_spawn_command_line_on_screen (gtk_widget_get_screen (GTK_WIDGET (callback_data)),
116 + g_free (file_path);
117 + g_object_unref (file);
121 action_trash_callback (GtkAction *action,
122 gpointer callback_data)
123 @@ -1686,20 +1757,20 @@
124 scripts_directory_uri = g_filename_to_uri(scripts_directory_path, NULL, NULL);
125 scripts_directory_uri_length = strlen(scripts_directory_uri);
127 - /* Support for GNOME Nautilus scripts
128 + /* Support for GNOME Caja scripts
130 - char* nautilus_scripts_path = g_build_filename(g_get_home_dir(), ".gnome2", "nautilus-scripts", NULL);
131 + char* caja_scripts_path = g_build_filename(g_get_home_dir(), ".gnome2", "caja-scripts", NULL);
133 - if (g_file_test(nautilus_scripts_path, G_FILE_TEST_IS_DIR) == TRUE)
134 + if (g_file_test(caja_scripts_path, G_FILE_TEST_IS_DIR) == TRUE)
136 - char* nautilus_syslink = g_build_filename(g_get_user_config_dir(), "caja", "scripts", "nautilus", NULL);
137 + char* caja_syslink = g_build_filename(g_get_user_config_dir(), "caja", "scripts", "caja", NULL);
138 /* If link already exists, or also any other kind of file/dir with same name, ignore it */
139 - if (g_file_test(nautilus_syslink, G_FILE_TEST_IS_SYMLINK) == FALSE &&
140 - g_file_test(nautilus_syslink, G_FILE_TEST_EXISTS) == FALSE &&
141 - g_file_test(nautilus_syslink, G_FILE_TEST_IS_DIR) == FALSE)
142 + if (g_file_test(caja_syslink, G_FILE_TEST_IS_SYMLINK) == FALSE &&
143 + g_file_test(caja_syslink, G_FILE_TEST_EXISTS) == FALSE &&
144 + g_file_test(caja_syslink, G_FILE_TEST_IS_DIR) == FALSE)
146 /* Check if we need to create a link */
147 - GDir* dir = g_dir_open(nautilus_scripts_path, 0, NULL);
148 + GDir* dir = g_dir_open(caja_scripts_path, 0, NULL);
152 @@ -1713,20 +1784,20 @@
156 - /* Create link to nautilus folder */
157 - int res = symlink (nautilus_scripts_path, nautilus_syslink);
158 + /* Create link to caja folder */
159 + int res = symlink (caja_scripts_path, caja_syslink);
161 - g_warning ("Can't create symlink to nautilus scripts folder");
162 + g_warning ("Can't create symlink to caja scripts folder");
169 - g_free(nautilus_syslink);
170 + g_free(caja_syslink);
173 - g_free(nautilus_scripts_path);
174 + g_free(caja_scripts_path);
177 g_free(scripts_directory_path);
178 @@ -7473,6 +7544,18 @@
179 /* label, accelerator */ "RenameSelectAll", "<shift>F2",
181 G_CALLBACK (action_rename_select_all_callback) },
182 + /* name, icon name */ { "Restore to", NULL,
183 + /* label, accelerator */ N_("Restore to Desktop"), NULL,
184 + /* tooltip */ N_("Move each selected item to the Desktop"),
185 + G_CALLBACK (action_restore_to_desktop_callback) },
186 + /* name, stock id */ { "View Snap", NULL,
187 + /* label, accelerator */ N_("View versions"), NULL,
188 + /* tooltip */ N_("View the versions of this file available in ZFS snapshots"),
189 + G_CALLBACK (action_show_snapshot_versions_callback) },
190 + /* name, stock id */ { "Snap Now", NULL,
191 + /* label, accelerator */ N_("Snapshot now"), NULL,
192 + /* tooltip */ N_("Take a ZFS snapshot of this directory now"),
193 + G_CALLBACK (action_snap_now) },
194 /* name, icon name */ { "Trash", NULL,
195 /* label, accelerator */ N_("Mo_ve to Trash"), NULL,
196 /* tooltip */ N_("Move each selected item to the Trash"),
197 @@ -8834,6 +8917,40 @@
203 + GCancellable *cancel;
208 +has_snapshot_ready_callback (gpointer user_data)
210 + GValue name = {0,};
211 + HasSnapshotData *data = (HasSnapshotData*) user_data;
212 + HasSnapshotResult result = caja_file_has_snapshot_version (data->file);
216 + case UNKNOWN_STATE:
218 + gtk_action_set_sensitive (data->action, FALSE);
219 + g_value_init (&name, G_TYPE_STRING);
221 + g_value_set_static_string (&name, _("No versions"));
222 + g_object_set_property (G_OBJECT (data->action), "label", &name);
225 + gtk_action_set_sensitive (data->action, TRUE);
226 + g_value_init (&name, G_TYPE_STRING);
228 + g_value_set_static_string (&name, _("Explore versions"));
229 + g_object_set_property (G_OBJECT (data->action), "label", &name);
236 real_update_menus (FMDirectoryView *view)
238 @@ -9211,6 +9328,75 @@
239 gtk_action_set_sensitive (action, can_copy_files);
240 G_GNUC_END_IGNORE_DEPRECATIONS;
242 + action = gtk_action_group_get_action (view->details->dir_action_group,
243 + FM_ACTION_RESTORE_TO);
244 + gtk_action_set_visible (action, can_copy_files &&
245 + caja_directory_is_in_snapshot (view->details->model));
247 + action = gtk_action_group_get_action (view->details->dir_action_group,
248 + FM_ACTION_SNAP_NOW);
250 + if (selection_count == 1 && caja_file_is_directory (CAJA_FILE (selection->data)))
252 + GFile *file = caja_file_get_location (CAJA_FILE (selection->data));
253 + char *path = g_file_get_path (file);
254 + char *fs = ts_get_zfs_filesystem (path);
257 + gtk_action_set_visible (action, TRUE);
261 + g_object_unref (file);
264 + gtk_action_set_visible (action, FALSE);
266 + action = gtk_action_group_get_action (view->details->dir_action_group,
267 + FM_ACTION_HAS_SNAPSHOT);
268 + if (selection_count == 1)
270 + GValue name = { 0, };
271 + int result = caja_file_has_snapshot_version (CAJA_FILE (selection->data));
276 + gtk_action_set_visible (action, FALSE);
279 + gtk_action_set_visible (action, TRUE);
280 + gtk_action_set_sensitive (action, TRUE);
281 + g_value_init (&name,G_TYPE_STRING);
283 + g_value_set_static_string (&name, _("Explore versions"));
284 + g_object_set_property (G_OBJECT (action), "label", &name);
286 + case UNKNOWN_STATE:
287 + gtk_action_set_visible (action, TRUE);
288 + gtk_action_set_sensitive (action, FALSE);
289 + g_value_init (&name,G_TYPE_STRING);
291 + g_value_set_static_string (&name, _("Scanning for versions"));
292 + g_object_set_property (G_OBJECT (action), "label", &name);
295 + if (result == UNKNOWN_STATE)
297 + HasSnapshotData *data = g_new0 (HasSnapshotData, 1);
298 + data->action = action;
299 + data->file = CAJA_FILE (selection->data);
300 + data->cancel = g_cancellable_new ();
301 + caja_file_get_snapshot_version (CAJA_FILE (selection->data),
302 + has_snapshot_ready_callback,
308 + gtk_action_set_visible (action, FALSE);
311 real_update_paste_menu (view, selection, selection_count);
313 disable_command_line = g_settings_get_boolean (mate_lockdown_preferences, CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE);