This file is indexed.

/usr/share/doc/libgnome2-perl/examples/session-management.pl is in libgnome2-perl 1.046-3+b1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/perl -w
use strict;
use Gnome2;

# $Id$

my $application = Gnome2::Program -> init("Test", "0.1", "libgnomeui");
my $client = Gnome2::Client -> master();

###############################################################################

$client -> signal_connect(die => sub {
  # No time to save anything, just die.
  Gtk2 -> main_quit();
});

$client -> signal_connect(save_yourself => sub {
  my ($client,
      $phase,
      $save_style,
      $shutting_down,
      $interact_style,
      $fast) = @_;

  if ($fast) { # We're in a hurry, so don't do anything that takes ages.
    unless (save_session_quickly()) {
      error("Saving session failed.") if ($interact_style & "error");
      return 0;
    }
  }
  else { # We've plenty of time.
    unless (save_session()) {
      if ($interact_style & "any") {
        question("Couldn't save session.  Do you want me to " .
                 "delete all your personal files in response?",
                 sub { delete_all_personal_files(); });
      }
      elsif ($interact_style & "error") {
        error("Saving session failed.");
      }

      return 0;
    }
  }

  return 1;
});

###############################################################################

my $app = Gnome2::App -> new("test", "Test");
my $box = Gtk2::VBox -> new(0, 0);

my $button_die = Gtk2::Button -> new("_Die");
my $button_save = Gtk2::Button -> new("_Save");
my $button_save_quickly = Gtk2::Button -> new("Save quickly");

# Normally, those events are fired by the session manager when the user logs
# out or kills the application via the session UI.  We emulate them here.
$button_die -> signal_connect(clicked => sub {
  $client -> signal_emit("die");
});

$button_save -> signal_connect(clicked => sub {
  $client -> request_save("local", 0, "any", 0, 0);
});

$button_save_quickly -> signal_connect(clicked => sub {
  $client -> request_save("local", 0, "errors", 1, 0);
});

$box -> pack_start($button_die, 0, 0, 0);
$box -> pack_start($button_save, 0, 0, 0);
$box -> pack_start($button_save_quickly, 0, 0, 0);

$app -> set_contents($box);
$app -> show_all();

$app -> signal_connect(destroy => sub {
  Gtk2 -> main_quit();
});

Gtk2 -> main();

###############################################################################

sub delete_all_personal_files {
  $| = 1;
  print "Deleting all personal files ...";
  select(undef, undef, undef, 0.25);
  print " done.\n";
}

sub error {
  my ($label) = @_;

  my $dialog = Gtk2::MessageDialog -> new($app,
                                          [qw(modal destroy-with-parent)],
                                          "error",
                                          "ok",
                                          $label);

  $dialog -> signal_connect(response => sub {
    my ($dialog, $response) = @_;
    $dialog -> hide();
  });

  $client -> save_error_dialog($dialog);
}

sub question {
  my ($label, $callback) = @_;

  my $dialog = Gtk2::MessageDialog -> new($app,
                                          [qw(modal destroy-with-parent)],
                                          "question",
                                          "yes-no",
                                          $label);

  $dialog -> signal_connect(response => sub {
    my ($dialog, $response) = @_;
    $callback -> () if ($response eq "yes");
    $dialog -> hide();
  });

  $client -> save_any_dialog($dialog);
}

sub save_session {
  select(undef, undef, undef, 0.5);
  return int(rand(2));
}

sub save_session_quickly {
  select(undef, undef, undef, 0.1);
  return int(rand(2));
}