/usr/share/perl5/Shutter/App/HelperFunctions.pm is in shutter 0.94-1.
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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | ###################################################
#
# Copyright (C) 2008-2013 Mario Kemper <mario.kemper@gmail.com>
#
# This file is part of Shutter.
#
# Shutter is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Shutter is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Shutter; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
###################################################
package Shutter::App::HelperFunctions;
#modules
#--------------------------------------
use utf8;
use strict;
use Gtk2;
#Glib
use Glib qw/TRUE FALSE/;
#--------------------------------------
##################public subs##################
sub new {
my $class = shift;
#constructor
my $self = { _common => shift };
#import shutter dialogs
my $current_window = $self->{_common}->get_mainwindow;
$self->{_dialogs} = Shutter::App::SimpleDialogs->new( $current_window );
#gettext
$self->{_d} = $self->{_common}->get_gettext;
bless $self, $class;
return $self;
}
sub xdg_open {
my ( $self, $dialog, $link, $user_data ) = @_;
my @args = ("xdg-open", "$link");
system(@args);
if($?){
my $response = $self->{_dialogs}->dlg_error_message(
sprintf( $self->{_d}->get("Error while executing %s."), "'xdg-open'"),
sprintf( $self->{_d}->get("There was an error executing %s."), "'xdg-open'"),
undef, undef, undef,
undef, undef, undef,
sprintf( $self->{_d}->get("Exit Code: %d."), $? >> 8)
);
}
}
sub xdg_open_mail {
my ( $self, $dialog, $mail, @user_data ) = @_;
my @cmd = 'xdg-email';
push @cmd, $mail if $mail;
system(@cmd, @user_data);
if($?){
my $response = $self->{_dialogs}->dlg_error_message(
sprintf( $self->{_d}->get("Error while executing %s."), "'xdg-email'"),
sprintf( $self->{_d}->get("There was an error executing %s."), "'xdg-email'"),
undef, undef, undef,
undef, undef, undef,
sprintf( $self->{_d}->get("Exit Code: %d."), $? >> 8)
);
}
}
sub nautilus_sendto {
my ( $self, $user_data ) = @_;
system('nautilus-sendto', $user_data);
if($?){
my $response = $self->{_dialogs}->dlg_error_message(
sprintf( $self->{_d}->get("Error while executing %s."), "'nautilus-sendto'"),
sprintf( $self->{_d}->get("There was an error executing %s."), "'nautilus-sendto'"),
undef, undef, undef,
undef, undef, undef,
sprintf( $self->{_d}->get("Exit Code: %d."), $? >> 8)
);
}
}
sub file_exists {
my ( $self, $filename ) = @_;
return FALSE unless $filename;
$filename = $self->switch_home_in_file($filename);
return TRUE if ( -f $filename && -r $filename );
return FALSE;
}
sub folder_exists {
my ( $self, $folder ) = @_;
return FALSE unless $folder;
$folder = $self->switch_home_in_file($folder);
return TRUE if ( -d $folder && -r $folder );
return FALSE;
}
sub uri_exists {
my ( $self, $filename ) = @_;
return FALSE unless $filename;
$filename = $self->switch_home_in_file($filename);
my $new_uri = Gnome2::VFS::URI->new($filename);
return TRUE if $new_uri->exists;
return FALSE;
}
sub file_executable {
my ( $self, $filename ) = @_;
return FALSE unless $filename;
$filename = $self->switch_home_in_file($filename);
return TRUE if ( -x $filename );
return FALSE;
}
sub switch_home_in_file {
my ( $self, $filename ) = @_;
$filename =~ s/^~/$ENV{ HOME }/; #switch ~ in path to /home/username
return $filename;
}
sub utf8_decode {
my $self = shift;
my $string = shift;
#see https://bugs.launchpad.net/shutter/+bug/347821
utf8::decode $string;
return $string;
}
sub usage {
my $self = shift;
print "shutter [options]\n";
print "Available options:\n\n"
. "Capture:\n"
. "--select (starts Shutter in selection mode)\n"
. "--full (starts Shutter and takes a full screen screenshot directly)\n"
. "--window (starts Shutter in window selection mode)\n"
. "--awindow (capture the active window)\n"
. "--section (starts Shutter in section selection mode)\n"
. "--menu (starts Shutter in menu selection mode)\n"
. "--tooltip (starts Shutter in tooltip selection mode)\n"
. "--web (starts Shutter in web capture mode)\n\n"
.
"Application:\n"
. "--min_at_startup (starts Shutter minimized to tray)\n"
. "--clear_cache (clears cache, e.g. installed plugins, at startup)\n"
. "--debug (prints a lot of debugging information to STDOUT)\n"
. "--disable_systray (disable systray icon)\n"
. "--version (displays version information)\n"
. "--help (displays this help)\n";
return TRUE;
}
1;
|