From ea3b78d47a1b4a6f5d7419fd414edbe59ad35bca Mon Sep 17 00:00:00 2001 From: nic80 Date: Sat, 30 May 2020 14:15:26 +0200 Subject: Get a working interface --- draksnapshot-config | 67 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 21 deletions(-) mode change 100755 => 100644 draksnapshot-config (limited to 'draksnapshot-config') diff --git a/draksnapshot-config b/draksnapshot-config old mode 100755 new mode 100644 index 8a6eb60..9982fe1 --- a/draksnapshot-config +++ b/draksnapshot-config @@ -28,7 +28,7 @@ use standalone; #- warning, standalone must be loaded very first, for 'expla use common; use interactive; use MDV::Snapshot::Common; -#use MDV::Snapshot::Hal; +use MDV::Snapshot::Hal; # i18n: IMPORTANT: to get correct namespace (drakconf instead of libDrakX) BEGIN { unshift @::textdomains, 'draksnapshot' } @@ -101,7 +101,7 @@ my @menu_items = ( { path => N("/_Help"), item_type => '' }, { path => N("/Help/_About...") } ); -my $_menubar = $::isEmbedded ? ugtk2::create_factory_menu($my_win->{rwindow}, @menu_items) : undef; +my $_menubar = $::isEmbedded ? Gtk3::MenuBar->new($my_win->{rwindow}, @menu_items) : undef; #my $_menubar = create_factory_menu($my_win->{rwindow}, @menu_items); ######### menus end @@ -111,9 +111,13 @@ my $where; # if not configured, just default where will be mounted the discs by HAL: if (!$backup_directory || $::testing) { my $dbus = get_system_bus(); - if ($dbus) { - my @discs = map { $_->GetProperty('volume.mount_point') } eval { find_removable_volumes($dbus) }; - $backup_directory = $discs[0]; + if ($dbus) {#decting by dbus is broken + # my @discs = map { $_ } eval { find_removable_volumes($dbus) }; + # $backup_directory = $discs[0]; + } + if (!$backup_directory) #not defined either by common.pm, rsnapshot.conf, or hal/udisks2 (current situation); Set a dummy path to be changed by user + { + $backup_directory="~/not_existing_path"; } } @@ -180,6 +184,7 @@ gtkadd($my_win->{window}, ]), ]), 0, gtknew('HButtonBox', layout => 'end', border_width => 5, spacing => 5, children_loose => [ + gtknew('Button', text => N("Restore"), clicked => \&restore), gtknew('Button', text => N("Apply"), clicked => \&save), gtknew('Button', text => $::isEmbedded ? N("Cancel") : N("Close"), clicked => sub { quit() }) ]) @@ -227,33 +232,44 @@ sub add { my $dlg = gtknew('Dialog', transient_for => $my_win->{real_window}, title => N("Add")); my $browse = gtknew('Button', text => N("browse")); my $file = gtknew('Entry', $o_iter ? (text => $model->get($o_iter, 1)) : ()); - my $alrd_exsts = defined $o_iter; + my $filename_choice; $browse->signal_connect(clicked => sub { - my $file_dlg = Gtk3::FileSelection->new(N("Path selection")); + my $file_dlg = Gtk3::FileChooserDialog->new(N("Path selection"),$dlg, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,N("Cancel") => GTK_RESPONSE_CANCEL,N("OK") => GTK_RESPONSE_OK); $file_dlg->set_modal(1); $file_dlg->set_transient_for($dlg); $file_dlg->show; $file_dlg->set_filename($file->get_text); - $file_dlg->cancel_button->signal_connect(clicked => sub { $file_dlg->destroy }); - $file_dlg->ok_button->signal_connect(clicked => sub { - $file->set_text($file_dlg->get_filename); - $file_dlg->destroy; - }); - }); - - gtkpack_($dlg->vbox, + my $answer_add=$file_dlg->run; + + if ( $answer_add eq 'cancel' ) + { + $file_dlg->destroy; + } + else + { + if ( $answer_add eq 'ok' ){ + $filename_choice=$file_dlg->get_filename; + $file->set_text($file_dlg->get_filename); + $file_dlg->destroy; + } + } + }); + + + gtkpack_($dlg->get_content_area(), 0, gtknew('Title2', label => N("Path")), 0, gtknew('HBox', border_width => 18, children => [ - 1, $file, - 0, $browse - ]), - ); + 1, $file, + 0, $browse + ]), + ); + #$dlg->set_has_separator(0); - gtkadd($dlg->action_area, + gtkadd($dlg->get_action_area, create_okcancel(my $w = { cancel_clicked => sub { $dlg->destroy }, @@ -280,7 +296,7 @@ sub add { } sub save() { - save_keyword('interval', map { + save_keyword('retain', map { my $val = $default_intervals{$_}; if_($val, join("\t", 'retain', $_, $val)); } @ordered_intervals); @@ -300,6 +316,15 @@ sub save() { generate_cron_entry(); } +sub fork_exec { + my $pid = run_program::raw({ detach => 1 }, @_); + return $pid; +} + +sub restore() { + fork_exec('/usr/sbin/draksnapshot-restore'); +} + sub save_keyword { my ($keyword, @values) = @_; my ($removed, $done); -- cgit v1.2.1