File size: 6,986 Bytes
7578e9d 2ef47a8 7578e9d 2ef47a8 7578e9d | 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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | ###################################################
#
# Copyright (C) 2008-2013 Mario Kemper <mario.kemper@gmail.com>
# Copyright (C) 2021 Alexander Ruzhnikov <ruzhnikov85@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::Common;
use utf8;
use Moo;
use Gtk3;
#Gettext and filename parsing
use POSIX qw/ setlocale /;
use Locale::gettext;
use Shutter::I18N ();
#Glib
use Glib qw/ TRUE FALSE /;
has shutter_root => ( is => "ro", required => 1 );
has main_window => ( is => "rw", required => 1 );
has appname => ( is => "ro", required => 1 );
has version => ( is => "ro", required => 1 );
has rev => ( is => "ro", required => 1 );
has pid => ( is => "ro", required => 1 );
has debug => ( is => "rw", default => sub {FALSE} );
has clear_cache => ( is => "rw", default => sub {FALSE} );
has min => ( is => "rw", default => sub {FALSE} );
has disable_systray => ( is => "rw", default => sub {FALSE} );
has exit_after_capture => ( is => "rw", default => sub {FALSE} );
has no_session => ( is => "rw", default => sub {FALSE} );
# private attributes
has _start_with => ( is => "rw", lazy => 1 );
has _start_with_extra => ( is => "rw", lazy => 1 );
has profile_to_start_with => ( is => "rw", lazy => 1 );
has export_filename => ( is => "rw", lazy => 1 );
has delay => ( is => "rw", lazy => 1 );
has include_cursor => ( is => "rw", lazy => 1 );
has remove_cursor => ( is => "rw", lazy => 1 );
has gettext_object => (
is => "rw",
lazy => 1,
builder => sub {
my $self = shift;
# Same object as Shutter::I18N's __()/__n(), so legacy $d and new
# code share one domain.
return Shutter::I18N::init( $self->shutter_root . "/share/locale" );
},
);
has notification => ( is => "rw", lazy => 1 );
has global_settings => ( is => "rw", lazy => 1 );
#icontheme to determine if icons exist or not
#in some cases we deliver fallback icons
has icontheme => (
is => "rw",
lazy => 1,
builder => "_setup_icontheme",
);
#recently used upload tab
has ruu_tab => ( is => "rw", default => sub {0} );
#... and details
has ruu_hosting => ( is => "rw", default => sub {0} );
has ruu_places => ( is => "rw", default => sub {0} );
# TODO: this attribute looks like isn't used. Consider to remove it later
has ruu_u1 => ( is => "rw", default => sub {0} );
#recently used save folder
has rusf => ( is => "rw", lazy => 1 );
#recently used open folder
has ruof => ( is => "rw", lazy => 1 );
sub BUILD {
my ( $self, $args ) = @_;
setlocale( LC_NUMERIC, "C" );
setlocale( LC_MESSAGES, "" );
$ENV{'SHUTTER_INTL'} = $args->{shutter_root} . "/share/locale";
}
sub _setup_icontheme {
my $self = shift;
my $theme = Gtk3::IconTheme::get_default();
$theme->append_search_path( $self->shutter_root . "/share/icons" );
return $theme;
}
sub get_current_monitor {
my $self = shift;
my ( $window_at_pointer, $x, $y, $mask ) = Gtk3::Gdk::get_default_root_window->get_pointer;
my $mon = Gtk3::Gdk::Screen::get_default->get_monitor_geometry(
Gtk3::Gdk::Screen::get_default->get_monitor_at_point( $x, $y ) );
return ($mon);
}
# Methods that were used in the old implementation and needed for backward compatibility
sub get_root { shift->shutter_root }
sub get_appname { shift->appname }
sub get_version { shift->version }
sub get_rev { shift->rev }
sub get_gettext { shift->gettext_object }
sub get_theme { shift->icontheme }
sub get_notification_object { shift->notification }
sub set_notification_object { shift->notification(shift) if @_ }
sub get_globalsettings_object { shift->global_settings }
sub set_globalsettings_object { shift->global_settings(shift) if @_ }
sub get_rusf { shift->rusf }
sub set_rusf { shift->rusf(shift) if @_ }
sub get_ruof { shift->ruof }
sub set_ruof { shift->ruof(shift) if @_ }
sub get_ruu_tab { shift->ruu_tab }
sub set_ruu_tab { shift->ruu_tab(shift) if @_ }
sub get_ruu_hosting { shift->ruu_hosting }
sub set_ruu_hosting { shift->ruu_hosting(shift) if @_ }
sub get_ruu_places { shift->ruu_places }
sub set_ruu_places { shift->ruu_places(shift) if @_ }
sub get_debug { shift->debug }
sub set_debug { shift->debug(shift) if @_ }
sub get_clear_cache { shift->clear_cache }
sub set_clear_cache { shift->clear_cache(shift) if @_ }
sub get_mainwindow { shift->main_window }
sub set_mainwindow { shift->main_window(shift) if @_ }
sub get_min { shift->min }
sub set_min { shift->min(shift) if @_ }
sub get_disable_systray { shift->disable_systray }
sub set_disable_systray { shift->disable_systray(shift) if @_ }
sub get_exit_after_capture { shift->exit_after_capture }
sub set_exit_after_capture { shift->exit_after_capture(shift) if @_ }
sub get_no_session { shift->no_session }
sub set_no_session { shift->no_session(shift) if @_ }
sub get_start_with {
my $self = shift;
return ( $self->_start_with, $self->_start_with_extra );
}
sub set_start_with {
my $self = shift;
if (@_) {
$self->_start_with(shift);
$self->_start_with_extra(shift);
}
return ( $self->_start_with, $self->_start_with_extra );
}
sub get_profile_to_start_with { shift->profile_to_start_with }
sub set_profile_to_start_with { shift->profile_to_start_with(shift) if @_ }
sub get_export_filename { shift->export_filename }
sub set_export_filename { shift->export_filename(shift) if @_ }
sub get_include_cursor { shift->include_cursor }
sub set_include_cursor { shift->include_cursor(shift) if @_ }
sub get_remove_cursor { shift->remove_cursor }
sub set_remove_cursor { shift->remove_cursor(shift) if @_ }
sub get_delay { shift->delay }
sub set_delay { shift->delay(shift) if @_ }
1;
|