jenkins-core-weekly: update to 2.491
[oi-userland.git] / components / desktop / mate / caja / patches / 13-timeslider-file-manager.patch
blob2c1bfcf09e6aee8c2249eac66b9152e3f2617eed
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
3 @@ -71,6 +71,9 @@
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"/>
13 @@ -168,6 +171,9 @@
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"/>
23 @@ -218,6 +224,7 @@
24 </placeholder>
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
33 @@ -58,6 +58,9 @@
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 @@
46 return FALSE;
49 + static void
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)),
60 + cmd, NULL);
62 + g_free (cmd);
63 + g_free (fs);
64 + g_free (path);
65 + g_object_unref (file);
68 +static void
69 +action_restore_to_desktop_callback (GtkAction *action,
70 + gpointer callback_data)
72 + GList *locations = NULL;
73 + GList *node;
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)
79 + return;
81 + if (desktop_directory == NULL)
82 + return;
85 + for (node = selection; node != NULL; node = node->next)
86 + {
87 + locations = g_list_prepend (locations,
88 + caja_file_get_uri ((CajaFile *) node->data));
89 + }
91 + fm_directory_view_move_copy_items (locations, NULL, desktop_directory,
92 + GDK_ACTION_COPY, 0, 0, view);
94 + caja_file_list_free (selection);
97 +static void
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,
110 + real_file_path);
111 + mate_gdk_spawn_command_line_on_screen (gtk_widget_get_screen (GTK_WIDGET (callback_data)),
112 + cmd, NULL);
113 + g_free (cmd);
116 + g_free (file_path);
117 + g_object_unref (file);
120 static void
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);
150 if (dir)
152 @@ -1713,20 +1784,20 @@
154 if (count > 0)
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);
160 if (res != 0)
161 - g_warning ("Can't create symlink to nautilus scripts folder");
162 + g_warning ("Can't create symlink to caja scripts folder");
165 g_dir_close(dir);
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",
180 /* tooltip */ NULL,
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 @@
198 return FALSE;
201 +typedef struct {
202 + CajaFile *file;
203 + GCancellable *cancel;
204 + GtkAction *action;
205 +} HasSnapshotData;
207 +static void
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);
214 + switch (result)
216 + case UNKNOWN_STATE:
217 + case NO:
218 + gtk_action_set_sensitive (data->action, FALSE);
219 + g_value_init (&name, G_TYPE_STRING);
220 + /* SUN_BRANDING */
221 + g_value_set_static_string (&name, _("No versions"));
222 + g_object_set_property (G_OBJECT (data->action), "label", &name);
223 + break;
224 + case YES:
225 + gtk_action_set_sensitive (data->action, TRUE);
226 + g_value_init (&name, G_TYPE_STRING);
227 + /* SUN_BRANDING */
228 + g_value_set_static_string (&name, _("Explore versions"));
229 + g_object_set_property (G_OBJECT (data->action), "label", &name);
230 + break;
232 + g_free (data);
235 static void
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);
255 + if (fs)
257 + gtk_action_set_visible (action, TRUE);
258 + g_free (fs);
260 + g_free (path);
261 + g_object_unref (file);
263 + else
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));
273 + switch (result)
275 + case NO:
276 + gtk_action_set_visible (action, FALSE);
277 + break;
278 + case YES:
279 + gtk_action_set_visible (action, TRUE);
280 + gtk_action_set_sensitive (action, TRUE);
281 + g_value_init (&name,G_TYPE_STRING);
282 + /* SUN_BRANDING */
283 + g_value_set_static_string (&name, _("Explore versions"));
284 + g_object_set_property (G_OBJECT (action), "label", &name);
285 + break;
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);
290 + /* SUN_BRANDING */
291 + g_value_set_static_string (&name, _("Scanning for versions"));
292 + g_object_set_property (G_OBJECT (action), "label", &name);
293 + break;
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,
303 + data->cancel,
304 + data);
307 + else
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);