~ubuntu-branches/ubuntu/trusty/shutter/trusty-proposed

« back to all changes in this revision

Viewing changes to share/shutter/resources/modules/Shutter/App/HelperFunctions.pm

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-04-26 11:06:22 UTC
  • Revision ID: james.westby@ubuntu.com-20090426110622-7dvoaw207bbm5icy
Tags: upstream-0.70.2
ImportĀ upstreamĀ versionĀ 0.70.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
###################################################
 
2
#
 
3
#  Copyright (C) Mario Kemper <mario.kemper@googlemail.com> and Shutter Team
 
4
#
 
5
#  This file is part of Shutter.
 
6
#
 
7
#  Shutter is free software; you can redistribute it and/or modify
 
8
#  it under the terms of the GNU General Public License as published by
 
9
#  the Free Software Foundation; either version 3 of the License, or
 
10
#  (at your option) any later version.
 
11
#
 
12
#  Shutter is distributed in the hope that it will be useful,
 
13
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#  GNU General Public License for more details.
 
16
#
 
17
#  You should have received a copy of the GNU General Public License
 
18
#  along with Shutter; if not, write to the Free Software
 
19
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
#
 
21
###################################################
 
22
 
 
23
package Shutter::App::HelperFunctions;
 
24
 
 
25
#modules
 
26
#--------------------------------------
 
27
use utf8;
 
28
use strict;
 
29
use Gtk2;
 
30
 
 
31
#Gettext and filename parsing
 
32
use POSIX qw/setlocale strftime/;
 
33
use Locale::gettext;
 
34
 
 
35
#define constants
 
36
#--------------------------------------
 
37
use constant TRUE  => 1;
 
38
use constant FALSE => 0;
 
39
 
 
40
#--------------------------------------
 
41
 
 
42
##################public subs##################
 
43
sub new {
 
44
        my $class = shift;
 
45
 
 
46
        #constructor
 
47
        my $self = { _common => shift };
 
48
 
 
49
        bless $self, $class;
 
50
        return $self;
 
51
}
 
52
 
 
53
sub gnome_open {
 
54
        my ( $self, $dialog, $link, $user_data ) = @_;
 
55
        system("gnome-open $link");
 
56
        return TRUE;
 
57
}
 
58
 
 
59
sub gnome_open_mail {
 
60
        my ( $self, $dialog, $mail, $user_data ) = @_;
 
61
        system("gnome-open mailto:$mail");
 
62
        return TRUE;
 
63
}
 
64
 
 
65
sub file_exists {
 
66
        my ( $self, $filename ) = @_;
 
67
        return FALSE unless $filename;
 
68
        $filename = $self->switch_home_in_file($filename);
 
69
        return TRUE if ( -f $filename && -r $filename );
 
70
        return FALSE;
 
71
}
 
72
 
 
73
sub switch_home_in_file {
 
74
        my ( $self, $filename ) = @_;
 
75
        $filename =~ s/^~/$ENV{ HOME }/;    #switch ~ in path to /home/username
 
76
        return $filename;
 
77
}
 
78
 
 
79
sub utf8_decode {
 
80
        my $self        = shift;
 
81
        my $string      = shift;
 
82
        
 
83
        #see https://bugs.launchpad.net/shutter/+bug/347821
 
84
        utf8::decode $string;
 
85
        
 
86
        return $string;
 
87
}
 
88
 
 
89
sub usage {
 
90
        my $self = shift;
 
91
 
 
92
        print "shutter [options]\n";
 
93
        print "Available options:\n\n"
 
94
                . "Capture:\n"
 
95
                . "--full (starts shutter and takes a full screen screenshot directly)\n"
 
96
                . "--selection (starts shutter in selection mode)\n"
 
97
                . "--window (starts shutter in window selection mode)\n"
 
98
                . "--section (starts shutter in section selection mode)\n\n"
 
99
                .
 
100
 
 
101
                "Application:\n"
 
102
                . "--min_at_startup (starts shutter minimized to tray)\n"
 
103
                . "--clear_cache (clears cache, e.g. installed plugins, at startup)\n"
 
104
                . "--debug (prints a lot of debugging information to STDOUT)\n"
 
105
                . "--disable_systray (disable systray icon)\n"
 
106
                . "--help (displays this help)\n";
 
107
 
 
108
        return TRUE;
 
109
}
 
110
 
 
111
1;