1 --- caja-1.28.0/src/caja-zfs-bar.h.orig 2024-02-26 08:42:41.083373824 +0100
2 +++ caja-1.28.0/src/caja-zfs-bar.h 2024-02-26 08:42:41.083327328 +0100
4 +#ifndef __CAJA_ZFS_BAR_H
5 +#define __CAJA_ZFS_BAR_H
8 +#include <libcaja-private/caja-directory.h>
9 +#include "caja-window-slot.h"
13 +#define CAJA_TYPE_ZFS_BAR (caja_zfs_bar_get_type ())
14 +#define CAJA_ZFS_BAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CAJA_TYPE_ZFS_BAR, CajaZfsBar))
15 +#define CAJA_ZFS_BAR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CAJA_TYPE_ZFS_BAR, CajaZfsBarClass))
16 +#define CAJA_IS_ZFS_BAR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CAJA_TYPE_ZFS_BAR))
17 +#define CAJA_IS_ZFS_BAR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CAJA_TYPE_ZFS_BAR))
18 +#define CAJA_ZFS_BAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CAJA_TYPE_ZFS_BAR, CajaZfsBarClass))
20 +typedef struct CajaZfsBarPrivate CajaZfsBarPrivate;
24 + GtkEventBox eventbox;
25 + CajaZfsBarPrivate *priv;
30 + GtkEventBoxClass parent_class;
33 +GType caja_zfs_bar_get_type (void) G_GNUC_CONST;
35 +GtkWidget * caja_zfs_bar_new ();
37 +void caja_zfs_bar_setup (CajaZfsBar* bar,
39 + CajaWindowSlot *active_slot,
40 + GtkToggleAction* action);
42 +void caja_zfs_bar_display (CajaZfsBar *bar,
44 + CajaDirectory *new_dir,
45 + GCancellable* cancellable);
47 +void caja_zfs_set_snap (CajaZfsBar *bar,
48 + CajaDirectory *dir);
49 +void caja_zfs_bar_remove_and_skip_snap
50 + (CajaZfsBar *bar, char *path);
52 +void caja_zfs_bar_hide (CajaZfsBar *bar);
54 +void caja_zfs_bar_cancel_tasks (CajaWindow *window);
55 +CajaDirectory * caja_zfs_bar_get_dir (CajaZfsBar* bar);
59 +#endif /* __CAJA_ZFS_BAR_H */
60 --- caja-1.28.0/src/caja-zfs-bar.c.orig 2024-02-26 08:42:41.083214681 +0100
61 +++ caja-1.28.0/src/caja-zfs-bar.c 2024-02-26 08:42:41.083165019 +0100
64 + * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
70 +#include <glib/gi18n-lib.h>
73 +#include "caja-zfs-bar.h"
74 +#include "caja-window.h"
75 +#include "caja-window-private.h"
76 +#include "timescale.h"
77 +#include <libcaja-private/caja-zfs.h>
78 +#include <libcaja-private/caja-file.h>
79 +#include <libcaja-private/caja-global-preferences.h>
80 +#include "caja-window-slot.h"
81 +#include "caja-navigation-window.h"
83 +#define CAJA_ZFS_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CAJA_TYPE_ZFS_BAR, CajaZfsBarPrivate))
85 +struct CajaZfsBarPrivate
89 + GtkWidget *delete_button;
90 + GdkColor in_snapshot;
91 + GtkToggleAction *action;
92 + CajaWindowSlot *slot;
93 + int num_range_items;
97 + ZfsSnapDirMonitor *zfs_dir_monitor_data;
98 + gboolean in_snapshot_dir;
99 + GtkWidget *camera_image;
100 + GtkWidget *delete_image;
101 + gboolean explicit_user_hide;
104 +G_DEFINE_TYPE (CajaZfsBar, caja_zfs_bar, GTK_TYPE_EVENT_BOX)
107 +close_clicked_callback (GtkWidget *widget,
110 +slider_moved_callback (TimeScale *ts,
113 +update_delete_or_snap_button (CajaZfsBar *bar,
117 +caja_zfs_bar_class_init (CajaZfsBarClass *klass)
119 + GObjectClass *object_class;
121 + object_class = G_OBJECT_CLASS (klass);
123 + g_type_class_add_private (klass, sizeof (CajaZfsBarPrivate));
127 +set_scale_range (CajaZfsBar *bar, gboolean set_initial_position)
132 + if (bar->priv->dir)
134 + i = caja_directory_get_num_snapshots (bar->priv->dir);
139 + bar->priv->num_range_items = i;
141 + tmp = caja_directory_get_snapshots (bar->priv->dir);
143 + if (set_initial_position)
144 + timescale_set_snapshots (TIMESCALE (bar->priv->scale), tmp, -1);
146 + timescale_set_snapshots (TIMESCALE (bar->priv->scale), tmp, bar->priv->num_range_items);
151 +update_range (CajaZfsBar *bar)
153 + if (caja_directory_get_snapshots (bar->priv->dir))
155 + set_scale_range (bar, FALSE);
156 + slider_moved_callback (TIMESCALE (bar->priv->scale), bar);
159 + close_clicked_callback (NULL, bar);
163 +match_func (ZfsDataSet *set, char *dir)
165 + /* remove trailing slash from dir */
166 + char mountp[PATH_MAX+1];
167 + int length = strlen (set->mountpoint);
169 + if (set->mountpoint[length-1] == '/')
171 + memcpy (mountp, set->mountpoint, length - 1);
172 + mountp[length-1] = NULL;
173 + return strcmp (mountp, dir);
176 + return strcmp (set->mountpoint, dir);
180 +caja_zfs_bar_remove_and_skip_snap (CajaZfsBar *bar, char *path)
182 + GList* match = NULL;
183 + GList* snap_list = NULL;
186 + snap_list = caja_directory_get_snapshots (bar->priv->dir);
187 + match = g_list_find_custom (snap_list, path, (GCompareFunc)match_func);
191 + snap = (ZfsDataSet*) match->data;
192 + caja_directory_remove_snapshot (bar->priv->dir, snap);
193 + update_range (bar);
198 +update_delete_or_snap_button (CajaZfsBar *bar, gboolean in_snap)
202 + if (!bar->priv->in_snapshot_dir)
203 + { /*in main dir to snap */
204 + bar->priv->in_snapshot_dir = TRUE;
205 + g_object_ref (bar->priv->camera_image);
206 + gtk_button_set_image (GTK_BUTTON (bar->priv->delete_button),
207 + bar->priv->delete_image);
208 + gtk_widget_set_tooltip_text (bar->priv->delete_button,
210 + _("Delete this snapshot"));
215 + if (bar->priv->in_snapshot_dir)
216 + { /* in snap to main dir */
217 + bar->priv->in_snapshot_dir = FALSE;
218 + g_object_ref (bar->priv->delete_image);
219 + gtk_button_set_image (GTK_BUTTON (bar->priv->delete_button),
220 + bar->priv->camera_image);
221 + gtk_widget_set_tooltip_text (bar->priv->delete_button,
223 + _("Take a zfs snapshot of this directory now"));
229 +slider_moved_callback (TimeScale *ts,
235 + int pos = timescale_get_position (ts);
237 + if (pos < bar->priv->num_range_items)
239 + tmp = caja_directory_get_snapshots (bar->priv->dir);
241 + snap = g_list_nth_data (tmp, pos);
243 + snap_file = g_file_new_for_path (snap->mountpoint);
247 + snap_file = caja_directory_get_location (bar->priv->dir);
248 + pos = bar->priv->num_range_items;
251 + if (!bar->priv->set_only)
253 + gboolean in_snap = FALSE;
254 + char *path = g_file_get_path (snap_file);
256 + if (g_file_test (path, G_FILE_TEST_IS_DIR))
258 + caja_window_slot_go_to (bar->priv->slot,
261 + if (bar->priv->current_path)
262 + g_free (bar->priv->current_path);
263 + bar->priv->current_path = path;
266 + { /* the snapshot diappeared try the next one */
268 + g_object_unref (snap_file);
269 + /* remove snap from list */
270 + caja_directory_remove_snapshot (bar->priv->dir, snap);
271 + update_range (bar);
275 + in_snap = ts_is_in_snapshot (path);
276 + update_delete_or_snap_button (bar, ts_is_in_snapshot (path));
280 + g_object_unref (snap_file);
285 +delete_clicked_callback (GtkWidget *widget,
292 + char *full_command;
293 + int pos = timescale_get_position (TIMESCALE (bar->priv->scale));
295 + if (bar->priv->in_snapshot_dir)
297 + tmp = caja_directory_get_snapshots (bar->priv->dir);
298 + snap = g_list_nth_data (tmp, pos);
299 + snap_file = g_file_new_for_path (snap->mountpoint);
300 + path = g_file_get_path (snap_file);
302 + g_object_unref (snap_file);
305 + /*printf ("path %s snapshot to delete %s\n", path, snap->name);*/
306 + full_command = g_strdup_printf ("/usr/lib/time-slider-delete '%s'", snap->name);
310 + /*printf ("path %s backup to delete %s\n", path, snap->name);*/
311 + full_command = g_strdup_printf ("/usr/lib/time-slider-delete '%s'", path);
314 + mate_gdk_spawn_command_line_on_screen (gtk_widget_get_screen (widget),
315 + full_command, NULL);
319 + path = g_file_get_path (caja_directory_get_location (bar->priv->dir));
320 + char *fs = ts_get_zfs_filesystem (path);
321 + /* printf ("take a snapshot of zfs fs %s for dir %s\n", fs, path); */
322 + full_command = g_strdup_printf ("/usr/lib/time-slider-snapshot '%s' '%s'", path, fs);
323 + mate_gdk_spawn_command_line_on_screen (gtk_widget_get_screen (widget),
324 + full_command, NULL);
328 + g_free (full_command);
333 +close_clicked_callback (GtkWidget *widget,
336 + GFile *snap_file = caja_directory_get_location (bar->priv->dir);
338 + caja_window_slot_go_to (bar->priv->slot,
341 + g_object_unref (snap_file);
343 + bar->priv->is_setup = FALSE;
345 + gtk_widget_hide (GTK_WIDGET (bar));
346 + gtk_toggle_action_set_active (bar->priv->action, FALSE);
351 +caja_zfs_bar_init (CajaZfsBar *bar)
353 + GtkWidget *hbox, *toolbar, *close, *delete, *image, *button_vbox;
357 + bar->priv = CAJA_ZFS_BAR_GET_PRIVATE (bar);
359 + bar->priv->dir = NULL;
360 + bar->priv->num_range_items = 0;
361 + bar->priv->action = NULL;
362 + bar->priv->slot = NULL;
363 + bar->priv->is_setup = FALSE;
364 + bar->priv->set_only = FALSE;
368 + toolbar = gtk_toolbar_new ();
369 + gtk_widget_show (toolbar);
371 + item = gtk_tool_item_new ();
372 + gtk_widget_show (GTK_WIDGET (item));
373 + gtk_tool_item_set_expand (item, TRUE);
375 + hbox = gtk_hbox_new (FALSE, 2);
376 + gtk_widget_show (GTK_WIDGET (hbox));
378 + gtk_container_add (GTK_CONTAINER (item),hbox);
380 + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
381 + gtk_container_add (GTK_CONTAINER (bar),toolbar);
382 + gtk_container_set_border_width (GTK_CONTAINER (bar), 0);
386 + button_vbox = gtk_vbox_new (FALSE, 0);
387 + gtk_widget_show (button_vbox);
389 + close = gtk_button_new ();
390 + gtk_button_set_relief (GTK_BUTTON (close), GTK_RELIEF_NONE);
391 + gtk_widget_set_tooltip_text (close,
393 + _("Close Time Slider and return to original directory"));
394 + gtk_widget_show (close);
396 + g_signal_connect (close,
398 + G_CALLBACK (close_clicked_callback),
401 + image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
402 + GTK_ICON_SIZE_MENU);
403 + gtk_widget_show (image);
405 + gtk_container_add (GTK_CONTAINER (close), image);
407 + gtk_box_pack_start (GTK_BOX (button_vbox), close, FALSE, FALSE, 0);
409 + delete = gtk_button_new ();
410 + gtk_button_set_relief (GTK_BUTTON (delete), GTK_RELIEF_NONE);
411 + gtk_widget_set_tooltip_text (delete,
413 + _("Take a zfs snapshot of this directory now"));
414 + gtk_widget_show (delete);
416 + g_signal_connect (delete,
418 + G_CALLBACK (delete_clicked_callback),
422 + GtkIconTheme *it = gtk_icon_theme_get_default ();
423 + GdkPixbuf * pb = gtk_icon_theme_load_icon (it,
424 + "user-trash-full.png",
426 + GTK_ICON_LOOKUP_GENERIC_FALLBACK,
428 + bar->priv->delete_image = gtk_image_new_from_pixbuf (pb);
429 + g_object_unref (pb);
432 + path = caja_pixmap_file ("camera.png");
433 + bar->priv->camera_image = gtk_image_new_from_file (path);
436 + gtk_widget_show (bar->priv->delete_image);
437 + gtk_widget_show (bar->priv->camera_image);
439 + gtk_container_add (GTK_CONTAINER (delete), bar->priv->camera_image);
441 + gtk_box_pack_end (GTK_BOX (button_vbox), delete, FALSE, FALSE, 0);
442 + gtk_box_pack_end (GTK_BOX (hbox), button_vbox, FALSE, FALSE, 0);
444 + bar->priv->delete_button = delete;
446 + bar->priv->scale = timescale_new();
448 + g_signal_connect (bar->priv->scale,
450 + G_CALLBACK (slider_moved_callback),
453 + gtk_widget_show (bar->priv->scale);
455 + gtk_box_pack_start (GTK_BOX (hbox), bar->priv->scale, TRUE, TRUE, 0);
460 +caja_zfs_bar_get_dir (CajaZfsBar* bar)
462 + g_return_val_if_fail (CAJA_IS_ZFS_BAR (bar), NULL);
463 + return bar->priv->dir;
467 +snapshot_data_ready (CajaDirectory *dir,
468 + GCancellable *cancellable,
469 + gpointer callback_data)
471 + CajaWindowSlot *slot;
473 + GFile *dir_location;
474 + CajaWindow *window = (CajaWindow*)callback_data;
476 + g_return_if_fail (CAJA_IS_WINDOW (window));
478 + slot = caja_window_get_active_slot (window);
479 + location = caja_window_slot_get_location (slot);
480 + dir_location = caja_directory_get_location (dir);
482 + if (g_cancellable_is_cancelled (cancellable) && g_file_equal (location, dir_location))
484 + caja_navigation_window_set_spinner_active (CAJA_NAVIGATION_WINDOW (window), FALSE);
485 + caja_navigation_window_set_restore_icon ( CAJA_NAVIGATION_WINDOW (window), RESTORE_NO);
487 + else if (g_file_equal (location, dir_location))
489 + char *path = g_file_get_path (dir_location);
490 + g_cancellable_cancel (cancellable);
491 + caja_window_slot_set_allow_stop (slot, FALSE);
492 + caja_navigation_window_set_restore_icon ( CAJA_NAVIGATION_WINDOW (window),
493 + caja_directory_has_snapshots (dir) ? RESTORE_NORMAL : RESTORE_NO);
494 + if (caja_directory_has_snapshots (dir))
495 + caja_window_allow_restore (window, TRUE);
497 + caja_window_allow_restore (window, FALSE);
502 + caja_window_slot_set_allow_stop (slot, FALSE);
504 + g_object_unref (location);
505 + g_object_unref (dir_location);
510 +caja_zfs_bar_cancel_tasks (CajaWindow *window)
512 + if (CAJA_IS_WINDOW (window))
514 + if (CAJA_IS_WINDOW_SLOT (window->details->active_pane->active_slot))
516 + CajaDirectory *directory = NULL;
517 + g_cancellable_cancel (window->details->active_pane->active_slot->find_zfs_snapshots_cancellable);
518 + g_object_unref (window->details->active_pane->active_slot->find_zfs_snapshots_cancellable);
519 + window->details->active_pane->active_slot->find_zfs_snapshots_cancellable = NULL;
520 + directory = caja_directory_get (window->details->active_pane->active_slot->location);
523 + caja_directory_cancel_restore_info (directory);
524 + caja_directory_unref (directory);
527 + if (CAJA_IS_NAVIGATION_WINDOW (window))
529 + CajaZfsBar *bar = CAJA_ZFS_BAR (CAJA_NAVIGATION_WINDOW (window)->zfs_bar);
530 + monitor_zfs_snap_directory_cancel (bar->priv->zfs_dir_monitor_data);
531 + bar->priv->zfs_dir_monitor_data = NULL;
537 +caja_zfs_bar_hide (CajaZfsBar *bar)
539 + bar->priv->explicit_user_hide = TRUE;
540 + close_clicked_callback (NULL, bar);
544 +/* Display AND Scan */
547 +caja_zfs_bar_display (CajaZfsBar *bar,
548 + CajaWindow *window,
549 + CajaDirectory *new_dir,
550 + GCancellable *cancellable)
552 + gboolean show = FALSE;
553 + gboolean time_slider_enabled = g_settings_get_boolean (caja_preferences,
554 + CAJA_PREFERENCES_ENABLE_TIME_SLIDER);
555 + gboolean visible = gtk_widget_get_visible (GTK_WIDGET (bar));
556 + gboolean enable_button = FALSE;
557 + gboolean do_scan = FALSE;
558 + gboolean do_cancel = FALSE;
562 + * if feature disabled
568 + * if bar was previously displayed and in same tab
580 + * if feature enabled
585 + * NOTE : action_restore_callback display bar when enabled
590 + if (!time_slider_enabled)
592 + close_clicked_callback (NULL, bar);
595 + if (new_dir == bar->priv->dir)
596 + enable_button = TRUE;
597 + if (caja_directory_is_a_snapshot_dir_of (new_dir, bar->priv->dir) || new_dir == bar->priv->dir)
601 + enable_button = TRUE;
607 + { /* bar is not visible */
608 + CajaWindowSlot *slot = caja_window_get_active_slot (window);
610 + if (bar->priv->is_setup && slot == bar->priv->slot && time_slider_enabled) /* check if we can redisplay the bar */
612 + if (caja_directory_is_a_snapshot_dir_of (new_dir, bar->priv->dir) && !bar->priv->explicit_user_hide)
615 + if (bar->priv->explicit_user_hide)
616 + enable_button = FALSE;
618 + if (new_dir == bar->priv->dir)
621 + enable_button = TRUE;
627 + { /* icon and throbber set is snapshot_data_ready */
628 + if (time_slider_enabled)
634 + if (enable_button) /* if button enabled set the icon to normal */
635 + caja_navigation_window_set_restore_icon (CAJA_NAVIGATION_WINDOW (window), RESTORE_NORMAL);
637 + caja_window_allow_restore (window, enable_button);
642 + gtk_widget_show (GTK_WIDGET (bar));
643 + caja_zfs_set_snap (bar, new_dir);
647 + gtk_widget_hide (GTK_WIDGET (bar));
648 + if (bar->priv->action)
649 + gtk_toggle_action_set_active (bar->priv->action, FALSE);
653 + g_cancellable_cancel (cancellable);
657 + g_cancellable_reset (cancellable);
658 + caja_navigation_window_set_restore_icon (CAJA_NAVIGATION_WINDOW (window), RESTORE_SEARCH);
659 + caja_window_slot_set_allow_stop (caja_window_get_active_slot (window), TRUE);
660 + caja_directory_get_snapshots_async (new_dir,
661 + snapshot_data_ready,
667 + GFile *file = caja_directory_get_location (new_dir);
668 + char *path = g_file_get_path (file);
670 + printf ("caja_zfs_bar_display %s\nenable_button : %s, show : %s, do_cancel : %s, do_scan : %s\n\n",
672 + enable_button ? "true" : "false",
673 + show ? "true" : "false",
674 + do_cancel ? "true" : "false",
675 + do_scan ? "true" : "false");
682 +caja_zfs_set_snap (CajaZfsBar *bar,
683 + CajaDirectory *dir)
685 + GList* match = NULL;
686 + GList* snap_list = NULL;
687 + gboolean in_snap = FALSE;
688 + char real_path [PATH_MAX+1];
694 + if (!bar->priv->is_setup)
697 + file = caja_directory_get_location (dir);
698 + path = g_file_get_path (file);
699 + ts_realpath (path, real_path);
702 + if (ts_is_in_remote_backup (real_path))
704 + /*FIXME: we do not have it */
706 + g_object_ref (dir);
709 + in_snap = ts_is_in_snapshot (real_path);
713 + snap_list = caja_directory_get_snapshots (bar->priv->dir);
714 + match = g_list_find_custom (snap_list, real_path, (GCompareFunc)match_func);
717 + g_object_unref (file);
719 + timescale_set_position (TIMESCALE (bar->priv->scale), match ? ((ZfsDataSet*)match->data)->mountpoint : NULL);
720 + update_delete_or_snap_button (bar, in_snap);
722 + /* printf ("caja_zfs_set_snap current_path %s real_path %s match %s\n", bar->priv->current_path, real_path,
723 + match ? "found" : "not found");*/
725 + if (bar->priv->current_path && (strcmp (bar->priv->current_path, real_path) != 0))
727 + bar->priv->set_only = TRUE;
728 + bar->priv->set_only = FALSE;
734 +snapshot_data_ready_from_change (CajaDirectory *dir,
735 + GCancellable *cancellable,
736 + gpointer callback_data)
738 + CajaZfsBar *bar = CAJA_ZFS_BAR (callback_data);
740 + snapshot_data_ready (dir, cancellable, bar->priv->slot->pane->window);
741 + update_range (bar);
742 + gtk_widget_set_sensitive (bar->priv->scale, TRUE);
746 +zfs_dir_change_callback (ZfsSnapDirMonitor *monitor_data,
749 + gtk_widget_set_sensitive (bar->priv->scale, FALSE);
751 + g_cancellable_reset (bar->priv->slot->find_zfs_snapshots_cancellable);
752 + caja_navigation_window_set_restore_icon (CAJA_NAVIGATION_WINDOW (bar->priv->slot->pane->window), RESTORE_SEARCH);
753 + caja_window_slot_set_allow_stop (bar->priv->slot, TRUE);
754 + caja_directory_get_snapshots_async (bar->priv->dir,
755 + snapshot_data_ready_from_change,
756 + bar->priv->slot->find_zfs_snapshots_cancellable,
761 +get_backup_dir (GList *snaplist)
763 + GList *tmp = snaplist;
767 + ZfsDataSet *snap = (ZfsDataSet*) tmp->data;
768 + if (snap->type == 0)
770 + char **root_split = NULL;
771 + char *result = NULL;
772 + root_split = g_strsplit (snap->mountpoint, snap->name, 2);
773 + /*printf (" name: %s\n mountpoint: %s\n mtime_str :%s\n space used : %s\n size in kilobytes : %f\n",
774 + snap->name, snap->mountpoint, snap->mtime_str, snap->used_space_str, snap->used_space); */
775 + result = g_strdup (root_split[0]);
777 + g_strfreev (root_split);
786 +caja_zfs_bar_setup (CajaZfsBar* bar,
787 + CajaDirectory *dir,
788 + CajaWindowSlot *active_slot,
789 + GtkToggleAction* action)
792 + char *path, *zfs_dir, *backup_dir = NULL;
793 + bar->priv->dir = dir;
794 + g_object_ref (dir);
795 + bar->priv->slot = active_slot;
796 + g_object_ref (active_slot);
798 + bar->priv->action = action;
799 + set_scale_range (bar, TRUE);
800 + bar->priv->is_setup = TRUE;
801 + bar->priv->explicit_user_hide = FALSE;
803 + file = caja_directory_get_location (dir);
804 + path = g_file_get_path (file);
805 + zfs_dir = ts_get_snapshot_dir (path);
806 + backup_dir = get_backup_dir (caja_directory_get_snapshots (dir));
808 + bar->priv->zfs_dir_monitor_data = monitor_zfs_snap_directory (zfs_dir,
810 + (ZfsDirChangeCallback) zfs_dir_change_callback,
812 + caja_zfs_set_snap (bar, dir);
816 + g_free(backup_dir);
817 + g_object_unref (file);
821 +zfs_bar_show_column (GtkWidget *widget, gpointer user_data)
823 + char **visible_columns;
824 + gboolean restore_col_visible = FALSE;
826 + GPtrArray *ret = NULL;
828 + visible_columns = g_settings_get_strv (caja_list_view_preferences,
829 + CAJA_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
831 + ret = g_ptr_array_new ();
833 + /* convert visible_columns in ptr array without "restore_info" */
834 + while (visible_columns[i])
836 + if (strcmp (visible_columns [i], "restore_info") == 0)
838 + restore_col_visible = TRUE;
842 + g_ptr_array_add (ret, g_strdup (visible_columns [i]));
846 + g_strfreev (visible_columns);
848 + if (restore_col_visible)
850 + if (!gtk_widget_get_visible (widget)) /* hide bar remove pref */
853 + g_ptr_array_add (ret, NULL);
854 + col_array = (char **)g_ptr_array_free (ret, FALSE);
855 + g_settings_set_strv (caja_list_view_preferences,
856 + CAJA_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
857 + (const char * const *)col_array);
858 + g_strfreev (col_array);
864 + if (gtk_widget_get_visible (widget))
867 + g_ptr_array_add (ret,strdup ("restore_info"));
868 + g_ptr_array_add (ret,NULL);
869 + col_array = (char **)g_ptr_array_free (ret, FALSE);
870 + g_settings_set_strv (caja_list_view_preferences,
871 + CAJA_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
872 + (const char * const *)col_array);
873 + g_strfreev (col_array);
880 + g_ptr_array_free (ret, TRUE);
885 +zfs_bar_hidden (GtkWidget *widget, gpointer user_data)
887 + CajaZfsBar *bar = CAJA_ZFS_BAR (user_data);
888 + monitor_zfs_snap_directory_cancel (bar->priv->zfs_dir_monitor_data);
889 + bar->priv->zfs_dir_monitor_data = NULL;
890 + caja_directory_cancel_restore_info (bar->priv->dir);
897 + CajaZfsBar *zfs_bar;
899 + bar = g_object_new (CAJA_TYPE_ZFS_BAR, NULL);
901 + g_signal_connect_object (bar, "show", G_CALLBACK (zfs_bar_show_column), bar, 0);
902 + g_signal_connect_object (bar, "hide", G_CALLBACK (zfs_bar_show_column), bar, 0);
903 + g_signal_connect_object (bar, "hide", G_CALLBACK (zfs_bar_hidden), bar, 0);
905 + zfs_bar_show_column (GTK_WIDGET (bar), NULL);
907 + ts_is_restore_column_enabled_init ();
909 + zfs_bar = CAJA_ZFS_BAR (bar);
911 + return GTK_WIDGET (bar);