diff --git a/TODO-GTK3.md b/TODO-GTK3.md new file mode 100644 index 000000000..57abfb8fe --- /dev/null +++ b/TODO-GTK3.md @@ -0,0 +1,4 @@ +drawing: rulers +ssh -X is broken +selection: cursor XY stickiness to edges +hidpi: fix possible issues with: multiple screens, subwindow captures, menu capture diff --git a/bin/shutter b/bin/shutter index 0e64754d3..55b752b47 100755 --- a/bin/shutter +++ b/bin/shutter @@ -32,39 +32,44 @@ use utf8; use strict; use warnings; +use diagnostics; use 5.10.1; +use Carp::Always; + +BEGIN { + use Glib::Object::Introspection; + Glib::Object::Introspection->setup( + basename => 'Gio', + version => '2.0', + package => 'Glib::IO', + ); + Glib::Object::Introspection->setup( + basename => 'Wnck', + version => '3.0', + package => 'Wnck', + ); + Glib::Object::Introspection->setup( + basename => 'GdkX11', + version => '3.0', + package => 'Gtk3::GdkX11', + ); +} + +package Shutter::App; + #Deal with encoding problem +binmode(STDOUT, "encoding(UTF-8)"); use Encode; use File::stat; use Number::Bytes::Human; -#Gnome2 libraries -#use Gnome2; -#use Gnome2::VFS '-init'; -use Gnome2::Wnck; - -#Use AuthenticationManager to handle user credentials easily -#Gnome2::AuthenticationManager->init; - -#Gtk2 and Gtk2::ImageView -use Gtk2 '-init'; -use Gtk2::Pango; -use Gtk2::ImageView; - -#Use single instance applications -use Gtk2::Unique; - #Glib use Glib qw/TRUE FALSE/; - -use Glib::Object::Introspection; -Glib::Object::Introspection->setup( - basename => 'Gio', - version => '2.0', - package => 'Glib::IO' -); +use Gtk3 '-init'; +use Glib::Object::Subclass qw/Gtk3::Application/; +use Gtk3::ImageView 7; #filename parsing use POSIX qw/ strftime /; @@ -184,7 +189,7 @@ my $gnome_web_photo = TRUE; my $nautilus_sendto = TRUE; my $goocanvas = TRUE; my $exiftool = TRUE; -my $appindicator = TRUE; +my $appindicator = FALSE; # Gtk3::StatusIcon works better albeit being deprecated in Gtk3 fct_init_depend(); #-------------------------------------- @@ -237,29 +242,10 @@ require Shutter::Upload::FTP; #-------------------------------------- -#main window -#-------------------------------------- -my $window = Gtk2::Window->new('toplevel'); - -#-------------------------------------- - -#create app objects -#-------------------------------------- -my $sc = Shutter::App::Common->new($shutter_root, $window, SHUTTER_NAME, SHUTTER_VERSION, SHUTTER_REV, $$); +my $sc = Shutter::App::Common->new($shutter_root, undef, SHUTTER_NAME, SHUTTER_VERSION, SHUTTER_REV, $$); my $shf = Shutter::App::HelperFunctions->new($sc); my $so = Shutter::App::Options->new($sc, $shf); my $sdir = Shutter::App::Directories->new(); -my $sas = Shutter::App::Autostart->new(); -my $sm = Shutter::App::Menu->new($sc); -my $st = Shutter::App::Toolbar->new($sc); -my $sd = Shutter::App::SimpleDialogs->new($window); - -my $sp = Shutter::Pixbuf::Save->new($sc); -my $lp = Shutter::Pixbuf::Load->new($sc); -my $lp_ne = Shutter::Pixbuf::Load->new($sc, undef, TRUE); -my $hu = Number::Bytes::Human->new(si => 1); - -#-------------------------------------- #set home #-------------------------------------- @@ -267,125 +253,39 @@ $ENV{'HOME'} = $sdir->get_home_dir; #-------------------------------------- -my $app = Gtk2::UniqueApp->new( - "org.shutter-project.Shutter", undef, - select => 1, - full => 2, - window => 3, - awindow => 4, - section => 5, - menu => 6, - tooltip => 7, - web => 8, - redoshot => 9, - profile => 10, - fopen => 11, - exitac => 12, - exfilename => 13, - delay => 14, - include_cursor => 15, - remove_cursor => 16, - nosession => 17, -); - #load command line arguments #as well as file to open when starting my $init_files = $so->get_options; # accept either path or uri as arguments, but store only uri my @init_files = map { Glib::IO::File::new_for_commandline_arg($_)->get_uri } @$init_files; -#The application is already running, send it a message -if ($app->is_running) { - - my ($cmdname, $extra) = $sc->get_start_with; - my $profile = $sc->get_profile_to_start_with; - my $exitac = $sc->get_exit_after_capture; - my $exfilename = $sc->get_export_filename; - my $delay = $sc->get_delay; - my $include_cursor = $sc->get_include_cursor; - my $remove_cursor = $sc->get_remove_cursor; - my $nosession = $sc->get_no_session; - - my $cmdid = undef; - if (defined $cmdname) { - if ($cmdname eq 'select') { - $cmdid = 1; - } elsif ($cmdname eq 'full') { - $cmdid = 2; - } elsif ($cmdname eq 'window') { - $cmdid = 3; - } elsif ($cmdname eq 'awindow') { - $cmdid = 4; - } elsif ($cmdname eq 'section') { - $cmdid = 5; - } elsif ($cmdname eq 'menu') { - $cmdid = 6; - } elsif ($cmdname eq 'tooltip') { - $cmdid = 7; - } elsif ($cmdname eq 'web') { - $cmdid = 8; - } elsif ($cmdname eq 'redoshot') { - $cmdid = 9; - } - } - - #change profile in running application - if (defined $profile && $profile) { - $app->send_message(10, text => $profile); - } - - #set exit flag in running application - if (defined $exitac && $exitac) { - $app->send_message(12, text => ''); - } - - #set export_filename (parameter -o) in running application - if (defined $exfilename && $exfilename) { - $app->send_message(13, text => $shf->utf8_decode($exfilename)); - } - - #change delay in running application - if (defined $delay && $delay) { - $app->send_message(14, text => $delay); - } - - #change include_cursor in running application - if (defined $include_cursor && $include_cursor) { - $app->send_message(15, text => ''); - } - - #change remove_cursor in running application - if (defined $remove_cursor && $remove_cursor) { - $app->send_message(16, text => ''); - } - - #set nosession flag in running application - if (defined $nosession && $nosession) { - $app->send_message(17, text => ''); - } - - #send $cmdid - if (defined $cmdid && defined $extra) { - $app->send_message($cmdid, text => $extra); - } elsif (defined $cmdid) { - $app->send_message($cmdid, text => 'shutter'); - } else { +sub STARTUP { + # This is called by $app->run below if another Shutter instance is not running. - #escape all filenames, see Bug #737428 - my @escaped_filenames; - foreach my $file (@init_files) { - push @escaped_filenames, escape_string($file); - } - $app->send_message(11, uris => \@escaped_filenames); - } + my ($app) = @_; + $app->SUPER::STARTUP(); - print "\nINFO: There is already another instance of Shutter running!\n"; + #main window + #-------------------------------------- + my $window = Gtk3::ApplicationWindow->new($app); + #-------------------------------------- - #Create the single application instance and wait for other requests -} else { + #create app objects + #-------------------------------------- + $sc->set_mainwindow($window); + my $sas = Shutter::App::Autostart->new(); + my $sm = Shutter::App::Menu->new($sc); + my $st = Shutter::App::Toolbar->new($sc); + my $sd = Shutter::App::SimpleDialogs->new($window); + + my $sp = Shutter::Pixbuf::Save->new($sc); + my $lp = Shutter::Pixbuf::Load->new($sc); + my $lp_ne = Shutter::Pixbuf::Load->new($sc, undef, TRUE); + my $hu = Number::Bytes::Human->new(si => 1); + #-------------------------------------- #Clipboard - my $clipboard = Gtk2::Clipboard->get(Gtk2::Gdk->SELECTION_CLIPBOARD); + my $clipboard = Gtk3::Clipboard::get($Gtk3::Gdk::SELECTION_CLIPBOARD); #Gettext my $d = $sc->get_gettext; @@ -405,113 +305,128 @@ if ($app->is_running) { # Watch the main window and register a handler that will be called each time # that there's a new message. - $app->watch_window($window); - my $app_watch_id = $app->signal_connect( - 'message-received' => sub { - my ($app, $cmd, $message, $time) = @_; - - #map $cmd id - if ($cmd =~ /^-*[0-9]+$/) { - if ($cmd == 1) { - $cmd = 'select'; - } elsif ($cmd == 2) { - $cmd = 'full'; - } elsif ($cmd == 3) { - $cmd = 'window'; - } elsif ($cmd == 4) { - $cmd = 'awindow'; - } elsif ($cmd == 5) { - $cmd = 'section'; - } elsif ($cmd == 6) { - $cmd = 'menu'; - } elsif ($cmd == 7) { - $cmd = 'tooltip'; - } elsif ($cmd == 8) { - $cmd = 'web'; - } elsif ($cmd == 9) { - $cmd = 'redoshot'; - } elsif ($cmd == 10) { - $cmd = 'profile'; - } elsif ($cmd == 11) { - $cmd = 'fopen'; - } elsif ($cmd == 12) { - $cmd = 'exitac'; - } elsif ($cmd == 13) { - $cmd = 'exfilename'; - } elsif ($cmd == 14) { - $cmd = 'delay'; - } elsif ($cmd == 15) { - $cmd = 'include_cursor'; - } elsif ($cmd == 16) { - $cmd = 'remove_cursor'; - } elsif ($cmd == 17) { - $cmd = 'nosession'; - } else { - $cmd = 'fopen'; - } - } - - #shutter window is presented automatically, sync our flag - $is_hidden = FALSE; - - if (defined $cmd) { - - #set exit flag - if ($cmd eq 'exitac') { - $sc->set_exit_after_capture(TRUE); - - #set export filename - } elsif ($cmd eq 'exfilename') { - my $arg = defined $message->get ? $message->get_text : ""; - $sc->set_export_filename($arg); - - #set delay - } elsif ($cmd eq 'delay') { - my $arg = defined $message->get ? $message->get_text : ""; - $sc->set_delay($arg); - - #set include_cursor flag - } elsif ($cmd eq 'include_cursor') { - $sc->set_include_cursor(TRUE); - $sc->set_remove_cursor(FALSE); - - #set remove_cursor flag - } elsif ($cmd eq 'remove_cursor') { - $sc->set_remove_cursor(TRUE); - $sc->set_include_cursor(FALSE); - - #set nosession flag - } elsif ($cmd eq 'nosession') { - my $arg = defined $message->get ? $message->get_text : ""; - $sc->set_no_session($arg); - - #open new files - } elsif ($cmd eq 'fopen') { - my @init_files = defined $message->get ? $message->get_uris : (); - if (scalar @init_files > 0) { - fct_open_files(@init_files); - } - fct_control_main_window('show'); - - #load profile - } elsif ($cmd eq 'profile') { - print "FIXME: switching profiles via IPC is not implemented yet\n"; - - #take screenshot - } else { - my $arg = defined $message->get ? $message->get_text : ""; - evt_take_screenshot('global_keybinding', $cmd, undef, $arg); - } - } - - return 'ok'; - }); + my @signal_connections; + my $action; + + $action = Glib::IO::SimpleAction->new('exitac', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + $sc->set_exit_after_capture(TRUE); + }); + + $action = Glib::IO::SimpleAction->new('exfilename', 's'); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + my $arg = $_[1]->get_string; + $sc->set_export_filename($arg); + }); + + $action = Glib::IO::SimpleAction->new('delay', 's'); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + my $arg = $_[1]->get_string; + $sc->set_delay($arg); + }); + + $action = Glib::IO::SimpleAction->new('include_cursor', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + $sc->set_include_cursor(TRUE); + $sc->set_remove_cursor(FALSE); + }); + + $action = Glib::IO::SimpleAction->new('remove_cursor', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + $sc->set_remove_cursor(TRUE); + $sc->set_include_cursor(FALSE); + }); + + $action = Glib::IO::SimpleAction->new('nosession', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + $sc->set_no_session(TRUE); + }); + + $action = Glib::IO::SimpleAction->new('fopen', 'as'); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + my $args = $_[1]->get('as'); + if (scalar @$args > 0) { + fct_open_files(@$args); + } + fct_control_main_window('show'); + }); + + $action = Glib::IO::SimpleAction->new('profile', 's'); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + my $arg = $_[1]->get_string; + print "FIXME: switching profiles via IPC is not implemented yet\n"; + }); + + $action = Glib::IO::SimpleAction->new('select', 's'); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + my $arg = $_[1]->get_string; + evt_take_screenshot('global_keybinding', 'select', undef, $arg); + }); + + $action = Glib::IO::SimpleAction->new('full', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + evt_take_screenshot('global_keybinding', 'full'); + }); + + $action = Glib::IO::SimpleAction->new('window', 's'); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + my $arg = $_[1]->get_string; + evt_take_screenshot('global_keybinding', 'window', undef, $arg); + }); + + $action = Glib::IO::SimpleAction->new('awindow', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + evt_take_screenshot('global_keybinding', 'awindow'); + }); + + $action = Glib::IO::SimpleAction->new('section', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + evt_take_screenshot('global_keybinding', 'section'); + }); + + $action = Glib::IO::SimpleAction->new('menu', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + evt_take_screenshot('global_keybinding', 'menu'); + }); + + $action = Glib::IO::SimpleAction->new('tooltip', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + evt_take_screenshot('global_keybinding', 'tooltip'); + }); + + $action = Glib::IO::SimpleAction->new('web', 's'); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + my $arg = $_[1]->get_string; + evt_take_screenshot('global_keybinding', 'web', undef, $arg); + }); + + $action = Glib::IO::SimpleAction->new('redoshot', ''); + $app->add_action($action); + push @signal_connections, $action->signal_connect('activate'=>sub { + evt_take_screenshot('global_keybinding', 'redoshot'); + }); #create needed directories etc. fct_init_environment(); #print debug output - &fct_init_debug_output if $sc->get_debug; + fct_init_debug_output() if $sc->get_debug; #shutdown Shutter carefully when INT or TERM are detected # => save settings @@ -524,7 +439,7 @@ if ($app->is_running) { #main window gui #-------------------------------------- - $window->set_default_icon_name("shutter"); + Gtk3::Window::set_default_icon_name("shutter"); $window->signal_connect('delete-event' => \&evt_delete_window); $window->set_border_width(0); $window->set_resizable(TRUE); @@ -532,41 +447,31 @@ if ($app->is_running) { $window->set_default_size(-1, 500); #UPDATE WINDOW LIST (signal is connected when GUI is loaded) - my $wnck_screen = Gnome2::Wnck::Screen->get_default; + my $wnck_screen = Wnck::Screen::get_default(); $wnck_screen->force_update; #TRAY ICON AND MENU my $tray = undef; - my $tray_box = undef; #Gtk2::TrayIcon needs and Gtk2::EventBox my $tray_menu = fct_ret_tray_menu(); #SESSION NOTEBOOK - my $notebook = Gtk2::Notebook->new; + my $notebook = Gtk3::Notebook->new; $notebook = fct_create_session_notebook(); #STATUSBAR - my $status = Gtk2::Statusbar->new; + my $status = Gtk3::Statusbar->new; $status->set_name('main-window-statusbar'); - #customize the statusbar style - Gtk2::Rc->parse_string( - "style 'statusbar-style' { - GtkStatusbar::shadow-type = GTK_SHADOW_NONE - } - widget '*.main-window-statusbar' style 'statusbar-style'" - ); - - my $combobox_status_profiles_label = Gtk2::Label->new($d->get("Profile") . ":"); - my $combobox_status_profiles = Gtk2::ComboBox->new_text; + my $combobox_status_profiles_label = Gtk3::Label->new($d->get("Profile") . ":"); + my $combobox_status_profiles = Gtk3::ComboBoxText->new; #arrange settings in notebook - my $notebook_settings = Gtk2::Notebook->new; + my $notebook_settings = Gtk3::Notebook->new; $notebook_settings->set_tab_pos('left'); - my $settings_dialog = Gtk2::Dialog->new(SHUTTER_NAME . " - " . $d->get("Preferences"), $window, [qw/modal destroy-with-parent/], 'gtk-close' => 'close'); - $settings_dialog->set_has_separator(FALSE); + my $settings_dialog = Gtk3::Dialog->new(SHUTTER_NAME . " - " . $d->get("Preferences"), $window, [qw/modal destroy-with-parent/], 'gtk-close' => 'close'); - my $vbox = Gtk2::VBox->new(FALSE, 0); + my $vbox = Gtk3::VBox->new(FALSE, 0); $window->add($vbox); #attach signal handlers to subroutines and pack menu @@ -576,13 +481,13 @@ if ($app->is_running) { $sm->{_menuitem_open}->signal_connect('activate', \&dlg_open, 'menu_open'); #recent manager and menu entry - $sm->{_menu_recent} = Gtk2::RecentChooserMenu->new_for_manager(Gtk2::RecentManager->get_default); + $sm->{_menu_recent} = Gtk3::RecentChooserMenu->new_for_manager(Gtk3::RecentManager::get_default()); $sm->{_menu_recent}->set_sort_type('mru'); $sm->{_menu_recent}->set_local_only(TRUE); $sm->{_menu_recent}->set_show_numbers(TRUE); $sm->{_menu_recent}->set_show_not_found(FALSE); - my $recentfilter = Gtk2::RecentFilter->new; + my $recentfilter = Gtk3::RecentFilter->new; $recentfilter->add_pixbuf_formats; $sm->{_menu_recent}->add_filter($recentfilter); $sm->{_menu_recent}->signal_connect( @@ -639,7 +544,7 @@ if ($app->is_running) { #screenshot menu #~ $sm->{_menu_actions}->signal_connect( 'focus', sub { $sm->{_menuitem_reopen}->set_submenu(&fct_ret_program_menu); }); - $sm->{_menuitem_reopen}->set_submenu(&fct_ret_program_menu); + $sm->{_menuitem_reopen}->set_submenu(fct_ret_program_menu()); $sm->{_menuitem_show_in_folder}->signal_connect('activate', \&fct_show_in_folder); $sm->{_menuitem_rename}->signal_connect('activate', \&fct_rename); $sm->{_menuitem_upload}->signal_connect('activate', \&fct_upload); @@ -667,7 +572,7 @@ if ($app->is_running) { sub { $sm->{_menuitem_large_reopen}->set_submenu(fct_ret_program_menu($sm->{_menuitem_large_reopen}->get_submenu)); }); - $sm->{_menuitem_large_reopen}->set_submenu(&fct_ret_program_menu); + $sm->{_menuitem_large_reopen}->set_submenu(fct_ret_program_menu()); $sm->{_menuitem_large_show_in_folder}->signal_connect('activate', \&fct_show_in_folder); $sm->{_menuitem_large_rename}->signal_connect('activate', \&fct_rename); $sm->{_menuitem_large_copy}->signal_connect('activate', \&fct_clipboard, 'image'); @@ -724,12 +629,12 @@ if ($app->is_running) { unless ($sc->get_disable_systray) { if ($appindicator) { - $tray = Gtk2::AppIndicator->new("Shutter", "shutter-panel"); + local $, = ' '; + $tray = AppIndicator::Indicator->new("Shutter", "shutter-panel", 'application-status'); $tray->set_menu($tray_menu); - $tray->set_active(); + $tray->set_status('active'); } else { - if (Gtk2->CHECK_VERSION(2, 10, 0)) { - $tray = Gtk2::StatusIcon->new(); + $tray = Gtk3::StatusIcon->new(); $tray->set_from_icon_name("shutter-panel"); $tray->set_visible(1); @@ -744,21 +649,6 @@ if ($app->is_running) { }, $tray ); - } else { - - my $tray_image = Gtk2::Image->new_from_icon_name('shutter-panel', 'large-toolbar'); - - #eventbox with shutter logo - $tray_box = Gtk2::EventBox->new; - $tray_box->add($tray_image); - - #tray icon - require Gtk2::TrayIcon; - $tray = Gtk2::TrayIcon->new('Shutter TrayIcon'); - $tray->add($tray_box); - $tray_box->{'hid'} = $tray_box->signal_connect('button_release_event', \&evt_show_systray); - $tray->show_all; - } } } @@ -767,108 +657,108 @@ if ($app->is_running) { #settings #-------------------------------------- - my $vbox_settings = Gtk2::VBox->new(FALSE, 12); - my $hbox_settings = Gtk2::HBox->new(FALSE, 12); - my $vbox_basic = Gtk2::VBox->new(FALSE, 12); - my $vbox_advanced = Gtk2::VBox->new(FALSE, 12); - my $vbox_actions = Gtk2::VBox->new(FALSE, 12); - my $vbox_imageview = Gtk2::VBox->new(FALSE, 12); - my $vbox_behavior = Gtk2::VBox->new(FALSE, 12); - my $vbox_keyboard = Gtk2::VBox->new(FALSE, 12); - my $vbox_accounts = Gtk2::VBox->new(FALSE, 12); + my $vbox_settings = Gtk3::VBox->new(FALSE, 12); + my $hbox_settings = Gtk3::HBox->new(FALSE, 12); + my $vbox_basic = Gtk3::VBox->new(FALSE, 12); + my $vbox_advanced = Gtk3::VBox->new(FALSE, 12); + my $vbox_actions = Gtk3::VBox->new(FALSE, 12); + my $vbox_imageview = Gtk3::VBox->new(FALSE, 12); + my $vbox_behavior = Gtk3::VBox->new(FALSE, 12); + my $vbox_keyboard = Gtk3::VBox->new(FALSE, 12); + my $vbox_accounts = Gtk3::VBox->new(FALSE, 12); #profiles - my $profiles_box = Gtk2::HBox->new(FALSE, 0); + my $profiles_box = Gtk3::HBox->new(FALSE, 0); #main - my $file_vbox = Gtk2::VBox->new(FALSE, 0); - my $save_vbox = Gtk2::VBox->new(FALSE, 0); - my $capture_vbox = Gtk2::VBox->new(FALSE, 0); - - my $scale_box = Gtk2::HBox->new(FALSE, 0); - my $filetype_box = Gtk2::HBox->new(FALSE, 0); - my $filename_box = Gtk2::HBox->new(FALSE, 0); - my $saveDir_box = Gtk2::HBox->new(FALSE, 0); - my $save_ask_box = Gtk2::HBox->new(FALSE, 0); - my $save_no_box = Gtk2::HBox->new(FALSE, 0); - my $save_auto_box = Gtk2::HBox->new(FALSE, 0); - my $no_autocopy_box = Gtk2::HBox->new(FALSE, 0); - my $image_autocopy_box = Gtk2::HBox->new(FALSE, 0); - my $fname_autocopy_box = Gtk2::HBox->new(FALSE, 0); - my $delay_box = Gtk2::HBox->new(FALSE, 0); - my $cursor_box = Gtk2::HBox->new(FALSE, 0); + my $file_vbox = Gtk3::VBox->new(FALSE, 0); + my $save_vbox = Gtk3::VBox->new(FALSE, 0); + my $capture_vbox = Gtk3::VBox->new(FALSE, 0); + + my $scale_box = Gtk3::HBox->new(FALSE, 0); + my $filetype_box = Gtk3::HBox->new(FALSE, 0); + my $filename_box = Gtk3::HBox->new(FALSE, 0); + my $saveDir_box = Gtk3::HBox->new(FALSE, 0); + my $save_ask_box = Gtk3::HBox->new(FALSE, 0); + my $save_no_box = Gtk3::HBox->new(FALSE, 0); + my $save_auto_box = Gtk3::HBox->new(FALSE, 0); + my $no_autocopy_box = Gtk3::HBox->new(FALSE, 0); + my $image_autocopy_box = Gtk3::HBox->new(FALSE, 0); + my $fname_autocopy_box = Gtk3::HBox->new(FALSE, 0); + my $delay_box = Gtk3::HBox->new(FALSE, 0); + my $cursor_box = Gtk3::HBox->new(FALSE, 0); #actions - my $actions_vbox = Gtk2::VBox->new(FALSE, 0); + my $actions_vbox = Gtk3::VBox->new(FALSE, 0); - my $progname_box = Gtk2::HBox->new(FALSE, 0); - my $im_colors_box = Gtk2::HBox->new(FALSE, 0); - my $thumbnail_box = Gtk2::HBox->new(FALSE, 0); - my $bordereffect_box = Gtk2::HBox->new(FALSE, 0); + my $progname_box = Gtk3::HBox->new(FALSE, 0); + my $im_colors_box = Gtk3::HBox->new(FALSE, 0); + my $thumbnail_box = Gtk3::HBox->new(FALSE, 0); + my $bordereffect_box = Gtk3::HBox->new(FALSE, 0); #advanced - my $sel_capture_vbox = Gtk2::VBox->new(FALSE, 0); - my $window_capture_vbox = Gtk2::VBox->new(FALSE, 0); - my $menu_capture_vbox = Gtk2::VBox->new(FALSE, 0); - my $web_capture_vbox = Gtk2::VBox->new(FALSE, 0); - - my $zoom_box = Gtk2::HBox->new(FALSE, 0); - my $as_help_box = Gtk2::HBox->new(FALSE, 0); - my $asel_isize_box = Gtk2::HBox->new(FALSE, 0); - my $asel_isize_box2 = Gtk2::HBox->new(FALSE, 0); - my $border_box = Gtk2::HBox->new(FALSE, 0); - my $winresize_box = Gtk2::HBox->new(FALSE, 0); - my $autoshape_box = Gtk2::HBox->new(FALSE, 0); - my $visible_windows_box = Gtk2::HBox->new(FALSE, 0); - my $menu_delay_box = Gtk2::HBox->new(FALSE, 0); - my $menu_waround_box = Gtk2::HBox->new(FALSE, 0); - my $web_width_box = Gtk2::HBox->new(FALSE, 0); + my $sel_capture_vbox = Gtk3::VBox->new(FALSE, 0); + my $window_capture_vbox = Gtk3::VBox->new(FALSE, 0); + my $menu_capture_vbox = Gtk3::VBox->new(FALSE, 0); + my $web_capture_vbox = Gtk3::VBox->new(FALSE, 0); + + my $zoom_box = Gtk3::HBox->new(FALSE, 0); + my $as_help_box = Gtk3::HBox->new(FALSE, 0); + my $asel_isize_box = Gtk3::HBox->new(FALSE, 0); + my $asel_isize_box2 = Gtk3::HBox->new(FALSE, 0); + my $border_box = Gtk3::HBox->new(FALSE, 0); + my $winresize_box = Gtk3::HBox->new(FALSE, 0); + my $autoshape_box = Gtk3::HBox->new(FALSE, 0); + my $visible_windows_box = Gtk3::HBox->new(FALSE, 0); + my $menu_delay_box = Gtk3::HBox->new(FALSE, 0); + my $menu_waround_box = Gtk3::HBox->new(FALSE, 0); + my $web_width_box = Gtk3::HBox->new(FALSE, 0); #imageview - my $transparent_vbox = Gtk2::VBox->new(FALSE, 0); - my $imageview_hbox1 = Gtk2::HBox->new(FALSE, 0); - my $imageview_hbox2 = Gtk2::HBox->new(FALSE, 0); - my $imageview_hbox3 = Gtk2::HBox->new(FALSE, 0); + my $transparent_vbox = Gtk3::VBox->new(FALSE, 0); + my $imageview_hbox1 = Gtk3::HBox->new(FALSE, 0); + my $imageview_hbox2 = Gtk3::HBox->new(FALSE, 0); + my $imageview_hbox3 = Gtk3::HBox->new(FALSE, 0); - my $session_vbox = Gtk2::VBox->new(FALSE, 0); - my $session_hbox1 = Gtk2::HBox->new(FALSE, 0); - my $session_hbox2 = Gtk2::HBox->new(FALSE, 0); + my $session_vbox = Gtk3::VBox->new(FALSE, 0); + my $session_hbox1 = Gtk3::HBox->new(FALSE, 0); + my $session_hbox2 = Gtk3::HBox->new(FALSE, 0); #behavior - my $first_vbox = Gtk2::VBox->new(FALSE, 0); - my $window_vbox = Gtk2::VBox->new(FALSE, 0); - my $notify_vbox = Gtk2::VBox->new(FALSE, 0); - my $trash_vbox = Gtk2::VBox->new(FALSE, 0); - my $keybinding_vbox = Gtk2::VBox->new(FALSE, 0); - - my $fs_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $fs_min_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $fs_nonot_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $hide_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $pafter_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $cac_hbox = Gtk2::HBox->new(FALSE, 0); - my $hide_time_hbox = Gtk2::HBox->new(FALSE, 0); - my $na_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $nt_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $npt_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $ns_combo_hbox = Gtk2::HBox->new(FALSE, 0); - my $aod_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $doc_active_hbox = Gtk2::HBox->new(FALSE, 0); - my $aofsd_active_hbox = Gtk2::HBox->new(FALSE, 0); + my $first_vbox = Gtk3::VBox->new(FALSE, 0); + my $window_vbox = Gtk3::VBox->new(FALSE, 0); + my $notify_vbox = Gtk3::VBox->new(FALSE, 0); + my $trash_vbox = Gtk3::VBox->new(FALSE, 0); + my $keybinding_vbox = Gtk3::VBox->new(FALSE, 0); + + my $fs_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $fs_min_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $fs_nonot_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $hide_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $pafter_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $cac_hbox = Gtk3::HBox->new(FALSE, 0); + my $hide_time_hbox = Gtk3::HBox->new(FALSE, 0); + my $na_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $nt_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $npt_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $ns_combo_hbox = Gtk3::HBox->new(FALSE, 0); + my $aod_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $doc_active_hbox = Gtk3::HBox->new(FALSE, 0); + my $aofsd_active_hbox = Gtk3::HBox->new(FALSE, 0); #upload - my $accounts_vbox = Gtk2::VBox->new(FALSE, 0); - my $ftp_vbox = Gtk2::VBox->new(FALSE, 0); + my $accounts_vbox = Gtk3::VBox->new(FALSE, 0); + my $ftp_vbox = Gtk3::VBox->new(FALSE, 0); - my $accounts_hbox = Gtk2::HBox->new(FALSE, 0); - my $ftp_hbox1 = Gtk2::HBox->new(FALSE, 0); - my $ftp_hbox2 = Gtk2::HBox->new(FALSE, 0); - my $ftp_hbox3 = Gtk2::HBox->new(FALSE, 0); - my $ftp_hbox4 = Gtk2::HBox->new(FALSE, 0); - my $ftp_hbox5 = Gtk2::HBox->new(FALSE, 0); + my $accounts_hbox = Gtk3::HBox->new(FALSE, 0); + my $ftp_hbox1 = Gtk3::HBox->new(FALSE, 0); + my $ftp_hbox2 = Gtk3::HBox->new(FALSE, 0); + my $ftp_hbox3 = Gtk3::HBox->new(FALSE, 0); + my $ftp_hbox4 = Gtk3::HBox->new(FALSE, 0); + my $ftp_hbox5 = Gtk3::HBox->new(FALSE, 0); #plugins - my $effects_vbox = Gtk2::VBox->new(FALSE, 0); + my $effects_vbox = Gtk3::VBox->new(FALSE, 0); #load settings #-------------------------------------- @@ -921,13 +811,13 @@ if ($app->is_running) { #init menus $st->{_full}->set_menu(fct_ret_workspace_menu(TRUE)); - $st->{_window}->set_menu(&fct_ret_window_menu); + $st->{_window}->set_menu(fct_ret_window_menu()); #and attach signal handlers $st->{_full}->signal_connect('show-menu' => sub { $st->{_full}->set_menu(fct_ret_workspace_menu(FALSE)) }); $st->{_window}->signal_connect('clicked' => \&evt_take_screenshot, 'window'); - $st->{_window}->signal_connect('show-menu' => sub { $st->{_window}->set_menu(&fct_ret_window_menu) }); + $st->{_window}->signal_connect('show-menu' => sub { $st->{_window}->set_menu(fct_ret_window_menu()) }); $st->{_section}->signal_connect('clicked' => \&evt_take_screenshot, 'section'); $st->{_menu}->signal_connect('clicked' => \&evt_take_screenshot, 'menu'); $st->{_tooltip}->signal_connect('clicked' => \&evt_take_screenshot, 'tooltip'); @@ -936,7 +826,7 @@ if ($app->is_running) { if ($gnome_web_photo) { $st->{_web}->set_sensitive(TRUE); $st->{_web}->signal_connect('clicked' => \&evt_take_screenshot, 'web'); - $st->{_web}->set_menu(&fct_ret_web_menu); + $st->{_web}->set_menu(fct_ret_web_menu()); $st->{_web}->signal_connect('show-menu' => \&fct_ret_web_menu); } else { $st->{_web}->set_tooltip_text($d->get("gnome-web-photo needs to be installed for this feature")); @@ -959,7 +849,7 @@ if ($app->is_running) { #handle profiles #-------------------------------------- - my $combobox_settings_profiles = Gtk2::ComboBox->new_text; + my $combobox_settings_profiles = Gtk3::ComboBoxText->new; my @current_profiles; my $current_index = 0; foreach my $pfile (sort bsd_glob("$ENV{'HOME'}/.shutter/profiles/*.xml")) { @@ -989,160 +879,160 @@ if ($app->is_running) { $current_profile_indx = 0; } - my $button_profile_save = Gtk2::Button->new; + my $button_profile_save = Gtk3::Button->new; $button_profile_save->signal_connect( 'clicked' => sub { my $widget = shift; evt_save_profile($widget, $combobox_settings_profiles, \@current_profiles); }); - $button_profile_save->set_image(Gtk2::Image->new_from_stock('gtk-save', 'button')); + $button_profile_save->set_image(Gtk3::Image->new_from_stock('gtk-save', 'button')); $button_profile_save->set_tooltip_text($d->get("Save configuration as profile")); - my $button_profile_delete = Gtk2::Button->new; + my $button_profile_delete = Gtk3::Button->new; $button_profile_delete->signal_connect( 'clicked' => sub { my $widget = shift; evt_delete_profile($widget, $combobox_settings_profiles, \@current_profiles); }); - $button_profile_delete->set_image(Gtk2::Image->new_from_stock('gtk-delete', 'button')); + $button_profile_delete->set_image(Gtk3::Image->new_from_stock('gtk-delete', 'button')); $button_profile_delete->set_tooltip_text($d->get("Delete profile")); - my $button_profile_apply = Gtk2::Button->new; + my $button_profile_apply = Gtk3::Button->new; $button_profile_apply->signal_connect( 'clicked' => sub { my $widget = shift; evt_apply_profile($widget, $combobox_settings_profiles, \@current_profiles); }); - $button_profile_apply->set_image(Gtk2::Image->new_from_stock('gtk-apply', 'button')); + $button_profile_apply->set_image(Gtk3::Image->new_from_stock('gtk-apply', 'button')); $button_profile_apply->set_tooltip_text($d->get("Load the selected profile's configuration")); #-------------------------------------- #frames and label for settings dialog #-------------------------------------- - my $file_frame_label = Gtk2::Label->new; + my $file_frame_label = Gtk3::Label->new; $file_frame_label->set_markup("" . $d->get("Image format") . ""); - my $file_frame = Gtk2::Frame->new(); + my $file_frame = Gtk3::Frame->new(); $file_frame->set_label_widget($file_frame_label); $file_frame->set_shadow_type('none'); - my $save_frame_label = Gtk2::Label->new; + my $save_frame_label = Gtk3::Label->new; $save_frame_label->set_markup("" . $d->get("Save") . ""); - my $save_frame = Gtk2::Frame->new(); + my $save_frame = Gtk3::Frame->new(); $save_frame->set_label_widget($save_frame_label); $save_frame->set_shadow_type('none'); - my $firstlaunch_frame_label = Gtk2::Label->new; + my $firstlaunch_frame_label = Gtk3::Label->new; $firstlaunch_frame_label->set_markup("" . $d->get("First-launch Behavior") . ""); - my $firstlaunch_frame = Gtk2::Frame->new(); + my $firstlaunch_frame = Gtk3::Frame->new(); $firstlaunch_frame->set_label_widget($firstlaunch_frame_label); $firstlaunch_frame->set_shadow_type('none'); - my $window_frame_label = Gtk2::Label->new; + my $window_frame_label = Gtk3::Label->new; $window_frame_label->set_markup("" . $d->get("Window Preferences") . ""); - my $window_frame = Gtk2::Frame->new(); + my $window_frame = Gtk3::Frame->new(); $window_frame->set_label_widget($window_frame_label); $window_frame->set_shadow_type('none'); - my $notify_frame_label = Gtk2::Label->new; + my $notify_frame_label = Gtk3::Label->new; $notify_frame_label->set_markup("" . $d->get("Notifications") . ""); - my $notify_frame = Gtk2::Frame->new(); + my $notify_frame = Gtk3::Frame->new(); $notify_frame->set_label_widget($notify_frame_label); $notify_frame->set_shadow_type('none'); - my $trash_frame_label = Gtk2::Label->new; + my $trash_frame_label = Gtk3::Label->new; $trash_frame_label->set_markup("" . $d->get("Trash") . ""); - my $trash_frame = Gtk2::Frame->new(); + my $trash_frame = Gtk3::Frame->new(); $trash_frame->set_label_widget($trash_frame_label); $trash_frame->set_shadow_type('none'); - my $keybinding_frame_label = Gtk2::Label->new; + my $keybinding_frame_label = Gtk3::Label->new; $keybinding_frame_label->set_markup("" . $d->get("Gnome-Keybinding") . ""); - my $keybinding_frame = Gtk2::Frame->new(); + my $keybinding_frame = Gtk3::Frame->new(); $keybinding_frame->set_label_widget($keybinding_frame_label); $keybinding_frame->set_shadow_type('none'); - my $actions_frame_label = Gtk2::Label->new; + my $actions_frame_label = Gtk3::Label->new; $actions_frame_label->set_markup("" . $d->get("Actions") . ""); - my $actions_frame = Gtk2::Frame->new(); + my $actions_frame = Gtk3::Frame->new(); $actions_frame->set_label_widget($actions_frame_label); $actions_frame->set_shadow_type('none'); - my $capture_frame_label = Gtk2::Label->new; + my $capture_frame_label = Gtk3::Label->new; $capture_frame_label->set_markup("" . $d->get("Capture") . ""); - my $capture_frame = Gtk2::Frame->new(); + my $capture_frame = Gtk3::Frame->new(); $capture_frame->set_label_widget($capture_frame_label); $capture_frame->set_shadow_type('none'); - my $sel_capture_frame_label = Gtk2::Label->new; + my $sel_capture_frame_label = Gtk3::Label->new; $sel_capture_frame_label->set_markup("" . $d->get("Selection Capture") . ""); - my $sel_capture_frame = Gtk2::Frame->new(); + my $sel_capture_frame = Gtk3::Frame->new(); $sel_capture_frame->set_label_widget($sel_capture_frame_label); $sel_capture_frame->set_shadow_type('none'); - my $window_capture_frame_label = Gtk2::Label->new; + my $window_capture_frame_label = Gtk3::Label->new; $window_capture_frame_label->set_markup("" . $d->get("Window Capture") . ""); - my $window_capture_frame = Gtk2::Frame->new(); + my $window_capture_frame = Gtk3::Frame->new(); $window_capture_frame->set_label_widget($window_capture_frame_label); $window_capture_frame->set_shadow_type('none'); - my $menu_capture_frame_label = Gtk2::Label->new; + my $menu_capture_frame_label = Gtk3::Label->new; $menu_capture_frame_label->set_markup("" . $d->get("Menu/Tooltip Capture") . ""); - my $menu_capture_frame = Gtk2::Frame->new(); + my $menu_capture_frame = Gtk3::Frame->new(); $menu_capture_frame->set_label_widget($menu_capture_frame_label); $menu_capture_frame->set_shadow_type('none'); - my $web_capture_frame_label = Gtk2::Label->new; + my $web_capture_frame_label = Gtk3::Label->new; $web_capture_frame_label->set_markup("" . $d->get("Website Capture") . ""); - my $web_capture_frame = Gtk2::Frame->new(); + my $web_capture_frame = Gtk3::Frame->new(); $web_capture_frame->set_label_widget($web_capture_frame_label); $web_capture_frame->set_shadow_type('none'); - my $accounts_frame_label = Gtk2::Label->new; + my $accounts_frame_label = Gtk3::Label->new; $accounts_frame_label->set_markup("" . $d->get("Accounts") . ""); - my $accounts_frame = Gtk2::Frame->new(); + my $accounts_frame = Gtk3::Frame->new(); $accounts_frame->set_label_widget($accounts_frame_label); $accounts_frame->set_shadow_type('none'); - my $ftp_frame_label = Gtk2::Label->new; + my $ftp_frame_label = Gtk3::Label->new; $ftp_frame_label->set_markup("" . $d->get("File Transfer Protocol (FTP)") . ""); - my $ftp_frame = Gtk2::Frame->new(); + my $ftp_frame = Gtk3::Frame->new(); $ftp_frame->set_label_widget($ftp_frame_label); $ftp_frame->set_shadow_type('none'); - my $transparent_frame_label = Gtk2::Label->new; + my $transparent_frame_label = Gtk3::Label->new; $transparent_frame_label->set_markup("" . $d->get("Transparent Parts") . ""); - my $transparent_frame = Gtk2::Frame->new(); + my $transparent_frame = Gtk3::Frame->new(); $transparent_frame->set_label_widget($transparent_frame_label); $transparent_frame->set_shadow_type('none'); - my $session_frame_label = Gtk2::Label->new; + my $session_frame_label = Gtk3::Label->new; $session_frame_label->set_markup("" . $d->get("Session View") . ""); - my $session_frame = Gtk2::Frame->new(); + my $session_frame = Gtk3::Frame->new(); $session_frame->set_label_widget($session_frame_label); $session_frame->set_shadow_type('none'); #filename #-------------------------------------- - my $filename_label = Gtk2::Label->new($d->get("Filename") . ":"); + my $filename_label = Gtk3::Label->new($d->get("Filename") . ":"); - my $filename = Gtk2::Entry->new; + my $filename = Gtk3::Entry->new; if (defined $settings_xml->{'general'}->{'filename'}) { $filename->set_text($settings_xml->{'general'}->{'filename'}); } else { @@ -1152,14 +1042,14 @@ if ($app->is_running) { #do some input validation #here are all invalid char codes my @invalid_codes = (47, 92, 63, 42, 58, 124, 34, 60, 62, 44, 59, 35, 38); - my $filename_hint = Gtk2::Label->new; + my $filename_hint = Gtk3::Label->new; $filename_hint->set_no_show_all(TRUE); $filename->signal_connect( 'key-press-event' => sub { my $filename = shift; my $event = shift; - my $input = Gtk2::Gdk->keyval_to_unicode($event->keyval); + my $input = Gtk3::Gdk::keyval_to_unicode($event->keyval); #invalid input #~ print $input."\n"; @@ -1180,7 +1070,7 @@ if ($app->is_running) { }); my $filename_tooltip_string = - $d->get("There are several wildcards available, like\n") + $d->get("There are several wildcards available, like\n") . $d->get("%Y = year\n") . $d->get("%m = month\n") . $d->get("%d = day\n") @@ -1204,8 +1094,8 @@ if ($app->is_running) { #filetype and scale #-------------------------------------- - my $scale = Gtk2::HScale->new_with_range(0, 9, 1); - my $scale_label = Gtk2::Label->new($d->get("Compression") . ":"); + my $scale = Gtk3::HScale->new_with_range(0, 9, 1); + my $scale_label = Gtk3::Label->new($d->get("Compression") . ":"); $scale->set_value_pos('right'); $scale->set_value(1); @@ -1221,30 +1111,30 @@ if ($app->is_running) { $scale_box->pack_start($scale, TRUE, TRUE, 0); #add compatile, writeable file types - my $combobox_type = Gtk2::ComboBox->new_text; + my $combobox_type = Gtk3::ComboBoxText->new; my ($int_png, $int_jpeg, $int_bmp) = (-1, -1, -1); my $format_counter = 0; - foreach my $format (Gtk2::Gdk::Pixbuf->get_formats) { - if ( $format->{name} eq "jpeg" - || $format->{name} eq "png" - || $format->{name} eq "bmp") + foreach my $format (Gtk3::Gdk::Pixbuf::get_formats()) { + if ( $format->get_name eq "jpeg" + || $format->get_name eq "png" + || $format->get_name eq "bmp") { #we want jpg not jpeg - if ($format->{name} eq "jpeg" || $format->{name} eq "jpg") { - $combobox_type->append_text("jpg" . " - " . $format->{description}); + if ($format->get_name eq "jpeg" || $format->get_name eq "jpg") { + $combobox_type->append_text("jpg" . " - " . $format->get_description); } else { - $combobox_type->append_text($format->{name} . " - " . $format->{description}); + $combobox_type->append_text($format->get_name . " - " . $format->get_description); } #a little ugly here, maybe the values are in alternative order on several machine... #just remember the number when appending, so we can set png as default for example - if ($format->{name} eq "jpeg" || $format->{name} eq "jpg") { + if ($format->get_name eq "jpeg" || $format->get_name eq "jpg") { $int_jpeg = $format_counter; - } elsif ($format->{name} eq "png") { + } elsif ($format->get_name eq "png") { $int_png = $format_counter; - } elsif ($format->{name} eq "bmp") { + } elsif ($format->get_name eq "bmp") { $int_bmp = $format_counter; } @@ -1296,7 +1186,7 @@ if ($app->is_running) { } - my $filetype_label = Gtk2::Label->new($d->get("Image format") . ":"); + my $filetype_label = Gtk3::Label->new($d->get("Image format") . ":"); $combobox_type->set_tooltip_text($d->get("Select a file format")); $filetype_label->set_tooltip_text($d->get("Select a file format")); $filetype_box->pack_start($filetype_label, FALSE, TRUE, 12); @@ -1307,8 +1197,8 @@ if ($app->is_running) { #saveDir #-------------------------------------- - my $saveDir_label = Gtk2::Label->new($d->get("Directory") . ":"); - my $saveDir_button = Gtk2::FileChooserButton->new("Shutter - " . $d->get("Choose folder"), 'select-folder'); + my $saveDir_label = Gtk3::Label->new($d->get("Directory") . ":"); + my $saveDir_button = Gtk3::FileChooserButton->new("Shutter - " . $d->get("Choose folder"), 'select-folder'); if (defined $settings_xml->{'general'}->{'folder'}) { $saveDir_button->set_current_folder($settings_xml->{'general'}->{'folder'}); } else { @@ -1325,17 +1215,17 @@ if ($app->is_running) { #save options #-------------------------------------- - my $save_ask_active = Gtk2::RadioButton->new_with_label(undef, $d->get("Browse for save folder every time")); + my $save_ask_active = Gtk3::RadioButton->new_with_label(undef, $d->get("Browse for save folder every time")); $save_ask_box->pack_start($save_ask_active, FALSE, TRUE, 12); $save_ask_active->set_tooltip_text($d->get("Browse for save folder every time")); - my $save_no_active = Gtk2::RadioButton->new_with_label($save_ask_active, $d->get("Do not save file automatically")); + my $save_no_active = Gtk3::RadioButton->new_with_label($save_ask_active, $d->get("Do not save file automatically")); $save_no_box->pack_start($save_no_active, FALSE, TRUE, 12); $save_no_active->set_tooltip_text($d->get("Do not save file automatically")); - my $save_auto_active = Gtk2::RadioButton->new_with_label($save_ask_active, $d->get("Automatically save file")); + my $save_auto_active = Gtk3::RadioButton->new_with_label($save_ask_active, $d->get("Automatically save file")); $save_auto_box->pack_start($save_auto_active, FALSE, TRUE, 12); $save_auto_active->set_tooltip_text($d->get("Automatically save file")); @@ -1362,7 +1252,7 @@ if ($app->is_running) { #image_autocopy #-------------------------------------- - my $image_autocopy_active = Gtk2::RadioButton->new_with_label(undef, $d->get("Automatically copy screenshot to clipboard")); + my $image_autocopy_active = Gtk3::RadioButton->new_with_label(undef, $d->get("Automatically copy screenshot to clipboard")); $image_autocopy_box->pack_start($image_autocopy_active, FALSE, TRUE, 12); if (defined $settings_xml->{'general'}->{'image_autocopy'}) { @@ -1378,7 +1268,7 @@ if ($app->is_running) { #fname_autocopy #-------------------------------------- - my $fname_autocopy_active = Gtk2::RadioButton->new_with_label($image_autocopy_active, $d->get("Automatically copy filename to clipboard")); + my $fname_autocopy_active = Gtk3::RadioButton->new_with_label($image_autocopy_active, $d->get("Automatically copy filename to clipboard")); $fname_autocopy_box->pack_start($fname_autocopy_active, FALSE, TRUE, 12); if (defined $settings_xml->{'general'}->{'fname_autocopy'}) { @@ -1394,7 +1284,7 @@ if ($app->is_running) { #no_autocopy #-------------------------------------- - my $no_autocopy_active = Gtk2::RadioButton->new_with_label($image_autocopy_active, $d->get("Do not copy anything to clipboard")); + my $no_autocopy_active = Gtk3::RadioButton->new_with_label($image_autocopy_active, $d->get("Do not copy anything to clipboard")); $no_autocopy_box->pack_start($no_autocopy_active, FALSE, TRUE, 12); if (defined $settings_xml->{'general'}->{'no_autocopy'}) { @@ -1412,18 +1302,18 @@ if ($app->is_running) { #-------------------------------------- #delay statusbar - my $delay_status_label = Gtk2::Label->new($d->get("Delay") . ":"); - my $delay_status = Gtk2::SpinButton->new_with_range(0, 99, 1); - my $delay_status_vlabel = Gtk2::Label->new($d->nget("second", "seconds", $delay_status->get_value)); + my $delay_status_label = Gtk3::Label->new($d->get("Delay") . ":"); + my $delay_status = Gtk3::SpinButton->new_with_range(0, 99, 1); + my $delay_status_vlabel = Gtk3::Label->new($d->nget("second", "seconds", $delay_status->get_value)); $delay_status->signal_connect( 'value-changed' => \&evt_value_changed, 'delay_status_changed' ); #delay settings dialog - my $delay_label = Gtk2::Label->new($d->get("Capture after a delay of")); - my $delay = Gtk2::SpinButton->new_with_range(0, 99, 1); - my $delay_vlabel = Gtk2::Label->new($d->nget("second", "seconds", $delay->get_value)); + my $delay_label = Gtk3::Label->new($d->get("Capture after a delay of")); + my $delay = Gtk3::SpinButton->new_with_range(0, 99, 1); + my $delay_vlabel = Gtk3::Label->new($d->nget("second", "seconds", $delay->get_value)); $delay->signal_connect( 'value-changed' => \&evt_value_changed, 'delay_changed' @@ -1452,14 +1342,14 @@ if ($app->is_running) { #cursor #-------------------------------------- - my $cursor_status_active = Gtk2::CheckButton->new_with_label($d->get("Include Cursor")); + my $cursor_status_active = Gtk3::CheckButton->new_with_label($d->get("Include Cursor")); $cursor_status_active->set_tooltip_text($d->get("Include cursor when taking a screenshot")); $cursor_status_active->signal_connect( 'toggled' => \&evt_value_changed, 'cursor_status_toggled' ); - my $cursor_active = Gtk2::CheckButton->new_with_label($d->get("Include cursor when taking a screenshot")); + my $cursor_active = Gtk3::CheckButton->new_with_label($d->get("Include cursor when taking a screenshot")); $cursor_active->set_tooltip_text($d->get("Include cursor when taking a screenshot")); $cursor_active->signal_connect( 'toggled' => \&evt_value_changed, @@ -1480,15 +1370,15 @@ if ($app->is_running) { #program #-------------------------------------- my $model = fct_get_program_model(); - my $progname = Gtk2::ComboBox->new($model); + my $progname = Gtk3::ComboBox->new_with_model($model); #add pixbuf renderer for icon - my $renderer_pix = Gtk2::CellRendererPixbuf->new; + my $renderer_pix = Gtk3::CellRendererPixbuf->new; $progname->pack_start($renderer_pix, FALSE); $progname->add_attribute($renderer_pix, pixbuf => 0); #add text renderer for app name - my $renderer_text = Gtk2::CellRendererText->new; + my $renderer_text = Gtk3::CellRendererText->new; $progname->pack_start($renderer_text, FALSE); $progname->add_attribute($renderer_text, text => 1); @@ -1504,7 +1394,7 @@ if ($app->is_running) { $progname->set_active(0); } - my $progname_active = Gtk2::CheckButton->new; + my $progname_active = Gtk3::CheckButton->new; $progname_active->set_active(TRUE); $progname_active->signal_connect( 'toggled' => \&evt_value_changed, @@ -1515,7 +1405,7 @@ if ($app->is_running) { } else { $progname_active->set_active(FALSE); } - my $progname_label = Gtk2::Label->new($d->get("Open with") . ":"); + my $progname_label = Gtk3::Label->new($d->get("Open with") . ":"); $progname->set_tooltip_text($d->get("Open your screenshot with this program after capturing")); $progname_active->set_tooltip_text($d->get("Open your screenshot with this program after capturing")); $progname_label->set_tooltip_text($d->get("Open your screenshot with this program after capturing")); @@ -1528,7 +1418,7 @@ if ($app->is_running) { #im_colors #-------------------------------------- - my $combobox_im_colors = Gtk2::ComboBox->new_text; + my $combobox_im_colors = Gtk3::ComboBoxText->new; $combobox_im_colors->insert_text(0, $d->get("16 colors - (4bit) ")); $combobox_im_colors->insert_text(1, $d->get("64 colors - (6bit) ")); $combobox_im_colors->insert_text(2, $d->get("256 colors - (8bit) ")); @@ -1543,7 +1433,7 @@ if ($app->is_running) { $combobox_im_colors->set_active(2); } - my $im_colors_active = Gtk2::CheckButton->new; + my $im_colors_active = Gtk3::CheckButton->new; $im_colors_active->set_active(TRUE); $im_colors_active->signal_connect( 'toggled' => \&evt_value_changed, @@ -1556,7 +1446,7 @@ if ($app->is_running) { $im_colors_active->set_active(FALSE); } - my $im_colors_label = Gtk2::Label->new($d->get("Reduce colors") . ":"); + my $im_colors_label = Gtk3::Label->new($d->get("Reduce colors") . ":"); $combobox_im_colors->set_tooltip_text($d->get("Automatically reduce colors after taking a screenshot")); $im_colors_active->set_tooltip_text($d->get("Automatically reduce colors after taking a screenshot")); $im_colors_label->set_tooltip_text($d->get("Automatically reduce colors after taking a screenshot")); @@ -1569,8 +1459,8 @@ if ($app->is_running) { #thumbnail #-------------------------------------- - my $thumbnail_label = Gtk2::Label->new($d->get("Thumbnail") . ":"); - my $thumbnail = Gtk2::HScale->new_with_range(1, 100, 1); + my $thumbnail_label = Gtk3::Label->new($d->get("Thumbnail") . ":"); + my $thumbnail = Gtk3::HScale->new_with_range(1, 100, 1); $thumbnail->signal_connect( 'value-changed' => \&evt_value_changed, 'thumbnail_changed' @@ -1582,7 +1472,7 @@ if ($app->is_running) { } else { $thumbnail->set_value(50); } - my $thumbnail_active = Gtk2::CheckButton->new; + my $thumbnail_active = Gtk3::CheckButton->new; $thumbnail_active->set_active(TRUE); $thumbnail_active->signal_connect( 'toggled' => \&evt_value_changed, @@ -1606,15 +1496,15 @@ if ($app->is_running) { #bordereffect #-------------------------------------- - my $bordereffect_active = Gtk2::CheckButton->new; + my $bordereffect_active = Gtk3::CheckButton->new; $bordereffect_active->set_active(TRUE); - my $bordereffect_label = Gtk2::Label->new($d->get("Border") . ":"); - my $bordereffect = Gtk2::SpinButton->new_with_range(1, 100, 1); - my $bordereffect_vlabel = Gtk2::Label->new($d->get("pixels")); + my $bordereffect_label = Gtk3::Label->new($d->get("Border") . ":"); + my $bordereffect = Gtk3::SpinButton->new_with_range(1, 100, 1); + my $bordereffect_vlabel = Gtk3::Label->new($d->get("pixels")); - my $bordereffect_clabel = Gtk2::Label->new($d->get("Color") . ":"); - my $bordereffect_cbtn = Gtk2::ColorButton->new(); + my $bordereffect_clabel = Gtk3::Label->new($d->get("Color") . ":"); + my $bordereffect_cbtn = Gtk3::ColorButton->new(); $bordereffect_cbtn->set_use_alpha(FALSE); $bordereffect_cbtn->set_title($d->get("Choose border color")); @@ -1655,9 +1545,9 @@ if ($app->is_running) { } if (defined $settings_xml->{'general'}->{'bordereffect_col'}) { - $bordereffect_cbtn->set_color(Gtk2::Gdk::Color->parse($settings_xml->{'general'}->{'bordereffect_col'})); + $bordereffect_cbtn->set_rgba(Gtk3::Gdk::RGBA::parse($settings_xml->{'general'}->{'bordereffect_col'})); } else { - $bordereffect_cbtn->set_color(Gtk2::Gdk::Color->parse('black')); + $bordereffect_cbtn->set_rgba(Gtk3::Gdk::RGBA::parse('black')); } #end - bordereffect @@ -1665,7 +1555,7 @@ if ($app->is_running) { #zoom window #-------------------------------------- - my $zoom_active = Gtk2::CheckButton->new_with_label($d->get("Enable zoom window")); + my $zoom_active = Gtk3::CheckButton->new_with_label($d->get("Enable zoom window")); if (defined $settings_xml->{'general'}->{'zoom_active'}) { $zoom_active->set_active($settings_xml->{'general'}->{'zoom_active'}); @@ -1682,16 +1572,16 @@ if ($app->is_running) { #initial size for selection tool #-------------------------------------- - my $asel_size_label1 = Gtk2::Label->new($d->get("Start with selection size of")); - my $asel_size_label2 = Gtk2::Label->new("x"); - my $asel_size_label3 = Gtk2::Label->new($d->get("at")); - my $asel_size_label4 = Gtk2::Label->new(","); - my $asel_size1 = Gtk2::SpinButton->new_with_range(0, 10000, 1); - my $asel_size2 = Gtk2::SpinButton->new_with_range(0, 10000, 1); - my $asel_size3 = Gtk2::SpinButton->new_with_range(0, 10000, 1); - my $asel_size4 = Gtk2::SpinButton->new_with_range(0, 10000, 1); - my $asel_size_vlabel1 = Gtk2::Label->new($d->get("pixels")); - my $asel_size_vlabel2 = Gtk2::Label->new($d->get("pixels")); + my $asel_size_label1 = Gtk3::Label->new($d->get("Start with selection size of")); + my $asel_size_label2 = Gtk3::Label->new("x"); + my $asel_size_label3 = Gtk3::Label->new($d->get("at")); + my $asel_size_label4 = Gtk3::Label->new(","); + my $asel_size1 = Gtk3::SpinButton->new_with_range(0, 10000, 1); + my $asel_size2 = Gtk3::SpinButton->new_with_range(0, 10000, 1); + my $asel_size3 = Gtk3::SpinButton->new_with_range(0, 10000, 1); + my $asel_size4 = Gtk3::SpinButton->new_with_range(0, 10000, 1); + my $asel_size_vlabel1 = Gtk3::Label->new($d->get("pixels")); + my $asel_size_vlabel2 = Gtk3::Label->new($d->get("pixels")); if (defined $settings_xml->{'general'}->{'asel_x'}) { $asel_size3->set_value($settings_xml->{'general'}->{'asel_x'}); @@ -1741,7 +1631,7 @@ if ($app->is_running) { #show help text when using advanced selection tool #-------------------------------------- - my $as_help_active = Gtk2::CheckButton->new_with_label($d->get("Show help text")); + my $as_help_active = Gtk3::CheckButton->new_with_label($d->get("Show help text")); if (defined $settings_xml->{'general'}->{'as_help_active'}) { $as_help_active->set_active($settings_xml->{'general'}->{'as_help_active'}); @@ -1758,7 +1648,7 @@ if ($app->is_running) { #border #-------------------------------------- - my $border_active = Gtk2::CheckButton->new_with_label($d->get("Include window decoration when capturing a window")); + my $border_active = Gtk3::CheckButton->new_with_label($d->get("Include window decoration when capturing a window")); $border_active->set_tooltip_text($d->get("Include window decoration when capturing a window")); $border_box->pack_start($border_active, FALSE, TRUE, 12); @@ -1774,13 +1664,13 @@ if ($app->is_running) { #window resize #-------------------------------------- - my ($x, $y, $w, $h) = Gtk2::Gdk->get_default_root_window->get_geometry; + my ($x, $y, $w, $h) = Gtk3::Gdk::get_default_root_window->get_geometry; - my $winresize_active = Gtk2::CheckButton->new_with_label($d->get("Automatically resize window to")); - my $winresize_label = Gtk2::Label->new("x"); - my $winresize_w = Gtk2::SpinButton->new_with_range(0, $w, 1); - my $winresize_h = Gtk2::SpinButton->new_with_range(0, $h, 1); - my $winresize_vlabel = Gtk2::Label->new($d->get("pixels")); + my $winresize_active = Gtk3::CheckButton->new_with_label($d->get("Automatically resize window to")); + my $winresize_label = Gtk3::Label->new("x"); + my $winresize_w = Gtk3::SpinButton->new_with_range(0, $w, 1); + my $winresize_h = Gtk3::SpinButton->new_with_range(0, $h, 1); + my $winresize_vlabel = Gtk3::Label->new($d->get("pixels")); if (defined $settings_xml->{'general'}->{'winresize_active'}) { $winresize_active->set_active($settings_xml->{'general'}->{'winresize_active'}); @@ -1827,7 +1717,7 @@ if ($app->is_running) { #window autoshape #-------------------------------------- - my $autoshape_active = Gtk2::CheckButton->new_with_label($d->get("Force rounded window corners")); + my $autoshape_active = Gtk3::CheckButton->new_with_label($d->get("Force rounded window corners")); if (defined $settings_xml->{'general'}->{'autoshape_active'}) { $autoshape_active->set_active($settings_xml->{'general'}->{'autoshape_active'}); @@ -1838,7 +1728,7 @@ if ($app->is_running) { $autoshape_active->set_tooltip_text( sprintf( $d->get( - "Shutter uses the XShape extension to determine the window's shape, " + "Shutter uses the XShape extension to determine the window's shape, " . "but this does not work under some circumstances, e.g. when running compiz.\n\n" . "When this option is activated Shutter uses fixed parameters to round the window corners. " . "You can overwrite the default parameters by creating a file named ~/.shutter/shape.conf and put custom values in it. " @@ -1854,7 +1744,7 @@ if ($app->is_running) { #visible windows only #-------------------------------------- - my $visible_windows_active = Gtk2::CheckButton->new_with_label($d->get("Select only visible windows")); + my $visible_windows_active = Gtk3::CheckButton->new_with_label($d->get("Select only visible windows")); $visible_windows_active->set_tooltip_text($d->get("Select only visible windows")); $visible_windows_box->pack_start($visible_windows_active, FALSE, TRUE, 12); @@ -1871,9 +1761,9 @@ if ($app->is_running) { #menu capture delay #-------------------------------------- #delay settings dialog - my $menu_delay_label = Gtk2::Label->new($d->get("Pre-Capture Delay") . ":"); - my $menu_delay = Gtk2::SpinButton->new_with_range(1, 99, 1); - my $menu_delay_vlabel = Gtk2::Label->new($d->nget("second", "seconds", $delay->get_value)); + my $menu_delay_label = Gtk3::Label->new($d->get("Pre-Capture Delay") . ":"); + my $menu_delay = Gtk3::SpinButton->new_with_range(1, 99, 1); + my $menu_delay_vlabel = Gtk3::Label->new($d->nget("second", "seconds", $delay->get_value)); $menu_delay->signal_connect( 'value-changed' => \&evt_value_changed, 'menu_delay_changed' @@ -1898,7 +1788,7 @@ if ($app->is_running) { #menu/tooltip workaround #-------------------------------------- - my $menu_waround_active = Gtk2::CheckButton->new_with_label($d->get("Ignore possibly wrong type hints")); + my $menu_waround_active = Gtk3::CheckButton->new_with_label($d->get("Ignore possibly wrong type hints")); $menu_waround_active->set_tooltip_text($d->get( "The type hint constants specify hints for the window manager that indicate what type of function the window has. Sometimes these type hints are not correctly set. By enabling this option Shutter will not insist on the requested type hint." )); @@ -1916,8 +1806,8 @@ if ($app->is_running) { #web width #-------------------------------------- - my $web_width_label = Gtk2::Label->new($d->get("Virtual browser width") . ":"); - my $combobox_web_width = Gtk2::ComboBox->new_text; + my $web_width_label = Gtk3::Label->new($d->get("Virtual browser width") . ":"); + my $combobox_web_width = Gtk3::ComboBoxText->new; $combobox_web_width->insert_text(0, "640"); $combobox_web_width->insert_text(1, "800"); $combobox_web_width->insert_text(2, "1024"); @@ -1929,7 +1819,7 @@ if ($app->is_running) { $combobox_web_width->insert_text(8, "1680"); $combobox_web_width->insert_text(9, "1920"); $combobox_web_width->insert_text(10, "2048"); - my $web_width_vlabel = Gtk2::Label->new($d->get("pixels")); + my $web_width_vlabel = Gtk3::Label->new($d->get("pixels")); if (defined $settings_xml->{'general'}->{'web_width'}) { $combobox_web_width->set_active($settings_xml->{'general'}->{'web_width'}); @@ -1950,13 +1840,15 @@ if ($app->is_running) { #imageview #-------------------------------------- - my $trans_check = Gtk2::RadioButton->new(undef, $d->get("Show as check pattern")); - my $trans_custom = Gtk2::RadioButton->new($trans_check, $d->get("Show as custom color:")); - my $trans_custom_btn = Gtk2::ColorButton->new(); + my $css_provider_alpha = Gtk3::CssProvider->new; + + my $trans_check = Gtk3::RadioButton->new_with_label(undef, $d->get("Show as check pattern")); + my $trans_custom = Gtk3::RadioButton->new_with_label($trans_check, $d->get("Show as custom color:")); + my $trans_custom_btn = Gtk3::ColorButton->new(); $trans_custom_btn->set_use_alpha(FALSE); $trans_custom_btn->set_title($d->get("Choose fill color")); - my $trans_backg = Gtk2::RadioButton->new($trans_custom, $d->get("Show as background")); + my $trans_backg = Gtk3::RadioButton->new_with_label($trans_custom, $d->get("Show as background")); $imageview_hbox1->pack_start($trans_check, FALSE, TRUE, 12); $imageview_hbox2->pack_start($trans_custom, FALSE, TRUE, 12); @@ -1964,9 +1856,9 @@ if ($app->is_running) { $imageview_hbox3->pack_start($trans_backg, FALSE, TRUE, 12); if (defined $settings_xml->{'general'}->{'trans_custom_col'}) { - $trans_custom_btn->set_color(Gtk2::Gdk::Color->parse($settings_xml->{'general'}->{'trans_custom_col'})); + $trans_custom_btn->set_rgba(Gtk3::Gdk::RGBA::parse($settings_xml->{'general'}->{'trans_custom_col'})); } else { - $trans_custom_btn->set_color(Gtk2::Gdk::Color->parse('black')); + $trans_custom_btn->set_rgba(Gtk3::Gdk::RGBA::parse('black')); } if ( defined $settings_xml->{'general'}->{'trans_check'} @@ -1979,6 +1871,8 @@ if ($app->is_running) { } else { $trans_check->set_active(TRUE); } + # initialize css + evt_value_changed(undef, 'transp_toggled'); $trans_check->set_tooltip_text($d->get("Displays any transparent parts of the image in a check pattern")); $trans_custom->set_tooltip_text($d->get("Displays any transparent parts of the image in a solid color that you specify")); @@ -2006,12 +1900,12 @@ if ($app->is_running) { ); #session view - my $session_asc = Gtk2::RadioButton->new(undef, $d->get("Sort ascending by")); - my $session_asc_combo = Gtk2::ComboBox->new_text(); + my $session_asc = Gtk3::RadioButton->new_with_label(undef, $d->get("Sort ascending by")); + my $session_asc_combo = Gtk3::ComboBoxText->new; $session_asc_combo->insert_text(0, $d->get("Filename")); $session_asc_combo->insert_text(1, $d->get("Key/Time Created")); - my $session_desc = Gtk2::RadioButton->new($session_asc, $d->get("Sort descending by")); - my $session_desc_combo = Gtk2::ComboBox->new_text(); + my $session_desc = Gtk3::RadioButton->new_with_label($session_asc, $d->get("Sort descending by")); + my $session_desc_combo = Gtk3::ComboBoxText->new; $session_desc_combo->insert_text(0, $d->get("Filename")); $session_desc_combo->insert_text(1, $d->get("Key/Time Created")); @@ -2075,29 +1969,29 @@ if ($app->is_running) { #behavior #-------------------------------------- - my $fs_active = Gtk2::CheckButton->new_with_label($d->get("Start Shutter at login")); - my $fs_min_active = Gtk2::CheckButton->new_with_label($d->get("Hide window on first launch")); - my $fs_nonot_active = Gtk2::CheckButton->new_with_label($d->get("Hide notification icon")); - - my $hide_active = Gtk2::CheckButton->new_with_label($d->get("Autohide main window when taking a screenshot")); - my $hide_time_label = Gtk2::Label->new($d->get("Redraw Delay") . ":"); - my $hide_time_vlabel = Gtk2::Label->new; - my $hide_time = Gtk2::SpinButton->new_with_range(100, 1000, 50); + my $fs_active = Gtk3::CheckButton->new_with_label($d->get("Start Shutter at login")); + my $fs_min_active = Gtk3::CheckButton->new_with_label($d->get("Hide window on first launch")); + my $fs_nonot_active = Gtk3::CheckButton->new_with_label($d->get("Hide notification icon")); + + my $hide_active = Gtk3::CheckButton->new_with_label($d->get("Autohide main window when taking a screenshot")); + my $hide_time_label = Gtk3::Label->new($d->get("Redraw Delay") . ":"); + my $hide_time_vlabel = Gtk3::Label->new; + my $hide_time = Gtk3::SpinButton->new_with_range(100, 1000, 50); $hide_time_vlabel->set_text($d->nget("millisecond", "milliseconds", $hide_time->get_value)); $hide_time->signal_connect( 'value-changed' => \&evt_value_changed, 'hide_time_changed' ); - my $present_after_active = Gtk2::CheckButton->new_with_label($d->get("Present main window after taking a screenshot")); - my $close_at_close_active = Gtk2::CheckButton->new_with_label($d->get("Minimize to tray when closing main window")); + my $present_after_active = Gtk3::CheckButton->new_with_label($d->get("Present main window after taking a screenshot")); + my $close_at_close_active = Gtk3::CheckButton->new_with_label($d->get("Minimize to tray when closing main window")); - my $notify_after_active = Gtk2::CheckButton->new_with_label($d->get("Display pop-up notification after taking a screenshot")); - my $notify_timeout_active = Gtk2::CheckButton->new_with_label($d->get("Display pop-up notification when using a delay")); - my $notify_ptimeout_active = Gtk2::CheckButton->new_with_label($d->get("Display pop-up notification when using a pre-capture delay")); + my $notify_after_active = Gtk3::CheckButton->new_with_label($d->get("Display pop-up notification after taking a screenshot")); + my $notify_timeout_active = Gtk3::CheckButton->new_with_label($d->get("Display pop-up notification when using a delay")); + my $notify_ptimeout_active = Gtk3::CheckButton->new_with_label($d->get("Display pop-up notification when using a pre-capture delay")); - my $ns_label = Gtk2::Label->new($d->get("Notification agent") . ":"); - my $combobox_ns = Gtk2::ComboBox->new_text; + my $ns_label = Gtk3::Label->new($d->get("Notification agent") . ":"); + my $combobox_ns = Gtk3::ComboBoxText->new; $combobox_ns->append_text($d->get("Desktop Notifications")); $combobox_ns->append_text($d->get("Built-In Notifications")); @@ -2106,9 +2000,9 @@ if ($app->is_running) { 'ns_changed' ); - my $ask_on_delete_active = Gtk2::CheckButton->new_with_label($d->get("Ask before moving files to trash")); - my $delete_on_close_active = Gtk2::CheckButton->new_with_label($d->get("Move file to trash when closing tab")); - my $ask_on_fs_delete_active = Gtk2::CheckButton->new_with_label($d->get("Notify when file was deleted from filesystem")); + my $ask_on_delete_active = Gtk3::CheckButton->new_with_label($d->get("Ask before moving files to trash")); + my $delete_on_close_active = Gtk3::CheckButton->new_with_label($d->get("Move file to trash when closing tab")); + my $ask_on_fs_delete_active = Gtk3::CheckButton->new_with_label($d->get("Notify when file was deleted from filesystem")); $fs_active_hbox->pack_start($fs_active, FALSE, TRUE, 12); $fs_min_active_hbox->pack_start($fs_min_active, FALSE, TRUE, 12); @@ -2257,7 +2151,7 @@ if ($app->is_running) { my $accounts_model = undef; fct_load_accounts_tree(); - my $accounts_tree = Gtk2::TreeView->new_with_model($accounts_model); + my $accounts_tree = Gtk3::TreeView->new_with_model($accounts_model); $accounts_tree->signal_connect( 'row-activated' => \&evt_accounts, @@ -2267,11 +2161,9 @@ if ($app->is_running) { fct_set_model_accounts($accounts_tree); #some notes related to uploading - my $pub_hint_pref = Gtk2::Label->new(); + my $pub_hint_pref = Gtk3::Label->new(); $pub_hint_pref->set_line_wrap(TRUE); - if (Gtk2->CHECK_VERSION(2, 9, 0)) { - $pub_hint_pref->set_line_wrap_mode('word-char'); - } + $pub_hint_pref->set_line_wrap_mode('word-char'); $pub_hint_pref->set_markup( "" @@ -2281,9 +2173,9 @@ if ($app->is_running) { ); #ftp uri - my $ftp_entry_label = Gtk2::Label->new($d->get("URI") . ":"); + my $ftp_entry_label = Gtk3::Label->new($d->get("URI") . ":"); - my $ftp_remote_entry = Gtk2::Entry->new; + my $ftp_remote_entry = Gtk3::Entry->new; if (defined $settings_xml->{'general'}->{'ftp_uri'}) { $ftp_remote_entry->set_text($settings_xml->{'general'}->{'ftp_uri'}); } else { @@ -2298,9 +2190,9 @@ if ($app->is_running) { $ftp_hbox1->pack_start($ftp_remote_entry, TRUE, TRUE, 0); #connection mode - my $ftp_mode_label = Gtk2::Label->new($d->get("Connection mode") . ":"); + my $ftp_mode_label = Gtk3::Label->new($d->get("Connection mode") . ":"); - my $ftp_mode_combo = Gtk2::ComboBox->new_text; + my $ftp_mode_combo = Gtk3::ComboBoxText->new; $ftp_mode_combo->insert_text(0, $d->get("Active mode")); $ftp_mode_combo->insert_text(1, $d->get("Passive mode")); if (defined $settings_xml->{'general'}->{'ftp_mode'}) { @@ -2317,9 +2209,9 @@ if ($app->is_running) { $ftp_hbox2->pack_start($ftp_mode_combo, TRUE, TRUE, 0); #username - my $ftp_username_label = Gtk2::Label->new($d->get("Username") . ":"); + my $ftp_username_label = Gtk3::Label->new($d->get("Username") . ":"); - my $ftp_username_entry = Gtk2::Entry->new; + my $ftp_username_entry = Gtk3::Entry->new; if (defined $settings_xml->{'general'}->{'ftp_username'}) { $ftp_username_entry->set_text($settings_xml->{'general'}->{'ftp_username'}); } else { @@ -2334,9 +2226,9 @@ if ($app->is_running) { $ftp_hbox3->pack_start($ftp_username_entry, TRUE, TRUE, 0); #password - my $ftp_password_label = Gtk2::Label->new($d->get("Password") . ":"); + my $ftp_password_label = Gtk3::Label->new($d->get("Password") . ":"); - my $ftp_password_entry = Gtk2::Entry->new; + my $ftp_password_entry = Gtk3::Entry->new; $ftp_password_entry->set_invisible_char("*"); $ftp_password_entry->set_visibility(FALSE); if (defined $settings_xml->{'general'}->{'ftp_password'}) { @@ -2353,9 +2245,9 @@ if ($app->is_running) { $ftp_hbox4->pack_start($ftp_password_entry, TRUE, TRUE, 0); #website url - my $ftp_wurl_label = Gtk2::Label->new($d->get("Website URL") . ":"); + my $ftp_wurl_label = Gtk3::Label->new($d->get("Website URL") . ":"); - my $ftp_wurl_entry = Gtk2::Entry->new; + my $ftp_wurl_entry = Gtk3::Entry->new; if (defined $settings_xml->{'general'}->{'ftp_wurl'}) { $ftp_wurl_entry->set_text($settings_xml->{'general'}->{'ftp_wurl'}); } else { @@ -2375,7 +2267,7 @@ if ($app->is_running) { #-------------------------------------- #settings main tab - my $label_basic = Gtk2::Label->new; + my $label_basic = Gtk3::Label->new; $label_basic->set_markup($d->get("Main")); $file_vbox->pack_start($scale_box, TRUE, TRUE, 3); @@ -2403,7 +2295,7 @@ if ($app->is_running) { $filename_label->set_alignment(0, 0.5); $saveDir_label->set_alignment(0, 0.5); - my $sg_main = Gtk2::SizeGroup->new('horizontal'); + my $sg_main = Gtk3::SizeGroup->new('horizontal'); $sg_main->add_widget($scale_label); $sg_main->add_widget($filetype_label); $sg_main->add_widget($filename_label); @@ -2415,7 +2307,7 @@ if ($app->is_running) { $vbox_basic->set_border_width(5); #settings actions tab - my $label_actions = Gtk2::Label->new; + my $label_actions = Gtk3::Label->new; $label_actions->set_markup($d->get("Actions")); $actions_vbox->pack_start($progname_box, FALSE, TRUE, 3); @@ -2430,7 +2322,7 @@ if ($app->is_running) { $thumbnail_label->set_alignment(0, 0.5); $bordereffect_label->set_alignment(0, 0.5); - my $sg_actions = Gtk2::SizeGroup->new('horizontal'); + my $sg_actions = Gtk3::SizeGroup->new('horizontal'); $sg_actions->add_widget($progname_label); $sg_actions->add_widget($im_colors_label); $sg_actions->add_widget($thumbnail_label); @@ -2440,17 +2332,17 @@ if ($app->is_running) { $vbox_actions->set_border_width(5); #settings advanced tab - my $label_advanced = Gtk2::Label->new; + my $label_advanced = Gtk3::Label->new; $label_advanced->set_markup($d->get("Advanced")); #all labels = one size $asel_size_label3->set_alignment(1, 0.5); - my $sg_asel = Gtk2::SizeGroup->new('horizontal'); + my $sg_asel = Gtk3::SizeGroup->new('horizontal'); $sg_asel->add_widget($asel_size_label1); $sg_asel->add_widget($asel_size_label3); - my $sg_asel2 = Gtk2::SizeGroup->new('horizontal'); + my $sg_asel2 = Gtk3::SizeGroup->new('horizontal'); $sg_asel2->add_widget($asel_size_label2); $sg_asel2->add_widget($asel_size_label4); @@ -2477,7 +2369,7 @@ if ($app->is_running) { $menu_delay_label->set_alignment(0, 0.5); $web_width_label->set_alignment(0, 0.5); - my $sg_adv = Gtk2::SizeGroup->new('horizontal'); + my $sg_adv = Gtk3::SizeGroup->new('horizontal'); $sg_adv->add_widget($menu_delay_label); $sg_adv->add_widget($web_width_label); @@ -2488,7 +2380,7 @@ if ($app->is_running) { $vbox_advanced->set_border_width(5); #settings image view tab - my $label_imageview = Gtk2::Label->new; + my $label_imageview = Gtk3::Label->new; $label_imageview->set_markup($d->get("Image View")); $transparent_vbox->pack_start($imageview_hbox1, TRUE, TRUE, 3); @@ -2496,7 +2388,7 @@ if ($app->is_running) { $transparent_vbox->pack_start($imageview_hbox3, TRUE, TRUE, 3); $transparent_frame->add($transparent_vbox); - my $sg_session = Gtk2::SizeGroup->new('horizontal'); + my $sg_session = Gtk3::SizeGroup->new('horizontal'); $sg_session->add_widget($session_asc); $sg_session->add_widget($session_desc); @@ -2509,7 +2401,7 @@ if ($app->is_running) { $vbox_imageview->set_border_width(5); #settings behavior tab - my $label_behavior = Gtk2::Label->new; + my $label_behavior = Gtk3::Label->new; $label_behavior->set_markup($d->get("Behavior")); $first_vbox->pack_start($fs_active_hbox, TRUE, TRUE, 3); @@ -2537,7 +2429,7 @@ if ($app->is_running) { #all labels = one size $hide_time_label->set_alignment(0, 0.5); - my $sg_behav = Gtk2::SizeGroup->new('horizontal'); + my $sg_behav = Gtk3::SizeGroup->new('horizontal'); $sg_behav->add_widget($hide_time_label); $vbox_behavior->pack_start($firstlaunch_frame, FALSE, TRUE, 3); @@ -2547,13 +2439,13 @@ if ($app->is_running) { $vbox_behavior->set_border_width(5); #settings upload tab - my $label_accounts = Gtk2::Label->new; + my $label_accounts = Gtk3::Label->new; $label_accounts->set_markup($d->get("Upload")); #align the hint $pub_hint_pref->set_alignment(0, 0.5); - my $scrolled_accounts_window = Gtk2::ScrolledWindow->new; + my $scrolled_accounts_window = Gtk3::ScrolledWindow->new; $scrolled_accounts_window->set_policy('automatic', 'automatic'); $scrolled_accounts_window->set_shadow_type('in'); $scrolled_accounts_window->add($accounts_tree); @@ -2576,7 +2468,7 @@ if ($app->is_running) { $ftp_password_label->set_alignment(0, 0.5); $ftp_wurl_label->set_alignment(0, 0.5); - my $sg_acc = Gtk2::SizeGroup->new('horizontal'); + my $sg_acc = Gtk3::SizeGroup->new('horizontal'); $sg_acc->add_widget($ftp_entry_label); $sg_acc->add_widget($ftp_mode_label); $sg_acc->add_widget($ftp_username_label); @@ -2599,23 +2491,23 @@ if ($app->is_running) { #not used in a standalone environment if (keys(%plugins) > 0 && !$ENV{PAR_TEMP}) { - my $effects_tree = Gtk2::TreeView->new_with_model(&fct_load_plugin_tree); + my $effects_tree = Gtk3::TreeView->new_with_model(fct_load_plugin_tree()); fct_set_model_plugins($effects_tree); - my $scrolled_plugins_window = Gtk2::ScrolledWindow->new; + my $scrolled_plugins_window = Gtk3::ScrolledWindow->new; $scrolled_plugins_window->set_policy('automatic', 'automatic'); $scrolled_plugins_window->set_shadow_type('in'); $scrolled_plugins_window->add($effects_tree); - my $label_plugins = Gtk2::Label->new; + my $label_plugins = Gtk3::Label->new; $label_plugins->set_markup($d->get("Plugins")); - my $label_treeview = Gtk2::Label->new($d->get("The following plugins are installed")); + my $label_treeview = Gtk3::Label->new($d->get("The following plugins are installed")); $label_treeview->set_alignment(0, 0.5); $effects_vbox->pack_start($label_treeview, FALSE, TRUE, 1); $effects_vbox->pack_start($scrolled_plugins_window, TRUE, TRUE, 1); - my $vbox_plugins = Gtk2::VBox->new(FALSE, 12); + my $vbox_plugins = Gtk3::VBox->new(FALSE, 12); $vbox_plugins->set_border_width(5); $vbox_plugins->pack_start($effects_vbox, TRUE, TRUE, 1); @@ -2623,7 +2515,7 @@ if ($app->is_running) { } #profiles - $profiles_box->pack_start(Gtk2::Label->new($d->get("Profile") . ":"), FALSE, TRUE, 1); + $profiles_box->pack_start(Gtk3::Label->new($d->get("Profile") . ":"), FALSE, TRUE, 1); $profiles_box->pack_start($combobox_settings_profiles, TRUE, TRUE, 6); $profiles_box->pack_start($button_profile_save, FALSE, TRUE, 1); $profiles_box->pack_start($button_profile_delete, FALSE, TRUE, 1); @@ -2634,11 +2526,11 @@ if ($app->is_running) { #settings $hbox_settings->pack_start($vbox_settings, TRUE, TRUE, 6); - $settings_dialog->vbox->add($hbox_settings); + $settings_dialog->get_child->add($hbox_settings); $settings_dialog->set_default_response('apply'); #~ #iconview - #~ my $iconview = Gtk2::IconView->new_with_model($session_start_screen{'first_page'}->{'model'}); + #~ my $iconview = Gtk3::IconView->new_with_model($session_start_screen{'first_page'}->{'model'}); #~ $iconview->set_item_width (150); #~ $iconview->set_pixbuf_column(0); #~ $iconview->set_text_column(1); @@ -2646,19 +2538,19 @@ if ($app->is_running) { #~ $iconview->signal_connect( 'selection-changed', \&evt_iconview_sel_changed ); #~ $iconview->signal_connect( 'item-activated', \&evt_iconview_item_activated ); #~ - #~ my $scrolled_window_view = Gtk2::ScrolledWindow->new; + #~ my $scrolled_window_view = Gtk3::ScrolledWindow->new; #~ $scrolled_window_view->set_policy( 'automatic', 'automatic' ); #~ $scrolled_window_view->set_shadow_type('in'); #~ $scrolled_window_view->add($iconview); #~ #~ #add an event box to show a context menu on right-click - #~ my $view_event = Gtk2::EventBox->new; + #~ my $view_event = Gtk3::EventBox->new; #~ $view_event->add($scrolled_window_view); #~ $view_event->signal_connect( 'button-press-event', \&evt_iconview_button_press, $iconview ); #~ #~ #~ #pack notebook and iconview into vpaned# - #~ my $vpaned = Gtk2::VPaned->new; + #~ my $vpaned = Gtk3::VPaned->new; #~ $vpaned->add1($notebook); #~ $vpaned->add2($view_event); #~ @@ -2755,11 +2647,11 @@ if ($app->is_running) { #pack statusbar $status->pack_start($cursor_status_active, FALSE, FALSE, 0); - $status->pack_start(Gtk2::HSeparator->new, FALSE, FALSE, 3); + $status->pack_start(Gtk3::HSeparator->new, FALSE, FALSE, 3); $status->pack_start($delay_status_label, FALSE, FALSE, 0); $status->pack_start($delay_status, FALSE, FALSE, 0); - $status->pack_start(Gtk2::HSeparator->new, FALSE, FALSE, 6); + $status->pack_start(Gtk3::HSeparator->new, FALSE, FALSE, 6); $vbox->pack_start($status, FALSE, FALSE, 0); @@ -2836,8 +2728,6 @@ if ($app->is_running) { return FALSE; }); - Gtk2->main; - 0; #events @@ -2871,27 +2761,23 @@ if ($app->is_running) { if ($data eq "transp_toggled") { #Sets how the view should draw transparent parts of images with an alpha channel - my $color = $trans_custom_btn->get_color; - my $color_string = sprintf("%02x%02x%02x", $color->red / 257, $color->green / 257, $color->blue / 257); - - my $mode; if ($trans_check->get_active) { - $mode = 'grid'; + $css_provider_alpha->load_from_data(" + .imageview.transparent { + background-image: url('$shutter_root/share/shutter/resources/gui/checkers.svg'); + } + "); } elsif ($trans_custom->get_active) { - $mode = 'color'; + my $color_string = $trans_custom_btn->get_rgba->to_string; + $css_provider_alpha->load_from_data(" + .imageview.transparent { + background-color: $color_string; + } + "); } elsif ($trans_backg->get_active) { - $mode = 'color'; - my $bg = $window->get_style->bg('normal'); - $color_string = sprintf("%02x%02x%02x", $bg->red / 257, $bg->green / 257, $bg->blue / 257); - } - - #change all imageviews in session - foreach my $key (keys %session_screens) { - if ($session_screens{$key}->{'image'}) { - $session_screens{$key}->{'image'}->set_transp($mode, hex $color_string); - } + $css_provider_alpha->load_from_data(" "); } - + $window->queue_draw; } #"cursor_status" toggled @@ -3014,7 +2900,7 @@ if ($app->is_running) { my $selfcapture = FALSE; if ($data =~ /^shutter_window_direct(.*)/) { my $xid = $1; - $selfcapture = TRUE if $xid == $window->window->XID; + $selfcapture = TRUE if $xid == $window->get_window->get_xid; } #hide mainwindow @@ -3055,6 +2941,10 @@ if ($app->is_running) { my $scd_text; if ($data eq "menu" || $data eq "tray_menu") { $scd_text = $d->get("Please activate the menu you want to capture"); + if ($ENV{GDK_SCALE} > 1) { + my $sd = Shutter::App::SimpleDialogs->new; + $sd->dlg_info_message("Capturing a cascading menu is known to be broken with HiDPI.\nPlease unset GDK_SCALE variable and restart Shutter.\nPlease follow https://github.com/shutter-project/shutter/issues/326 and send us the patch\nWill attempt capturing it anyway...", undef, 'gtk-ok'); + } } elsif ($data eq "tooltip" || $data eq "tray_tooltip") { $scd_text = $d->get("Please activate the tooltip you want to capture"); } @@ -3119,6 +3009,10 @@ if ($app->is_running) { return FALSE; }); } else { + if (($data eq "section" || $data eq "tray_section") && $ENV{GDK_SCALE} > 1) { + my $sd = Shutter::App::SimpleDialogs->new; + $sd->dlg_info_message("Capturing a window section is known to be broken with HiDPI.\nPlease unset GDK_SCALE variable and restart Shutter.\nPlease follow https://github.com/shutter-project/shutter/issues/326 and send us the patch\nWill attempt capturing it anyway...", undef, 'gtk-ok'); + } #A short timeout to give the server a chance to #redraw the area that was obscured by our dialog. @@ -3166,7 +3060,7 @@ if ($app->is_running) { && defined $session_screens{$ckey}->{'image'}) { unless ($session_screens{$ckey}->{'image'}->get_pixbuf) { - $session_screens{$ckey}->{'image'}->set_pixbuf($lp->load($session_screens{$key}->{'long'}, undef, undef, undef, TRUE)); + $session_screens{$ckey}->{'image'}->set_pixbuf($lp->load($session_screens{$key}->{'long'}, undef, undef, undef, TRUE), TRUE); } } } @@ -3251,7 +3145,7 @@ if ($app->is_running) { #autostart $sas->create_autostart_file($sdir->get_autostart_dir, $fs_active->get_active, $fs_min_active->get_active, $fs_nonot_active->get_active); - Gtk2->main_quit; + $app->quit; return FALSE; }); @@ -3314,7 +3208,7 @@ if ($app->is_running) { undef, # parent menu shell undef, # parent menu item sub { - return Gtk2::StatusIcon::position_menu($tray_menu, 0, 0, $tray); + return Gtk3::StatusIcon::position_menu($tray_menu, 0, 0, $tray); }, # menu pos func undef, # data $time ? $button : 0, @@ -3400,12 +3294,14 @@ if ($app->is_running) { #we don't handle selection changes #if we are not in the session tab - if (&fct_get_current_file) { + if (fct_get_current_file()) { return FALSE; } - my @sel_items = $view->get_selected_items; + my $items = $view->get_selected_items; + my @sel_items; + @sel_items = @$items if $items; #enable/disable menu entry when we are in the session tab and selection changes if (scalar @sel_items == 1) { @@ -3463,7 +3359,7 @@ if ($app->is_running) { $child->destroy; } } else { - $menu_links = Gtk2::Menu->new; + $menu_links = Gtk3::Menu->new; } my $nmenu_entries = 0; @@ -3480,24 +3376,24 @@ if ($app->is_running) { unless defined $session_screens{$key}->{'links'}->{$hoster}->{'menuentry'}; #create menu entry - my $menuitem_hoster = Gtk2::ImageMenuItem->new_with_mnemonic($session_screens{$key}->{'links'}->{$hoster}->{'menuentry'}); + my $menuitem_hoster = Gtk3::ImageMenuItem->new_with_mnemonic($session_screens{$key}->{'links'}->{$hoster}->{'menuentry'}); if (defined $session_screens{$key}->{'links'}->{$hoster}->{'menuimage'}) { if ($traytheme->has_icon($session_screens{$key}->{'links'}->{$hoster}->{'menuimage'})) { - $menuitem_hoster->set_image(Gtk2::Image->new_from_icon_name($session_screens{$key}->{'links'}->{$hoster}->{'menuimage'}, 'menu')); + $menuitem_hoster->set_image(Gtk3::Image->new_from_icon_name($session_screens{$key}->{'links'}->{$hoster}->{'menuimage'}, 'menu')); } } #create submenu with urls - my $menu_urls = Gtk2::Menu->new; + my $menu_urls = Gtk3::Menu->new; foreach my $url (keys %{$session_screens{$key}->{'links'}->{$hoster}}) { next if $url eq 'menuimage'; next if $url eq 'menuentry'; next if $url eq 'pubfile'; #create item - my $menuitem_url = Gtk2::MenuItem->new_with_label($session_screens{$key}->{'links'}->{$hoster}->{$url}); + my $menuitem_url = Gtk3::MenuItem->new_with_label($session_screens{$key}->{'links'}->{$hoster}->{$url}); foreach my $child ($menuitem_url->get_children) { - if ($child =~ m/Gtk2::AccelLabel/) { + if ($child =~ m/Gtk3::AccelLabel/) { $child->set_ellipsize('middle'); $child->set_width_chars(20); last; @@ -3585,7 +3481,7 @@ if ($app->is_running) { #last capture foreach my $child ($tray_menu->get_children) { if ($child->get_name eq 'redoshot') { - $child->set_sensitive(&fct_get_last_capture); + $child->set_sensitive(fct_get_last_capture()); last; } } @@ -3594,7 +3490,7 @@ if ($app->is_running) { #-------------------------------------- #last capture - $st->{_redoshot}->set_sensitive(&fct_get_last_capture); + $st->{_redoshot}->set_sensitive(fct_get_last_capture()); #goocanvas is optional, don't enable it when not installed if ($goocanvas) { @@ -3604,12 +3500,8 @@ if ($app->is_running) { } #upload links - my ($nmenu_entries_tb, $menu_links_tb) = fct_ret_upload_links_menu($key, $st->{_upload}->get_menu); - if ($nmenu_entries_tb) { - $st->{_upload}->set_menu($menu_links_tb); - } else { - $st->{_upload}->set_menu(undef); - } + my (undef, $menu_links_tb) = fct_ret_upload_links_menu($key, $st->{_upload}->get_menu); + $st->{_upload}->set_menu($menu_links_tb); $st->{_upload}->set_sensitive($n_items); #MENU @@ -3826,12 +3718,12 @@ if ($app->is_running) { my ($widget, $data) = @_; #restore settings if prossible - my $ssettings = Gtk2::PrintSettings->new; + my $ssettings = Gtk3::PrintSettings->new; if ($shf->file_exists("$ENV{ HOME }/.shutter/printing.xml")) { - eval { $ssettings = Gtk2::PrintSettings->new_from_file("$ENV{ HOME }/.shutter/printing.xml"); }; + eval { $ssettings = Gtk3::PrintSettings->new_from_file("$ENV{ HOME }/.shutter/printing.xml"); }; } - $pagesetup = Gtk2::Print->run_page_setup_dialog($window, $pagesetup, $ssettings); + $pagesetup = Gtk3::Print->run_page_setup_dialog($window, $pagesetup, $ssettings); return TRUE; } @@ -3971,18 +3863,23 @@ if ($app->is_running) { $notebook->set('scrollable' => TRUE); #enable dnd for it - $notebook->drag_dest_set('all', ['copy', 'private', 'default', 'move', 'link', 'ask']); + $notebook->drag_dest_set('all', [Gtk3::TargetEntry->new('text/uri-list', [], 0)], 'link'); $notebook->signal_connect(drag_data_received => \&fct_drop_handler); - - my $target_list = Gtk2::TargetList->new(); - my $atom_dest = Gtk2::Gdk::Atom->new('text/uri-list'); - $target_list->add($atom_dest, 0, 0); - $notebook->drag_dest_set_target_list($target_list); + $notebook->signal_connect(drag_motion => sub { + my ($view, $ctx, $x, $y, $time) = @_; + for my $target (@{$ctx->list_targets}) { + if ($target->name eq 'text/uri-list') { + Gtk3::Gdk::drag_status($ctx, 'link', $time); + return TRUE; + } + } + return FALSE; + }); #packing and first page - my $hbox_first_label = Gtk2::HBox->new(FALSE, 0); - my $thumb_first_icon = Gtk2::Image->new_from_stock('gtk-index', 'menu'); - my $tab_first_label = Gtk2::Label->new(); + my $hbox_first_label = Gtk3::HBox->new(FALSE, 0); + my $thumb_first_icon = Gtk3::Image->new_from_stock('gtk-index', 'menu'); + my $tab_first_label = Gtk3::Label->new(); $tab_first_label->set_markup("" . $d->get("Session") . ""); $hbox_first_label->pack_start($thumb_first_icon, FALSE, FALSE, 1); $hbox_first_label->pack_start($tab_first_label, FALSE, FALSE, 1); @@ -4025,7 +3922,7 @@ if ($app->is_running) { } #add to recentmanager - Gtk2::RecentManager->get_default->add_item($giofile->get_path); + Gtk3::RecentManager::get_default->add_item($giofile->get_path); #FIXME my $num_files = $session_start_screen{'first_page'}->{'num_session_files'}; @@ -4044,7 +3941,7 @@ if ($app->is_running) { $indx = $count; } else { $indx = $num_files + 1; - while ($indx < &fct_get_latest_tab_key) { + while ($indx < fct_get_latest_tab_key()) { $indx++; } @@ -4067,34 +3964,23 @@ if ($app->is_running) { } #setup tab label (thumb, preview etc.) - my $hbox_tab_label = Gtk2::HBox->new(FALSE, 0); - my $close_icon = Gtk2::Image->new_from_icon_name('gtk-close', 'menu'); + my $hbox_tab_label = Gtk3::HBox->new(FALSE, 0); + my $close_icon = Gtk3::Image->new_from_icon_name('gtk-close', 'menu'); - $session_screens{$key}->{'tab_icon'} = Gtk2::Image->new; + $session_screens{$key}->{'tab_icon'} = Gtk3::Image->new; #setup tab label - my $tab_close_button = Gtk2::Button->new; + my $tab_close_button = Gtk3::Button->new; $tab_close_button->set_relief('none'); $tab_close_button->set_image($close_icon); $tab_close_button->set_name('tab-close-button'); - #customize the button style - Gtk2::Rc->parse_string( - "style 'tab-close-button-style' { - GtkWidget::focus-padding = 0 - GtkWidget::focus-line-width = 0 - xthickness = 0 - ythickness = 0 - } - widget '*.tab-close-button' style 'tab-close-button-style'" - ); - - my $tab_label = Gtk2::Label->new($key); + my $tab_label = Gtk3::Label->new($key); $tab_label->set_ellipsize('middle'); $tab_label->set_width_chars(20); $hbox_tab_label->pack_start($session_screens{$key}->{'tab_icon'}, FALSE, FALSE, 1); $hbox_tab_label->pack_start($tab_label, TRUE, TRUE, 1); - $hbox_tab_label->pack_start(Gtk2::HBox->new, TRUE, TRUE, 1); + $hbox_tab_label->pack_start(Gtk3::HBox->new, TRUE, TRUE, 1); $hbox_tab_label->pack_start($tab_close_button, FALSE, FALSE, 1); $hbox_tab_label->show_all; @@ -4206,26 +4092,24 @@ if ($app->is_running) { $sensitive = FALSE; #block signals - if ($app->signal_handler_is_connected($app_watch_id)) { - $app->signal_handler_block($app_watch_id); + foreach my $connection (@signal_connections) { + if ($app->signal_handler_is_connected($connection)) { + $app->signal_handler_block($connection); + } } #and block status icon handler - if ($tray && $tray->isa('Gtk2::StatusIcon')) { + if ($tray && $tray->isa('Gtk3::StatusIcon')) { if ($tray->signal_handler_is_connected($tray->{'hid'})) { $tray->signal_handler_block($tray->{'hid'}); } if ($tray->signal_handler_is_connected($tray->{'hid2'})) { $tray->signal_handler_block($tray->{'hid2'}); } - } elsif ($tray && $tray->isa('Gtk2::AppIndicator')) { - if (Gtk2::AppIndicator->VERSION > 0.12) { + } elsif ($tray && $tray->isa('AppIndicator::Indicator')) { + if (Gtk3::AppIndicator->VERSION > 0.12) { $tray->set_passive(); } - } elsif ($tray) { - if ($tray_box->signal_handler_is_connected($tray_box->{'hid'})) { - $tray_box->signal_handler_block($tray_box->{'hid'}); - } } } elsif ($action eq 'unblock') { @@ -4233,26 +4117,24 @@ if ($app->is_running) { $sensitive = TRUE; #attach signal-handler again - if ($app->signal_handler_is_connected($app_watch_id)) { - $app->signal_handler_unblock($app_watch_id); + foreach my $connection (@signal_connections) { + if ($app->signal_handler_is_connected($connection)) { + $app->signal_handler_unblock($connection); + } } #and unblock status icon handler - if ($tray && $tray->isa('Gtk2::StatusIcon')) { + if ($tray && $tray->isa('Gtk3::StatusIcon')) { if ($tray->signal_handler_is_connected($tray->{'hid'})) { $tray->signal_handler_unblock($tray->{'hid'}); } if ($tray->signal_handler_is_connected($tray->{'hid2'})) { $tray->signal_handler_unblock($tray->{'hid2'}); } - } elsif ($tray && $tray->isa('Gtk2::AppIndicator')) { - if (Gtk2::AppIndicator->VERSION > 0.12) { + } elsif ($tray && $tray->isa('AppIndicator::Indicator')) { + if (Gtk3::AppIndicator->VERSION > 0.12) { $tray->set_active(); } - } elsif ($tray) { - if ($tray_box->signal_handler_is_connected($tray_box->{'hid'})) { - $tray_box->signal_handler_unblock($tray_box->{'hid'}); - } } } @@ -4281,7 +4163,7 @@ if ($app->is_running) { $st->{_web}->set_sensitive($sensitive) if ($gnome_web_photo); #special case: redoshot (toolbar and menu) - if (&fct_get_last_capture) { + if (fct_get_last_capture()) { $st->{_redoshot}->set_sensitive($sensitive); $sm->{_menuitem_redoshot}->set_sensitive($sensitive); } @@ -4301,15 +4183,18 @@ if ($app->is_running) { #this is an unusual method for raising the window #to the top within the stacking order (z-axis) #but it works best here - if ($mode eq 'show' && $is_hidden && $present) { + if ($mode eq 'show' && $present) { #move window to saved position $window->move($window->{x}, $window->{y}) if (defined $window->{x} && defined $window->{y}); + #if it's shown already, but behind other windows, without hiding it doesn't show + $window->hide; + $window->show_all; - $window->window->focus(Gtk2->get_current_event_time) - if defined $window->window; + #$window->window->focus(Gtk3->get_current_event_time) + # if defined $window->window; $window->present; #set flag @@ -4346,36 +4231,22 @@ if ($app->is_running) { sub fct_create_tab { my ($key, $is_all) = @_; - my $vbox = Gtk2::VBox->new(FALSE, 0); - my $vbox_tab = Gtk2::VBox->new(FALSE, 0); - my $vbox_tab_event = Gtk2::EventBox->new; + my $vbox = Gtk3::VBox->new(FALSE, 0); + my $vbox_tab = Gtk3::VBox->new(FALSE, 0); + my $vbox_tab_event = Gtk3::EventBox->new; unless ($is_all) { #Gtk2::ImageView - empty at first - $session_screens{$key}->{'image'} = Gtk2::ImageView->new(); - $session_screens{$key}->{'image'}->set_interpolation('tiles'); - $session_screens{$key}->{'image'}->set_show_frame(FALSE); - - #Sets how the view should draw transparent parts of images with an alpha channel - my $color = $trans_custom_btn->get_color; - my $color_string = sprintf("%02x%02x%02x", $color->red / 257, $color->green / 257, $color->blue / 257); - - my $mode; - if ($trans_check->get_active) { - $mode = 'grid'; - } elsif ($trans_custom->get_active) { - $mode = 'color'; - } elsif ($trans_backg->get_active) { - $mode = 'color'; - my $bg = $window->get_style->bg('normal'); - $color_string = sprintf("%02x%02x%02x", $bg->red / 257, $bg->green / 257, $bg->blue / 257); - } - - $session_screens{$key}->{'image'}->set_transp($mode, hex $color_string); + $session_screens{$key}->{'image'} = Gtk3::ImageView->new(); + #$session_screens{$key}->{'image'}->set_show_frame(FALSE); + $session_screens{$key}->{'image'}->set_fitting(TRUE); + $session_screens{$key}->{'image'}->get_style_context->add_provider($css_provider_alpha, 0); #Gtk2::ImageView::ScrollWin packaged in a Gtk2::ScrolledWindow - my $scrolled_window_image = Gtk2::ImageView::ScrollWin->new($session_screens{$key}->{'image'}); + #my $scrolled_window_image = Gtk2::ImageView::ScrollWin->new($session_screens{$key}->{'image'}); + my $scrolled_window_image = Gtk3::ScrolledWindow->new; + $scrolled_window_image->add_with_viewport($session_screens{$key}->{'image'}); #WORKAROUND #upstream bug @@ -4406,50 +4277,44 @@ if ($app->is_running) { } }); - #dnd - $session_screens{$key}->{'image'}->drag_source_set('button1-mask', ['copy'], {'target' => "text/uri-list", 'flags' => [], 'info' => 0}); + $session_screens{$key}->{'image'}->signal_connect( + 'dnd-start', + sub { + my ($view, $x, $y, $button) = @_; + my $list = Gtk3::TargetList->new; + $list->add_table([Gtk3::TargetEntry->new('text/uri-list', [], 0)]); + $view->drag_begin_with_coordinates( + $list, + ['copy'], + $button, + undef, + $x, $y, + ); + return TRUE; + } + ); $session_screens{$key}->{'image'}->signal_connect( 'drag-data-get', sub { my ($widget, $context, $data, $info, $time) = @_; - if (exists $session_screens{$key}->{'giofile'} - && defined $session_screens{$key}->{'giofile'}) - { - $data->set($data->target, 8, $session_screens{$key}->{'giofile'}->get_uri); - } - }); - - #maybe we need to disable dnd to allow scrolling + $data->set_uris([$session_screens{$key}->{'giofile'}->get_uri]); + } + ); $session_screens{$key}->{'image'}->signal_connect( - 'expose-event', + 'zoom-changed', sub { - my ($view) = @_; - my $block_dnd = FALSE; - foreach my $child ($scrolled_window_image->get_children) { - if ($child =~ /Scrollbar/) { - if ($child->visible) { - $block_dnd = TRUE; - last; - } - } - } - if ($block_dnd) { - $view->drag_source_unset; + my ($view, $zoom) = @_; + if ($zoom >= 1) { + $view->set_interpolation('nearest'); } else { - $view->drag_source_set( - 'button1-mask', - ['copy'], - { - 'target' => "text/uri-list", - 'flags' => [], - 'info' => 0 - }); + $view->set_interpolation('bilinear'); } - }); + } + ); $vbox_tab->pack_start($scrolled_window_image, TRUE, TRUE, 0); - $vbox->pack_start_defaults($vbox_tab); + $vbox->pack_start($vbox_tab, TRUE, TRUE, 0); #pack vbox into an event box so we can listen #to various key and button events @@ -4462,12 +4327,12 @@ if ($app->is_running) { } else { #create iconview for session - $session_start_screen{'first_page'}->{'model'} = Gtk2::ListStore->new('Gtk2::Gdk::Pixbuf', 'Glib::String', 'Glib::String'); + $session_start_screen{'first_page'}->{'model'} = Gtk3::ListStore->new('Gtk3::Gdk::Pixbuf', 'Glib::String', 'Glib::String'); $session_start_screen{'first_page'}->{'model'}->set_sort_column_id(2, 'descending'); - $session_start_screen{'first_page'}->{'view'} = Gtk2::IconView->new_with_model($session_start_screen{'first_page'}->{'model'}); + $session_start_screen{'first_page'}->{'view'} = Gtk3::IconView->new_with_model($session_start_screen{'first_page'}->{'model'}); #~ $session_start_screen{'first_page'}->{'view'}->set_orientation('horizontal'); - $session_start_screen{'first_page'}->{'view'}->set_item_width(150); + $session_start_screen{'first_page'}->{'view'}->set_item_width(100); $session_start_screen{'first_page'}->{'view'}->set_pixbuf_column(0); $session_start_screen{'first_page'}->{'view'}->set_text_column(1); $session_start_screen{'first_page'}->{'view'}->set_selection_mode('multiple'); @@ -4477,24 +4342,27 @@ if ($app->is_running) { $session_start_screen{'first_page'}->{'view'}->signal_connect('item-activated', \&evt_iconview_item_activated, 'item_activated'); #pack into scrolled window - my $scrolled_window_view = Gtk2::ScrolledWindow->new; + my $scrolled_window_view = Gtk3::ScrolledWindow->new; $scrolled_window_view->set_policy('automatic', 'automatic'); $scrolled_window_view->set_shadow_type('in'); $scrolled_window_view->add($session_start_screen{'first_page'}->{'view'}); #add an event box to show a context menu on right-click - my $view_event = Gtk2::EventBox->new; + my $view_event = Gtk3::EventBox->new; $view_event->add($scrolled_window_view); $view_event->signal_connect('button-press-event', \&evt_iconview_button_press, $session_start_screen{'first_page'}->{'view'}); #dnd - $session_start_screen{'first_page'}->{'view'}->enable_model_drag_source('button1-mask', ['copy'], {'target' => "text/uri-list", 'flags' => [], 'info' => 0}); + $session_start_screen{'first_page'}->{'view'}->enable_model_drag_source( + 'button1-mask', + [Gtk3::TargetEntry->new('text/uri-list', [], 0)], + ['copy']); $session_start_screen{'first_page'}->{'view'}->signal_connect( 'drag-data-get', sub { my ($widget, $context, $data, $info, $time) = @_; - my $target_list; + my @target_list; $session_start_screen{'first_page'}->{'view'}->selected_foreach( sub { my ($view, $path) = @_; @@ -4504,18 +4372,18 @@ if ($app->is_running) { if (exists $session_screens{$key}->{'giofile'} && defined $session_screens{$key}->{'giofile'}) { - $target_list .= $session_screens{$key}->{'giofile'}->get_uri . "\n"; + push @target_list, $session_screens{$key}->{'giofile'}->get_uri; } } }); - $data->set($data->target, 8, $target_list); + $data->set_uris(\@target_list); }); $vbox_tab->pack_start($view_event, TRUE, TRUE, 0); - $vbox->pack_start_defaults($vbox_tab); + $vbox->pack_start($vbox_tab, TRUE, TRUE, 0); $vbox->show_all; return $vbox; @@ -4563,7 +4431,7 @@ if ($app->is_running) { $settings{'general'}->{'filetype'} = $combobox_type->get_active; $settings{'general'}->{'quality'} = $scale->get_value(); $settings{'general'}->{'filename'} = $filename->get_text(); - $settings{'general'}->{'folder'} = $saveDir_button->get_filename(); + $settings{'general'}->{'folder'} = Glib::filename_to_unicode($saveDir_button->get_filename()); #~ print "Pfad ".$saveDir_button->get_filename()."\n"; #~ print "Pfad ".$saveDir_button->get_uri()."\n"; @@ -4843,7 +4711,7 @@ if ($app->is_running) { $bordereffect->set_value($settings_xml->{'general'}->{'bordereffect'}); $bordereffect_active->set_active($settings_xml->{'general'}->{'bordereffect_active'}); if (defined $settings_xml->{'general'}->{'bordereffect_col'}) { - $bordereffect_cbtn->set_color(Gtk2::Gdk::Color->parse($settings_xml->{'general'}->{'bordereffect_col'})); + $bordereffect_cbtn->set_rgba(Gtk3::Gdk::RGBA::parse($settings_xml->{'general'}->{'bordereffect_col'})); } #advanced settings @@ -4872,7 +4740,7 @@ if ($app->is_running) { $trans_check->set_active($settings_xml->{'general'}->{'trans_check'}); $trans_custom->set_active($settings_xml->{'general'}->{'trans_custom'}); if (defined $settings_xml->{'general'}->{'trans_custom_col'}) { - $trans_custom_btn->set_color(Gtk2::Gdk::Color->parse($settings_xml->{'general'}->{'trans_custom_col'})); + $trans_custom_btn->set_rgba(Gtk3::Gdk::RGBA::parse($settings_xml->{'general'}->{'trans_custom_col'})); } $trans_backg->set_active($settings_xml->{'general'}->{'trans_backg'}); @@ -4993,14 +4861,14 @@ if ($app->is_running) { } sub fct_get_program_model { - my $model = Gtk2::ListStore->new('Gtk2::Gdk::Pixbuf', 'Glib::String', 'Glib::Scalar'); + my $model = Gtk3::ListStore->new('Gtk3::Gdk::Pixbuf', 'Glib::String', 'Glib::Scalar'); #add Shutter's built-in editor to the list if ($goocanvas) { my $icon_pixbuf = undef; my $icon = 'shutter'; if ($sc->get_theme->has_icon($icon)) { - my ($iw, $ih) = Gtk2::IconSize->lookup('menu'); + my ($iw, $ih) = $shf->icon_size('menu'); eval { $icon_pixbuf = $sc->get_theme->load_icon($icon, $ih, 'generic-fallback'); }; if ($@) { print "\nWARNING: Could not load icon $icon: $@\n"; @@ -5030,7 +4898,7 @@ if ($app->is_running) { my $icon_pixbuf = undef; my $icon = $app->get_icon; if ($icon) { - my ($iw, $ih) = Gtk2::IconSize->lookup('menu'); + my ($iw, $ih) = $shf->icon_size('menu'); eval { my $icon_info = $sc->get_theme->choose_icon($icon->get_names, $ih, []); $icon_pixbuf = $icon_info->load_icon if $icon_info; @@ -5096,15 +4964,17 @@ if ($app->is_running) { sub fct_drop_handler { my ($widget, $context, $x, $y, $selection, $info, $time) = @_; - my $type = $selection->target->name; - my $data = $selection->data; + my $type = $selection->get_target->name; return unless $type eq 'text/uri-list'; + my $data = $selection->get_data; + $data = join('', map { chr } @$data); my @files = grep defined($_), split /[\r\n]+/, $data; my @valid_files; foreach my $file (@files) { - my ($mime_type) = Glib::Object::Introspection->invoke('Gio', undef, 'content_type_guess', $file); + my $giofile = Glib::IO::File::new_for_uri($file); + my ($mime_type) = Glib::Object::Introspection->invoke('Gio', undef, 'content_type_guess', $giofile->get_path); $mime_type =~ s/image\/x\-apple\-ios\-png/image\/png/; #FIXME if ($mime_type && fct_check_valid_mime_type($mime_type)) { push @valid_files, $file; @@ -5114,20 +4984,19 @@ if ($app->is_running) { #open all valid files if (@valid_files) { fct_open_files(@valid_files); + Gtk3::drag_finish($context, 1, 0, $time); + return TRUE; } else { - $context->finish(0, 0, $time); + Gtk3::drag_finish($context, 0, 0, $time); return FALSE; } - - $context->finish(1, 0, $time); - return TRUE; } sub fct_check_valid_mime_type { my $mime_type = shift; - foreach my $format (Gtk2::Gdk::Pixbuf->get_formats) { - foreach my $mtype (@{$format->{mime_types}}) { + foreach my $format (Gtk3::Gdk::Pixbuf::get_formats()) { + foreach my $mtype (@{$format->get_mime_types}) { return TRUE if $mtype eq $mime_type; last; } @@ -5205,9 +5074,9 @@ if ($app->is_running) { return FALSE; } } - $throbber = Gtk2::Image->new_from_file("$shutter_root/share/shutter/resources/icons/throbber_16x16.gif"); + $throbber = Gtk3::Image->new_from_file("$shutter_root/share/shutter/resources/icons/throbber_16x16.gif"); $throbber->set_name('throbber'); - $sep = Gtk2::HSeparator->new; + $sep = Gtk3::HSeparator->new; $status->pack_start($sep, FALSE, FALSE, 3); $status->pack_end($throbber, FALSE, FALSE, 0); } @@ -5299,7 +5168,7 @@ if ($app->is_running) { #close current tab (unless $key is provided or close_all) unless (defined $action && $action eq 'menu_close_all') { - $key = &fct_get_current_file unless $key; + $key = fct_get_current_file() unless $key; } #single file @@ -5318,7 +5187,7 @@ if ($app->is_running) { eval { #remove from recentmanager - Gtk2::RecentManager->get_default->remove_item($session_screens{$key}->{'giofile'}->get_path); + Gtk3::RecentManager::get_default->remove_item($session_screens{$key}->{'giofile'}->get_path); }; } @@ -5378,7 +5247,7 @@ if ($app->is_running) { eval { #remove from recentmanager - Gtk2::RecentManager->get_default->remove_item($session_screens{$key}->{'giofile'}->get_path); + Gtk3::RecentManager::get_default->remove_item($session_screens{$key}->{'giofile'}->get_path); }; } @@ -5428,7 +5297,7 @@ if ($app->is_running) { #close current tab (unless $key is provided or close_all) unless (defined $action && $action eq 'menu_close_all') { - $key = &fct_get_current_file unless $key; + $key = fct_get_current_file() unless $key; } #single file @@ -5528,10 +5397,10 @@ if ($app->is_running) { sub fct_update_gui { - while (Gtk2->events_pending) { - Gtk2->main_iteration; + while (Gtk3::events_pending()) { + Gtk3::main_iteration(); } - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); return TRUE; } @@ -5599,14 +5468,14 @@ if ($app->is_running) { } my $clipboard_string = undef; - my $clipboard_region = Gtk2::Gdk::Region->new; + my $clipboard_region = Gtk3::Gdk::Region->new; my @pixbuf_array; my @rects_array; foreach my $key (@clipboard_array) { if ($mode eq 'image') { my $pixbuf = $lp->load($session_screens{$key}->{'long'}); - my $rect = Gtk2::Gdk::Rectangle->new($sr->get_clipbox($clipboard_region)->width, 0, $pixbuf->get_width, $pixbuf->get_height); + my $rect = {x=>$sr->get_clipbox($clipboard_region)->{width}, y=>0, width=>$pixbuf->get_width, height=>$pixbuf->get_height}; $clipboard_region->union_with_rect($rect); push @pixbuf_array, $pixbuf; push @rects_array, $rect; @@ -5623,7 +5492,7 @@ if ($app->is_running) { } if ($clipboard_region->get_rectangles) { - my $clipboard_image = Gtk2::Gdk::Pixbuf->new('rgb', TRUE, 8, $sr->get_clipbox($clipboard_region)->width, $sr->get_clipbox($clipboard_region)->height); + my $clipboard_image = Gtk3::Gdk::Pixbuf->new('rgb', TRUE, 8, $sr->get_clipbox($clipboard_region)->{width}, $sr->get_clipbox($clipboard_region)->{height}); $clipboard_image->fill(0x00000000); #copy images to the blank pixbuf @@ -5938,7 +5807,7 @@ if ($app->is_running) { my $filetype_value = undef; #folder to save - my $folder = $saveDir_button->get_filename || $folder_from_config; + my $folder = Glib::filename_to_unicode($saveDir_button->get_filename) || $folder_from_config; if ($save_no_active->get_active) { $folder = $sdir->get_cache_dir; } @@ -6167,7 +6036,7 @@ if ($app->is_running) { #~ $screenshot = 3; #~ } - if ($screenshooter = &fct_get_last_capture) { + if ($screenshooter = fct_get_last_capture()) { #we need to handle menu and tooltip in a special way if ($screenshooter->can('get_mode')) { @@ -6410,7 +6279,7 @@ if ($app->is_running) { return FALSE; } - print "New uri after exists check: " . $giofile->get_path . "\n" + print "New uri after exists check: " . $shf->utf8_decode($giofile->get_path) . "\n" if $sc->get_debug; #manipulate before saving @@ -6617,7 +6486,7 @@ if ($app->is_running) { #update window list foreach my $child ($tray_menu->get_children) { if ($child->get_name eq 'windowlist') { - $child->set_submenu(&fct_ret_window_menu); + $child->set_submenu(fct_ret_window_menu()); last; } } @@ -6742,7 +6611,7 @@ if ($app->is_running) { push(@pages, $session_screens{$key}->{'long'}); } - my $op = Gtk2::PrintOperation->new; + my $op = Gtk3::PrintOperation->new; $op->set_job_name(SHUTTER_NAME . " - " . SHUTTER_VERSION . " - " . localtime); $op->set_n_pages(scalar @pages); $op->set_unit('pixel'); @@ -6752,7 +6621,7 @@ if ($app->is_running) { #restore settings if prossible if ($shf->file_exists("$ENV{ HOME }/.shutter/printing.xml")) { eval { - my $ssettings = Gtk2::PrintSettings->new_from_file("$ENV{ HOME }/.shutter/printing.xml"); + my $ssettings = Gtk3::PrintSettings->new_from_file("$ENV{ HOME }/.shutter/printing.xml"); $op->set_print_settings($ssettings); }; } @@ -6782,7 +6651,7 @@ if ($app->is_running) { $cr->scale(min($scale_x, $scale_y), min($scale_x, $scale_y)); } - Gtk2::Gdk::Cairo::Context::set_source_pixbuf($cr, $pixbuf, 0, 0); + Gtk3::Gdk::cairo_set_source_pixbuf($cr, $pixbuf, 0, 0); } @@ -6874,16 +6743,15 @@ if ($app->is_running) { $plugin_dialog->hide if defined $plugin_dialog; #dialog to show the plugin - my $sdialog = Gtk2::Dialog->new($plugin_name, $window, [qw/modal destroy-with-parent/]); + my $sdialog = Gtk3::Dialog->new($plugin_name, $window, [qw/modal destroy-with-parent/]); $sdialog->set_resizable(FALSE); - $sdialog->set_has_separator(FALSE); # Ensure that the dialog box is destroyed when the user responds. $sdialog->signal_connect(response => sub { $_[0]->destroy }); #initiate the socket to draw the contents of the plugin to our dialog - my $socket = Gtk2::Socket->new; - $sdialog->vbox->add($socket); + my $socket = Gtk3::Socket->new; + $sdialog->get_child->add($socket); $socket->signal_connect( 'plug-removed' => sub { $sdialog->destroy(); @@ -7042,21 +6910,19 @@ if ($app->is_running) { $status->push(1, sprintf($d->nget("%s screenshot", "%s screenshots", scalar(keys(%session_screens))), scalar(keys(%session_screens))) . " " - . $shf->utf8_decode($hu->format(&fct_get_total_size_of_session))); + . $shf->utf8_decode($hu->format(fct_get_total_size_of_session()))); } #TRAY TOOLTIP #-------------------------------------- if ($combobox_settings_profiles) { - if ($tray && $tray->isa('Gtk2::StatusIcon')) { + if ($tray && $tray->isa('Gtk3::StatusIcon')) { if ($combobox_settings_profiles->get_active_text) { - $tray->set_tooltip($d->get("Current profile") . ": " . $combobox_settings_profiles->get_active_text); + $tray->set_tooltip_text($d->get("Current profile") . ": " . $combobox_settings_profiles->get_active_text); } else { - $tray->set_tooltip(SHUTTER_NAME . " " . SHUTTER_VERSION); + $tray->set_tooltip_text(SHUTTER_NAME . " " . SHUTTER_VERSION); } - } elsif ($tray && $tray->isa('Gtk2::TrayIcon')) { - $tray->set_tooltip_text(SHUTTER_NAME . " " . SHUTTER_VERSION); } } @@ -7194,8 +7060,8 @@ if ($app->is_running) { $combobox_status_profiles->destroy; } - $combobox_status_profiles_label = Gtk2::Label->new($d->get("Profile") . ":"); - $combobox_status_profiles = Gtk2::ComboBox->new_text; + $combobox_status_profiles_label = Gtk3::Label->new($d->get("Profile") . ":"); + $combobox_status_profiles = Gtk3::ComboBoxText->new; $status->pack_start($combobox_status_profiles_label, FALSE, FALSE, 0); $status->pack_start($combobox_status_profiles, FALSE, FALSE, 0); @@ -7346,7 +7212,7 @@ if ($app->is_running) { } else { #If image pixbuf was not loaded, get image info without loading it into the memory - ($im_format, $im_height, $im_width) = Gtk2::Gdk::Pixbuf->get_file_info($session_screens{$key}->{'long'}); + ($im_format, $im_height, $im_width) = Gtk3::Gdk::Pixbuf::get_file_info($session_screens{$key}->{'long'}); unless ($im_format) { #increment error counter @@ -7450,7 +7316,7 @@ if ($app->is_running) { unless ($session_screens{$key}->{'no_thumbnail'}) { #update tab icon - $thumb = $lp_ne->load($shf->utf8_decode($session_screens{$key}->{'giofile'}->get_path), Gtk2::IconSize->lookup('small-toolbar')); + $thumb = $lp_ne->load($shf->utf8_decode($session_screens{$key}->{'giofile'}->get_path), $shf->icon_size('small-toolbar')); $session_screens{$key}->{'tab_icon'}->set_from_pixbuf($thumb); } @@ -7477,7 +7343,7 @@ if ($app->is_running) { #update dnd pixbuf $session_screens{$key}->{'image'}->drag_source_set_icon_pixbuf($thumb_view); } else { - $thumb_view = Gtk2::Gdk::Pixbuf->new('rgb', TRUE, 8, 5, 5); + $thumb_view = Gtk3::Gdk::Pixbuf->new('rgb', TRUE, 8, 5, 5); $thumb_view->fill(0x00000000); } @@ -7938,7 +7804,7 @@ if ($app->is_running) { sub fct_check_installed_plugins { - my $plugin_dialog = Gtk2::MessageDialog->new($window, [qw/modal destroy-with-parent/], 'info', 'close', $d->get("Updating plugin information")); + my $plugin_dialog = Gtk3::MessageDialog->new($window, [qw/modal destroy-with-parent/], 'info', 'close', $d->get("Updating plugin information")); $plugin_dialog->{destroyed} = FALSE; $plugin_dialog->set_title("Shutter"); @@ -7949,13 +7815,16 @@ if ($app->is_running) { $plugin_dialog->set_resizable(TRUE); - my $plugin_progress = Gtk2::ProgressBar->new; + my $plugin_progress = Gtk3::ProgressBar->new; $plugin_progress->set_no_show_all(TRUE); $plugin_progress->set_ellipsize('middle'); - $plugin_progress->set_orientation('left-to-right'); + $plugin_progress->set_orientation('horizontal'); $plugin_progress->set_fraction(0); - $plugin_dialog->vbox->add($plugin_progress); + $plugin_dialog->get_child->add($plugin_progress); + my $current_plugin = Gtk3::Label->new(""); + $current_plugin->set_line_wrap(TRUE); + $plugin_dialog->get_child->add($current_plugin); my @plugin_paths = ("$shutter_root/share/shutter/resources/system/plugins/*/*", "$ENV{'HOME'}/.shutter/plugins/*/*"); @@ -7963,7 +7832,7 @@ if ($app->is_running) { # maybe the plugin # does not provide a custom icon my $fb_pixbuf_path = "$shutter_root/share/shutter/resources/icons/executable.svg"; - my $fb_pixbuf = $lp->load($fb_pixbuf_path, Gtk2::IconSize->lookup('menu')); + my $fb_pixbuf = $lp->load($fb_pixbuf_path, $shf->icon_size('menu')); foreach my $plugin_path (@plugin_paths) { my @plugins = bsd_glob($plugin_path); @@ -7989,7 +7858,7 @@ if ($app->is_running) { { #show dialog and progress bar - if ( !$plugin_dialog->window + if ( !$plugin_dialog->get_window && !$plugin_dialog->{destroyed}) { $plugin_progress->show; @@ -8018,7 +7887,7 @@ if ($app->is_running) { #refresh the progressbar $plugin_progress->pulse; - $plugin_progress->set_text($plugins{$pkey}->{'binary'}); + $current_plugin->set_text($plugins{$pkey}->{'binary'}); #refresh gui fct_update_gui(); @@ -8040,7 +7909,7 @@ if ($app->is_running) { if ($shf->file_exists($plugins{$pkey}->{'binary'} . ".svg")); if ($shf->file_exists($plugins{$pkey}->{'pixbuf'})) { - $plugins{$pkey}->{'pixbuf_object'} = $lp->load($plugins{$pkey}->{'pixbuf'}, Gtk2::IconSize->lookup('menu')); + $plugins{$pkey}->{'pixbuf_object'} = $lp->load($plugins{$pkey}->{'pixbuf'}, $shf->icon_size('menu')); } else { $plugins{$pkey}->{'pixbuf'} = $fb_pixbuf_path; $plugins{$pkey}->{'pixbuf_object'} = $fb_pixbuf; @@ -8082,7 +7951,7 @@ if ($app->is_running) { sub fct_check_installed_upload_plugins { - my $upload_plugin_dialog = Gtk2::MessageDialog->new($window, [qw/modal destroy-with-parent/], 'info', 'close', $d->get("Updating upload plugin information")); + my $upload_plugin_dialog = Gtk3::MessageDialog->new($window, [qw/modal destroy-with-parent/], 'info', 'close', $d->get("Updating upload plugin information")); $upload_plugin_dialog->{destroyed} = FALSE; $upload_plugin_dialog->set_title("Shutter"); @@ -8093,13 +7962,16 @@ if ($app->is_running) { $upload_plugin_dialog->set_resizable(TRUE); - my $upload_plugin_progress = Gtk2::ProgressBar->new; + my $upload_plugin_progress = Gtk3::ProgressBar->new; $upload_plugin_progress->set_no_show_all(TRUE); $upload_plugin_progress->set_ellipsize('middle'); - $upload_plugin_progress->set_orientation('left-to-right'); + $upload_plugin_progress->set_orientation('horizontal'); $upload_plugin_progress->set_fraction(0); - $upload_plugin_dialog->vbox->add($upload_plugin_progress); + $upload_plugin_dialog->get_child->add($upload_plugin_progress); + my $current_plugin = Gtk3::Label->new(""); + $current_plugin->set_line_wrap(TRUE); + $upload_plugin_dialog->get_child->add($current_plugin); #plugins in user-home not supported yet FIXME my @upload_plugin_paths = ("$shutter_root/share/shutter/resources/system/upload_plugins/upload/*"); @@ -8127,7 +7999,7 @@ if ($app->is_running) { { #show dialog and progress bar - if ( !$upload_plugin_dialog->window + if ( !$upload_plugin_dialog->get_window && !$upload_plugin_dialog->{destroyed}) { $upload_plugin_progress->show; @@ -8174,7 +8046,7 @@ if ($app->is_running) { #refresh the progressbar $upload_plugin_progress->pulse; - $upload_plugin_progress->set_text($accounts{$name}->{path}); + $current_plugin->set_text($accounts{$name}->{path}); } else { print "\nERROR: upload-plugin exists but does not work properly - $folder$name\n"; @@ -8227,9 +8099,9 @@ if ($app->is_running) { sub fct_ret_workspace_menu { my $init = shift; - my $menu_wrksp = Gtk2::Menu->new; + my $menu_wrksp = Gtk3::Menu->new; - my $wnck_screen = Gnome2::Wnck::Screen->get_default; + my $wnck_screen = Wnck::Screen::get_default(); $wnck_screen->force_update(); #we determine the wm name but on older @@ -8239,7 +8111,8 @@ if ($app->is_running) { # #this leads to a known problem when switching #the wm => wm_name will still remain the old one - my $wm_name = Gtk2::Gdk::Screen->get_default->get_window_manager_name; + #but it doesn't work on gtk3 + my $wm_name; if ($wnck_screen->can('get_window_manager_name')) { $wm_name = $wnck_screen->get_window_manager_name; } @@ -8281,7 +8154,7 @@ if ($app->is_running) { print "shutter_wrksp_direct_compiz" . $vp[0] . "x" . $vp[1] . "\n" if $sc->get_debug; - my $vp_item = Gtk2::MenuItem->new_with_label(ucfirst $vp_name); + my $vp_item = Gtk3::MenuItem->new_with_label(ucfirst $vp_name); $vp_item->signal_connect( 'activate' => \&evt_take_screenshot, "shutter_wrksp_direct_compiz" . $vp[0] . "x" . $vp[1]); @@ -8298,7 +8171,7 @@ if ($app->is_running) { #we could add more of them here if needed } else { - my $wrkspace_item = Gtk2::MenuItem->new_with_label($space->get_name); + my $wrkspace_item = Gtk3::MenuItem->new_with_label($space->get_name); $wrkspace_item->signal_connect( 'activate' => \&evt_take_screenshot, "shutter_wrksp_direct" . $space->get_number @@ -8315,9 +8188,9 @@ if ($app->is_running) { } #entry for capturing all workspaces - $menu_wrksp->append(Gtk2::SeparatorMenuItem->new); + $menu_wrksp->append(Gtk3::SeparatorMenuItem->new); - my $allwspaces_item = Gtk2::MenuItem->new_with_label($d->get("Capture All Workspaces")); + my $allwspaces_item = Gtk3::MenuItem->new_with_label($d->get("Capture All Workspaces")); $allwspaces_item->signal_connect( 'activate' => \&evt_take_screenshot, "shutter_wrksp_direct" . 'all' @@ -8325,12 +8198,12 @@ if ($app->is_running) { $menu_wrksp->append($allwspaces_item); #monitor flag - my $n_mons = Gtk2::Gdk::Screen->get_default->get_n_monitors; + my $n_mons = Gtk3::Gdk::Screen::get_default->get_n_monitors; #use only current monitor - $menu_wrksp->append(Gtk2::SeparatorMenuItem->new); + $menu_wrksp->append(Gtk3::SeparatorMenuItem->new); if ($init) { - $current_monitor_active = Gtk2::CheckMenuItem->new_with_label($d->get("Limit to current monitor")); + $current_monitor_active = Gtk3::CheckMenuItem->new_with_label($d->get("Limit to current monitor")); if (defined $settings_xml->{'general'}->{'current_monitor_active'}) { $current_monitor_active->set_active($settings_xml->{'general'}->{'current_monitor_active'}); } else { @@ -8363,7 +8236,7 @@ if ($app->is_running) { sub fct_ret_window_menu { - my $menu_windows = Gtk2::Menu->new; + my $menu_windows = Gtk3::Menu->new; my $active_workspace = $wnck_screen->get_active_workspace; my $icontheme = $sc->get_theme; @@ -8371,15 +8244,14 @@ if ($app->is_running) { #add item for active window my $active_window_item_image; if ($icontheme->has_icon('preferences-system-windows')) { - $active_window_item_image = Gtk2::Image->new_from_icon_name('preferences-system-windows', 'menu'); + $active_window_item_image = Gtk3::Image->new_from_icon_name('preferences-system-windows', 'menu'); } else { - $active_window_item_image = Gtk2::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window_active.svg", Gtk2::IconSize->lookup('menu'))); + $active_window_item_image = Gtk3::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window_active.svg", $shf->icon_size('menu'))); } - my $active_window_item = Gtk2::ImageMenuItem->new_with_label($d->get("Active Window")); + my $active_window_item = Gtk3::ImageMenuItem->new_with_label($d->get("Active Window")); $active_window_item->set_image($active_window_item_image); - $active_window_item->set('always_show_image' => TRUE) - if Gtk2->CHECK_VERSION(2, 16, 0); + $active_window_item->set('always_show_image' => TRUE); $active_window_item->set_tooltip_text($d->get("Capture the last active window")); @@ -8389,24 +8261,23 @@ if ($app->is_running) { ); $menu_windows->append($active_window_item); - $menu_windows->append(Gtk2::SeparatorMenuItem->new); + $menu_windows->append(Gtk3::SeparatorMenuItem->new); #add all windows to menu to capture it directly - foreach my $win ($wnck_screen->get_windows_stacked) { + foreach my $win (@{$wnck_screen->get_windows_stacked}) { if ($active_workspace && $win->is_on_workspace($active_workspace)) { my $win_name = $win->get_name; Encode::_utf8_on($win_name); - my $window_item = Gtk2::ImageMenuItem->new_with_label($win_name); + my $window_item = Gtk3::ImageMenuItem->new_with_label($win_name); foreach my $child ($window_item->get_children) { - if ($child =~ /Gtk2::AccelLabel/) { + if ($child =~ /Gtk3::AccelLabel/) { $child->set_width_chars(50); $child->set_ellipsize('middle'); last; } } - $window_item->set_image(Gtk2::Image->new_from_pixbuf($win->get_mini_icon)); - $window_item->set('always_show_image' => TRUE) - if Gtk2->CHECK_VERSION(2, 16, 0); + $window_item->set_image(Gtk3::Image->new_from_pixbuf($win->get_mini_icon)); + $window_item->set('always_show_image' => TRUE); $window_item->signal_connect( 'activate' => \&evt_take_screenshot, "shutter_window_direct" . $win->get_xid @@ -8423,19 +8294,19 @@ if ($app->is_running) { my $traytheme = $sc->get_theme; - my $menu_tray = Gtk2::Menu->new(); + my $menu_tray = Gtk3::Menu->new(); #selection - my $menuitem_select = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Selection')); + my $menuitem_select = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Selection')); eval { - my $ccursor_pb = Gtk2::Gdk::Cursor->new('left_ptr')->get_image->scale_simple(Gtk2::IconSize->lookup('menu'), 'bilinear'); - $menuitem_select->set_image(Gtk2::Image->new_from_pixbuf($ccursor_pb)); + my $ccursor_pb = Gtk3::Gdk::Cursor::new('left_ptr')->get_image->scale_simple($shf->icon_size('menu'), 'bilinear'); + $menuitem_select->set_image(Gtk3::Image->new_from_pixbuf($ccursor_pb)); }; if ($@) { if ($traytheme->has_icon('applications-accessories')) { - $menuitem_select->set_image(Gtk2::Image->new_from_icon_name('applications-accessories', 'menu')); + $menuitem_select->set_image(Gtk3::Image->new_from_icon_name('applications-accessories', 'menu')); } else { - $menuitem_select->set_image(Gtk2::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/selection.svg", Gtk2::IconSize->lookup('menu')))); + $menuitem_select->set_image(Gtk3::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/selection.svg", $shf->icon_size('menu')))); } } $menuitem_select->signal_connect( @@ -8444,13 +8315,13 @@ if ($app->is_running) { ); #full screen - my $menuitem_full = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Desktop')); + my $menuitem_full = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Desktop')); if ($traytheme->has_icon('user-desktop')) { - $menuitem_full->set_image(Gtk2::Image->new_from_icon_name('user-desktop', 'menu')); + $menuitem_full->set_image(Gtk3::Image->new_from_icon_name('user-desktop', 'menu')); } elsif ($traytheme->has_icon('desktop')) { - $menuitem_full->set_image(Gtk2::Image->new_from_icon_name('desktop', 'menu')); + $menuitem_full->set_image(Gtk3::Image->new_from_icon_name('desktop', 'menu')); } else { - $menuitem_full->set_image(Gtk2::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/desktop.svg", Gtk2::IconSize->lookup('menu')))); + $menuitem_full->set_image(Gtk3::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/desktop.svg", $shf->icon_size('menu')))); } $menuitem_full->signal_connect( activate => \&evt_take_screenshot, @@ -8458,13 +8329,13 @@ if ($app->is_running) { ); #~ #awindow - #~ my $menuitem_awindow = Gtk2::ImageMenuItem->new_with_mnemonic( $d->get('_Active Window') ); + #~ my $menuitem_awindow = Gtk3::ImageMenuItem->new_with_mnemonic( $d->get('_Active Window') ); #~ if($traytheme->has_icon('preferences-system-windows')){ - #~ $menuitem_awindow->set_image( Gtk2::Image->new_from_icon_name( 'preferences-system-windows', 'menu' ) ); + #~ $menuitem_awindow->set_image( Gtk3::Image->new_from_icon_name( 'preferences-system-windows', 'menu' ) ); #~ }else{ #~ $menuitem_awindow->set_image( - #~ Gtk2::Image->new_from_pixbuf( - #~ $lp->load( "$shutter_root/share/shutter/resources/icons/sel_window_active.svg", Gtk2::IconSize->lookup('menu') ) + #~ Gtk3::Image->new_from_pixbuf( + #~ $lp->load( "$shutter_root/share/shutter/resources/icons/sel_window_active.svg", $shf->icon_size('menu') ) #~ ) #~ ); #~ } @@ -8474,11 +8345,11 @@ if ($app->is_running) { #~ ); #window - my $menuitem_window = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Window _under Cursor')); + my $menuitem_window = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Window _under Cursor')); if ($traytheme->has_icon('preferences-system-windows')) { - $menuitem_window->set_image(Gtk2::Image->new_from_icon_name('preferences-system-windows', 'menu')); + $menuitem_window->set_image(Gtk3::Image->new_from_icon_name('preferences-system-windows', 'menu')); } else { - $menuitem_window->set_image(Gtk2::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window.svg", Gtk2::IconSize->lookup('menu')))); + $menuitem_window->set_image(Gtk3::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window.svg", $shf->icon_size('menu')))); } $menuitem_window->signal_connect( activate => \&evt_take_screenshot, @@ -8486,21 +8357,21 @@ if ($app->is_running) { ); #window list - my $menuitem_window_list = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Select W_indow')); + my $menuitem_window_list = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Select W_indow')); if ($traytheme->has_icon('preferences-system-windows')) { - $menuitem_window_list->set_image(Gtk2::Image->new_from_icon_name('preferences-system-windows', 'menu')); + $menuitem_window_list->set_image(Gtk3::Image->new_from_icon_name('preferences-system-windows', 'menu')); } else { - $menuitem_window_list->set_image(Gtk2::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window.svg", Gtk2::IconSize->lookup('menu')))); + $menuitem_window_list->set_image(Gtk3::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window.svg", $shf->icon_size('menu')))); } $menuitem_window_list->set_name('windowlist'); - $menuitem_window_list->set_submenu(&fct_ret_window_menu); + $menuitem_window_list->set_submenu(fct_ret_window_menu()); #section - my $menuitem_window_sect = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Se_ction')); + my $menuitem_window_sect = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Se_ction')); if ($traytheme->has_icon('gdm-xnest')) { - $menuitem_window_sect->set_image(Gtk2::Image->new_from_icon_name('gdm-xnest', 'menu')); + $menuitem_window_sect->set_image(Gtk3::Image->new_from_icon_name('gdm-xnest', 'menu')); } else { - $menuitem_window_sect->set_image(Gtk2::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window_section.svg", Gtk2::IconSize->lookup('menu')))); + $menuitem_window_sect->set_image(Gtk3::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window_section.svg", $shf->icon_size('menu')))); } $menuitem_window_sect->signal_connect( activate => \&evt_take_screenshot, @@ -8508,11 +8379,11 @@ if ($app->is_running) { ); #menu - my $menuitem_window_menu = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Menu')); + my $menuitem_window_menu = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Menu')); if ($traytheme->has_icon('alacarte')) { - $menuitem_window_menu->set_image(Gtk2::Image->new_from_icon_name('alacarte', 'menu')); + $menuitem_window_menu->set_image(Gtk3::Image->new_from_icon_name('alacarte', 'menu')); } else { - $menuitem_window_menu->set_image(Gtk2::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window_menu.svg", Gtk2::IconSize->lookup('menu')))); + $menuitem_window_menu->set_image(Gtk3::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window_menu.svg", $shf->icon_size('menu')))); } $menuitem_window_menu->signal_connect( activate => \&evt_take_screenshot, @@ -8520,11 +8391,11 @@ if ($app->is_running) { ); #tooltip - my $menuitem_window_tooltip = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Tooltip')); + my $menuitem_window_tooltip = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Tooltip')); if ($traytheme->has_icon('help-faq')) { - $menuitem_window_tooltip->set_image(Gtk2::Image->new_from_icon_name('help-faq', 'menu')); + $menuitem_window_tooltip->set_image(Gtk3::Image->new_from_icon_name('help-faq', 'menu')); } else { - $menuitem_window_tooltip->set_image(Gtk2::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window_tooltip.svg", Gtk2::IconSize->lookup('menu')))); + $menuitem_window_tooltip->set_image(Gtk3::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/sel_window_tooltip.svg", $shf->icon_size('menu')))); } $menuitem_window_tooltip->signal_connect( activate => \&evt_take_screenshot, @@ -8532,12 +8403,12 @@ if ($app->is_running) { ); #web - my $menuitem_web = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Web')); + my $menuitem_web = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Web')); $menuitem_web->set_sensitive($gnome_web_photo); if ($traytheme->has_icon('web-browser')) { - $menuitem_web->set_image(Gtk2::Image->new_from_icon_name('web-browser', 'menu')); + $menuitem_web->set_image(Gtk3::Image->new_from_icon_name('web-browser', 'menu')); } else { - $menuitem_web->set_image(Gtk2::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/web_image.svg", Gtk2::IconSize->lookup('menu')))); + $menuitem_web->set_image(Gtk3::Image->new_from_pixbuf($lp->load("$shutter_root/share/shutter/resources/icons/web_image.svg", $shf->icon_size('menu')))); } $menuitem_web->signal_connect( activate => \&evt_take_screenshot, @@ -8545,47 +8416,47 @@ if ($app->is_running) { ); #show main window - my $menuitem_show_window = Gtk2::MenuItem->new_with_mnemonic($d->get('S_how main window')); + my $menuitem_show_window = Gtk3::MenuItem->new_with_mnemonic($d->get('S_how main window')); $menuitem_show_window->signal_connect('activate', sub { $is_hidden = TRUE; fct_control_main_window('show'); }); $menuitem_show_window->set_name('show_window'); $menuitem_show_window->set_sensitive(TRUE); #redo last screenshot - my $menuitem_redoshot = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Redo last screenshot')); - $menuitem_redoshot->set_image(Gtk2::Image->new_from_stock('gtk-refresh', 'menu')); + my $menuitem_redoshot = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Redo last screenshot')); + $menuitem_redoshot->set_image(Gtk3::Image->new_from_stock('gtk-refresh', 'menu')); $menuitem_redoshot->signal_connect('activate', \&evt_take_screenshot, 'redoshot'); $menuitem_redoshot->set_name('redoshot'); $menuitem_redoshot->set_sensitive(FALSE); #preferences - my $menuitem_settings = Gtk2::ImageMenuItem->new_from_stock('gtk-preferences'); + my $menuitem_settings = Gtk3::ImageMenuItem->new_from_stock('gtk-preferences'); $menuitem_settings->signal_connect("activate", \&evt_show_settings); #quick profile selector - my $menuitem_quicks = Gtk2::MenuItem->new_with_mnemonic($d->get('_Quick profile select')); + my $menuitem_quicks = Gtk3::MenuItem->new_with_mnemonic($d->get('_Quick profile select')); #set name to identify the item later - we use this in really rare cases $menuitem_quicks->set_name('quicks'); $menuitem_quicks->set_sensitive(FALSE); #info - my $menuitem_info = Gtk2::ImageMenuItem->new_from_stock('gtk-about'); + my $menuitem_info = Gtk3::ImageMenuItem->new_from_stock('gtk-about'); $menuitem_info->signal_connect("activate", \&evt_about); #quit - my $menuitem_quit = Gtk2::ImageMenuItem->new_from_stock('gtk-quit'); + my $menuitem_quit = Gtk3::ImageMenuItem->new_from_stock('gtk-quit'); $menuitem_quit->signal_connect("activate", \&evt_delete_window, 'quit'); $menu_tray->append($menuitem_show_window); - $menu_tray->append(Gtk2::SeparatorMenuItem->new); + $menu_tray->append(Gtk3::SeparatorMenuItem->new); $menu_tray->append($menuitem_redoshot); - $menu_tray->append(Gtk2::SeparatorMenuItem->new); + $menu_tray->append(Gtk3::SeparatorMenuItem->new); $menu_tray->append($menuitem_select); - #~ $menu_tray->append( Gtk2::SeparatorMenuItem->new ); + #~ $menu_tray->append( Gtk3::SeparatorMenuItem->new ); $menu_tray->append($menuitem_full); - #~ $menu_tray->append( Gtk2::SeparatorMenuItem->new ); + #~ $menu_tray->append( Gtk3::SeparatorMenuItem->new ); #~ $menu_tray->append($menuitem_awindow); $menu_tray->append($menuitem_window); $menu_tray->append($menuitem_window_list); @@ -8593,12 +8464,12 @@ if ($app->is_running) { $menu_tray->append($menuitem_window_menu); $menu_tray->append($menuitem_window_tooltip); - #~ $menu_tray->append( Gtk2::SeparatorMenuItem->new ); + #~ $menu_tray->append( Gtk3::SeparatorMenuItem->new ); $menu_tray->append($menuitem_web); - $menu_tray->append(Gtk2::SeparatorMenuItem->new); + $menu_tray->append(Gtk3::SeparatorMenuItem->new); $menu_tray->append($menuitem_settings); $menu_tray->append($menuitem_quicks); - $menu_tray->append(Gtk2::SeparatorMenuItem->new); + $menu_tray->append(Gtk3::SeparatorMenuItem->new); $menu_tray->append($menuitem_info); $menu_tray->append($menuitem_quit); $menu_tray->show_all; @@ -8609,7 +8480,7 @@ if ($app->is_running) { sub fct_ret_program_menu { my $menu_programs = shift; - $menu_programs = Gtk2::Menu->new unless defined $menu_programs; + $menu_programs = Gtk3::Menu->new unless defined $menu_programs; foreach my $child ($menu_programs->get_children) { $child->destroy; } @@ -8680,15 +8551,14 @@ if ($app->is_running) { #I think so ;-) # $app->{'id'} =~ s/^(kde4|kde)-//g; - my $program_item = Gtk2::ImageMenuItem->new_with_label($app->get_display_name); - $program_item->set('always_show_image' => TRUE) - if Gtk2->CHECK_VERSION(2, 16, 0); + my $program_item = Gtk3::ImageMenuItem->new_with_label($app->get_display_name); + $program_item->set('always_show_image' => TRUE); $menu_programs->append($program_item); my $icon = $app->get_icon; if ($icon && $program_item) { my $icon_pixbuf = undef; - my ($iw, $ih) = Gtk2::IconSize->lookup('menu'); + my ($iw, $ih) = $shf->icon_size('menu'); eval { my $icon_info = $sc->get_theme->choose_icon($icon->get_names, $ih, []); $icon_pixbuf = $icon_info->load_icon if $icon_info; @@ -8698,7 +8568,7 @@ if ($app->is_running) { $icon_pixbuf = undef; } if ($icon_pixbuf) { - $program_item->set_image(Gtk2::Image->new_from_pixbuf($icon_pixbuf)); + $program_item->set_image(Gtk3::Image->new_from_pixbuf($icon_pixbuf)); } } @@ -8723,13 +8593,13 @@ if ($app->is_running) { sub fct_ret_web_menu { - my $menu_web = Gtk2::Menu->new; + my $menu_web = Gtk3::Menu->new; - my $timeout0 = Gtk2::RadioMenuItem->new(undef, $d->get("Wait indefinitely")); - my $timeout1 = Gtk2::RadioMenuItem->new($timeout0, sprintf($d->nget("Wait max %d second", "Wait max %d seconds", 10), 10)); - my $timeout2 = Gtk2::RadioMenuItem->new($timeout0, sprintf($d->nget("Wait max %d second", "Wait max %d seconds", 10), 30)); - my $timeout3 = Gtk2::RadioMenuItem->new($timeout0, sprintf($d->nget("Wait max %d minute", "Wait max %d minutes", 1), 1)); - my $timeout4 = Gtk2::RadioMenuItem->new($timeout0, sprintf($d->nget("Wait max %d minute", "Wait max %d minutes", 2), 2)); + my $timeout0 = Gtk3::RadioMenuItem->new(undef, $d->get("Wait indefinitely")); + my $timeout1 = Gtk3::RadioMenuItem->new($timeout0, sprintf($d->nget("Wait max %d second", "Wait max %d seconds", 10), 10)); + my $timeout2 = Gtk3::RadioMenuItem->new($timeout0, sprintf($d->nget("Wait max %d second", "Wait max %d seconds", 10), 30)); + my $timeout3 = Gtk3::RadioMenuItem->new($timeout0, sprintf($d->nget("Wait max %d minute", "Wait max %d minutes", 1), 1)); + my $timeout4 = Gtk3::RadioMenuItem->new($timeout0, sprintf($d->nget("Wait max %d minute", "Wait max %d minutes", 2), 2)); $timeout0->set_name("timeout0"); $timeout1->set_name("timeout10"); @@ -8805,7 +8675,7 @@ if ($app->is_running) { my $current_profiles_ref = shift; my $menu_profile = shift; - $menu_profile = Gtk2::Menu->new unless defined $menu_profile; + $menu_profile = Gtk3::Menu->new unless defined $menu_profile; foreach my $child ($menu_profile->get_children) { $child->destroy; } @@ -8813,7 +8683,7 @@ if ($app->is_running) { my $group = undef; my $counter = 0; foreach my $profile (@{$current_profiles_ref}) { - my $profile_item = Gtk2::RadioMenuItem->new($group, $profile); + my $profile_item = Gtk3::RadioMenuItem::new($group, $profile); $profile_item->set_active(TRUE) if $profile eq $combobox_settings_profiles->get_active_text; $profile_item->signal_connect( @@ -8841,7 +8711,7 @@ if ($app->is_running) { sub fct_load_accounts_tree { - $accounts_model = Gtk2::ListStore->new( + $accounts_model = Gtk3::ListStore->new( 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::Boolean', 'Glib::Boolean', 'Glib::Boolean' ); @@ -8865,7 +8735,7 @@ if ($app->is_running) { sub fct_load_plugin_tree { - my $effects_model = Gtk2::ListStore->new('Gtk2::Gdk::Pixbuf', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String',); + my $effects_model = Gtk3::ListStore->new('Gtk3::Gdk::Pixbuf', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String',); foreach my $pkey (sort keys %plugins) { if ($plugins{$pkey}->{'binary'}) { @@ -8883,10 +8753,10 @@ if ($app->is_running) { if ($shf->file_exists($plugins{$pkey}->{'binary'} . ".svg")); if ($shf->file_exists($plugins{$pkey}->{'pixbuf'})) { - $plugins{$pkey}->{'pixbuf_object'} = $lp->load($plugins{$pkey}->{'pixbuf'}, Gtk2::IconSize->lookup('menu')); + $plugins{$pkey}->{'pixbuf_object'} = $lp->load($plugins{$pkey}->{'pixbuf'}, $shf->icon_size('menu')); } else { $plugins{$pkey}->{'pixbuf'} = "$shutter_root/share/shutter/resources/icons/executable.svg"; - $plugins{$pkey}->{'pixbuf_object'} = $lp->load($plugins{$pkey}->{'pixbuf'}, Gtk2::IconSize->lookup('menu')); + $plugins{$pkey}->{'pixbuf_object'} = $lp->load($plugins{$pkey}->{'pixbuf'}, $shf->icon_size('menu')); } } @@ -8911,22 +8781,21 @@ if ($app->is_running) { $accounts_tree->remove_column($col); } - $accounts_tree->set_tooltip_column(9) - if Gtk2->CHECK_VERSION(2, 11, 0); + $accounts_tree->set_tooltip_column(9); #name - my $tv_clmn_name_text = Gtk2::TreeViewColumn->new; + my $tv_clmn_name_text = Gtk3::TreeViewColumn->new; $tv_clmn_name_text->set_title($d->get("Host")); - my $renderer_name_accounts = Gtk2::CellRendererText->new; + my $renderer_name_accounts = Gtk3::CellRendererText->new; $tv_clmn_name_text->pack_start($renderer_name_accounts, FALSE); $tv_clmn_name_text->set_attributes($renderer_name_accounts, text => 6); $accounts_tree->append_column($tv_clmn_name_text); #username - my $tv_clmn_username_text = Gtk2::TreeViewColumn->new; + my $tv_clmn_username_text = Gtk3::TreeViewColumn->new; $tv_clmn_username_text->set_max_width(100); $tv_clmn_username_text->set_title($d->get("Username")); - my $renderer_username_accounts = Gtk2::CellRendererText->new; + my $renderer_username_accounts = Gtk3::CellRendererText->new; $tv_clmn_username_text->pack_start($renderer_username_accounts, FALSE); $tv_clmn_username_text->set_attributes( $renderer_username_accounts, @@ -8937,7 +8806,7 @@ if ($app->is_running) { $renderer_username_accounts->signal_connect( 'edited' => sub { my ($cell, $text_path, $new_text, $model) = @_; - my $path = Gtk2::TreePath->new_from_string($text_path); + my $path = Gtk3::TreePath->new_from_string($text_path); my $iter = $model->get_iter($path); #save entered username to the hash @@ -8951,10 +8820,10 @@ if ($app->is_running) { $accounts_tree->append_column($tv_clmn_username_text); #password - my $tv_clmn_password_text = Gtk2::TreeViewColumn->new; + my $tv_clmn_password_text = Gtk3::TreeViewColumn->new; $tv_clmn_password_text->set_max_width(100); $tv_clmn_password_text->set_title($d->get("Password")); - my $renderer_password_accounts = Gtk2::CellRendererText->new; + my $renderer_password_accounts = Gtk3::CellRendererText->new; $tv_clmn_password_text->pack_start($renderer_password_accounts, FALSE); $tv_clmn_password_text->set_attributes( $renderer_password_accounts, @@ -8965,7 +8834,7 @@ if ($app->is_running) { $renderer_password_accounts->signal_connect( 'edited' => sub { my ($cell, $text_path, $new_text, $model) = @_; - my $path = Gtk2::TreePath->new_from_string($text_path); + my $path = Gtk3::TreePath->new_from_string($text_path); my $iter = $model->get_iter($path); my $hidden_text = ""; @@ -8982,43 +8851,41 @@ if ($app->is_running) { $accounts_tree->append_column($tv_clmn_password_text); #upload features - my $tv_clmn_f1_toggle = Gtk2::TreeViewColumn->new; + my $tv_clmn_f1_toggle = Gtk3::TreeViewColumn->new; $tv_clmn_f1_toggle->set_title($d->get("Anonymous Upload")); - my $f1_toggle = Gtk2::CellRendererToggle->new(); + my $f1_toggle = Gtk3::CellRendererToggle->new(); $tv_clmn_f1_toggle->pack_start($f1_toggle, FALSE); $tv_clmn_f1_toggle->set_attributes($f1_toggle, active => 10); $accounts_tree->append_column($tv_clmn_f1_toggle); - my $tv_clmn_f2_toggle = Gtk2::TreeViewColumn->new; + my $tv_clmn_f2_toggle = Gtk3::TreeViewColumn->new; $tv_clmn_f2_toggle->set_title($d->get("Authorized Upload")); - my $f2_toggle = Gtk2::CellRendererToggle->new(); + my $f2_toggle = Gtk3::CellRendererToggle->new(); $tv_clmn_f2_toggle->pack_start($f2_toggle, FALSE); $tv_clmn_f2_toggle->set_attributes($f2_toggle, active => 11); $accounts_tree->append_column($tv_clmn_f2_toggle); - my $tv_clmn_f3_toggle = Gtk2::TreeViewColumn->new; + my $tv_clmn_f3_toggle = Gtk3::TreeViewColumn->new; $tv_clmn_f3_toggle->set_title($d->get("OAuth Upload")); - my $f3_toggle = Gtk2::CellRendererToggle->new(); + my $f3_toggle = Gtk3::CellRendererToggle->new(); $tv_clmn_f3_toggle->pack_start($f3_toggle, FALSE); $tv_clmn_f3_toggle->set_attributes($f3_toggle, active => 12); $accounts_tree->append_column($tv_clmn_f3_toggle); #description #tooltip column (show as columns when needed) - unless (Gtk2->CHECK_VERSION(2, 12, 0)) { - my $tv_clmn_descr_text = Gtk2::TreeViewColumn->new; - $tv_clmn_descr_text->set_resizable(TRUE); - $tv_clmn_descr_text->set_title($d->get("Description")); - my $renderer_descr_effects = Gtk2::CellRendererText->new; - $tv_clmn_descr_text->pack_start($renderer_descr_effects, FALSE); - $tv_clmn_descr_text->set_attributes($renderer_descr_effects, text => 9); - $accounts_tree->append_column($tv_clmn_descr_text); - } + my $tv_clmn_descr_text = Gtk3::TreeViewColumn->new; + $tv_clmn_descr_text->set_resizable(TRUE); + $tv_clmn_descr_text->set_title($d->get("Description")); + my $renderer_descr_effects = Gtk3::CellRendererText->new; + $tv_clmn_descr_text->pack_start($renderer_descr_effects, FALSE); + $tv_clmn_descr_text->set_attributes($renderer_descr_effects, text => 9); + $accounts_tree->append_column($tv_clmn_descr_text); #register - my $tv_clmn_pix_text = Gtk2::TreeViewColumn->new; + my $tv_clmn_pix_text = Gtk3::TreeViewColumn->new; $tv_clmn_pix_text->set_title($d->get("Register")); - my $ren_text = Gtk2::CellRendererText->new(); + my $ren_text = Gtk3::CellRendererText->new(); $tv_clmn_pix_text->pack_start($ren_text, FALSE); $tv_clmn_pix_text->set_attributes($ren_text, 'text', 5, 'foreground', 4); $accounts_tree->append_column($tv_clmn_pix_text); @@ -9035,61 +8902,57 @@ if ($app->is_running) { #~ } #tooltip - $effects_tree->set_tooltip_column(3) - if Gtk2->CHECK_VERSION(2, 11, 0); + $effects_tree->set_tooltip_column(3); - my $tv_clmn_pix_text = Gtk2::TreeViewColumn->new; + my $tv_clmn_pix_text = Gtk3::TreeViewColumn->new; $tv_clmn_pix_text->set_resizable(TRUE); $tv_clmn_pix_text->set_title($d->get("Icon")); - my $renderer_pix_effects = Gtk2::CellRendererPixbuf->new; + my $renderer_pix_effects = Gtk3::CellRendererPixbuf->new; $tv_clmn_pix_text->pack_start($renderer_pix_effects, FALSE); $tv_clmn_pix_text->set_attributes($renderer_pix_effects, pixbuf => 0); $effects_tree->append_column($tv_clmn_pix_text); #name - my $tv_clmn_text_text = Gtk2::TreeViewColumn->new; + my $tv_clmn_text_text = Gtk3::TreeViewColumn->new; $tv_clmn_text_text->set_resizable(TRUE); $tv_clmn_text_text->set_title($d->get("Name")); - my $renderer_text_effects = Gtk2::CellRendererText->new; + my $renderer_text_effects = Gtk3::CellRendererText->new; $tv_clmn_text_text->pack_start($renderer_text_effects, FALSE); $tv_clmn_text_text->set_attributes($renderer_text_effects, text => 1); $effects_tree->append_column($tv_clmn_text_text); #category - my $tv_clmn_category_text = Gtk2::TreeViewColumn->new; + my $tv_clmn_category_text = Gtk3::TreeViewColumn->new; $tv_clmn_category_text->set_resizable(TRUE); $tv_clmn_category_text->set_title($d->get("Category")); - my $renderer_category_effects = Gtk2::CellRendererText->new; + my $renderer_category_effects = Gtk3::CellRendererText->new; $tv_clmn_category_text->pack_start($renderer_category_effects, FALSE); $tv_clmn_category_text->set_attributes($renderer_category_effects, text => 2); $effects_tree->append_column($tv_clmn_category_text); - #tooltip column - unless (Gtk2->CHECK_VERSION(2, 12, 0)) { - my $tv_clmn_descr_text = Gtk2::TreeViewColumn->new; - $tv_clmn_descr_text->set_resizable(TRUE); - $tv_clmn_descr_text->set_title($d->get("Description")); - my $renderer_descr_effects = Gtk2::CellRendererText->new; - $tv_clmn_descr_text->pack_start($renderer_descr_effects, FALSE); - $tv_clmn_descr_text->set_attributes($renderer_descr_effects, text => 3); - $effects_tree->append_column($tv_clmn_descr_text); - } + my $tv_clmn_descr_text = Gtk3::TreeViewColumn->new; + $tv_clmn_descr_text->set_resizable(TRUE); + $tv_clmn_descr_text->set_title($d->get("Description")); + my $renderer_descr_effects = Gtk3::CellRendererText->new; + $tv_clmn_descr_text->pack_start($renderer_descr_effects, FALSE); + $tv_clmn_descr_text->set_attributes($renderer_descr_effects, text => 3); + $effects_tree->append_column($tv_clmn_descr_text); #language - my $tv_clmn_lang_text = Gtk2::TreeViewColumn->new; + my $tv_clmn_lang_text = Gtk3::TreeViewColumn->new; $tv_clmn_lang_text->set_resizable(TRUE); $tv_clmn_lang_text->set_title($d->get("Language")); - my $renderer_lang_effects = Gtk2::CellRendererText->new; + my $renderer_lang_effects = Gtk3::CellRendererText->new; $tv_clmn_lang_text->pack_start($renderer_lang_effects, FALSE); $tv_clmn_lang_text->set_attributes($renderer_lang_effects, text => 4); $effects_tree->append_column($tv_clmn_lang_text); #path - my $tv_clmn_path_text = Gtk2::TreeViewColumn->new; + my $tv_clmn_path_text = Gtk3::TreeViewColumn->new; $tv_clmn_path_text->set_resizable(TRUE); $tv_clmn_path_text->set_title($d->get("Path")); - my $renderer_path_effects = Gtk2::CellRendererText->new; + my $renderer_path_effects = Gtk3::CellRendererText->new; $tv_clmn_path_text->pack_start($renderer_path_effects, FALSE); $tv_clmn_path_text->set_attributes($renderer_path_effects, text => 5); $effects_tree->append_column($tv_clmn_path_text); @@ -9116,7 +8979,7 @@ if ($app->is_running) { } #goocanvas - eval { require Goo::Canvas }; + eval { require GooCanvas2; require GooCanvas2::CairoTypes; }; if ($@) { warn "WARNING: Goo::Canvas/libgoo-canvas-perl is missing --> drawing tool will be disabled!\n\n"; $goocanvas = FALSE; @@ -9129,10 +8992,16 @@ if ($app->is_running) { $exiftool = FALSE; } - #libgtk2-appindicator-perl - eval { require Gtk2::AppIndicator }; - if ($@) { - warn "WARNING: Gtk2::AppIndicator is missing --> there will be no icon showing up in the status bar when running Unity!\n\n"; + #dev-libs/libappindicator[introspection] + eval { + Glib::Object::Introspection->setup( + basename => 'AppIndicator3', + version => '0.1', + package => 'AppIndicator', + ); + } if 0; + if (0 && $@) { + warn "WARNING: AppIndicator is missing --> there will be no icon showing up in the status bar when running Unity!\n\n"; $appindicator = FALSE; } @@ -9244,14 +9113,14 @@ if ($app->is_running) { } printf "Glib %s \n", $Glib::VERSION; - printf "Gtk2 %s \n", $Gtk2::VERSION; + printf "Gtk3 %s \n", $Gtk3::VERSION; print "\n"; # The version info stuff appeared in 1.040. - print "Glib built for " . join(".", Glib->GET_VERSION_INFO) . ", running with " . join(".", &Glib::major_version, &Glib::minor_version, &Glib::micro_version) . "\n" + print "Glib built for " . join(".", Glib->GET_VERSION_INFO) . ", running with " . join(".", Glib::major_version(), Glib::minor_version(), Glib::micro_version()) . "\n" if $Glib::VERSION >= 1.040; - print "Gtk2 built for " . join(".", Gtk2->GET_VERSION_INFO) . ", running with " . join(".", &Gtk2::major_version, &Gtk2::minor_version, &Gtk2::micro_version) . "\n" - if $Gtk2::VERSION >= 1.040; + print "Gtk3 built for " . join(".", Gtk3->GET_VERSION_INFO) . ", running with " . join(".", Gtk3::major_version(), Gtk3::minor_version(), Gtk3::micro_version()) . "\n" + if $Gtk3::VERSION >= 1.040; print "\n"; return TRUE; @@ -9267,29 +9136,29 @@ if ($app->is_running) { foreach my $key (@file_to_rename_keys) { - my $input_dialog = Gtk2::MessageDialog->new($window, [qw/modal destroy-with-parent/], 'other', 'none', undef); + my $input_dialog = Gtk3::MessageDialog->new($window, [qw/modal destroy-with-parent/], 'other', 'none', undef); $input_dialog->set_title($d->get("Rename")); - $input_dialog->set('image' => Gtk2::Image->new_from_stock('gtk-save-as', 'dialog')); + $input_dialog->set('image' => Gtk3::Image->new_from_stock('gtk-save-as', 'dialog')); $input_dialog->set('text' => sprintf($d->get("Rename image %s"), "'$session_screens{$key}->{'short'}'")); $input_dialog->set('secondary-text' => $d->get("New filename") . ": "); #rename button - my $rename_btn = Gtk2::Button->new_with_mnemonic($d->get("_Rename")); - $rename_btn->set_image(Gtk2::Image->new_from_stock('gtk-save-as', 'button')); - $rename_btn->can_default(TRUE); + my $rename_btn = Gtk3::Button->new_with_mnemonic($d->get("_Rename")); + $rename_btn->set_image(Gtk3::Image->new_from_stock('gtk-save-as', 'button')); + $rename_btn->set_can_default(TRUE); $input_dialog->add_button('gtk-cancel', 'reject'); $input_dialog->add_action_widget($rename_btn, 'accept'); $input_dialog->set_default_response('accept'); - my $new_filename_vbox = Gtk2::VBox->new(); - my $new_filename_hint = Gtk2::Label->new(); - my $new_filename = Gtk2::Entry->new(); + my $new_filename_vbox = Gtk3::VBox->new(); + my $new_filename_hint = Gtk3::Label->new(); + my $new_filename = Gtk3::Entry->new(); $new_filename->set_activates_default(TRUE); #here are all invalid char codes @@ -9299,7 +9168,7 @@ if ($app->is_running) { my $new_filename = shift; my $event = shift; - my $input = Gtk2::Gdk->keyval_to_unicode($event->keyval); + my $input = Gtk3::Gdk::keyval_to_unicode($event->keyval); #invalid input #~ print $input."\n"; @@ -9346,9 +9215,9 @@ if ($app->is_running) { $rename_btn->set_sensitive(FALSE); } - $new_filename_vbox->pack_start_defaults($new_filename); - $new_filename_vbox->pack_start_defaults($new_filename_hint); - $input_dialog->vbox->add($new_filename_vbox); + $new_filename_vbox->pack_start($new_filename, TRUE, TRUE, 0); + $new_filename_vbox->pack_start($new_filename_hint, TRUE, TRUE, 0); + $input_dialog->get_child->add($new_filename_vbox); $input_dialog->show_all; #run dialog @@ -9403,8 +9272,8 @@ if ($app->is_running) { #ask the user to replace the image #replace button - my $replace_btn = Gtk2::Button->new_with_mnemonic($d->get("_Replace")); - $replace_btn->set_image(Gtk2::Image->new_from_stock('gtk-save-as', 'button')); + my $replace_btn = Gtk3::Button->new_with_mnemonic($d->get("_Replace")); + $replace_btn->set_image(Gtk3::Image->new_from_stock('gtk-save-as', 'button')); my $sd = Shutter::App::SimpleDialogs->new; @@ -9499,8 +9368,8 @@ if ($app->is_running) { #maybe we open a recently opened file that is #selected via menu my @new_files; - unless ($widget =~ /Gtk2::RecentChooserMenu/) { - my $fs = Gtk2::FileChooserDialog->new( + unless ($widget =~ /Gtk3::RecentChooserMenu/) { + my $fs = Gtk3::FileChooserDialog->new( $d->get("Choose file to open"), $window, 'open', 'gtk-cancel' => 'reject', @@ -9509,7 +9378,7 @@ if ($app->is_running) { $fs->set_select_multiple(TRUE); #preview widget - my $iprev = Gtk2::Image->new; + my $iprev = Gtk3::Image->new; $fs->set_preview_widget($iprev); $fs->signal_connect( @@ -9529,17 +9398,17 @@ if ($app->is_running) { } }); - my $filter_all = Gtk2::FileFilter->new; + my $filter_all = Gtk3::FileFilter->new; $filter_all->set_name($d->get("All compatible image formats")); $fs->add_filter($filter_all); - foreach my $format (Gtk2::Gdk::Pixbuf->get_formats) { - my $filter = Gtk2::FileFilter->new; + foreach my $format (Gtk3::Gdk::Pixbuf::get_formats()) { + my $filter = Gtk3::FileFilter->new; #add all known formats to the dialog - $filter->set_name($format->{name} . " - " . $format->{description}); + $filter->set_name($format->get_name . " - " . $format->get_description); - foreach my $ext (@{$format->{extensions}}) { + foreach my $ext (@{$format->get_extensions}) { $filter->add_pattern("*." . uc $ext); $filter_all->add_pattern("*." . uc $ext); $filter->add_pattern("*." . $ext); @@ -9608,7 +9477,7 @@ if ($app->is_running) { $rfilename = $session_screens{$key}->{'long'} if $key; - my $fs = Gtk2::FileChooserDialog->new( + my $fs = Gtk3::FileChooserDialog->new( $d->get("Choose a location to save to"), $window, 'save', 'gtk-cancel' => 'reject', @@ -9634,7 +9503,7 @@ if ($app->is_running) { } #preview widget - my $iprev = Gtk2::Image->new; + my $iprev = Gtk3::Image->new; $fs->set_preview_widget($iprev); $fs->signal_connect( @@ -9660,11 +9529,11 @@ if ($app->is_running) { $fs->set_current_name($short . "." . $rfiletype); } - my $extra_hbox = Gtk2::HBox->new; + my $extra_hbox = Gtk3::HBox->new; - my $label_save_as_type = Gtk2::Label->new($d->get("Image format") . ":"); + my $label_save_as_type = Gtk3::Label->new($d->get("Image format") . ":"); - my $combobox_save_as_type = Gtk2::ComboBox->new_text; + my $combobox_save_as_type = Gtk3::ComboBoxText->new; #add supported formats to combobox my $counter = 0; @@ -9684,24 +9553,24 @@ if ($app->is_running) { #images } else { - foreach my $format (Gtk2::Gdk::Pixbuf->get_formats) { + foreach my $format (Gtk3::Gdk::Pixbuf::get_formats()) { #we don't want svg here - this is a dedicated action in the DrawingTool - next if !defined $rfiletype && $format->{name} =~ /svg/; + next if !defined $rfiletype && $format->get_name =~ /svg/; #we have a requested filetype - nothing else will be offered - next if defined $rfiletype && $format->{name} ne $rfiletype; + next if defined $rfiletype && $format->get_name ne $rfiletype; #we want jpg not jpeg - if ($format->{name} eq "jpeg" || $format->{name} eq "jpg") { - $combobox_save_as_type->insert_text($counter, "jpg" . " - " . $format->{description}); + if ($format->get_name eq "jpeg" || $format->get_name eq "jpg") { + $combobox_save_as_type->insert_text($counter, "jpg" . " - " . $format->get_description); } else { - $combobox_save_as_type->insert_text($counter, $format->{name} . " - " . $format->{description}); + $combobox_save_as_type->insert_text($counter, $format->get_name . " - " . $format->get_description); } #set active when mime_type is matching #loop because multiple mime types are registered for fome file formats - foreach my $mime (@{$format->{mime_types}}) { + foreach my $mime (@{$format->get_mime_types}) { if (defined $key) { if ($mime eq $session_screens{$key}->{'mime_type'} @@ -9745,11 +9614,11 @@ if ($app->is_running) { $combobox_save_as_type->signal_connect( 'changed' => sub { - my $filename = $fs->get_filename; + my $filename = $shf->utf8_decode($fs->get_filename); my $choosen_format = $combobox_save_as_type->get_active_text; $choosen_format =~ s/ \-.*//; #get png or jpeg (jpg) for example - #~ print $choosen_format . "\n"; + #~ print $choosen_format . "\n"; #parse filename my ($short, $folder, $ext) = fileparse($filename, qr/\.[^.]*/); @@ -9763,7 +9632,7 @@ if ($app->is_running) { $extra_hbox->pack_start($label_save_as_type, FALSE, FALSE, 5); $extra_hbox->pack_start($combobox_save_as_type, FALSE, FALSE, 5); - my $align_save_as_type = Gtk2::Alignment->new(1, 0, 0, 0); + my $align_save_as_type = Gtk3::Alignment->new(1, 0, 0, 0); $align_save_as_type->add($extra_hbox); $align_save_as_type->show_all; @@ -9773,7 +9642,7 @@ if ($app->is_running) { my $fs_resp = $fs->run; if ($fs_resp eq "accept") { - my $filename = $fs->get_filename; + my $filename = $shf->utf8_decode($fs->get_filename); #parse filename my ($short, $folder, $ext) = fileparse($filename, qr/\.[^.]*/); @@ -9844,8 +9713,8 @@ if ($app->is_running) { #ask the user to replace the image #replace button - my $replace_btn = Gtk2::Button->new_with_mnemonic($d->get("_Replace")); - $replace_btn->set_image(Gtk2::Image->new_from_stock('gtk-save-as', 'button')); + my $replace_btn = Gtk3::Button->new_with_mnemonic($d->get("_Replace")); + $replace_btn->set_image(Gtk3::Image->new_from_stock('gtk-save-as', 'button')); my $response = $sd->dlg_warning_message( sprintf($d->get("The image already exists in %s. Replacing it will overwrite its contents."), "'" . $folder . "'"), @@ -9940,21 +9809,21 @@ if ($app->is_running) { sub dlg_plugin { my (@file_to_plugin_keys) = @_; - my $plugin_dialog = Gtk2::Dialog->new($d->get("Choose a plugin"), $window, [qw/modal destroy-with-parent/]); + my $plugin_dialog = Gtk3::Dialog->new($d->get("Choose a plugin"), $window, [qw/modal destroy-with-parent/]); $plugin_dialog->set_size_request(350, -1); $plugin_dialog->set_resizable(FALSE); #rename button - my $run_btn = Gtk2::Button->new_with_mnemonic($d->get("_Run")); - $run_btn->set_image(Gtk2::Image->new_from_stock('gtk-execute', 'button')); - $run_btn->can_default(TRUE); + my $run_btn = Gtk3::Button->new_with_mnemonic($d->get("_Run")); + $run_btn->set_image(Gtk3::Image->new_from_stock('gtk-execute', 'button')); + $run_btn->set_can_default(TRUE); $plugin_dialog->add_button('gtk-cancel', 'reject'); $plugin_dialog->add_action_widget($run_btn, 'accept'); $plugin_dialog->set_default_response('accept'); - my $model = Gtk2::ListStore->new('Gtk2::Gdk::Pixbuf', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String'); + my $model = Gtk3::ListStore->new('Gtk3::Gdk::Pixbuf', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String'); #temp variables to restore the #recent plugin @@ -9996,32 +9865,32 @@ if ($app->is_running) { } - my $plugin_label = Gtk2::Label->new($d->get("Plugin") . ":"); - my $plugin = Gtk2::ComboBox->new($model); + my $plugin_label = Gtk3::Label->new($d->get("Plugin") . ":"); + my $plugin = Gtk3::ComboBox->new_with_model($model); #plugin description - my $plugin_descr = Gtk2::TextBuffer->new; - my $plugin_descr_view = Gtk2::TextView->new_with_buffer($plugin_descr); + my $plugin_descr = Gtk3::TextBuffer->new; + my $plugin_descr_view = Gtk3::TextView->new_with_buffer($plugin_descr); $plugin_descr_view->set_sensitive(FALSE); $plugin_descr_view->set_wrap_mode('word'); - my $textview_hbox = Gtk2::HBox->new(FALSE, 5); + my $textview_hbox = Gtk3::HBox->new(FALSE, 5); $textview_hbox->set_border_width(8); - $textview_hbox->pack_start_defaults($plugin_descr_view); + $textview_hbox->pack_start($plugin_descr_view, TRUE, TRUE, 0); - my $plugin_descr_label = Gtk2::Label->new(); + my $plugin_descr_label = Gtk3::Label->new(); $plugin_descr_label->set_markup("" . $d->get("Description") . ""); - my $plugin_descr_frame = Gtk2::Frame->new(); + my $plugin_descr_frame = Gtk3::Frame->new(); $plugin_descr_frame->set_label_widget($plugin_descr_label); $plugin_descr_frame->set_shadow_type('none'); $plugin_descr_frame->add($textview_hbox); #plugin image - my $plugin_image = Gtk2::Image->new; + my $plugin_image = Gtk3::Image->new; #packing - my $plugin_vbox1 = Gtk2::VBox->new(FALSE, 5); - my $plugin_hbox1 = Gtk2::HBox->new(FALSE, 5); - my $plugin_hbox2 = Gtk2::HBox->new(FALSE, 5); + my $plugin_vbox1 = Gtk3::VBox->new(FALSE, 5); + my $plugin_hbox1 = Gtk3::HBox->new(FALSE, 5); + my $plugin_hbox2 = Gtk3::HBox->new(FALSE, 5); $plugin_hbox2->set_border_width(10); #what plugin is selected? @@ -10051,31 +9920,31 @@ if ($app->is_running) { } }); - my $renderer_pix = Gtk2::CellRendererPixbuf->new; + my $renderer_pix = Gtk3::CellRendererPixbuf->new; $plugin->pack_start($renderer_pix, FALSE); $plugin->add_attribute($renderer_pix, pixbuf => 0); - my $renderer_text = Gtk2::CellRendererText->new; + my $renderer_text = Gtk3::CellRendererText->new; $plugin->pack_start($renderer_text, FALSE); $plugin->add_attribute($renderer_text, text => 1); #we try to activate the last executed plugin if that's possible $plugin->set_active_iter($iter_lastex_plugin); - $plugin_hbox1->pack_start_defaults($plugin); + $plugin_hbox1->pack_start($plugin, TRUE, TRUE, 0); - $plugin_hbox2->pack_start_defaults($plugin_image); - $plugin_hbox2->pack_start_defaults($plugin_descr_frame); + $plugin_hbox2->pack_start($plugin_image, TRUE, TRUE, 0); + $plugin_hbox2->pack_start($plugin_descr_frame, TRUE, TRUE, 0); $plugin_vbox1->pack_start($plugin_hbox1, FALSE, TRUE, 1); $plugin_vbox1->pack_start($plugin_hbox2, TRUE, TRUE, 1); - $plugin_dialog->vbox->add($plugin_vbox1); + $plugin_dialog->get_child->add($plugin_vbox1); - my $plugin_progress = Gtk2::ProgressBar->new; + my $plugin_progress = Gtk3::ProgressBar->new; $plugin_progress->set_no_show_all(TRUE); $plugin_progress->set_ellipsize('middle'); - $plugin_progress->set_orientation('left-to-right'); - $plugin_dialog->vbox->add($plugin_progress); + $plugin_progress->set_orientation('horizontal'); + $plugin_dialog->get_child->add($plugin_progress); $plugin_dialog->show_all; @@ -10095,7 +9964,7 @@ if ($app->is_running) { #disable buttons and combobox $plugin->set_sensitive(FALSE); - foreach my $dialog_child ($plugin_dialog->vbox->get_children) { + foreach my $dialog_child ($plugin_dialog->get_child->get_children) { $dialog_child->set_sensitive(FALSE) if $dialog_child =~ /Button/; } @@ -10136,14 +10005,15 @@ if ($app->is_running) { return FALSE if @files_to_upload < 1; my $dlg_header = $d->get("Upload / Export"); - my $hosting_dialog = Gtk2::Dialog->new($dlg_header, $window, [qw/modal destroy-with-parent/]); + my $hosting_dialog = Gtk3::Dialog->new($dlg_header, $window, [qw/modal destroy-with-parent/]); + $hosting_dialog->set_default_size(400, 300); my $close_button = $hosting_dialog->add_button('gtk-close', 'close'); my $upload_button = $hosting_dialog->add_button($d->get("_Upload"), 'accept'); - $upload_button->set_image(Gtk2::Image->new_from_stock('gtk-go-up', 'button')); + $upload_button->set_image(Gtk3::Image->new_from_stock('gtk-go-up', 'button')); $hosting_dialog->set_default_response('accept'); - my $model = Gtk2::ListStore->new('Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String'); + my $model = Gtk3::ListStore->new('Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String', 'Glib::String'); foreach (keys %accounts) { @@ -10177,34 +10047,30 @@ if ($app->is_running) { } } - my $hosting_image = Gtk2::Image->new; - #set up account combobox - my $hosting = Gtk2::ComboBox->new($model); - my $renderer_host = Gtk2::CellRendererText->new; + my $hosting = Gtk3::ComboBox->new_with_model($model); + my $renderer_host = Gtk3::CellRendererText->new; $hosting->pack_start($renderer_host, FALSE); $hosting->add_attribute($renderer_host, text => 0); - my $renderer_username = Gtk2::CellRendererText->new; + my $renderer_username = Gtk3::CellRendererText->new; $hosting->pack_start($renderer_username, FALSE); $hosting->add_attribute($renderer_username, text => 3); $hosting->set_active(0); #public hosting settings - my $pub_hbox1 = Gtk2::HBox->new(FALSE, 0); - my $pub_hbox2 = Gtk2::HBox->new(FALSE, 0); - my $pub_hbox_hint = Gtk2::HBox->new(FALSE, 0); - my $pub_hbox_hint2 = Gtk2::HBox->new(FALSE, 0); - my $pub_vbox1 = Gtk2::VBox->new(FALSE, 0); - - my $pub_hint = Gtk2::Label->new(); - my $pub_hint2 = Gtk2::Label->new(); + my $pub_hbox1 = Gtk3::HBox->new(FALSE, 0); + my $pub_hbox2 = Gtk3::HBox->new(FALSE, 0); + my $pub_hbox_hint = Gtk3::HBox->new(FALSE, 0); + my $pub_hbox_hint2 = Gtk3::HBox->new(FALSE, 0); + my $pub_vbox1 = Gtk3::VBox->new(FALSE, 0); + + my $pub_hint = Gtk3::Label->new(); + my $pub_hint2 = Gtk3::Label->new(); $pub_hint->set_line_wrap(TRUE); $pub_hint2->set_line_wrap(TRUE); - if (Gtk2->CHECK_VERSION(2, 9, 0)) { - $pub_hint->set_line_wrap_mode('word-char'); - $pub_hint2->set_line_wrap_mode('word-char'); - } + $pub_hint->set_line_wrap_mode('word-char'); + $pub_hint2->set_line_wrap_mode('word-char'); $pub_hint->set_markup( "" @@ -10216,8 +10082,8 @@ if ($app->is_running) { . $d->get("Please note: If a plugin allows only authorized uploading you need to enter your credentials in preferences first to make it appear in the list above.") . ""); - $pub_hbox1->pack_start(Gtk2::Label->new($d->get("Choose account") . ":"), FALSE, FALSE, 6); - $pub_hbox1->pack_start_defaults($hosting); + $pub_hbox1->pack_start(Gtk3::Label->new($d->get("Choose account") . ":"), FALSE, FALSE, 6); + $pub_hbox1->pack_start($hosting, TRUE, TRUE, 0); $pub_hbox_hint->pack_start($pub_hint, TRUE, TRUE, 6); $pub_hbox_hint2->pack_start($pub_hint2, TRUE, TRUE, 6); @@ -10229,27 +10095,27 @@ if ($app->is_running) { $pub_vbox1->pack_start($pub_hbox_hint2, FALSE, FALSE, 3); #places settings - my $pl_hbox1 = Gtk2::HBox->new(FALSE, 0); - my $pl_vbox1 = Gtk2::VBox->new(FALSE, 0); - my $places_fc = Gtk2::FileChooserButton->new_with_backend("Shutter - " . $d->get("Choose folder"), 'select-folder', 'gnome-vfs'); + my $pl_hbox1 = Gtk3::HBox->new(FALSE, 0); + my $pl_vbox1 = Gtk3::VBox->new(FALSE, 0); + my $places_fc = Gtk3::FileChooserButton->new("Shutter - " . $d->get("Choose folder"), 'select-folder'); $places_fc->set('local-only' => FALSE); - $pl_hbox1->pack_start(Gtk2::Label->new($d->get("Choose folder") . ":"), FALSE, FALSE, 6); - $pl_hbox1->pack_start_defaults($places_fc); + $pl_hbox1->pack_start(Gtk3::Label->new($d->get("Choose folder") . ":"), FALSE, FALSE, 6); + $pl_hbox1->pack_start($places_fc, TRUE, TRUE, 0); $pl_vbox1->pack_start($pl_hbox1, FALSE, FALSE, 3); #ftp settings #we are using the same widgets as in the settings and populate #them with saved values when possible - my $ftp_hbox1_dlg = Gtk2::HBox->new(FALSE, 0); - my $ftp_hbox2_dlg = Gtk2::HBox->new(FALSE, 0); - my $ftp_hbox3_dlg = Gtk2::HBox->new(FALSE, 0); - my $ftp_hbox4_dlg = Gtk2::HBox->new(FALSE, 0); - my $ftp_hbox5_dlg = Gtk2::HBox->new(FALSE, 0); + my $ftp_hbox1_dlg = Gtk3::HBox->new(FALSE, 0); + my $ftp_hbox2_dlg = Gtk3::HBox->new(FALSE, 0); + my $ftp_hbox3_dlg = Gtk3::HBox->new(FALSE, 0); + my $ftp_hbox4_dlg = Gtk3::HBox->new(FALSE, 0); + my $ftp_hbox5_dlg = Gtk3::HBox->new(FALSE, 0); #uri - my $ftp_entry_label_dlg = Gtk2::Label->new($d->get("URI") . ":"); + my $ftp_entry_label_dlg = Gtk3::Label->new($d->get("URI") . ":"); $ftp_hbox1_dlg->pack_start($ftp_entry_label_dlg, FALSE, TRUE, 10); - my $ftp_remote_entry_dlg = Gtk2::Entry->new; + my $ftp_remote_entry_dlg = Gtk3::Entry->new; $ftp_remote_entry_dlg->set_text($ftp_remote_entry->get_text); $ftp_entry_label_dlg->set_tooltip_text($d->get("URI\nExample: ftp://host:port/path")); @@ -10259,9 +10125,9 @@ if ($app->is_running) { $ftp_hbox1_dlg->pack_start($ftp_remote_entry_dlg, TRUE, TRUE, 10); #connection mode - my $ftp_mode_label_dlg = Gtk2::Label->new($d->get("Connection mode") . ":"); + my $ftp_mode_label_dlg = Gtk3::Label->new($d->get("Connection mode") . ":"); $ftp_hbox2_dlg->pack_start($ftp_mode_label_dlg, FALSE, TRUE, 10); - my $ftp_mode_combo_dlg = Gtk2::ComboBox->new_text; + my $ftp_mode_combo_dlg = Gtk3::ComboBoxText->new; $ftp_mode_combo_dlg->insert_text(0, $d->get("Active mode")); $ftp_mode_combo_dlg->insert_text(1, $d->get("Passive mode")); $ftp_mode_combo_dlg->set_active($ftp_mode_combo->get_active); @@ -10273,9 +10139,9 @@ if ($app->is_running) { $ftp_hbox2_dlg->pack_start($ftp_mode_combo_dlg, TRUE, TRUE, 10); #username - my $ftp_username_label_dlg = Gtk2::Label->new($d->get("Username") . ":"); + my $ftp_username_label_dlg = Gtk3::Label->new($d->get("Username") . ":"); $ftp_hbox3_dlg->pack_start($ftp_username_label_dlg, FALSE, TRUE, 10); - my $ftp_username_entry_dlg = Gtk2::Entry->new; + my $ftp_username_entry_dlg = Gtk3::Entry->new; $ftp_username_entry_dlg->set_text($ftp_username_entry->get_text); $ftp_username_label_dlg->set_tooltip_text($d->get("Username")); @@ -10285,9 +10151,9 @@ if ($app->is_running) { $ftp_hbox3_dlg->pack_start($ftp_username_entry_dlg, TRUE, TRUE, 10); #password - my $ftp_password_label_dlg = Gtk2::Label->new($d->get("Password") . ":"); + my $ftp_password_label_dlg = Gtk3::Label->new($d->get("Password") . ":"); $ftp_hbox4_dlg->pack_start($ftp_password_label_dlg, FALSE, TRUE, 10); - my $ftp_password_entry_dlg = Gtk2::Entry->new; + my $ftp_password_entry_dlg = Gtk3::Entry->new; $ftp_password_entry_dlg->set_invisible_char("*"); $ftp_password_entry_dlg->set_visibility(FALSE); $ftp_password_entry_dlg->set_text($ftp_password_entry->get_text); @@ -10299,9 +10165,9 @@ if ($app->is_running) { $ftp_hbox4_dlg->pack_start($ftp_password_entry_dlg, TRUE, TRUE, 10); #website url - my $ftp_wurl_label_dlg = Gtk2::Label->new($d->get("Website URL") . ":"); + my $ftp_wurl_label_dlg = Gtk3::Label->new($d->get("Website URL") . ":"); $ftp_hbox5_dlg->pack_start($ftp_wurl_label_dlg, FALSE, TRUE, 10); - my $ftp_wurl_entry_dlg = Gtk2::Entry->new; + my $ftp_wurl_entry_dlg = Gtk3::Entry->new; $ftp_wurl_entry_dlg->set_text($ftp_wurl_entry->get_text); $ftp_wurl_label_dlg->set_tooltip_text($d->get("Website URL")); @@ -10310,7 +10176,7 @@ if ($app->is_running) { $ftp_hbox5_dlg->pack_start($ftp_wurl_entry_dlg, TRUE, TRUE, 10); - my $ftp_vbox_dlg = Gtk2::VBox->new(FALSE, 0); + my $ftp_vbox_dlg = Gtk3::VBox->new(FALSE, 0); $ftp_vbox_dlg->pack_start($ftp_hbox1_dlg, FALSE, TRUE, 3); $ftp_vbox_dlg->pack_start($ftp_hbox2_dlg, FALSE, TRUE, 3); $ftp_vbox_dlg->pack_start($ftp_hbox3_dlg, FALSE, TRUE, 3); @@ -10324,7 +10190,7 @@ if ($app->is_running) { $ftp_password_label_dlg->set_alignment(0, 0.5); $ftp_wurl_label_dlg->set_alignment(0, 0.5); - my $sg_ftp_dlg = Gtk2::SizeGroup->new('horizontal'); + my $sg_ftp_dlg = Gtk3::SizeGroup->new('horizontal'); $sg_ftp_dlg->add_widget($ftp_entry_label_dlg); $sg_ftp_dlg->add_widget($ftp_mode_label_dlg); $sg_ftp_dlg->add_widget($ftp_username_label_dlg); @@ -10332,17 +10198,23 @@ if ($app->is_running) { $sg_ftp_dlg->add_widget($ftp_wurl_label_dlg); #setup notebook - my $unotebook = Gtk2::Notebook->new; - $unotebook->append_page($pub_vbox1, $d->get("Public hosting")); - $unotebook->append_page($ftp_vbox_dlg, "FTP"); - $unotebook->append_page($pl_vbox1, $d->get("Places")); - $hosting_dialog->vbox->add($unotebook); - - my $hosting_progress = Gtk2::ProgressBar->new; + my $unotebook = Gtk3::Notebook->new; + my $hosting_label = Gtk3::Label->new; + $hosting_label->set_text($d->get("Public hosting")); + $unotebook->append_page($pub_vbox1, $hosting_label); + my $ftp_label = Gtk3::Label->new; + $ftp_label->set_text("FTP"); + $unotebook->append_page($ftp_vbox_dlg, $ftp_label); + my $places_label = Gtk3::Label->new; + $places_label->set_text($d->get("Places")); + $unotebook->append_page($pl_vbox1, $places_label); + $hosting_dialog->get_child->add($unotebook); + + my $hosting_progress = Gtk3::ProgressBar->new; $hosting_progress->set_no_show_all(TRUE); $hosting_progress->set_ellipsize('middle'); - $hosting_progress->set_orientation('left-to-right'); - $hosting_dialog->vbox->add($hosting_progress); + $hosting_progress->set_orientation('horizontal'); + $hosting_dialog->get_child->add($hosting_progress); $hosting_dialog->show_all; @@ -10608,8 +10480,8 @@ if ($app->is_running) { #ask the user to replace the image #replace button - my $replace_btn = Gtk2::Button->new_with_mnemonic($d->get("_Replace")); - $replace_btn->set_image(Gtk2::Image->new_from_stock('gtk-save-as', 'button')); + my $replace_btn = Gtk3::Button->new_with_mnemonic($d->get("_Replace")); + $replace_btn->set_image(Gtk3::Image->new_from_stock('gtk-save-as', 'button')); my $target_path = $shf->utf8_decode(unescape_string($target_giofile->get_path // $target_giofile->get_uri)); @@ -10722,8 +10594,8 @@ if ($app->is_running) { my $target_path = $shf->utf8_decode(unescape_string($target_giofile->get_path // $target_giofile->get_uri)); #retry button - my $retry_btn = Gtk2::Button->new_with_mnemonic($d->get("_Retry")); - $retry_btn->set_image(Gtk2::Image->new_from_stock('gtk-redo', 'button')); + my $retry_btn = Gtk3::Button->new_with_mnemonic($d->get("_Retry")); + $retry_btn->set_image(Gtk3::Image->new_from_stock('gtk-redo', 'button')); my $response = $sd->dlg_error_message( sprintf($d->get("Error while copying the image %s."), "'" . $target_giofile->get_basename . "'"), @@ -10757,11 +10629,11 @@ if ($app->is_running) { sub dlg_profile_name { my ($curr_profile_name, $combobox_settings_profiles) = @_; - my $profile_dialog = Gtk2::MessageDialog->new($window, [qw/modal destroy-with-parent/], 'other', 'none', undef); + my $profile_dialog = Gtk3::MessageDialog->new($window, [qw/modal destroy-with-parent/], 'other', 'none', undef); $profile_dialog->set_title("Shutter"); - $profile_dialog->set('image' => Gtk2::Image->new_from_stock('gtk-dialog-question', 'dialog')); + $profile_dialog->set('image' => Gtk3::Image->new_from_stock('gtk-dialog-question', 'dialog')); $profile_dialog->set('text' => $d->get("Save current preferences as new profile")); @@ -10772,9 +10644,9 @@ if ($app->is_running) { $profile_dialog->set_default_response('accept'); - my $new_profile_name_vbox = Gtk2::VBox->new(); - my $new_profile_name_hint = Gtk2::Label->new(); - my $new_profile_name = Gtk2::Entry->new(); + my $new_profile_name_vbox = Gtk3::VBox->new(); + my $new_profile_name_hint = Gtk3::Label->new(); + my $new_profile_name = Gtk3::Entry->new(); $new_profile_name->set_activates_default(TRUE); #here are all invalid char codes @@ -10784,7 +10656,7 @@ if ($app->is_running) { my $new_profile_name = shift; my $event = shift; - my $input = Gtk2::Gdk->keyval_to_unicode($event->keyval); + my $input = Gtk3::Gdk::keyval_to_unicode($event->keyval); #invalid input #~ print $input."\n"; @@ -10805,9 +10677,9 @@ if ($app->is_running) { $new_profile_name->set_text($curr_profile_name) if defined $curr_profile_name; - $new_profile_name_vbox->pack_start_defaults($new_profile_name); - $new_profile_name_vbox->pack_start_defaults($new_profile_name_hint); - $profile_dialog->vbox->add($new_profile_name_vbox); + $new_profile_name_vbox->pack_start($new_profile_name, TRUE, TRUE, 0); + $new_profile_name_vbox->pack_start($new_profile_name_hint, TRUE, TRUE, 0); + $profile_dialog->get_child->add($new_profile_name_vbox); $profile_dialog->show_all; #run dialog @@ -10821,8 +10693,8 @@ if ($app->is_running) { #ask the user to replace the profile #replace button - my $replace_btn = Gtk2::Button->new_with_mnemonic($d->get("_Replace")); - $replace_btn->set_image(Gtk2::Image->new_from_stock('gtk-save-as', 'button')); + my $replace_btn = Gtk3::Button->new_with_mnemonic($d->get("_Replace")); + $replace_btn->set_image(Gtk3::Image->new_from_stock('gtk-save-as', 'button')); my $response = $sd->dlg_warning_message( $d->get("Replacing it will overwrite its contents."), @@ -10902,6 +10774,87 @@ if ($app->is_running) { #-------------------------------------- } +package main; + +my $app = Shutter::App->new( + application_id=>'org.shutter-project.Shutter', + flags=>['flags-none']); + +$app->run; +if ($app->get_is_remote) { + #The application is already running, send it a message + + my ($cmdname, $extra) = $sc->get_start_with; + my $profile = $sc->get_profile_to_start_with; + my $exitac = $sc->get_exit_after_capture; + my $exfilename = $sc->get_export_filename; + my $delay = $sc->get_delay; + my $include_cursor = $sc->get_include_cursor; + my $remove_cursor = $sc->get_remove_cursor; + my $nosession = $sc->get_no_session; + + #change profile in running application + if (defined $profile && $profile) { + $app->activate_action('profile', Glib::Variant->new_string($profile)); + } + + #set exit flag in running application + if (defined $exitac && $exitac) { + $app->activate_action('exitac', Glib::Variant->new('')); + } + + #set export_filename (parameter -o) in running application + if (defined $exfilename && $exfilename) { + $app->activate_action('exfilename', Glib::Variant->new_string($shf->utf8_decode($exfilename))); + } + + #change delay in running application + if (defined $delay && $delay) { + $app->activate_action('delay', Glib::Variant->new_string($delay)); + } + + #change include_cursor in running application + if (defined $include_cursor && $include_cursor) { + $app->activate_action('include_cursor', Glib::Variant->new('')); + } + + #change remove_cursor in running application + if (defined $remove_cursor && $remove_cursor) { + $app->activate_action('remove_cursor', Glib::Variant->new('')); + } + + #set nosession flag in running application + if (defined $nosession && $nosession) { + $app->activate_action('nosession', Glib::Variant->new('')); + } + + my %screenshot_cmds = ( + select => 1, + full => 1, + window => 1, + awindow => 1, + section => 1, + menu => 1, + tooltip => 1, + web => 1, + redoshot => 1, + ); + if (defined $cmdname && $screenshot_cmds{$cmdname} && defined $extra) { + $app->activate_action($cmdname, Glib::Variant->new_string($extra)); + } elsif (defined $cmdname && $screenshot_cmds{$cmdname}) { + $app->activate_action($cmdname, Glib::Variant->new('')); + } else { + + my @variants; + foreach my $uri (@init_files) { + push @variants, Glib::Variant->new_string($uri); + } + $app->activate_action('fopen', Glib::Variant->new_array(undef, \@variants)); + } + + print "\nINFO: There is already another instance of Shutter running!\n"; +} + __END__ =head1 NAME diff --git a/share/shutter/resources/credits/dev b/share/shutter/resources/credits/dev index f218977a8..201543b34 100644 --- a/share/shutter/resources/credits/dev +++ b/share/shutter/resources/credits/dev @@ -5,6 +5,7 @@ Patches and Bugfixing: Vadim Rutkovsky Franco Zeoli José Borges Ferreira +Alexey Sokolov Plugins: Edwood Ocasio diff --git a/share/shutter/resources/gui/checkers.svg b/share/shutter/resources/gui/checkers.svg new file mode 100644 index 000000000..212567b7c --- /dev/null +++ b/share/shutter/resources/gui/checkers.svg @@ -0,0 +1,4 @@ + + + + diff --git a/share/shutter/resources/gui/stipple.png b/share/shutter/resources/gui/stipple.png new file mode 100644 index 000000000..557710725 Binary files /dev/null and b/share/shutter/resources/gui/stipple.png differ diff --git a/share/shutter/resources/modules/Shutter/App/AboutDialog.pm b/share/shutter/resources/modules/Shutter/App/AboutDialog.pm index 52e960305..13e6f5ec5 100644 --- a/share/shutter/resources/modules/Shutter/App/AboutDialog.pm +++ b/share/shutter/resources/modules/Shutter/App/AboutDialog.pm @@ -26,7 +26,7 @@ package Shutter::App::AboutDialog; #-------------------------------------- use utf8; use strict; -use Gtk2; +use Gtk3; #Glib use Glib qw/TRUE FALSE/; @@ -69,39 +69,35 @@ sub show { } close(GPL); - my $all_dev = ""; + my @all_dev; open(DEVCREDITS, "$shutter_root/share/shutter/resources/credits/dev") or die $!; while (my $dev = ) { + chomp $dev; utf8::decode $dev; - $all_dev .= $dev; + push @all_dev, $dev; } close(DEVCREDITS); - my $all_art = ""; + my @all_art; open(ARTCREDITS, "$shutter_root/share/shutter/resources/credits/art") or die $!; while (my $art = ) { + chomp $art; utf8::decode $art; - $all_art .= $art; + push @all_art, $art; } close(ARTCREDITS); - my $about = Gtk2::AboutDialog->new; + my $about = Gtk3::AboutDialog->new; $about->set_logo_icon_name('shutter'); - if (Gtk2->CHECK_VERSION(2, 12, 0)) { - $about->set_program_name($self->{_sc}->get_appname); - } else { - $about->set_name($self->{_sc}->get_appname); - } + $about->set_program_name($self->{_sc}->get_appname); $about->set_version($self->{_sc}->get_version); - $about->set_url_hook(sub { $shf->xdg_open(@_) }); #~ $about->set_website_label("Shutter-Website"); - $about->set_website("http://shutter-project.org"); - $about->set_email_hook(sub { $shf->xdg_open_mail(@_) }); - $about->set_authors($all_dev); - $about->set_artists($all_art); + $about->set_website("https://shutter-project.org"); + $about->set_authors(\@all_dev); + $about->set_artists(\@all_art); $about->set_translator_credits($d->get("translator-credits")); $about->set_copyright($all_hint); $about->set_license($all_gpl); diff --git a/share/shutter/resources/modules/Shutter/App/Common.pm b/share/shutter/resources/modules/Shutter/App/Common.pm index e5add0a88..c6e4bd971 100644 --- a/share/shutter/resources/modules/Shutter/App/Common.pm +++ b/share/shutter/resources/modules/Shutter/App/Common.pm @@ -26,7 +26,7 @@ package Shutter::App::Common; #-------------------------------------- use utf8; use strict; -use Gtk2; +use Gtk3; #Gettext and filename parsing use POSIX qw/setlocale/; @@ -81,7 +81,7 @@ sub new { #icontheme to determine if icons exist or not #in some cases we deliver fallback icons - $self->{_icontheme} = Gtk2::IconTheme->get_default; + $self->{_icontheme} = Gtk3::IconTheme::get_default(); $self->{_icontheme}->append_search_path($self->{_shutter_root} . "/share/icons"); #recently used upload tab @@ -432,8 +432,8 @@ sub set_delay { sub get_current_monitor { my $self = shift; - my ($window_at_pointer, $x, $y, $mask) = Gtk2::Gdk->get_default_root_window->get_pointer; - my $mon = Gtk2::Gdk::Screen->get_default->get_monitor_geometry(Gtk2::Gdk::Screen->get_default->get_monitor_at_point($x, $y)); + 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); } diff --git a/share/shutter/resources/modules/Shutter/App/HelperFunctions.pm b/share/shutter/resources/modules/Shutter/App/HelperFunctions.pm index 56423c41b..ad07a3fcb 100644 --- a/share/shutter/resources/modules/Shutter/App/HelperFunctions.pm +++ b/share/shutter/resources/modules/Shutter/App/HelperFunctions.pm @@ -26,7 +26,7 @@ package Shutter::App::HelperFunctions; #-------------------------------------- use utf8; use strict; -use Gtk2; +use Gtk3; #Glib use Glib qw/TRUE FALSE/; @@ -165,4 +165,22 @@ sub usage { return TRUE; } +# to help migration from Gtk2 to Gtk3 +# Native Gtk3::IconSize doesn't work for some reason +sub icon_size { + my $self = shift; + my $size = shift; + my @result = Glib::Object::Introspection->invoke('Gtk', undef, 'icon_size_lookup', Glib::Object::Introspection->convert_sv_to_enum('Gtk3::IconSize', $size)); + my $one = shift @result; + die "icon_size($size)=$one, @result" if $one != 1; + return @result; +} + +# to help migration from Gtk2 to Gtk3 +sub accel { + my $self = shift; + my $str = shift; + Glib::Object::Introspection->invoke('Gtk', undef, 'accelerator_parse', $str); +} + 1; diff --git a/share/shutter/resources/modules/Shutter/App/Menu.pm b/share/shutter/resources/modules/Shutter/App/Menu.pm index beb6c13a5..d8949d871 100644 --- a/share/shutter/resources/modules/Shutter/App/Menu.pm +++ b/share/shutter/resources/modules/Shutter/App/Menu.pm @@ -26,7 +26,7 @@ package Shutter::App::Menu; #-------------------------------------- use utf8; use strict; -use Gtk2; +use Gtk3; #Glib use Glib qw/TRUE FALSE/; @@ -35,9 +35,13 @@ use Glib qw/TRUE FALSE/; sub new { my $class = shift; + my $sc = shift; #constructor - my $self = {_common => shift}; + my $self = { + _common => $sc, + _shf => Shutter::App::HelperFunctions->new($sc), + }; bless $self, $class; return $self; @@ -49,39 +53,39 @@ sub create_menu { my $d = $self->{_common}->get_gettext; my $shutter_root = $self->{_common}->get_root; - my $accel_group = Gtk2::AccelGroup->new; + my $accel_group = Gtk3::AccelGroup->new; $self->{_common}->get_mainwindow->add_accel_group($accel_group); #MenuBar - $self->{_menubar} = Gtk2::MenuBar->new(); + $self->{_menubar} = Gtk3::MenuBar->new(); #file - $self->{_menuitem_file} = Gtk2::MenuItem->new_with_mnemonic($d->get('_File')); + $self->{_menuitem_file} = Gtk3::MenuItem->new_with_mnemonic($d->get('_File')); $self->{_menuitem_file}->set_submenu($self->fct_ret_file_menu($accel_group, $d, $shutter_root)); $self->{_menubar}->append($self->{_menuitem_file}); #edit - $self->{_menuitem_edit} = Gtk2::MenuItem->new_with_mnemonic($d->get('_Edit')); + $self->{_menuitem_edit} = Gtk3::MenuItem->new_with_mnemonic($d->get('_Edit')); $self->{_menuitem_edit}->set_submenu($self->fct_ret_edit_menu($accel_group, $d, $shutter_root)); $self->{_menubar}->append($self->{_menuitem_edit}); #view - $self->{_menuitem_view} = Gtk2::MenuItem->new_with_mnemonic($d->get('_View')); + $self->{_menuitem_view} = Gtk3::MenuItem->new_with_mnemonic($d->get('_View')); $self->{_menuitem_view}->set_submenu($self->fct_ret_view_menu($accel_group, $d, $shutter_root)); $self->{_menubar}->append($self->{_menuitem_view}); #actions - $self->{_menuitem_actions} = Gtk2::MenuItem->new_with_mnemonic($d->get('_Screenshot')); + $self->{_menuitem_actions} = Gtk3::MenuItem->new_with_mnemonic($d->get('_Screenshot')); $self->{_menuitem_actions}->set_submenu($self->fct_ret_actions_menu($accel_group, $d, $shutter_root)); $self->{_menubar}->append($self->{_menuitem_actions}); #go-to - $self->{_menuitem_session} = Gtk2::MenuItem->new_with_mnemonic($d->get('_Go')); + $self->{_menuitem_session} = Gtk3::MenuItem->new_with_mnemonic($d->get('_Go')); $self->{_menuitem_session}->set_submenu($self->fct_ret_session_menu($accel_group, $d, $shutter_root)); $self->{_menubar}->append($self->{_menuitem_session}); #help - $self->{_menuitem_help} = Gtk2::MenuItem->new_with_mnemonic($d->get('_Help')); + $self->{_menuitem_help} = Gtk3::MenuItem->new_with_mnemonic($d->get('_Help')); $self->{_menuitem_help}->set_submenu($self->fct_ret_help_menu($accel_group, $d, $shutter_root)); $self->{_menubar}->append($self->{_menuitem_help}); @@ -101,92 +105,92 @@ sub fct_ret_file_menu { #Icontheme my $icontheme = $self->{_common}->get_theme; - $self->{_menu_file} = Gtk2::Menu->new(); + $self->{_menu_file} = Gtk3::Menu->new(); - $self->{_menuitem_new} = Gtk2::ImageMenuItem->new_from_stock('gtk-new'); + $self->{_menuitem_new} = Gtk3::ImageMenuItem->new_from_stock('gtk-new'); $self->{_menuitem_new}->set_submenu($self->fct_ret_new_menu($accel_group, $d, $shutter_root)); $self->{_menu_file}->append($self->{_menuitem_new}); - $self->{_menu_file}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_file}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_open} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Open...')); - $self->{_menuitem_open}->set_image(Gtk2::Image->new_from_stock('gtk-open', 'menu')); - $self->{_menuitem_open}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('O'), qw/visible/); + $self->{_menuitem_open} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Open...')); + $self->{_menuitem_open}->set_image(Gtk3::Image->new_from_stock('gtk-open', 'menu')); + $self->{_menuitem_open}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('O'), qw/visible/); $self->{_menu_file}->append($self->{_menuitem_open}); - $self->{_menuitem_recent} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Recent _Files')); + $self->{_menuitem_recent} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Recent _Files')); $self->{_menu_file}->append($self->{_menuitem_recent}); - $self->{_menu_file}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_file}->append(Gtk3::SeparatorMenuItem->new); - #~ $self->{_menuitem_save} = Gtk2::ImageMenuItem->new_with_mnemonic( $d->get('_Save') ); - #~ $self->{_menuitem_save}->set_image( Gtk2::Image->new_from_stock( 'gtk-save', 'menu' ) ); + #~ $self->{_menuitem_save} = Gtk3::ImageMenuItem->new_with_mnemonic( $d->get('_Save') ); + #~ $self->{_menuitem_save}->set_image( Gtk3::Image->new_from_stock( 'gtk-save', 'menu' ) ); #~ $self->{_menuitem_save}->set_sensitive(FALSE); - #~ $self->{_menuitem_save}->add_accelerator( 'activate', $accel_group, Gtk2::Accelerator->parse('S'), qw/visible/ ); + #~ $self->{_menuitem_save}->add_accelerator( 'activate', $accel_group, $self->{_shf}->accel('S'), qw/visible/ ); #~ $self->{_menu_file}->append( $self->{_menuitem_save} ); - $self->{_menuitem_save_as} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Save _As...')); - $self->{_menuitem_save_as}->set_image(Gtk2::Image->new_from_stock('gtk-save-as', 'menu')); + $self->{_menuitem_save_as} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Save _As...')); + $self->{_menuitem_save_as}->set_image(Gtk3::Image->new_from_stock('gtk-save-as', 'menu')); $self->{_menuitem_save_as}->set_sensitive(FALSE); - $self->{_menuitem_save_as}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('S'), qw/visible/); + $self->{_menuitem_save_as}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('S'), qw/visible/); $self->{_menu_file}->append($self->{_menuitem_save_as}); - #~ $self->{_menuitem_export_svg} = Gtk2::ImageMenuItem->new_with_mnemonic( $d->get('Export to SVG...') ); + #~ $self->{_menuitem_export_svg} = Gtk3::ImageMenuItem->new_with_mnemonic( $d->get('Export to SVG...') ); #~ $self->{_menuitem_export_svg}->set_sensitive(FALSE); - #~ $self->{_menuitem_export_svg}->add_accelerator( 'activate', $accel_group, Gtk2::Accelerator->parse('G'), qw/visible/ ); + #~ $self->{_menuitem_export_svg}->add_accelerator( 'activate', $accel_group, $self->{_shf}->accel('G'), qw/visible/ ); #~ $self->{_menu_file}->append( $self->{_menuitem_export_svg} ); - $self->{_menuitem_export_pdf} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('E_xport to PDF...')); + $self->{_menuitem_export_pdf} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('E_xport to PDF...')); $self->{_menuitem_export_pdf}->set_sensitive(FALSE); - $self->{_menuitem_export_pdf}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('P'), qw/visible/); + $self->{_menuitem_export_pdf}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('P'), qw/visible/); $self->{_menu_file}->append($self->{_menuitem_export_pdf}); - $self->{_menuitem_export_pscript} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Export to Post_Script...')); + $self->{_menuitem_export_pscript} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Export to Post_Script...')); $self->{_menuitem_export_pscript}->set_sensitive(FALSE); - $self->{_menuitem_export_pscript}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('S'), qw/visible/); + $self->{_menuitem_export_pscript}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('S'), qw/visible/); $self->{_menu_file}->append($self->{_menuitem_export_pscript}); - $self->{_menu_file}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_file}->append(Gtk3::SeparatorMenuItem->new); - #~ $self->{_menuitem_pagesetup} = Gtk2::ImageMenuItem->new_from_stock('gtk-page-setup'); + #~ $self->{_menuitem_pagesetup} = Gtk3::ImageMenuItem->new_from_stock('gtk-page-setup'); #~ $self->{_menu_file}->append( $self->{_menuitem_pagesetup} ); - $self->{_menuitem_pagesetup} = Gtk2::ImageMenuItem->new($d->get('Page Set_up')); - $self->{_menuitem_pagesetup}->set_image(Gtk2::Image->new_from_icon_name('document-page-setup', 'menu')); + $self->{_menuitem_pagesetup} = Gtk3::ImageMenuItem->new($d->get('Page Set_up')); + $self->{_menuitem_pagesetup}->set_image(Gtk3::Image->new_from_icon_name('document-page-setup', 'menu')); $self->{_menuitem_pagesetup}->set_sensitive(FALSE); $self->{_menu_file}->append($self->{_menuitem_pagesetup}); - $self->{_menuitem_print} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Print...')); - $self->{_menuitem_print}->set_image(Gtk2::Image->new_from_stock('gtk-print', 'menu')); - $self->{_menuitem_print}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('P'), qw/visible/); + $self->{_menuitem_print} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Print...')); + $self->{_menuitem_print}->set_image(Gtk3::Image->new_from_stock('gtk-print', 'menu')); + $self->{_menuitem_print}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('P'), qw/visible/); $self->{_menuitem_print}->set_sensitive(FALSE); $self->{_menu_file}->append($self->{_menuitem_print}); - $self->{_menu_file}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_file}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_email} = Gtk2::ImageMenuItem->new($d->get('Send by E_mail...')); - $self->{_menuitem_email}->set_image(Gtk2::Image->new_from_icon_name('mail-send', 'menu')); + $self->{_menuitem_email} = Gtk3::ImageMenuItem->new($d->get('Send by E_mail...')); + $self->{_menuitem_email}->set_image(Gtk3::Image->new_from_icon_name('mail-send', 'menu')); $self->{_menuitem_email}->set_sensitive(FALSE); - $self->{_menuitem_email}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('E'), qw/visible/); + $self->{_menuitem_email}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('E'), qw/visible/); $self->{_menu_file}->append($self->{_menuitem_email}); - $self->{_menu_file}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_file}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_close} = Gtk2::ImageMenuItem->new_from_stock('gtk-close'); + $self->{_menuitem_close} = Gtk3::ImageMenuItem->new_from_stock('gtk-close'); $self->{_menuitem_close}->set_sensitive(FALSE); - $self->{_menuitem_close}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('W'), qw/visible/); + $self->{_menuitem_close}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('W'), qw/visible/); $self->{_menu_file}->append($self->{_menuitem_close}); - $self->{_menuitem_close_all} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('C_lose all')); - $self->{_menuitem_close_all}->set_image(Gtk2::Image->new_from_stock('gtk-close', 'menu')); + $self->{_menuitem_close_all} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('C_lose all')); + $self->{_menuitem_close_all}->set_image(Gtk3::Image->new_from_stock('gtk-close', 'menu')); $self->{_menuitem_close_all}->set_sensitive(FALSE); - $self->{_menuitem_close_all}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('W'), qw/visible/); + $self->{_menuitem_close_all}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('W'), qw/visible/); $self->{_menu_file}->append($self->{_menuitem_close_all}); - $self->{_menu_file}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_file}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_quit} = Gtk2::ImageMenuItem->new_from_stock('gtk-quit'); - $self->{_menuitem_quit}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('Q'), qw/visible/); + $self->{_menuitem_quit} = Gtk3::ImageMenuItem->new_from_stock('gtk-quit'); + $self->{_menuitem_quit}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('Q'), qw/visible/); $self->{_menu_file}->append($self->{_menuitem_quit}); return $self->{_menu_file}; @@ -201,52 +205,52 @@ sub fct_ret_edit_menu { #Icontheme my $icontheme = $self->{_common}->get_theme; - $self->{_menu_edit} = Gtk2::Menu->new(); + $self->{_menu_edit} = Gtk3::Menu->new(); - $self->{_menuitem_undo} = Gtk2::ImageMenuItem->new_from_stock('gtk-undo'); - $self->{_menuitem_undo}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('Z'), qw/visible/); + $self->{_menuitem_undo} = Gtk3::ImageMenuItem->new_from_stock('gtk-undo'); + $self->{_menuitem_undo}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('Z'), qw/visible/); $self->{_menuitem_undo}->set_sensitive(FALSE); $self->{_menu_edit}->append($self->{_menuitem_undo}); - $self->{_menuitem_redo} = Gtk2::ImageMenuItem->new_from_stock('gtk-redo'); - $self->{_menuitem_redo}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('Y'), qw/visible/); + $self->{_menuitem_redo} = Gtk3::ImageMenuItem->new_from_stock('gtk-redo'); + $self->{_menuitem_redo}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('Y'), qw/visible/); $self->{_menuitem_redo}->set_sensitive(FALSE); $self->{_menu_edit}->append($self->{_menuitem_redo}); - $self->{_menu_edit}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_edit}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_copy} = Gtk2::ImageMenuItem->new_from_stock('gtk-copy'); - $self->{_menuitem_copy}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('C'), qw/visible/); + $self->{_menuitem_copy} = Gtk3::ImageMenuItem->new_from_stock('gtk-copy'); + $self->{_menuitem_copy}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('C'), qw/visible/); $self->{_menuitem_copy}->set_sensitive(FALSE); $self->{_menu_edit}->append($self->{_menuitem_copy}); - $self->{_menuitem_copy_filename} = Gtk2::ImageMenuItem->new_from_stock('gtk-copy'); + $self->{_menuitem_copy_filename} = Gtk3::ImageMenuItem->new_from_stock('gtk-copy'); $self->{_menuitem_copy_filename}->get_child->set_text_with_mnemonic($d->get('Copy _Filename')); - $self->{_menuitem_copy_filename}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('C'), qw/visible/); + $self->{_menuitem_copy_filename}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('C'), qw/visible/); $self->{_menuitem_copy_filename}->set_sensitive(FALSE); $self->{_menu_edit}->append($self->{_menuitem_copy_filename}); - $self->{_menuitem_trash} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Move to _Trash')); - $self->{_menuitem_trash}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('Delete'), qw/visible/); - $self->{_menuitem_trash}->set_image(Gtk2::Image->new_from_icon_name('user-trash', 'menu')); + $self->{_menuitem_trash} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Move to _Trash')); + $self->{_menuitem_trash}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('Delete'), qw/visible/); + $self->{_menuitem_trash}->set_image(Gtk3::Image->new_from_icon_name('user-trash', 'menu')); $self->{_menuitem_trash}->set_sensitive(FALSE); $self->{_menu_edit}->append($self->{_menuitem_trash}); - $self->{_menu_edit}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_edit}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_select_all} = Gtk2::ImageMenuItem->new_from_stock('gtk-select-all'); - $self->{_menuitem_select_all}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('A'), qw/visible/); + $self->{_menuitem_select_all} = Gtk3::ImageMenuItem->new_from_stock('gtk-select-all'); + $self->{_menuitem_select_all}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('A'), qw/visible/); $self->{_menu_edit}->append($self->{_menuitem_select_all}); - $self->{_menu_edit}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_edit}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_quicks} = Gtk2::MenuItem->new_with_mnemonic($d->get('_Quick profile select')); + $self->{_menuitem_quicks} = Gtk3::MenuItem->new_with_mnemonic($d->get('_Quick profile select')); $self->{_menu_edit}->append($self->{_menuitem_quicks}); - $self->{_menu_edit}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_edit}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_settings} = Gtk2::ImageMenuItem->new_from_stock('gtk-preferences'); - $self->{_menuitem_settings}->add_accelerator('activate', $accel_group, Gtk2::Gdk->keyval_from_name('P'), qw/mod1-mask/, qw/visible/); + $self->{_menuitem_settings} = Gtk3::ImageMenuItem->new_from_stock('gtk-preferences'); + $self->{_menuitem_settings}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('P'), qw/visible/); $self->{_menu_edit}->append($self->{_menuitem_settings}); return $self->{_menu_edit}; @@ -261,42 +265,42 @@ sub fct_ret_view_menu { #Icontheme my $icontheme = $self->{_common}->get_theme; - $self->{_menu_view} = Gtk2::Menu->new(); + $self->{_menu_view} = Gtk3::Menu->new(); - $self->{_menuitem_btoolbar} = Gtk2::CheckMenuItem->new_with_mnemonic($d->get('Show Navigation _Toolbar')); + $self->{_menuitem_btoolbar} = Gtk3::CheckMenuItem->new_with_mnemonic($d->get('Show Navigation _Toolbar')); $self->{_menuitem_btoolbar}->set_active(FALSE); $self->{_menu_view}->append($self->{_menuitem_btoolbar}); - $self->{_menu_view}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_view}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_zoom_in} = Gtk2::ImageMenuItem->new_from_stock('gtk-zoom-in'); - $self->{_menuitem_zoom_in}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('plus'), qw/visible/); - $self->{_menuitem_zoom_in}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('equal'), qw/visible/); - $self->{_menuitem_zoom_in}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('KP_Add'), qw/visible/); + $self->{_menuitem_zoom_in} = Gtk3::ImageMenuItem->new_from_stock('gtk-zoom-in'); + $self->{_menuitem_zoom_in}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('plus'), qw/visible/); + $self->{_menuitem_zoom_in}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('equal'), qw/visible/); + $self->{_menuitem_zoom_in}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('KP_Add'), qw/visible/); $self->{_menuitem_zoom_in}->set_sensitive(FALSE); $self->{_menu_view}->append($self->{_menuitem_zoom_in}); - $self->{_menuitem_zoom_out} = Gtk2::ImageMenuItem->new_from_stock('gtk-zoom-out'); - $self->{_menuitem_zoom_out}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('minus'), qw/visible/); - $self->{_menuitem_zoom_out}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('KP_Subtract'), qw/visible/); + $self->{_menuitem_zoom_out} = Gtk3::ImageMenuItem->new_from_stock('gtk-zoom-out'); + $self->{_menuitem_zoom_out}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('minus'), qw/visible/); + $self->{_menuitem_zoom_out}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('KP_Subtract'), qw/visible/); $self->{_menuitem_zoom_out}->set_sensitive(FALSE); $self->{_menu_view}->append($self->{_menuitem_zoom_out}); - $self->{_menuitem_zoom_100} = Gtk2::ImageMenuItem->new_from_stock('gtk-zoom-100'); - $self->{_menuitem_zoom_100}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('0'), qw/visible/); + $self->{_menuitem_zoom_100} = Gtk3::ImageMenuItem->new_from_stock('gtk-zoom-100'); + $self->{_menuitem_zoom_100}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('0'), qw/visible/); $self->{_menuitem_zoom_100}->set_sensitive(FALSE); $self->{_menu_view}->append($self->{_menuitem_zoom_100}); - $self->{_menuitem_zoom_best} = Gtk2::ImageMenuItem->new_from_stock('gtk-zoom-fit'); + $self->{_menuitem_zoom_best} = Gtk3::ImageMenuItem->new_from_stock('gtk-zoom-fit'); $self->{_menuitem_zoom_best}->set_sensitive(FALSE); $self->{_menu_view}->append($self->{_menuitem_zoom_best}); - $self->{_menu_view}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_view}->append(Gtk3::SeparatorMenuItem->new); #create an image item from stock to reuse the translated text - $self->{_menuitem_fullscreen_image} = Gtk2::ImageMenuItem->new_from_stock('gtk-fullscreen'); - $self->{_menuitem_fullscreen} = Gtk2::CheckMenuItem->new_with_label($self->{_menuitem_fullscreen_image}->get_child->get_text); - $self->{_menuitem_fullscreen}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('F11'), qw/visible/); + $self->{_menuitem_fullscreen_image} = Gtk3::ImageMenuItem->new_from_stock('gtk-fullscreen'); + $self->{_menuitem_fullscreen} = Gtk3::CheckMenuItem->new_with_label($self->{_menuitem_fullscreen_image}->get_child->get_text); + $self->{_menuitem_fullscreen}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('F11'), qw/visible/); $self->{_menu_view}->append($self->{_menuitem_fullscreen}); return $self->{_menu_view}; @@ -311,24 +315,24 @@ sub fct_ret_session_menu { #Icontheme my $icontheme = $self->{_common}->get_theme; - $self->{_menu_session} = Gtk2::Menu->new(); + $self->{_menu_session} = Gtk3::Menu->new(); - $self->{_menuitem_back} = Gtk2::ImageMenuItem->new_from_stock('gtk-go-back'); - $self->{_menuitem_back}->add_accelerator('activate', $accel_group, Gtk2::Gdk->keyval_from_name('Left'), qw/mod1-mask/, qw/visible/); + $self->{_menuitem_back} = Gtk3::ImageMenuItem->new_from_stock('gtk-go-back'); + $self->{_menuitem_back}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('Left'), qw/visible/); $self->{_menu_session}->append($self->{_menuitem_back}); - $self->{_menuitem_forward} = Gtk2::ImageMenuItem->new_from_stock('gtk-go-forward'); - $self->{_menuitem_forward}->add_accelerator('activate', $accel_group, Gtk2::Gdk->keyval_from_name('Right'), qw/mod1-mask/, qw/visible/); + $self->{_menuitem_forward} = Gtk3::ImageMenuItem->new_from_stock('gtk-go-forward'); + $self->{_menuitem_forward}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('Right'), qw/visible/); $self->{_menu_session}->append($self->{_menuitem_forward}); - $self->{_menu_session}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_session}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_first} = Gtk2::ImageMenuItem->new_from_stock('gtk-goto-first'); - $self->{_menuitem_first}->add_accelerator('activate', $accel_group, Gtk2::Gdk->keyval_from_name('Home'), qw/mod1-mask/, qw/visible/); + $self->{_menuitem_first} = Gtk3::ImageMenuItem->new_from_stock('gtk-goto-first'); + $self->{_menuitem_first}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('Home'), qw/visible/); $self->{_menu_session}->append($self->{_menuitem_first}); - $self->{_menuitem_last} = Gtk2::ImageMenuItem->new_from_stock('gtk-goto-last'); - $self->{_menuitem_last}->add_accelerator('activate', $accel_group, Gtk2::Gdk->keyval_from_name('End'), qw/mod1-mask/, qw/visible/); + $self->{_menuitem_last} = Gtk3::ImageMenuItem->new_from_stock('gtk-goto-last'); + $self->{_menuitem_last}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('End'), qw/visible/); $self->{_menu_session}->append($self->{_menuitem_last}); return $self->{_menu_session}; @@ -343,42 +347,42 @@ sub fct_ret_help_menu { #Icontheme my $icontheme = $self->{_common}->get_theme; - $self->{_menu_help} = Gtk2::Menu->new(); + $self->{_menu_help} = Gtk3::Menu->new(); - $self->{_menuitem_question} = Gtk2::ImageMenuItem->new($d->get('Get Help Online...')); + $self->{_menuitem_question} = Gtk3::ImageMenuItem->new($d->get('Get Help Online...')); if ($icontheme->has_icon('lpi-help')) { - $self->{_menuitem_question}->set_image(Gtk2::Image->new_from_icon_name('lpi-help', 'menu')); + $self->{_menuitem_question}->set_image(Gtk3::Image->new_from_icon_name('lpi-help', 'menu')); } else { $self->{_menuitem_question} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/lpi-help.png", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/lpi-help.png", $self->{_shf}->icon_size('menu')))); } $self->{_menu_help}->append($self->{_menuitem_question}); - $self->{_menuitem_translate} = Gtk2::ImageMenuItem->new($d->get('Translate this Application...')); + $self->{_menuitem_translate} = Gtk3::ImageMenuItem->new($d->get('Translate this Application...')); if ($icontheme->has_icon('lpi-translate')) { - $self->{_menuitem_translate}->set_image(Gtk2::Image->new_from_icon_name('lpi-translate', 'menu')); + $self->{_menuitem_translate}->set_image(Gtk3::Image->new_from_icon_name('lpi-translate', 'menu')); } else { $self->{_menuitem_translate} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/lpi-translate.png", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/lpi-translate.png", $self->{_shf}->icon_size('menu')))); } $self->{_menu_help}->append($self->{_menuitem_translate}); - $self->{_menuitem_bug} = Gtk2::ImageMenuItem->new($d->get('Report a Problem')); + $self->{_menuitem_bug} = Gtk3::ImageMenuItem->new($d->get('Report a Problem')); if ($icontheme->has_icon('lpi-bug')) { - $self->{_menuitem_bug}->set_image(Gtk2::Image->new_from_icon_name('lpi-bug', 'menu')); + $self->{_menuitem_bug}->set_image(Gtk3::Image->new_from_icon_name('lpi-bug', 'menu')); } else { $self->{_menuitem_bug} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/lpi-bug.png", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/lpi-bug.png", $self->{_shf}->icon_size('menu')))); } $self->{_menu_help}->append($self->{_menuitem_bug}); - $self->{_menu_help}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_help}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_about} = Gtk2::ImageMenuItem->new_from_stock('gtk-about'); - $self->{_menuitem_about}->add_accelerator('activate', $accel_group, Gtk2::Gdk->keyval_from_name('I'), qw/control-mask/, qw/visible/); + $self->{_menuitem_about} = Gtk3::ImageMenuItem->new_from_stock('gtk-about'); + $self->{_menuitem_about}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('I'), qw/visible/); $self->{_menu_help}->append($self->{_menuitem_about}); return $self->{_menu_help}; @@ -393,118 +397,118 @@ sub fct_ret_new_menu { #Icontheme my $icontheme = $self->{_common}->get_theme; - $self->{_menu_new} = Gtk2::Menu->new; + $self->{_menu_new} = Gtk3::Menu->new; #redo last capture - $self->{_menuitem_redoshot} = Gtk2::ImageMenuItem->new_from_stock('gtk-refresh'); + $self->{_menuitem_redoshot} = Gtk3::ImageMenuItem->new_from_stock('gtk-refresh'); $self->{_menuitem_redoshot}->get_child->set_text_with_mnemonic($d->get('_Redo last screenshot')); - $self->{_menuitem_redoshot}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('F5'), qw/visible/); + $self->{_menuitem_redoshot}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('F5'), qw/visible/); $self->{_menuitem_redoshot}->set_sensitive(FALSE); $self->{_menu_new}->append($self->{_menuitem_redoshot}); - $self->{_menu_new}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_new}->append(Gtk3::SeparatorMenuItem->new); #selection - $self->{_menuitem_selection} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Selection')); + $self->{_menuitem_selection} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Selection')); eval { - my $ccursor_pb = Gtk2::Gdk::Cursor->new('left_ptr')->get_image->scale_simple(Gtk2::IconSize->lookup('menu'), 'bilinear'); - $self->{_menuitem_selection}->set_image(Gtk2::Image->new_from_pixbuf($ccursor_pb)); + my $ccursor_pb = Gtk3::Gdk::Cursor->new('left_ptr')->get_image->scale_simple($self->{_shf}->icon_size('menu'), 'bilinear'); + $self->{_menuitem_selection}->set_image(Gtk3::Image->new_from_pixbuf($ccursor_pb)); }; if ($@) { if ($icontheme->has_icon('applications-accessories')) { - $self->{_menuitem_selection}->set_image(Gtk2::Image->new_from_icon_name('applications-accessories', 'menu')); + $self->{_menuitem_selection}->set_image(Gtk3::Image->new_from_icon_name('applications-accessories', 'menu')); } else { $self->{_menuitem_selection} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/selection.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/selection.svg", $self->{_shf}->icon_size('menu')))); } } $self->{_menu_new}->append($self->{_menuitem_selection}); - #~ $self->{_menu_new}->append( Gtk2::SeparatorMenuItem->new ); + #~ $self->{_menu_new}->append( Gtk3::SeparatorMenuItem->new ); #full screen - $self->{_menuitem_full} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Desktop')); + $self->{_menuitem_full} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Desktop')); if ($icontheme->has_icon('user-desktop')) { - $self->{_menuitem_full}->set_image(Gtk2::Image->new_from_icon_name('user-desktop', 'menu')); + $self->{_menuitem_full}->set_image(Gtk3::Image->new_from_icon_name('user-desktop', 'menu')); } elsif ($icontheme->has_icon('desktop')) { - $self->{_menuitem_full}->set_image(Gtk2::Image->new_from_icon_name('desktop', 'menu')); + $self->{_menuitem_full}->set_image(Gtk3::Image->new_from_icon_name('desktop', 'menu')); } else { $self->{_menuitem_full} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/desktop.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/desktop.svg", $self->{_shf}->icon_size('menu')))); } $self->{_menu_new}->append($self->{_menuitem_full}); - #~ $self->{_menu_new}->append( Gtk2::SeparatorMenuItem->new ); + #~ $self->{_menu_new}->append( Gtk3::SeparatorMenuItem->new ); #awindow - $self->{_menuitem_awindow} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Active Window')); + $self->{_menuitem_awindow} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Active Window')); if ($icontheme->has_icon('preferences-system-windows')) { - $self->{_menuitem_awindow}->set_image(Gtk2::Image->new_from_icon_name('preferences-system-windows', 'menu')); + $self->{_menuitem_awindow}->set_image(Gtk3::Image->new_from_icon_name('preferences-system-windows', 'menu')); } else { $self->{_menuitem_awindow} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_active.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_active.svg", $self->{_shf}->icon_size('menu')))); } $self->{_menu_new}->append($self->{_menuitem_awindow}); #window - $self->{_menuitem_window} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Select W_indow')); + $self->{_menuitem_window} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Select W_indow')); if ($icontheme->has_icon('preferences-system-windows')) { - $self->{_menuitem_window}->set_image(Gtk2::Image->new_from_icon_name('preferences-system-windows', 'menu')); + $self->{_menuitem_window}->set_image(Gtk3::Image->new_from_icon_name('preferences-system-windows', 'menu')); } else { $self->{_menuitem_window} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window.svg", $self->{_shf}->icon_size('menu')))); } $self->{_menu_new}->append($self->{_menuitem_window}); #section - $self->{_menuitem_section} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Se_ction')); + $self->{_menuitem_section} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Se_ction')); if ($icontheme->has_icon('gdm-xnest')) { - $self->{_menuitem_section}->set_image(Gtk2::Image->new_from_icon_name('gdm-xnest', 'menu')); + $self->{_menuitem_section}->set_image(Gtk3::Image->new_from_icon_name('gdm-xnest', 'menu')); } else { $self->{_menuitem_section} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_section.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_section.svg", $self->{_shf}->icon_size('menu')))); } $self->{_menu_new}->append($self->{_menuitem_section}); #menu - $self->{_menuitem_menu} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Menu')); + $self->{_menuitem_menu} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Menu')); if ($icontheme->has_icon('alacarte')) { - $self->{_menuitem_menu}->set_image(Gtk2::Image->new_from_icon_name('alacarte', 'menu')); + $self->{_menuitem_menu}->set_image(Gtk3::Image->new_from_icon_name('alacarte', 'menu')); } else { $self->{_menuitem_menu} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_menu.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_menu.svg", $self->{_shf}->icon_size('menu')))); } $self->{_menu_new}->append($self->{_menuitem_menu}); #tooltip - $self->{_menuitem_tooltip} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Tooltip')); + $self->{_menuitem_tooltip} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Tooltip')); if ($icontheme->has_icon('help-faq')) { - $self->{_menuitem_tooltip}->set_image(Gtk2::Image->new_from_icon_name('help-faq', 'menu')); + $self->{_menuitem_tooltip}->set_image(Gtk3::Image->new_from_icon_name('help-faq', 'menu')); } else { $self->{_menuitem_tooltip} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_tooltip.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_tooltip.svg", $self->{_shf}->icon_size('menu')))); } $self->{_menu_new}->append($self->{_menuitem_tooltip}); - #~ $self->{_menu_new}->append( Gtk2::SeparatorMenuItem->new ); + #~ $self->{_menu_new}->append( Gtk3::SeparatorMenuItem->new ); #web - $self->{_menuitem_web} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Web')); + $self->{_menuitem_web} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Web')); if ($icontheme->has_icon('web-browser')) { - $self->{_menuitem_web}->set_image(Gtk2::Image->new_from_icon_name('web-browser', 'menu')); + $self->{_menuitem_web}->set_image(Gtk3::Image->new_from_icon_name('web-browser', 'menu')); } else { $self->{_menuitem_web} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/web_image.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/web_image.svg", $self->{_shf}->icon_size('menu')))); } $self->{_menu_new}->append($self->{_menuitem_web}); - $self->{_menu_new}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_new}->append(Gtk3::SeparatorMenuItem->new); #import from clipboard - $self->{_menuitem_iclipboard} = Gtk2::ImageMenuItem->new_from_stock('gtk-paste'); + $self->{_menuitem_iclipboard} = Gtk3::ImageMenuItem->new_from_stock('gtk-paste'); $self->{_menuitem_iclipboard}->get_child->set_text_with_mnemonic($d->get('Import from clip_board')); - $self->{_menuitem_iclipboard}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('V'), qw/visible/); + $self->{_menuitem_iclipboard}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('V'), qw/visible/); $self->{_menu_new}->append($self->{_menuitem_iclipboard}); $self->{_menu_new}->show_all; @@ -521,77 +525,77 @@ sub fct_ret_actions_menu { #Icontheme my $icontheme = $self->{_common}->get_theme; - $self->{_menu_actions} = Gtk2::Menu->new(); + $self->{_menu_actions} = Gtk3::Menu->new(); - $self->{_menuitem_reopen} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Open wit_h')); - $self->{_menuitem_reopen}->set_image(Gtk2::Image->new_from_stock('gtk-open', 'menu')); + $self->{_menuitem_reopen} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Open wit_h')); + $self->{_menuitem_reopen}->set_image(Gtk3::Image->new_from_stock('gtk-open', 'menu')); $self->{_menuitem_reopen}->set_sensitive(FALSE); $self->{_menuitem_reopen}->set_name('item-reopen-list'); $self->{_menu_actions}->append($self->{_menuitem_reopen}); - $self->{_menuitem_show_in_folder} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Show in _folder')); - $self->{_menuitem_show_in_folder}->set_image(Gtk2::Image->new_from_stock('gtk-open', 'menu')); + $self->{_menuitem_show_in_folder} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Show in _folder')); + $self->{_menuitem_show_in_folder}->set_image(Gtk3::Image->new_from_stock('gtk-open', 'menu')); $self->{_menuitem_show_in_folder}->set_sensitive(FALSE); $self->{_menuitem_show_in_folder}->set_name('item-reopen-default'); $self->{_menu_actions}->append($self->{_menuitem_show_in_folder}); - $self->{_menuitem_rename} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Rename...')); - $self->{_menuitem_rename}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('F2'), qw/visible/) if $accel_group; - $self->{_menuitem_rename}->set_image(Gtk2::Image->new_from_stock('gtk-edit', 'menu')); + $self->{_menuitem_rename} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Rename...')); + $self->{_menuitem_rename}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('F2'), qw/visible/) if $accel_group; + $self->{_menuitem_rename}->set_image(Gtk3::Image->new_from_stock('gtk-edit', 'menu')); $self->{_menuitem_rename}->set_sensitive(FALSE); $self->{_menuitem_rename}->set_name('item-rename'); $self->{_menu_actions}->append($self->{_menuitem_rename}); - $self->{_menu_actions}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_actions}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_send} = Gtk2::ImageMenuItem->new($d->get('_Send To...')); - $self->{_menuitem_send}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('S'), qw/visible/); - $self->{_menuitem_send}->set_image(Gtk2::Image->new_from_icon_name('document-send', 'menu')); + $self->{_menuitem_send} = Gtk3::ImageMenuItem->new($d->get('_Send To...')); + $self->{_menuitem_send}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('S'), qw/visible/); + $self->{_menuitem_send}->set_image(Gtk3::Image->new_from_icon_name('document-send', 'menu')); $self->{_menuitem_send}->set_sensitive(FALSE); $self->{_menuitem_send}->set_name('item-send'); $self->{_menu_actions}->append($self->{_menuitem_send}); - $self->{_menuitem_upload} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('E_xport...')); - $self->{_menuitem_upload}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('U'), qw/visible/) if $accel_group; - $self->{_menuitem_upload}->set_image(Gtk2::Image->new_from_stock('gtk-network', 'menu')); + $self->{_menuitem_upload} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('E_xport...')); + $self->{_menuitem_upload}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('U'), qw/visible/) if $accel_group; + $self->{_menuitem_upload}->set_image(Gtk3::Image->new_from_stock('gtk-network', 'menu')); $self->{_menuitem_upload}->set_sensitive(FALSE); $self->{_menuitem_upload}->set_name('item-upload'); $self->{_menu_actions}->append($self->{_menuitem_upload}); - $self->{_menuitem_links} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Public URLs')); - $self->{_menuitem_links}->set_image(Gtk2::Image->new_from_stock('gtk-network', 'menu')); + $self->{_menuitem_links} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Public URLs')); + $self->{_menuitem_links}->set_image(Gtk3::Image->new_from_stock('gtk-network', 'menu')); $self->{_menuitem_links}->set_sensitive(FALSE); $self->{_menuitem_links}->set_name('item-links'); $self->{_menu_actions}->append($self->{_menuitem_links}); - $self->{_menu_actions}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_actions}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_draw} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Edit...')); - $self->{_menuitem_draw}->set_image(Gtk2::Image->new_from_stock('gtk-edit', 'menu')); - $self->{_menuitem_draw}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('E'), qw/visible/) if $accel_group; + $self->{_menuitem_draw} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Edit...')); + $self->{_menuitem_draw}->set_image(Gtk3::Image->new_from_stock('gtk-edit', 'menu')); + $self->{_menuitem_draw}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('E'), qw/visible/) if $accel_group; if ($icontheme->has_icon('applications-graphics')) { - $self->{_menuitem_draw}->set_image(Gtk2::Image->new_from_icon_name('applications-graphics', 'menu')); + $self->{_menuitem_draw}->set_image(Gtk3::Image->new_from_icon_name('applications-graphics', 'menu')); } else { $self->{_menuitem_draw} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/draw.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/draw.svg", $self->{_shf}->icon_size('menu')))); } $self->{_menuitem_draw}->set_sensitive(FALSE); $self->{_menuitem_draw}->set_name('item-draw'); $self->{_menu_actions}->append($self->{_menuitem_draw}); - $self->{_menuitem_plugin} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Run a _plugin...')); - $self->{_menuitem_plugin}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('P'), qw/visible/) if $accel_group; - $self->{_menuitem_plugin}->set_image(Gtk2::Image->new_from_stock('gtk-execute', 'menu')); + $self->{_menuitem_plugin} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Run a _plugin...')); + $self->{_menuitem_plugin}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('P'), qw/visible/) if $accel_group; + $self->{_menuitem_plugin}->set_image(Gtk3::Image->new_from_stock('gtk-execute', 'menu')); $self->{_menuitem_plugin}->set_sensitive(FALSE); $self->{_menuitem_plugin}->set_name('item-plugin'); $self->{_menu_actions}->append($self->{_menuitem_plugin}); - $self->{_menu_actions}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_actions}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_redoshot_this} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Redo _this screenshot')); - $self->{_menuitem_redoshot_this}->add_accelerator('activate', $accel_group, Gtk2::Accelerator->parse('F5'), qw/visible/) if $accel_group; - $self->{_menuitem_redoshot_this}->set_image(Gtk2::Image->new_from_stock('gtk-refresh', 'menu')); + $self->{_menuitem_redoshot_this} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Redo _this screenshot')); + $self->{_menuitem_redoshot_this}->add_accelerator('activate', $accel_group, $self->{_shf}->accel('F5'), qw/visible/) if $accel_group; + $self->{_menuitem_redoshot_this}->set_image(Gtk3::Image->new_from_stock('gtk-refresh', 'menu')); $self->{_menuitem_redoshot_this}->set_sensitive(FALSE); $self->{_menuitem_redoshot_this}->set_name('item-redoshot'); $self->{_menu_actions}->append($self->{_menuitem_redoshot_this}); @@ -611,90 +615,90 @@ sub fct_ret_actions_menu_large { #Icontheme my $icontheme = $self->{_common}->get_theme; - $self->{_menu_large_actions} = Gtk2::Menu->new(); + $self->{_menu_large_actions} = Gtk3::Menu->new(); - $self->{_menuitem_large_reopen} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Open wit_h')); - $self->{_menuitem_large_reopen}->set_image(Gtk2::Image->new_from_stock('gtk-open', 'menu')); + $self->{_menuitem_large_reopen} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Open wit_h')); + $self->{_menuitem_large_reopen}->set_image(Gtk3::Image->new_from_stock('gtk-open', 'menu')); $self->{_menuitem_large_reopen}->set_sensitive(FALSE); $self->{_menuitem_large_reopen}->set_name('item-large-reopen-list'); $self->{_menu_large_actions}->append($self->{_menuitem_large_reopen}); - $self->{_menuitem_large_show_in_folder} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Show in _folder')); - $self->{_menuitem_large_show_in_folder}->set_image(Gtk2::Image->new_from_stock('gtk-open', 'menu')); + $self->{_menuitem_large_show_in_folder} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Show in _folder')); + $self->{_menuitem_large_show_in_folder}->set_image(Gtk3::Image->new_from_stock('gtk-open', 'menu')); $self->{_menuitem_large_show_in_folder}->set_sensitive(FALSE); $self->{_menuitem_large_show_in_folder}->set_name('item-reopen-default'); $self->{_menu_large_actions}->append($self->{_menuitem_large_show_in_folder}); - $self->{_menuitem_large_rename} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Rename...')); - $self->{_menuitem_large_rename}->set_image(Gtk2::Image->new_from_stock('gtk-edit', 'menu')); + $self->{_menuitem_large_rename} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Rename...')); + $self->{_menuitem_large_rename}->set_image(Gtk3::Image->new_from_stock('gtk-edit', 'menu')); $self->{_menuitem_large_rename}->set_sensitive(FALSE); $self->{_menuitem_large_rename}->set_name('item-large-rename'); $self->{_menu_large_actions}->append($self->{_menuitem_large_rename}); - $self->{_menu_large_actions}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_large_actions}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_large_send} = Gtk2::ImageMenuItem->new($d->get('_Send To...')); - $self->{_menuitem_large_send}->set_image(Gtk2::Image->new_from_icon_name('document-send', 'menu')); + $self->{_menuitem_large_send} = Gtk3::ImageMenuItem->new($d->get('_Send To...')); + $self->{_menuitem_large_send}->set_image(Gtk3::Image->new_from_icon_name('document-send', 'menu')); $self->{_menuitem_send}->set_sensitive(FALSE); $self->{_menuitem_send}->set_name('item-large-send'); $self->{_menu_large_actions}->append($self->{_menuitem_large_send}); - $self->{_menuitem_large_upload} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('E_xport...')); - $self->{_menuitem_large_upload}->set_image(Gtk2::Image->new_from_stock('gtk-network', 'menu')); + $self->{_menuitem_large_upload} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('E_xport...')); + $self->{_menuitem_large_upload}->set_image(Gtk3::Image->new_from_stock('gtk-network', 'menu')); $self->{_menuitem_large_upload}->set_sensitive(FALSE); $self->{_menuitem_large_upload}->set_name('item-large-upload'); $self->{_menu_large_actions}->append($self->{_menuitem_large_upload}); - $self->{_menuitem_large_links} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Public URLs')); - $self->{_menuitem_large_links}->set_image(Gtk2::Image->new_from_stock('gtk-network', 'menu')); + $self->{_menuitem_large_links} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Public URLs')); + $self->{_menuitem_large_links}->set_image(Gtk3::Image->new_from_stock('gtk-network', 'menu')); $self->{_menuitem_large_links}->set_sensitive(FALSE); $self->{_menuitem_large_links}->set_name('item-large-links'); $self->{_menu_large_actions}->append($self->{_menuitem_large_links}); - $self->{_menu_large_actions}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_large_actions}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_large_copy} = Gtk2::ImageMenuItem->new_from_stock('gtk-copy'); + $self->{_menuitem_large_copy} = Gtk3::ImageMenuItem->new_from_stock('gtk-copy'); $self->{_menuitem_large_copy}->set_sensitive(FALSE); $self->{_menuitem_large_copy}->set_name('item-large-copy'); $self->{_menu_large_actions}->append($self->{_menuitem_large_copy}); - $self->{_menuitem_large_copy_filename} = Gtk2::ImageMenuItem->new_from_stock('gtk-copy'); + $self->{_menuitem_large_copy_filename} = Gtk3::ImageMenuItem->new_from_stock('gtk-copy'); $self->{_menuitem_large_copy_filename}->get_child->set_text_with_mnemonic($d->get('Copy _Filename')); $self->{_menuitem_large_copy_filename}->set_sensitive(FALSE); $self->{_menuitem_large_copy_filename}->set_name('item-large-copy-filename'); $self->{_menu_large_actions}->append($self->{_menuitem_large_copy_filename}); - $self->{_menuitem_large_trash} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Move to _Trash')); - $self->{_menuitem_large_trash}->set_image(Gtk2::Image->new_from_icon_name('gnome-stock-trash', 'menu')); + $self->{_menuitem_large_trash} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Move to _Trash')); + $self->{_menuitem_large_trash}->set_image(Gtk3::Image->new_from_icon_name('gnome-stock-trash', 'menu')); $self->{_menuitem_large_trash}->set_sensitive(FALSE); $self->{_menuitem_large_trash}->set_name('item-large-trash'); $self->{_menu_large_actions}->append($self->{_menuitem_large_trash}); - $self->{_menu_large_actions}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_large_actions}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_large_draw} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('_Edit...')); - $self->{_menuitem_large_draw}->set_image(Gtk2::Image->new_from_stock('gtk-edit', 'menu')); + $self->{_menuitem_large_draw} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('_Edit...')); + $self->{_menuitem_large_draw}->set_image(Gtk3::Image->new_from_stock('gtk-edit', 'menu')); if ($icontheme->has_icon('applications-graphics')) { - $self->{_menuitem_large_draw}->set_image(Gtk2::Image->new_from_icon_name('applications-graphics', 'menu')); + $self->{_menuitem_large_draw}->set_image(Gtk3::Image->new_from_icon_name('applications-graphics', 'menu')); } else { $self->{_menuitem_large_draw} - ->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/draw.svg", Gtk2::IconSize->lookup('menu')))); + ->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/draw.svg", $self->{_shf}->icon_size('menu')))); } $self->{_menuitem_large_draw}->set_sensitive(FALSE); $self->{_menuitem_large_draw}->set_name('item-large-draw'); $self->{_menu_large_actions}->append($self->{_menuitem_large_draw}); - $self->{_menuitem_large_plugin} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Run a _Plugin...')); - $self->{_menuitem_large_plugin}->set_image(Gtk2::Image->new_from_stock('gtk-execute', 'menu')); + $self->{_menuitem_large_plugin} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Run a _Plugin...')); + $self->{_menuitem_large_plugin}->set_image(Gtk3::Image->new_from_stock('gtk-execute', 'menu')); $self->{_menuitem_large_plugin}->set_sensitive(FALSE); $self->{_menuitem_large_plugin}->set_name('item-large-plugin'); $self->{_menu_large_actions}->append($self->{_menuitem_large_plugin}); - $self->{_menu_large_actions}->append(Gtk2::SeparatorMenuItem->new); + $self->{_menu_large_actions}->append(Gtk3::SeparatorMenuItem->new); - $self->{_menuitem_large_redoshot_this} = Gtk2::ImageMenuItem->new_with_mnemonic($d->get('Redo _this screenshot')); - $self->{_menuitem_large_redoshot_this}->set_image(Gtk2::Image->new_from_stock('gtk-refresh', 'menu')); + $self->{_menuitem_large_redoshot_this} = Gtk3::ImageMenuItem->new_with_mnemonic($d->get('Redo _this screenshot')); + $self->{_menuitem_large_redoshot_this}->set_image(Gtk3::Image->new_from_stock('gtk-refresh', 'menu')); $self->{_menuitem_large_redoshot_this}->set_sensitive(FALSE); $self->{_menuitem_large_redoshot_this}->set_name('item-large-redoshot'); $self->{_menu_large_actions}->append($self->{_menuitem_large_redoshot_this}); diff --git a/share/shutter/resources/modules/Shutter/App/ShutterNotification.pm b/share/shutter/resources/modules/Shutter/App/ShutterNotification.pm index f3a3840b6..ae40810f5 100644 --- a/share/shutter/resources/modules/Shutter/App/ShutterNotification.pm +++ b/share/shutter/resources/modules/Shutter/App/ShutterNotification.pm @@ -31,9 +31,9 @@ use warnings; #Glib use Glib qw/TRUE FALSE/; -#Gtk2 and Pango -use Gtk2; -use Gtk2::Pango; +#Gtk3 and Pango +use Gtk3; +use Pango; #-------------------------------------- @@ -46,9 +46,13 @@ sub new { eval { #notification window (borderless gtk window) - $self->{_notifications_window} = Gtk2::Window->new('popup'); + $self->{_notifications_window} = Gtk3::Window->new('popup'); if ($self->{_sc}->get_mainwindow->get_screen->is_composited) { - $self->{_notifications_window}->set_colormap($self->{_sc}->get_mainwindow->get_screen->get_rgba_colormap); + my $screen = $self->{_sc}->get_mainwindow->get_screen; + # Glib::Object::Introspection doesn't support method call via + # cross-package inheritance, call it as a free function instead + # (X11Screen inherits from Screen) + $self->{_notifications_window}->set_visual(Gtk3::Gdk::Screen::get_rgba_visual($screen) || Gtk3::Gdb::Screen::get_system_visual($screen)); } $self->{_notifications_window}->set_app_paintable(TRUE); @@ -60,20 +64,20 @@ sub new { $self->{_notifications_window}->add_events('GDK_ENTER_NOTIFY_MASK'); #shape the window - my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($self->{_sc}->get_root . "/share/shutter/resources/icons/notify.svg"); + my $pixbuf = Gtk3::Gdk::Pixbuf->new_from_file($self->{_sc}->get_root . "/share/shutter/resources/icons/notify.svg"); #~ my ($pixmap, $mask) = $pixbuf->render_pixmap_and_mask (1); #~ $self->{_notifications_window}->shape_combine_mask($mask, 0, 0); #add a widget to control size of the window - my $fixed = Gtk2::Fixed->new; + my $fixed = Gtk3::Fixed->new; $fixed->set_size_request(300, 120); $self->{_notifications_window}->add($fixed); $self->{_notifications_window}->signal_connect( - 'expose-event' => sub { + 'draw' => sub { - return FALSE unless $self->{_notifications_window}->window; + return FALSE unless $self->{_notifications_window}; return FALSE unless $self->{_summary}; @@ -82,7 +86,7 @@ sub new { #initial position unless (defined $self->{_notifications_window}->{'pos'}) { - $self->{_notifications_window}->move($mon->x + $mon->width - 315, $mon->y + $mon->height - 140); + $self->{_notifications_window}->move($mon->{x} + $mon->{width} - 315, $mon->{y} + $mon->{height} - 140); $self->{_notifications_window}->{'pos'} = 1; } @@ -91,26 +95,25 @@ sub new { my ($x, $y) = $self->{_notifications_window}->get_position; #obtain current colors and font_desc from the main window - my $style = $self->{_sc}->get_mainwindow->get_style; - my $sel_bg = Gtk2::Gdk::Color->parse('#131313'); - my $sel_tx = Gtk2::Gdk::Color->parse('white'); - my $font_fam = $style->font_desc->get_family; - my $font_size = $style->font_desc->get_size / Gtk2::Pango->scale; + my $style = $self->{_sc}->get_mainwindow->get_style_context; + my $sel_bg = Gtk3::Gdk::RGBA::parse('#131313'); + my $font_fam = $style->get_font('normal')->get_family; + my $font_size = $style->get_font('normal')->get_size / Pango->scale; #create cairo context - my $cr = Gtk2::Gdk::Cairo::Context->create($self->{_notifications_window}->window); + my $cr = $_[1]; #pango layout - my $layout = Gtk2::Pango::Cairo::create_layout($cr); - $layout->set_width(($w - 30) * Gtk2::Pango->scale); + my $layout = Pango::Cairo::create_layout($cr); + $layout->set_width(($w - 30) * Pango->scale); - if (Gtk2::Pango->CHECK_VERSION(1, 20, 0)) { - $layout->set_height(($h - 20) * Gtk2::Pango->scale); + if (Pango->CHECK_VERSION(1, 20, 0)) { + $layout->set_height(($h - 20) * Pango->scale); } else { warn "WARNING: \$layout->set_height is not available - outdated Pango version\n"; } - if (Gtk2::Pango->CHECK_VERSION(1, 6, 0)) { + if (Pango->CHECK_VERSION(1, 6, 0)) { $layout->set_ellipsize('middle'); } else { warn "WARNING: \$layout->set_ellipsize is not available - outdated Pango version\n"; @@ -130,10 +133,10 @@ sub new { if ($self->{_sc}->get_mainwindow->get_screen->is_composited) { $cr->set_source_rgba(1.0, 1.0, 1.0, 0); - Gtk2::Gdk::Cairo::Context::set_source_pixbuf($cr, $pixbuf, 0, 0); + Gtk3::Gdk::cairo_set_source_pixbuf($cr, $pixbuf, 0, 0); $cr->paint; } else { - $cr->set_source_rgb($sel_bg->red / 257 / 255, $sel_bg->green / 257 / 255, $sel_bg->blue / 257 / 255); + $cr->set_source_rgb($sel_bg->red, $sel_bg->green, $sel_bg->blue); $cr->paint; } @@ -142,7 +145,7 @@ sub new { #get layout size my ($lw, $lh) = $layout->get_pixel_size; $cr->move_to(($w - $lw) / 2, ($h - $lh) / 2); - Gtk2::Pango::Cairo::show_layout($cr, $layout); + Pango::Cairo::show_layout($cr, $layout); return TRUE; }); @@ -159,10 +162,10 @@ sub new { my $mon = $self->{_sc}->get_current_monitor; if (defined $self->{_notifications_window}->{'pos'} && $self->{_notifications_window}->{'pos'} == 1) { - $self->{_notifications_window}->move($mon->x + $mon->width - 315, $mon->y + 40); + $self->{_notifications_window}->move($mon->{x} + $mon->{width} - 315, $mon->{y} + 40); $self->{_notifications_window}->{'pos'} = 0; } else { - $self->{_notifications_window}->move($mon->x + $mon->width - 315, $mon->y + $mon->height - 140); + $self->{_notifications_window}->move($mon->{x} + $mon->{width} - 315, $mon->{y} + $mon->{height} - 140); $self->{_notifications_window}->{'pos'} = 1; } @@ -222,7 +225,7 @@ sub close { $self->{_body} = undef; } - $self->{_notifications_window}->hide_all; + $self->{_notifications_window}->hide; $self->{_notifications_window}->{'pos'} = undef; diff --git a/share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm b/share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm index d127eaba5..90e52c916 100644 --- a/share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm +++ b/share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm @@ -28,7 +28,7 @@ use utf8; use strict; use warnings; -use Gtk2; +use Gtk3; #Glib use Glib qw/TRUE FALSE/; @@ -61,7 +61,7 @@ sub dlg_info_message { my $content_widget = shift; my $content_widget2 = shift; - my $info_dialog = Gtk2::MessageDialog->new($self->{_window}, [qw/modal destroy-with-parent/], 'info', 'none', undef); + my $info_dialog = Gtk3::MessageDialog->new($self->{_window}, [qw/modal destroy-with-parent/], 'info', 'none', undef); $info_dialog->set_title("Shutter"); @@ -86,32 +86,32 @@ sub dlg_info_message { #show a detailed message (use expander to show it) if ($detail_message) { - my $expander = Gtk2::Expander->new_with_mnemonic('Show more _details'); - my $detail_label = Gtk2::Label->new($detail_message); + my $expander = Gtk3::Expander->new_with_mnemonic('Show more _details'); + my $detail_label = Gtk3::Label->new($detail_message); $detail_label->set_width_chars(50); $detail_label->set_line_wrap(TRUE); $detail_label->set_alignment(0, 0.5); $expander->add($detail_label); - my $detail_hbox = Gtk2::HBox->new(); - $detail_hbox->pack_start(Gtk2::Label->new, FALSE, FALSE, 12); - $detail_hbox->pack_start_defaults($expander); - $info_dialog->vbox->add($detail_hbox); + my $detail_hbox = Gtk3::HBox->new(); + $detail_hbox->pack_start(Gtk3::Label->new, FALSE, FALSE, 12); + $detail_hbox->pack_start($expander, TRUE, TRUE, 0); + $info_dialog->get_child->add($detail_hbox); } #show a detailed message with checkbox my $dcheck = undef; if ($detail_checkbox) { - $dcheck = Gtk2::CheckButton->new_with_mnemonic($detail_checkbox); - my $detail_hbox = Gtk2::HBox->new(); - $detail_hbox->pack_start(Gtk2::Label->new, FALSE, FALSE, 12); - $detail_hbox->pack_start_defaults($dcheck); - $info_dialog->vbox->add($detail_hbox); + $dcheck = Gtk3::CheckButton->new_with_mnemonic($detail_checkbox); + my $detail_hbox = Gtk3::HBox->new(); + $detail_hbox->pack_start(Gtk3::Label->new, FALSE, FALSE, 12); + $detail_hbox->pack_start($dcheck, TRUE, TRUE, 0); + $info_dialog->get_child->add($detail_hbox); } $info_dialog->show_all; - if (defined $self->{_gdk_window} && $self->{_gdk_window} =~ /Gtk2::Gdk::Window/) { - $info_dialog->window->set_transient_for($self->{_gdk_window}); + if (defined $self->{_gdk_window} && $self->{_gdk_window} =~ /Gtk3::Gdk::Window|Gtk3::GdkX11::X11Window/) { + $info_dialog->get_window->set_transient_for($self->{_gdk_window}); } else { $info_dialog->set_transient_for($self->{_window}); } @@ -138,11 +138,11 @@ sub dlg_question_message { my $detail_message = shift; my $detail_checkbox = shift; - my $question_dialog = Gtk2::MessageDialog->new($self->{_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); + my $question_dialog = Gtk3::MessageDialog->new($self->{_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); $question_dialog->set_title("Shutter"); - $question_dialog->set('image' => Gtk2::Image->new_from_stock('gtk-dialog-question', 'dialog')); + $question_dialog->set('image' => Gtk3::Image->new_from_stock('gtk-dialog-question', 'dialog')); $question_dialog->set('text' => $dlg_question_header); @@ -158,32 +158,32 @@ sub dlg_question_message { #show a detailed message (use expander to show it) if ($detail_message) { - my $expander = Gtk2::Expander->new_with_mnemonic('Show more _details'); - my $detail_label = Gtk2::Label->new($detail_message); + my $expander = Gtk3::Expander->new_with_mnemonic('Show more _details'); + my $detail_label = Gtk3::Label->new($detail_message); $detail_label->set_width_chars(50); $detail_label->set_line_wrap(TRUE); $detail_label->set_alignment(0, 0.5); $expander->add($detail_label); - my $detail_hbox = Gtk2::HBox->new(); - $detail_hbox->pack_start(Gtk2::Label->new, FALSE, FALSE, 12); - $detail_hbox->pack_start_defaults($expander); - $question_dialog->vbox->add($detail_hbox); + my $detail_hbox = Gtk3::HBox->new(); + $detail_hbox->pack_start(Gtk3::Label->new, FALSE, FALSE, 12); + $detail_hbox->pack_start($expander, TRUE, TRUE, 0); + $question_dialog->get_child->add($detail_hbox); } #show a detailed message with checkbox my $dcheck = undef; if ($detail_checkbox) { - $dcheck = Gtk2::CheckButton->new_with_mnemonic($detail_checkbox); - my $detail_hbox = Gtk2::HBox->new(); - $detail_hbox->pack_start(Gtk2::Label->new, FALSE, FALSE, 12); - $detail_hbox->pack_start_defaults($dcheck); - $question_dialog->vbox->add($detail_hbox); + $dcheck = Gtk3::CheckButton->new_with_mnemonic($detail_checkbox); + my $detail_hbox = Gtk3::HBox->new(); + $detail_hbox->pack_start(Gtk3::Label->new, FALSE, FALSE, 12); + $detail_hbox->pack_start($dcheck, TRUE, TRUE, 0); + $question_dialog->get_child->add($detail_hbox); } $question_dialog->show_all; - if (defined $self->{_gdk_window} && $self->{_gdk_window} =~ /Gtk2::Gdk::Window/) { - $question_dialog->window->set_transient_for($self->{_gdk_window}); + if (defined $self->{_gdk_window} && $self->{_gdk_window} =~ /Gtk3::Gdk::Window|Gtk3::GdkX11::X11Window/) { + $question_dialog->get_window->set_transient_for($self->{_gdk_window}); } else { $question_dialog->set_transient_for($self->{_window}); } @@ -214,11 +214,11 @@ sub dlg_error_message { my $button_widget_extra3 = shift; my $detail_message = shift; - my $error_dialog = Gtk2::MessageDialog->new($self->{_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); + my $error_dialog = Gtk3::MessageDialog->new($self->{_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); $error_dialog->set_title("Shutter"); - $error_dialog->set('image' => Gtk2::Image->new_from_stock('gtk-dialog-error', 'dialog')); + $error_dialog->set('image' => Gtk3::Image->new_from_stock('gtk-dialog-error', 'dialog')); $error_dialog->set('text' => $dlg_error_header); @@ -235,22 +235,22 @@ sub dlg_error_message { #show a detailed message (use expander to show it) if ($detail_message) { - my $expander = Gtk2::Expander->new_with_mnemonic('Show more _details'); - my $detail_label = Gtk2::Label->new($detail_message); + my $expander = Gtk3::Expander->new_with_mnemonic('Show more _details'); + my $detail_label = Gtk3::Label->new($detail_message); $detail_label->set_width_chars(50); $detail_label->set_line_wrap(TRUE); $detail_label->set_alignment(0, 0.5); $expander->add($detail_label); - my $detail_hbox = Gtk2::HBox->new(); - $detail_hbox->pack_start(Gtk2::Label->new, FALSE, FALSE, 12); - $detail_hbox->pack_start_defaults($expander); - $error_dialog->vbox->add($detail_hbox); + my $detail_hbox = Gtk3::HBox->new(); + $detail_hbox->pack_start(Gtk3::Label->new, FALSE, FALSE, 12); + $detail_hbox->pack_start($expander, TRUE, TRUE, 0); + $error_dialog->get_child->add($detail_hbox); } $error_dialog->show_all; - if (defined $self->{_gdk_window} && $self->{_gdk_window} =~ /Gtk2::Gdk::Window/) { - $error_dialog->window->set_transient_for($self->{_gdk_window}); + if (defined $self->{_gdk_window} && $self->{_gdk_window} =~ /Gtk3::Gdk::Window|Gtk3::GdkX11::X11Window/) { + $error_dialog->get_window->set_transient_for($self->{_gdk_window}); } else { $error_dialog->set_transient_for($self->{_window}); } @@ -276,11 +276,11 @@ sub dlg_warning_message { my $button_widget_extra3 = shift; my $detail_message = shift; - my $warning_dialog = Gtk2::MessageDialog->new($self->{_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); + my $warning_dialog = Gtk3::MessageDialog->new($self->{_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); $warning_dialog->set_title("Shutter"); - $warning_dialog->set('image' => Gtk2::Image->new_from_stock('gtk-dialog-warning', 'dialog')); + $warning_dialog->set('image' => Gtk3::Image->new_from_stock('gtk-dialog-warning', 'dialog')); $warning_dialog->set('text' => $dlg_warning_header); @@ -297,22 +297,22 @@ sub dlg_warning_message { #show a detailed message (use expander to show it) if ($detail_message) { - my $expander = Gtk2::Expander->new_with_mnemonic('Show more _details'); - my $detail_label = Gtk2::Label->new($detail_message); + my $expander = Gtk3::Expander->new_with_mnemonic('Show more _details'); + my $detail_label = Gtk3::Label->new($detail_message); $detail_label->set_width_chars(50); $detail_label->set_line_wrap(TRUE); $detail_label->set_alignment(0, 0.5); $expander->add($detail_label); - my $detail_hbox = Gtk2::HBox->new(); - $detail_hbox->pack_start(Gtk2::Label->new, FALSE, FALSE, 12); - $detail_hbox->pack_start_defaults($expander); - $warning_dialog->vbox->add($detail_hbox); + my $detail_hbox = Gtk3::HBox->new(); + $detail_hbox->pack_start(Gtk3::Label->new, FALSE, FALSE, 12); + $detail_hbox->pack_start($expander, TRUE, TRUE, 0); + $warning_dialog->get_child->add($detail_hbox); } $warning_dialog->show_all; - if (defined $self->{_gdk_window} && $self->{_gdk_window} =~ /Gtk2::Gdk::Window/) { - $warning_dialog->window->set_transient_for($self->{_gdk_window}); + if (defined $self->{_gdk_window} && $self->{_gdk_window} =~ /Gtk3::Gdk::Window|Gtk3::GdkX11::X11Window/) { + $warning_dialog->get_window->set_transient_for($self->{_gdk_window}); } else { $warning_dialog->set_transient_for($self->{_window}); } diff --git a/share/shutter/resources/modules/Shutter/App/Toolbar.pm b/share/shutter/resources/modules/Shutter/App/Toolbar.pm index feef0d241..016ccbb53 100644 --- a/share/shutter/resources/modules/Shutter/App/Toolbar.pm +++ b/share/shutter/resources/modules/Shutter/App/Toolbar.pm @@ -26,7 +26,7 @@ package Shutter::App::Toolbar; #-------------------------------------- use utf8; use strict; -use Gtk2; +use Gtk3; #Glib use Glib qw/TRUE FALSE/; @@ -35,9 +35,13 @@ use Glib qw/TRUE FALSE/; sub new { my $class = shift; + my $sc = shift; #constructor - my $self = {_common => shift}; + my $self = { + _common => $sc, + _shf => Shutter::App::HelperFunctions->new($sc), + }; bless $self, $class; return $self; @@ -55,8 +59,8 @@ sub create_toolbar { #button redoshot #-------------------------------------- - my $image_redoshot = Gtk2::Image->new_from_stock('gtk-refresh', 'large-toolbar'); - $self->{_redoshot} = Gtk2::ToolButton->new($image_redoshot, $d->get("Redo")); + my $image_redoshot = Gtk3::Image->new_from_stock('gtk-refresh', 'large-toolbar'); + $self->{_redoshot} = Gtk3::ToolButton->new($image_redoshot, $d->get("Redo")); #~ $self->{_redoshot}->set_is_important (TRUE); @@ -68,19 +72,19 @@ sub create_toolbar { #-------------------------------------- my $image_select; eval { - my $ccursor_pb = Gtk2::Gdk::Cursor->new('left_ptr')->get_image->scale_simple(Gtk2::IconSize->lookup('large-toolbar'), 'bilinear'); - $image_select = Gtk2::Image->new_from_pixbuf($ccursor_pb); + my $ccursor_pb = Gtk3::Gdk::Cursor->new('left_ptr')->get_image->scale_simple($self->{_shf}->icon_size('large-toolbar'), 'bilinear'); + $image_select = Gtk3::Image->new_from_pixbuf($ccursor_pb); }; if ($@) { if ($icontheme->has_icon('applications-accessories')) { - $image_select = Gtk2::Image->new_from_icon_name('applications-accessories', 'large-toolbar'); + $image_select = Gtk3::Image->new_from_icon_name('applications-accessories', 'large-toolbar'); } else { $image_select = - Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/selection.svg", Gtk2::IconSize->lookup('large-toolbar'))); + Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/selection.svg", $self->{_shf}->icon_size('large-toolbar'))); } } - $self->{_select} = Gtk2::ToolButton->new($image_select, $d->get("Selection")); + $self->{_select} = Gtk3::ToolButton->new($image_select, $d->get("Selection")); #The GtkToolButton class uses this property to determine whether #to show or hide its label when the toolbar style is GTK_TOOLBAR_BOTH_HORIZ. @@ -96,13 +100,13 @@ sub create_toolbar { #-------------------------------------- my $image_full; if ($icontheme->has_icon('user-desktop')) { - $image_full = Gtk2::Image->new_from_icon_name('user-desktop', 'large-toolbar'); + $image_full = Gtk3::Image->new_from_icon_name('user-desktop', 'large-toolbar'); } elsif ($icontheme->has_icon('desktop')) { - $image_full = Gtk2::Image->new_from_icon_name('desktop', 'large-toolbar'); + $image_full = Gtk3::Image->new_from_icon_name('desktop', 'large-toolbar'); } else { - $image_full = Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/desktop.svg", Gtk2::IconSize->lookup('large-toolbar'))); + $image_full = Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/desktop.svg", $self->{_shf}->icon_size('large-toolbar'))); } - $self->{_full} = Gtk2::MenuToolButton->new($image_full, $d->get("Desktop")); + $self->{_full} = Gtk3::MenuToolButton->new($image_full, $d->get("Desktop")); $self->{_full}->set_is_important(TRUE); $self->{_full}->set_tooltip_text($d->get("Take a screenshot of your whole desktop")); @@ -114,16 +118,16 @@ sub create_toolbar { #-------------------------------------- #~ my $image_awindow; #~ if($icontheme->has_icon('preferences-system-windows')){ - #~ $image_awindow = Gtk2::Image->new_from_icon_name( 'preferences-system-windows', 'large-toolbar' ); + #~ $image_awindow = Gtk3::Image->new_from_icon_name( 'preferences-system-windows', 'large-toolbar' ); #~ }else{ - #~ $image_awindow = Gtk2::Image->new_from_pixbuf( - #~ Gtk2::Gdk::Pixbuf->new_from_file_at_size( + #~ $image_awindow = Gtk3::Image->new_from_pixbuf( + #~ Gtk3::Gdk::Pixbuf->new_from_file_at_size( #~ "$shutter_root/share/shutter/resources/icons/sel_window_active.svg", - #~ Gtk2::IconSize->lookup('large-toolbar') + #~ $self->{_shf}->icon_size('large-toolbar') #~ ) #~ ); #~ } - #~ $self->{_awindow} = Gtk2::MenuToolButton->new( $image_awindow, $d->get("Window") ); + #~ $self->{_awindow} = Gtk3::MenuToolButton->new( $image_awindow, $d->get("Window") ); #~ $self->{_awindow}->set_is_important (TRUE); #~ #~ $self->{_awindow}->set_tooltip_text($d->get("Capture active window") ); @@ -135,11 +139,11 @@ sub create_toolbar { #-------------------------------------- my $image_window; if ($icontheme->has_icon('preferences-system-windows')) { - $image_window = Gtk2::Image->new_from_icon_name('preferences-system-windows', 'large-toolbar'); + $image_window = Gtk3::Image->new_from_icon_name('preferences-system-windows', 'large-toolbar'); } else { - $image_window = Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window.svg", Gtk2::IconSize->lookup('large-toolbar'))); + $image_window = Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window.svg", $self->{_shf}->icon_size('large-toolbar'))); } - $self->{_window} = Gtk2::MenuToolButton->new($image_window, $d->get("Window")); + $self->{_window} = Gtk3::MenuToolButton->new($image_window, $d->get("Window")); $self->{_window}->set_is_important(TRUE); $self->{_window}->set_tooltip_text($d->get("Select a window with your mouse")); @@ -149,12 +153,12 @@ sub create_toolbar { #-------------------------------------- my $image_window_sect; if ($icontheme->has_icon('gdm-xnest')) { - $image_window_sect = Gtk2::Image->new_from_icon_name('gdm-xnest', 'large-toolbar'); + $image_window_sect = Gtk3::Image->new_from_icon_name('gdm-xnest', 'large-toolbar'); } else { $image_window_sect = - Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_section.svg", Gtk2::IconSize->lookup('large-toolbar'))); + Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_section.svg", $self->{_shf}->icon_size('large-toolbar'))); } - $self->{_section} = Gtk2::ToolButton->new($image_window_sect, $d->get("Section")); + $self->{_section} = Gtk3::ToolButton->new($image_window_sect, $d->get("Section")); $self->{_section}->set_tooltip_text($d->get("Captures only a section of the window. You will be able to select any child window by moving the mouse over it")); @@ -164,12 +168,12 @@ sub create_toolbar { #-------------------------------------- my $image_window_menu; if ($icontheme->has_icon('alacarte')) { - $image_window_menu = Gtk2::Image->new_from_icon_name('alacarte', 'large-toolbar'); + $image_window_menu = Gtk3::Image->new_from_icon_name('alacarte', 'large-toolbar'); } else { $image_window_menu = - Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_menu.svg", Gtk2::IconSize->lookup('large-toolbar'))); + Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_menu.svg", $self->{_shf}->icon_size('large-toolbar'))); } - $self->{_menu} = Gtk2::ToolButton->new($image_window_menu, $d->get("Menu")); + $self->{_menu} = Gtk3::ToolButton->new($image_window_menu, $d->get("Menu")); $self->{_menu}->set_tooltip_text($d->get("Select a single menu or cascading menus from any application")); @@ -179,12 +183,12 @@ sub create_toolbar { #-------------------------------------- my $image_window_tooltip; if ($icontheme->has_icon('help-faq')) { - $image_window_tooltip = Gtk2::Image->new_from_icon_name('help-faq', 'large-toolbar'); + $image_window_tooltip = Gtk3::Image->new_from_icon_name('help-faq', 'large-toolbar'); } else { $image_window_tooltip = - Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_tooltip.svg", Gtk2::IconSize->lookup('large-toolbar'))); + Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/sel_window_tooltip.svg", $self->{_shf}->icon_size('large-toolbar'))); } - $self->{_tooltip} = Gtk2::ToolButton->new($image_window_tooltip, $d->get("Tooltip")); + $self->{_tooltip} = Gtk3::ToolButton->new($image_window_tooltip, $d->get("Tooltip")); $self->{_tooltip}->set_tooltip_text($d->get("Capture a tooltip")); @@ -194,11 +198,11 @@ sub create_toolbar { #-------------------------------------- my $image_web; if ($icontheme->has_icon('web-browser')) { - $image_web = Gtk2::Image->new_from_icon_name('web-browser', 'large-toolbar'); + $image_web = Gtk3::Image->new_from_icon_name('web-browser', 'large-toolbar'); } else { - $image_web = Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/web_image.svg", Gtk2::IconSize->lookup('large-toolbar'))); + $image_web = Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/web_image.svg", $self->{_shf}->icon_size('large-toolbar'))); } - $self->{_web} = Gtk2::MenuToolButton->new($image_web, $d->get("Web")); + $self->{_web} = Gtk3::MenuToolButton->new($image_web, $d->get("Web")); $self->{_web}->set_tooltip_text($d->get("Take a screenshot of a website")); $self->{_web}->set_arrow_tooltip_text($d->get("Set how long Shutter will wait for the screenshot to complete before aborting the process if it's taking too long")); @@ -207,7 +211,7 @@ sub create_toolbar { #expanding separator #-------------------------------------- - my $expander_r = Gtk2::SeparatorToolItem->new; + my $expander_r = Gtk3::SeparatorToolItem->new; $expander_r->set_expand(TRUE); $expander_r->set_draw(FALSE); @@ -215,11 +219,11 @@ sub create_toolbar { #-------------------------------------- my $image_edit; if ($icontheme->has_icon('applications-graphics')) { - $image_edit = Gtk2::Image->new_from_icon_name('applications-graphics', 'large-toolbar'); + $image_edit = Gtk3::Image->new_from_icon_name('applications-graphics', 'large-toolbar'); } else { - $image_edit = Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/draw.svg", Gtk2::IconSize->lookup('large-toolbar'))); + $image_edit = Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size("$shutter_root/share/shutter/resources/icons/draw.svg", $self->{_shf}->icon_size('large-toolbar'))); } - $self->{_edit} = Gtk2::ToolButton->new($image_edit, $d->get("Edit")); + $self->{_edit} = Gtk3::ToolButton->new($image_edit, $d->get("Edit")); $self->{_edit}->set_is_important(TRUE); $self->{_edit}->set_tooltip_text($d->get("Use the built-in editor to highlight important fragments of your screenshot or crop it to a desired size")); @@ -228,8 +232,8 @@ sub create_toolbar { #button upload #-------------------------------------- - my $image_upload = Gtk2::Image->new_from_stock('gtk-network', 'large-toolbar'); - $self->{_upload} = Gtk2::MenuToolButton->new($image_upload, $d->get("Export")); + my $image_upload = Gtk3::Image->new_from_stock('gtk-network', 'large-toolbar'); + $self->{_upload} = Gtk3::MenuToolButton->new($image_upload, $d->get("Export")); $self->{_upload}->set_is_important(TRUE); $self->{_upload}->set_tooltip_text($d->get("Upload your images to an image hosting service, FTP site or export them to an arbitrary folder")); @@ -238,24 +242,24 @@ sub create_toolbar { #-------------------------------------- #create the toolbar - $self->{_toolbar} = Gtk2::Toolbar->new; + $self->{_toolbar} = Gtk3::Toolbar->new; $self->{_toolbar}->set_show_arrow(FALSE); $self->{_toolbar}->insert($self->{_redoshot}, -1); - $self->{_toolbar}->insert(Gtk2::SeparatorToolItem->new, -1); + $self->{_toolbar}->insert(Gtk3::SeparatorToolItem->new, -1); $self->{_toolbar}->insert($self->{_select}, -1); $self->{_toolbar}->insert($self->{_full}, -1); - #~ $self->{_toolbar}->insert( Gtk2::SeparatorToolItem->new, -1 ); + #~ $self->{_toolbar}->insert( Gtk3::SeparatorToolItem->new, -1 ); #~ $self->{_toolbar}->insert( $self->{_aindow}, -1 ); $self->{_toolbar}->insert($self->{_window}, -1); $self->{_toolbar}->insert($self->{_section}, -1); $self->{_toolbar}->insert($self->{_menu}, -1); $self->{_toolbar}->insert($self->{_tooltip}, -1); - #~ $self->{_toolbar}->insert( Gtk2::SeparatorToolItem->new, -1 ); + #~ $self->{_toolbar}->insert( Gtk3::SeparatorToolItem->new, -1 ); $self->{_toolbar}->insert($self->{_web}, -1); - #~ $self->{_toolbar}->insert( Gtk2::SeparatorToolItem->new, -1 ); + #~ $self->{_toolbar}->insert( Gtk3::SeparatorToolItem->new, -1 ); $self->{_toolbar}->insert($expander_r, -1); $self->{_toolbar}->insert($self->{_edit}, -1); $self->{_toolbar}->insert($self->{_upload}, -1); @@ -275,7 +279,7 @@ sub create_btoolbar { #expanding separator #-------------------------------------- - my $expander_l = Gtk2::SeparatorToolItem->new; + my $expander_l = Gtk3::SeparatorToolItem->new; $expander_l->set_expand(TRUE); $expander_l->set_draw(FALSE); @@ -283,51 +287,51 @@ sub create_btoolbar { #button ascending #-------------------------------------- - my $image_sorta = Gtk2::Image->new_from_stock('gtk-sort-ascending', 'small-toolbar'); - $self->{_sorta} = Gtk2::ToggleToolButton->new(); + my $image_sorta = Gtk3::Image->new_from_stock('gtk-sort-ascending', 'small-toolbar'); + $self->{_sorta} = Gtk3::ToggleToolButton->new(); $self->{_sorta}->set_icon_widget($image_sorta); #-------------------------------------- #button back #-------------------------------------- - my $image_back = Gtk2::Image->new_from_stock('gtk-go-back', 'small-toolbar'); - $self->{_back} = Gtk2::ToolButton->new($image_back, ''); + my $image_back = Gtk3::Image->new_from_stock('gtk-go-back', 'small-toolbar'); + $self->{_back} = Gtk3::ToolButton->new($image_back, ''); #-------------------------------------- #button home #-------------------------------------- - my $image_home = Gtk2::Image->new_from_stock('gtk-index', 'small-toolbar'); - $self->{_home} = Gtk2::ToolButton->new($image_home, ''); + my $image_home = Gtk3::Image->new_from_stock('gtk-index', 'small-toolbar'); + $self->{_home} = Gtk3::ToolButton->new($image_home, ''); #-------------------------------------- #button forward #-------------------------------------- - my $image_forw = Gtk2::Image->new_from_stock('gtk-go-forward', 'small-toolbar'); - $self->{_forw} = Gtk2::ToolButton->new($image_forw, ''); + my $image_forw = Gtk3::Image->new_from_stock('gtk-go-forward', 'small-toolbar'); + $self->{_forw} = Gtk3::ToolButton->new($image_forw, ''); #-------------------------------------- #button sort descending #-------------------------------------- - my $image_sortd = Gtk2::Image->new_from_stock('gtk-sort-descending', 'small-toolbar'); - $self->{_sortd} = Gtk2::ToggleToolButton->new(); + my $image_sortd = Gtk3::Image->new_from_stock('gtk-sort-descending', 'small-toolbar'); + $self->{_sortd} = Gtk3::ToggleToolButton->new(); $self->{_sortd}->set_icon_widget($image_sortd); #-------------------------------------- #expanding separator #-------------------------------------- - my $expander_r = Gtk2::SeparatorToolItem->new; + my $expander_r = Gtk3::SeparatorToolItem->new; $expander_r->set_expand(TRUE); $expander_r->set_draw(FALSE); #-------------------------------------- #create the toolbar - $self->{_btoolbar} = Gtk2::Toolbar->new; + $self->{_btoolbar} = Gtk3::Toolbar->new; $self->{_btoolbar}->set_no_show_all(TRUE); $self->{_btoolbar}->set_show_arrow(FALSE); $self->{_btoolbar}->set_style('icons'); diff --git a/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm b/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm index 23d56f37f..47c956855 100644 --- a/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm +++ b/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm @@ -22,6 +22,17 @@ #perl -x -S perltidy -l=0 -b "%f" +# Native Gtk3::IconSize doesn't work for some reason +# FIXME This package should be cleaned up when fixing DrawingTool +package Gtk3::IconSize; +sub lookup { + my $self = shift; + my $size = shift; + Shutter::App::HelperFunctions->icon_size($size); +} + +1; + package Shutter::Draw::DrawingTool; #modules @@ -30,10 +41,11 @@ use utf8; use strict; use warnings; -use Gtk2; +use Gtk3; use Exporter; -use Goo::Canvas; +use GooCanvas2; +use GooCanvas2::CairoTypes; use File::Basename qw/ fileparse dirname basename /; use File::Glob qw/ bsd_glob /; use File::Temp qw/ tempfile tempdir /; @@ -54,13 +66,15 @@ sub new { my $class = shift; my $self = {_sc => shift}; + $self->{_shf} = Shutter::App::HelperFunctions->new($self->{_sc}); #view, selector, dragger - $self->{_view} = Gtk2::ImageView->new; - $self->{_selector} = Gtk2::ImageView::Tool::Selector->new($self->{_view}); - $self->{_dragger} = Gtk2::ImageView::Tool::Dragger->new($self->{_view}); - $self->{_view}->set_interpolation('tiles'); + $self->{_view} = Gtk3::ImageView->new; + $self->{_selector} = Gtk3::ImageView::Tool::Selector->new($self->{_view}); + $self->{_dragger} = Gtk3::ImageView::Tool::Dragger->new($self->{_view}); $self->{_view}->set_tool($self->{_selector}); + $self->{_view_css_provider_alpha} = Gtk3::CssProvider->new; + $self->{_view}->get_style_context->add_provider($self->{_view_css_provider_alpha}, 0); #WORKAROUND #upstream bug @@ -83,13 +97,17 @@ sub new { #ignore zoom values greater 10 (see: #654185) $self->{_view}->signal_connect( 'zoom-changed' => sub { - if ($self->{_view}->get_zoom > 10) { - $self->{_view}->set_zoom(10); + my ($view, $zoom) = @_; + if ($zoom >= 1) { + $view->set_interpolation('nearest'); + $view->set_zoom(10) if $zoom > 10; + } else { + $view->set_interpolation('bilinear'); } }); #clipboard - $self->{_clipboard} = Gtk2::Clipboard->get(Gtk2::Gdk->SELECTION_CLIPBOARD); + $self->{_clipboard} = Gtk3::Clipboard::get($Gtk3::Gdk::SELECTION_CLIPBOARD); #file $self->{_filename} = undef; @@ -121,24 +139,25 @@ sub new { #drawing colors and line width #general - shown in the bottom hbox - $self->{_fill_color} = Gtk2::Gdk::Color->parse('#0000ff'); - $self->{_fill_color_alpha} = 0.25; - $self->{_stroke_color} = Gtk2::Gdk::Color->parse('#ff0000'); - $self->{_stroke_color_alpha} = 1; + $self->{_fill_color} = Gtk3::Gdk::RGBA::parse('#0000ff'); + $self->{_fill_color}->alpha(0.25); + $self->{_stroke_color} = Gtk3::Gdk::RGBA::parse('#ff0000'); + $self->{_stroke_color}->alpha(1); $self->{_line_width} = 3; $self->{_font} = 'Sans Regular 16'; #obtain current colors and font_desc from the main window - $self->{_style} = $self->{_sc}->get_mainwindow->get_style; - $self->{_style_bg} = $self->{_style}->bg('selected'); - $self->{_style_tx} = $self->{_style}->text('selected'); + $self->{_style} = $self->{_sc}->get_mainwindow->get_style_context; + $self->{_style_bg} = $self->{_style}->get_background_color('selected'); + $self->{_style_bg}->alpha(1); + #$self->{_style_tx} = $self->{_style}->text('selected'); #remember drawing colors, line width and font settings #maybe we have to restore them - $self->{_last_fill_color} = Gtk2::Gdk::Color->parse('#0000ff'); - $self->{_last_fill_color_alpha} = 0.25; - $self->{_last_stroke_color} = Gtk2::Gdk::Color->parse('#ff0000'); - $self->{_last_stroke_color_alpha} = 1; + $self->{_last_fill_color} = Gtk3::Gdk::RGBA::parse('#0000ff'); + $self->{_last_fill_color}->alpha(0.25); + $self->{_last_stroke_color} = Gtk3::Gdk::RGBA::parse('#ff0000'); + $self->{_last_stroke_color}->alpha(1); $self->{_last_line_width} = 3; $self->{_last_font} = 'Sans Regular 16'; @@ -156,6 +175,8 @@ sub new { $self->{_start_time} = undef; + $self->{_stipple_pixbuf} = Gtk3::Gdk::Pixbuf->new_from_file($self->{_sc}{_shutter_root} . '/share/shutter/resources/gui/stipple.png'); + bless $self, $class; return $self; @@ -185,11 +206,11 @@ sub show { #MAIN WINDOW #------------------------------------------------- - $self->{_root} = Gtk2::Gdk->get_default_root_window; + $self->{_root} = Gtk3::Gdk::get_default_root_window(); ($self->{_root}->{x}, $self->{_root}->{y}, $self->{_root}->{w}, $self->{_root}->{h}) = $self->{_root}->get_geometry; ($self->{_root}->{x}, $self->{_root}->{y}) = $self->{_root}->get_origin; - $self->{_drawing_window} = Gtk2::Window->new('toplevel'); + $self->{_drawing_window} = Gtk3::Window->new('toplevel'); if (defined $self->{_is_unsaved} && $self->{_is_unsaved}) { $self->{_drawing_window}->set_title("*" . $self->{_name} . " - Shutter DrawingTool"); } else { @@ -218,7 +239,7 @@ sub show { my @cursors = bsd_glob($self->{_dicons} . "/cursor/*"); foreach my $cursor_path (@cursors) { my ($cname, $folder, $type) = fileparse($cursor_path, qr/\.[^.]*/); - $self->{_cursors}{$cname} = Gtk2::Gdk::Pixbuf->new_from_file($cursor_path); + $self->{_cursors}{$cname} = Gtk3::Gdk::Pixbuf->new_from_file($cursor_path); #see 'man xcursor' for a detailed description #of these values @@ -241,17 +262,21 @@ sub show { #CANVAS #------------------------------------------------- - $self->{_canvas} = Goo::Canvas->new(); + $self->{_canvas} = GooCanvas2::Canvas->new(); #enable dnd for it - $self->{_canvas}->drag_dest_set('all', ['copy', 'private', 'default', 'move', 'link', 'ask']); + $self->{_canvas}->drag_dest_set('all', [Gtk3::TargetEntry->new('text/uri-list', [], 0)], 'copy'); $self->{_canvas}->signal_connect(drag_data_received => sub { $self->import_from_dnd(@_) }); - - my $target_list = Gtk2::TargetList->new(); - my $atom1 = Gtk2::Gdk::Atom->new('text/uri-list'); - $target_list->add($atom1, 0, 0); - - $self->{_canvas}->drag_dest_set_target_list($target_list); + $self->{_canvas}->signal_connect(drag_motion => sub { + my ($view, $ctx, $x, $y, $time) = @_; + for my $target (@{$ctx->list_targets}) { + if ($target->name eq 'text/uri-list') { + Gtk3::Gdk::drag_status($ctx, 'copy', $time); + return TRUE; + } + } + return FALSE; + }); #'redraw-when-scrolled' to reduce the flicker of static items # @@ -262,7 +287,7 @@ sub show { $self->{_canvas}->set('redraw-when-scrolled' => TRUE); } - #~ my $bg = Gtk2::Gdk::Color->parse('gray'); + #~ my $bg = Gtk3::Gdk::RGBA::parse('gray'); $self->{_canvas}->set( 'automatic-bounds' => FALSE, 'bounds-from-origin' => FALSE, @@ -272,17 +297,17 @@ sub show { #and attach scroll event #to imitate scroll behavior of - #Gtk2::ImageView widget Ctrl+Mouse Wheel + #Gtk3::ImageView widget Ctrl+Mouse Wheel $self->{_canvas}->signal_connect( 'scroll-event' => sub { my ($canvas, $ev) = @_; - my $alloc = $self->{_canvas}->allocation; + my $alloc = $self->{_canvas}->get_allocation; my $scale = $canvas->get_scale; if ($ev->state >= 'control-mask' && ($ev->direction eq 'up' || $ev->direction eq 'left')) { $self->zoom_in_cb; - $canvas->scroll_to(int($ev->x - $alloc->width / 2) / $scale, int($ev->y - $alloc->height / 2) / $scale); + $canvas->scroll_to(int($ev->x - $alloc->{width} / 2) / $scale, int($ev->y - $alloc->{height} / 2) / $scale); return TRUE; } elsif ($ev->state >= 'control-mask' && ($ev->direction eq 'down' || $ev->direction eq 'right')) { $self->zoom_out_cb; @@ -292,17 +317,16 @@ sub show { }); #create rectangle to resize the background - my $bg_color = $self->create_color(Gtk2::Gdk::Color->parse('gray'), 1.0); - $self->{_canvas_bg_rect} = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, 0, 0, $self->{_drawing_pixbuf}->get_width, $self->{_drawing_pixbuf}->get_height, - 'fill-pattern' => $bg_color, - 'line-dash' => Goo::Canvas::LineDash->new([5, 5]), + $self->{_canvas_bg_rect} = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>0, y=>0, width=>$self->{_drawing_pixbuf}->get_width, height=>$self->{_drawing_pixbuf}->get_height, + 'fill-color-gdk-rgba' => Gtk3::Gdk::RGBA::parse('gray'), + 'line-dash' => GooCanvas2::CanvasLineDash->newv([5, 5]), 'line-width' => 1, 'stroke-color' => 'black', ); #save color - $self->{_canvas_bg_rect}{fill_color} = Gtk2::Gdk::Color->parse('gray'); + $self->{_canvas_bg_rect}{fill_color} = Gtk3::Gdk::RGBA::parse('gray'); $self->setup_item_signals($self->{_canvas_bg_rect}); $self->handle_bg_rects('create'); @@ -321,9 +345,9 @@ sub show { $self->{_current_pixbuf} = $self->{_drawing_pixbuf}; #construct an event and create a new image object - my $initevent = Gtk2::Gdk::Event->new('motion-notify'); - $initevent->set_time(Gtk2->get_current_event_time); - $initevent->window($self->{_drawing_window}->window); + my $initevent = Gtk3::Gdk::Event->new('motion-notify'); + $initevent->time(Gtk3::get_current_event_time()); + $initevent->window($self->{_drawing_window}->get_window); $initevent->x(int($self->{_canvas_bg_rect}->get('width') / 2)); $initevent->y(int($self->{_canvas_bg_rect}->get('height') / 2)); @@ -338,11 +362,11 @@ sub show { #PACKING #------------------------------------------------- - $self->{_drawing_vbox} = Gtk2::VBox->new(FALSE, 0); - $self->{_drawing_inner_vbox} = Gtk2::VBox->new(FALSE, 0); - $self->{_drawing_inner_vbox_c} = Gtk2::VBox->new(FALSE, 0); - $self->{_drawing_hbox} = Gtk2::HBox->new(FALSE, 0); - $self->{_drawing_hbox_c} = Gtk2::HBox->new(FALSE, 0); + $self->{_drawing_vbox} = Gtk3::VBox->new(FALSE, 0); + $self->{_drawing_inner_vbox} = Gtk3::VBox->new(FALSE, 0); + $self->{_drawing_inner_vbox_c} = Gtk3::VBox->new(FALSE, 0); + $self->{_drawing_hbox} = Gtk3::HBox->new(FALSE, 0); + $self->{_drawing_hbox_c} = Gtk3::HBox->new(FALSE, 0); #mark some actions as important $self->{_uimanager}->get_widget("/ToolBar/Close")->set_is_important(TRUE); @@ -371,29 +395,29 @@ sub show { #DRAWING TOOL CONTAINER #------------------------------------------------- #scrolled window for the canvas - $self->{_scrolled_window} = Gtk2::ScrolledWindow->new; + $self->{_scrolled_window} = Gtk3::ScrolledWindow->new; $self->{_scrolled_window}->set_policy('automatic', 'automatic'); $self->{_scrolled_window}->add($self->{_canvas}); $self->{_hscroll_hid} = $self->{_scrolled_window}->get_hscrollbar->signal_connect('value-changed' => sub { $self->adjust_rulers }); $self->{_vscroll_hid} = $self->{_scrolled_window}->get_vscrollbar->signal_connect('value-changed' => sub { $self->adjust_rulers }); #vruler - $self->{_vruler} = Gtk2::VRuler->new; - $self->{_vruler}->set_metric('pixels'); - $self->{_vruler}->set_range(0, $self->{_drawing_pixbuf}->get_height, 0, $self->{_drawing_pixbuf}->get_height); + #$self->{_vruler} = Gtk3::VRuler->new; + #$self->{_vruler}->set_metric('pixels'); + #$self->{_vruler}->set_range(0, $self->{_drawing_pixbuf}->get_height, 0, $self->{_drawing_pixbuf}->get_height); #hruler - $self->{_hruler} = Gtk2::HRuler->new; - $self->{_hruler}->set_metric('pixels'); - $self->{_hruler}->set_range(0, $self->{_drawing_pixbuf}->get_width, 0, $self->{_drawing_pixbuf}->get_width); + #$self->{_hruler} = Gtk3::HRuler->new; + #$self->{_hruler}->set_metric('pixels'); + #$self->{_hruler}->set_range(0, $self->{_drawing_pixbuf}->get_width, 0, $self->{_drawing_pixbuf}->get_width); #create a table for placing the ruler and scrolle window - $self->{_table} = new Gtk2::Table(3, 2, FALSE); + $self->{_table} = Gtk3::Table->new(3, 2, FALSE); #attach scrolled window and rulers to the table $self->{_table}->attach($self->{_scrolled_window}, 1, 2, 1, 2, ['expand', 'fill'], ['expand', 'fill'], 0, 0); - $self->{_table}->attach($self->{_hruler}, 1, 2, 0, 1, ['expand', 'shrink', 'fill'], [], 0, 0); - $self->{_table}->attach($self->{_vruler}, 0, 1, 1, 2, [], ['fill', 'expand', 'shrink'], 0, 0); + #$self->{_table}->attach($self->{_hruler}, 1, 2, 0, 1, ['expand', 'shrink', 'fill'], [], 0, 0); + #$self->{_table}->attach($self->{_vruler}, 0, 1, 1, 2, [], ['fill', 'expand', 'shrink'], 0, 0); $self->{_bhbox} = $self->setup_bottom_hbox; $self->{_drawing_inner_vbox}->pack_start($self->{_table}, TRUE, TRUE, 0); @@ -402,7 +426,9 @@ sub show { #CROPPING TOOL CONTAINER #------------------------------------------------- #scrolled window for the cropping tool - $self->{_scrolled_window_c} = Gtk2::ImageView::ScrollWin->new($self->{_view}); + #$self->{_scrolled_window_c} = Gtk3::ImageView::ScrollWin->new($self->{_view}); + $self->{_scrolled_window_c} = Gtk3::ScrolledWindow->new; + $self->{_scrolled_window_c}->add_with_viewport($self->{_view}); ($self->{_rframe_c}, $self->{_btn_ok_c}) = $self->setup_right_vbox_c; $self->{_drawing_hbox_c}->pack_start($self->{_scrolled_window_c}, TRUE, TRUE, 0); $self->{_drawing_hbox_c}->pack_start($self->{_rframe_c}, FALSE, FALSE, 3); @@ -419,8 +445,8 @@ sub show { $self->{_drawing_vbox}->pack_start($self->{_drawing_hbox}, TRUE, TRUE, 0); #statusbar - $self->{_drawing_statusbar} = Gtk2::Statusbar->new; - $self->{_drawing_statusbar_image} = Gtk2::Image->new; + $self->{_drawing_statusbar} = Gtk3::Statusbar->new; + $self->{_drawing_statusbar_image} = Gtk3::Image->new; $self->{_drawing_statusbar}->pack_start($self->{_drawing_statusbar_image}, FALSE, FALSE, 3); $self->{_drawing_statusbar}->reorder_child($self->{_drawing_statusbar_image}, 0); $self->{_drawing_vbox}->pack_start($self->{_drawing_statusbar}, FALSE, FALSE, 6); @@ -429,7 +455,7 @@ sub show { #STARTUP PROCEDURE #------------------------------------------------- - $self->{_drawing_window}->window->focus(Gtk2->get_current_event_time); + $self->{_drawing_window}->get_window->focus(Gtk3::get_current_event_time()); $self->adjust_rulers; @@ -438,10 +464,8 @@ sub show { #remember drawing colors, line width and font settings #maybe we have to restore them - $self->{_last_fill_color} = $self->{_fill_color_w}->get_color; - $self->{_last_fill_color_alpha} = $self->{_fill_color_w}->get_alpha / 65535; - $self->{_last_stroke_color} = $self->{_stroke_color_w}->get_color; - $self->{_last_stroke_color_alpha} = $self->{_stroke_color_w}->get_alpha / 65535; + $self->{_last_fill_color} = $self->{_fill_color_w}->get_rgba; + $self->{_last_stroke_color} = $self->{_stroke_color_w}->get_rgba; $self->{_last_line_width} = $self->{_line_spin_w}->get_value; $self->{_last_font} = $self->{_font_btn_w}->get_font_name; @@ -461,7 +485,7 @@ sub show { #start with everything deactivated $self->deactivate_all; - Gtk2->main; + Gtk3->main; return TRUE; } @@ -469,13 +493,12 @@ sub show { sub setup_bottom_hbox { my $self = shift; - my $drawing_bottom_hbox = Gtk2::HBox->new(FALSE, 5); + my $drawing_bottom_hbox = Gtk3::HBox->new(FALSE, 5); #fill color - my $fill_color_label = Gtk2::Label->new($self->{_d}->get("Fill color") . ":"); - $self->{_fill_color_w} = Gtk2::ColorButton->new(); - $self->{_fill_color_w}->set_color($self->{_fill_color}); - $self->{_fill_color_w}->set_alpha(int($self->{_fill_color_alpha} * 65636)); + my $fill_color_label = Gtk3::Label->new($self->{_d}->get("Fill color") . ":"); + $self->{_fill_color_w} = Gtk3::ColorButton->new(); + $self->{_fill_color_w}->set_rgba($self->{_fill_color}); $self->{_fill_color_w}->set_use_alpha(TRUE); $self->{_fill_color_w}->set_title($self->{_d}->get("Choose fill color")); @@ -486,10 +509,9 @@ sub setup_bottom_hbox { $drawing_bottom_hbox->pack_start($self->{_fill_color_w}, FALSE, FALSE, 5); #stroke color - my $stroke_color_label = Gtk2::Label->new($self->{_d}->get("Stroke color") . ":"); - $self->{_stroke_color_w} = Gtk2::ColorButton->new(); - $self->{_stroke_color_w}->set_color($self->{_stroke_color}); - $self->{_stroke_color_w}->set_alpha(int($self->{_stroke_color_alpha} * 65535)); + my $stroke_color_label = Gtk3::Label->new($self->{_d}->get("Stroke color") . ":"); + $self->{_stroke_color_w} = Gtk3::ColorButton->new(); + $self->{_stroke_color_w}->set_rgba($self->{_stroke_color}); $self->{_stroke_color_w}->set_use_alpha(TRUE); $self->{_stroke_color_w}->set_title($self->{_d}->get("Choose stroke color")); @@ -500,8 +522,8 @@ sub setup_bottom_hbox { $drawing_bottom_hbox->pack_start($self->{_stroke_color_w}, FALSE, FALSE, 5); #line_width - my $linew_label = Gtk2::Label->new($self->{_d}->get("Line width") . ":"); - $self->{_line_spin_w} = Gtk2::SpinButton->new_with_range(0.5, 20, 0.1); + my $linew_label = Gtk3::Label->new($self->{_d}->get("Line width") . ":"); + $self->{_line_spin_w} = Gtk3::SpinButton->new_with_range(0.5, 20, 0.1); $self->{_line_spin_w}->set_value($self->{_line_width}); $linew_label->set_tooltip_text($self->{_d}->get("Adjust line width")); @@ -511,8 +533,8 @@ sub setup_bottom_hbox { $drawing_bottom_hbox->pack_start($self->{_line_spin_w}, FALSE, FALSE, 5); #font button - my $font_label = Gtk2::Label->new($self->{_d}->get("Font") . ":"); - $self->{_font_btn_w} = Gtk2::FontButton->new(); + my $font_label = Gtk3::Label->new($self->{_d}->get("Font") . ":"); + $self->{_font_btn_w} = Gtk3::FontButton->new(); $self->{_font_btn_w}->set_font_name($self->{_font}); $font_label->set_tooltip_text($self->{_d}->get("Select font family and size")); @@ -522,8 +544,8 @@ sub setup_bottom_hbox { $drawing_bottom_hbox->pack_start($self->{_font_btn_w}, FALSE, FALSE, 5); #image button - my $image_label = Gtk2::Label->new($self->{_d}->get("Insert image") . ":"); - my $image_btn = Gtk2::MenuToolButton->new(undef, undef); + my $image_label = Gtk3::Label->new($self->{_d}->get("Insert image") . ":"); + my $image_btn = Gtk3::MenuToolButton->new(undef, undef); Glib::Idle->add( sub { @@ -557,8 +579,7 @@ sub setup_bottom_hbox { $self->{_stroke_color_wh} = $self->{_stroke_color_w}->signal_connect( 'color-set' => sub { - $self->{_stroke_color} = $self->{_stroke_color_w}->get_color; - $self->{_stroke_color_alpha} = $self->{_stroke_color_w}->get_alpha / 65535; + $self->{_stroke_color} = $self->{_stroke_color_w}->get_rgba; if ($self->{_current_item}) { @@ -580,8 +601,7 @@ sub setup_bottom_hbox { $self->{_fill_color_wh} = $self->{_fill_color_w}->signal_connect( 'color-set' => sub { - $self->{_fill_color} = $self->{_fill_color_w}->get_color; - $self->{_fill_color_alpha} = $self->{_fill_color_w}->get_alpha / 65636; + $self->{_fill_color} = $self->{_fill_color_w}->get_rgba; if ($self->{_current_item}) { @@ -603,7 +623,7 @@ sub setup_bottom_hbox { $self->{_font_btn_wh} = $self->{_font_btn_w}->signal_connect( 'font-set' => sub { - my $font_descr = Gtk2::Pango::FontDescription->from_string($self->{_font_btn_w}->get_font_name); + my $font_descr = Pango::FontDescription->from_string($self->{_font_btn_w}->get_font_name); $self->{_font} = $self->{_font_btn_w}->get_font_name; if ($self->{_current_item}) { @@ -626,7 +646,7 @@ sub setup_bottom_hbox { $image_btn->signal_connect( 'clicked' => sub { - $self->{_canvas}->window->set_cursor($self->change_cursor_to_current_pixbuf); + $self->{_canvas}->get_window->set_cursor($self->change_cursor_to_current_pixbuf); }); $image_label->set_tooltip_text($self->{_d}->get("Insert an arbitrary object or file")); @@ -641,64 +661,56 @@ sub setup_bottom_hbox { sub setup_right_vbox_c { my $self = shift; - my $cropping_bottom_vbox = Gtk2::VBox->new(FALSE, 5); + my $cropping_bottom_vbox = Gtk3::VBox->new(FALSE, 5); #get current pixbuf my $pixbuf = $self->{_view}->get_pixbuf || $self->{_drawing_pixbuf}; + sub value_callback { + $self->{_selector}->set_selection({x=>$self->{_x_spin_w}->get_value, y=>$self->{_y_spin_w}->get_value, width=>$self->{_width_spin_w}->get_value, height=>$self->{_height_spin_w}->get_value}); + } + #X - my $xw_label = Gtk2::Label->new($self->{_d}->get("X") . ":"); - $self->{_x_spin_w} = Gtk2::SpinButton->new_with_range(0, $pixbuf->get_width, 1); + my $xw_label = Gtk3::Label->new($self->{_d}->get("X") . ":"); + $self->{_x_spin_w} = Gtk3::SpinButton->new_with_range(0, $pixbuf->get_width, 1); $self->{_x_spin_w}->set_value(0); $self->{_x_spin_w_handler} = $self->{_x_spin_w}->signal_connect( - 'value-changed' => sub { - $self->{_selector} - ->set_selection(Gtk2::Gdk::Rectangle->new($self->{_x_spin_w}->get_value, $self->{_y_spin_w}->get_value, $self->{_width_spin_w}->get_value, $self->{_height_spin_w}->get_value)); - }); + 'value-changed' => \&value_callback); - my $xw_hbox = Gtk2::HBox->new(FALSE, 5); + my $xw_hbox = Gtk3::HBox->new(FALSE, 5); $xw_hbox->pack_start($xw_label, FALSE, FALSE, 5); $xw_hbox->pack_start($self->{_x_spin_w}, FALSE, FALSE, 5); #y - my $yw_label = Gtk2::Label->new($self->{_d}->get("Y") . ":"); - $self->{_y_spin_w} = Gtk2::SpinButton->new_with_range(0, $pixbuf->get_height, 1); + my $yw_label = Gtk3::Label->new($self->{_d}->get("Y") . ":"); + $self->{_y_spin_w} = Gtk3::SpinButton->new_with_range(0, $pixbuf->get_height, 1); $self->{_y_spin_w}->set_value(0); $self->{_y_spin_w_handler} = $self->{_y_spin_w}->signal_connect( - 'value-changed' => sub { - $self->{_selector} - ->set_selection(Gtk2::Gdk::Rectangle->new($self->{_x_spin_w}->get_value, $self->{_y_spin_w}->get_value, $self->{_width_spin_w}->get_value, $self->{_height_spin_w}->get_value)); - }); + 'value-changed' => \&value_callback); - my $yw_hbox = Gtk2::HBox->new(FALSE, 5); + my $yw_hbox = Gtk3::HBox->new(FALSE, 5); $yw_hbox->pack_start($yw_label, FALSE, FALSE, 5); $yw_hbox->pack_start($self->{_y_spin_w}, FALSE, FALSE, 5); #width - my $widthw_label = Gtk2::Label->new($self->{_d}->get("Width") . ":"); - $self->{_width_spin_w} = Gtk2::SpinButton->new_with_range(0, $pixbuf->get_width, 1); + my $widthw_label = Gtk3::Label->new($self->{_d}->get("Width") . ":"); + $self->{_width_spin_w} = Gtk3::SpinButton->new_with_range(0, $pixbuf->get_width, 1); $self->{_width_spin_w}->set_value(0); $self->{_width_spin_w_handler} = $self->{_width_spin_w}->signal_connect( - 'value-changed' => sub { - $self->{_selector} - ->set_selection(Gtk2::Gdk::Rectangle->new($self->{_x_spin_w}->get_value, $self->{_y_spin_w}->get_value, $self->{_width_spin_w}->get_value, $self->{_height_spin_w}->get_value)); - }); + 'value-changed' => \&value_callback); - my $ww_hbox = Gtk2::HBox->new(FALSE, 5); + my $ww_hbox = Gtk3::HBox->new(FALSE, 5); $ww_hbox->pack_start($widthw_label, FALSE, FALSE, 5); $ww_hbox->pack_start($self->{_width_spin_w}, FALSE, FALSE, 5); #height - my $heightw_label = Gtk2::Label->new($self->{_d}->get("Height") . ":"); - $self->{_height_spin_w} = Gtk2::SpinButton->new_with_range(0, $pixbuf->get_height, 1); + my $heightw_label = Gtk3::Label->new($self->{_d}->get("Height") . ":"); + $self->{_height_spin_w} = Gtk3::SpinButton->new_with_range(0, $pixbuf->get_height, 1); $self->{_height_spin_w}->set_value(0); $self->{_height_spin_w_handler} = $self->{_height_spin_w}->signal_connect( - 'value-changed' => sub { - $self->{_selector} - ->set_selection(Gtk2::Gdk::Rectangle->new($self->{_x_spin_w}->get_value, $self->{_y_spin_w}->get_value, $self->{_width_spin_w}->get_value, $self->{_height_spin_w}->get_value)); - }); + 'value-changed' => \&value_callback); - my $hw_hbox = Gtk2::HBox->new(FALSE, 5); + my $hw_hbox = Gtk3::HBox->new(FALSE, 5); $hw_hbox->pack_start($heightw_label, FALSE, FALSE, 5); $hw_hbox->pack_start($self->{_height_spin_w}, FALSE, FALSE, 5); @@ -709,12 +721,12 @@ sub setup_right_vbox_c { }); #cancel button - my $crop_c = Gtk2::Button->new_from_stock('gtk-cancel'); + my $crop_c = Gtk3::Button->new_from_stock('gtk-cancel'); $crop_c->signal_connect('clicked' => sub { $self->abort_current_mode }); #crop button - my $crop_ok = Gtk2::Button->new_with_mnemonic($self->{_d}->get("_Crop")); - $crop_ok->set_image(Gtk2::Image->new_from_file($self->{_dicons} . '/transform-crop.png')); + my $crop_ok = Gtk3::Button->new_with_mnemonic($self->{_d}->get("_Crop")); + $crop_ok->set_image(Gtk3::Image->new_from_file($self->{_dicons} . '/transform-crop.png')); $crop_ok->signal_connect( 'clicked' => sub { @@ -729,7 +741,7 @@ sub setup_right_vbox_c { #create new pixbuf #create temp pixbuf because selected area might be bigger than #source pixbuf (screenshot) => canvas area is resizeable - my $temp = Gtk2::Gdk::Pixbuf->new($self->{_drawing_pixbuf}->get_colorspace, TRUE, 8, $p->get_width, $p->get_height); + my $temp = Gtk3::Gdk::Pixbuf->new($self->{_drawing_pixbuf}->get_colorspace, TRUE, 8, $p->get_width, $p->get_height); #whole pixbuf is transparent $temp->fill(0x00000000); @@ -738,11 +750,11 @@ sub setup_right_vbox_c { $self->{_drawing_pixbuf}->copy_area(0, 0, $self->{_drawing_pixbuf}->get_width, $self->{_drawing_pixbuf}->get_height, $temp, 0, 0); #and create a new subpixbuf from the temp pixbuf - my $new_p = $temp->new_subpixbuf($s->x, $s->y, $s->width, $s->height); + my $new_p = $temp->new_subpixbuf($s->{x}, $s->{y}, $s->{width}, $s->{height}); $self->{_drawing_pixbuf} = $new_p->copy; #update bounds and bg_rects - $self->{_canvas_bg_rect}->set('width' => $s->width, 'height' => $s->height); + $self->{_canvas_bg_rect}->set('width' => $s->{width}, 'height' => $s->{height}); $self->handle_bg_rects('update'); #update canvas and show the new pixbuf @@ -751,7 +763,7 @@ sub setup_right_vbox_c { #now move all items, #so they are in the right position #~ print $s->x ." - ".$s->y."\n"; - $self->move_all($s->x, $s->y); + $self->move_all($s->{x}, $s->{y}); #adjust stack order $self->{_canvas_bg}->lower; @@ -770,11 +782,11 @@ sub setup_right_vbox_c { #put buttons in a separated box #all buttons = one size - my $sg_butt = Gtk2::SizeGroup->new('vertical'); + my $sg_butt = Gtk3::SizeGroup->new('vertical'); $sg_butt->add_widget($crop_c); $sg_butt->add_widget($crop_ok); - my $cropping_bottom_vbox_b = Gtk2::VBox->new(FALSE, 5); + my $cropping_bottom_vbox_b = Gtk3::VBox->new(FALSE, 5); $cropping_bottom_vbox_b->pack_start($crop_c, FALSE, FALSE, 0); $cropping_bottom_vbox_b->pack_start($crop_ok, FALSE, FALSE, 0); @@ -785,7 +797,7 @@ sub setup_right_vbox_c { $widthw_label->set_alignment(0, 0.5); $heightw_label->set_alignment(0, 0.5); - my $sg_main = Gtk2::SizeGroup->new('horizontal'); + my $sg_main = Gtk3::SizeGroup->new('horizontal'); $sg_main->add_widget($xw_label); $sg_main->add_widget($yw_label); $sg_main->add_widget($widthw_label); @@ -798,10 +810,10 @@ sub setup_right_vbox_c { $cropping_bottom_vbox->pack_start($cropping_bottom_vbox_b, TRUE, TRUE, 3); #nice frame as well - my $crop_frame_label = Gtk2::Label->new; + my $crop_frame_label = Gtk3::Label->new; $crop_frame_label->set_markup("" . $self->{_d}->get("Selection") . ""); - my $crop_frame = Gtk2::Frame->new(); + my $crop_frame = Gtk3::Frame->new(); $crop_frame->set_border_width(5); $crop_frame->set_label_widget($crop_frame_label); $crop_frame->set_shadow_type('none'); @@ -825,17 +837,17 @@ sub adjust_crop_values { my $s = $self->{_selector}->get_selection; if ($s) { - $self->{_x_spin_w}->set_value($s->x); - $self->{_x_spin_w}->set_range(0, $pixbuf->get_width - $s->width); + $self->{_x_spin_w}->set_value($s->{x}); + $self->{_x_spin_w}->set_range(0, $pixbuf->get_width - $s->{width}); - $self->{_y_spin_w}->set_value($s->y); - $self->{_y_spin_w}->set_range(0, $pixbuf->get_height - $s->height); + $self->{_y_spin_w}->set_value($s->{y}); + $self->{_y_spin_w}->set_range(0, $pixbuf->get_height - $s->{height}); - $self->{_width_spin_w}->set_value($s->width); - $self->{_width_spin_w}->set_range(0, $pixbuf->get_width - $s->x); + $self->{_width_spin_w}->set_value($s->{width}); + $self->{_width_spin_w}->set_range(0, $pixbuf->get_width - $s->{x}); - $self->{_height_spin_w}->set_value($s->height); - $self->{_height_spin_w}->set_range(0, $pixbuf->get_height - $s->y); + $self->{_height_spin_w}->set_value($s->{height}); + $self->{_height_spin_w}->set_range(0, $pixbuf->get_height - $s->{y}); } #unblock 'value-change' handlers for widgets @@ -955,7 +967,7 @@ sub change_drawing_tool_cb { $self->{_current_mode} = $action; } - my $cursor = Gtk2::Gdk::Cursor->new('left-ptr'); + my $cursor = Gtk3::Gdk::Cursor->new('left-ptr'); #tool is switched from "highlighter" OR censor to something else (excluding select tool) if ( $self->{_current_mode} != $self->{_last_mode} @@ -980,7 +992,7 @@ sub change_drawing_tool_cb { $self->{_drawing_inner_vbox}->show_all; #hide cropping tool - $self->{_drawing_inner_vbox_c}->hide_all; + $self->{_drawing_inner_vbox_c}->hide; } @@ -1005,7 +1017,7 @@ sub change_drawing_tool_cb { } elsif ($self->{_current_mode} == 30) { $self->{_current_mode_descr} = "highlighter"; - $cursor = Gtk2::Gdk::Cursor->new('dotbox'); + $cursor = Gtk3::Gdk::Cursor->new('dotbox'); #disable controls, because they are not useful $self->{_fill_color_w}->set_sensitive(FALSE); @@ -1090,32 +1102,35 @@ sub change_drawing_tool_cb { $self->{_view}->set_zoom(1); #adjust transp color - my $color_string = - sprintf("%02x%02x%02x", $self->{_canvas_bg_rect}{fill_color}->red / 257, $self->{_canvas_bg_rect}{fill_color}->green / 257, $self->{_canvas_bg_rect}{fill_color}->blue / 257); - $self->{_view}->set_transp('color', hex $color_string); + my $color_string = $self->{_canvas_bg_rect}{fill_color}->to_string; + $self->{_view_css_provider_alpha}->load_from_data(" + .imageview.transparent { + background-color: $color_string; + } + "); $self->{_view}->show_all; $self->{_drawing_inner_vbox_c}->show_all; #hide drawing tool widgets - $self->{_drawing_inner_vbox}->hide_all; + $self->{_drawing_inner_vbox}->hide; #focus crop-ok-button $self->{_btn_ok_c}->grab_focus; } - if ($self->{_canvas} && $self->{_canvas}->window) { + if ($self->{_canvas} && $self->{_canvas}->get_window) { if (exists $self->{_cursors}{$self->{_current_mode_descr}}) { - $cursor = Gtk2::Gdk::Cursor->new_from_pixbuf( - Gtk2::Gdk::Display->get_default, $self->{_cursors}{$self->{_current_mode_descr}}, + $cursor = Gtk3::Gdk::Cursor->new_from_pixbuf( + Gtk3::Gdk::Display::get_default(), $self->{_cursors}{$self->{_current_mode_descr}}, $self->{_cursors}{$self->{_current_mode_descr}}{'x_hot'}, $self->{_cursors}{$self->{_current_mode_descr}}{'y_hot'}, ); } - $self->{_canvas}->window->set_cursor($cursor); + $self->{_canvas}->get_window->set_cursor($cursor); } return TRUE; @@ -1169,6 +1184,7 @@ sub zoom_normal_cb { } sub adjust_rulers { + return TRUE; my ($self, $ev, $item) = @_; my $s = $self->{_canvas}->get_scale; @@ -1192,7 +1208,7 @@ sub adjust_rulers { #modify rulers (e.g. done when scrolling or zooming) if ($self->{_hruler} && $self->{_hruler}) { - my ($x, $y, $width, $height, $depth) = $self->{_canvas}->window->get_geometry; + my ($x, $y, $width, $height, $depth) = $self->{_canvas}->get_window->get_geometry; my $ha = $self->{_scrolled_window}->get_hadjustment->value / $s; my $va = $self->{_scrolled_window}->get_vadjustment->value / $s; @@ -1219,7 +1235,7 @@ sub quit { if ($show_warning && (defined $self->{_undo} && scalar(@{$self->{_undo}}) > 0)) { #warn the user if there are any unsaved changes - my $warn_dialog = Gtk2::MessageDialog->new($self->{_drawing_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); + my $warn_dialog = Gtk3::MessageDialog->new($self->{_drawing_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); #set question text $warn_dialog->set('text' => sprintf($self->{_d}->get("Save the changes to image %s before closing?"), "'$name$type'")); @@ -1235,20 +1251,20 @@ sub quit { return TRUE; }); - $warn_dialog->set('image' => Gtk2::Image->new_from_stock('gtk-save', 'dialog')); + $warn_dialog->set('image' => Gtk3::Image->new_from_stock('gtk-save', 'dialog')); $warn_dialog->set('title' => $self->{_d}->get("Close") . " " . $name . $type); #don't save button - my $dsave_btn = Gtk2::Button->new_with_mnemonic($self->{_d}->get("Do_n't save")); - $dsave_btn->set_image(Gtk2::Image->new_from_stock('gtk-delete', 'button')); + my $dsave_btn = Gtk3::Button->new_with_mnemonic($self->{_d}->get("Do_n't save")); + $dsave_btn->set_image(Gtk3::Image->new_from_stock('gtk-delete', 'button')); #cancel button - my $cancel_btn = Gtk2::Button->new_from_stock('gtk-cancel'); - $cancel_btn->can_default(TRUE); + my $cancel_btn = Gtk3::Button->new_from_stock('gtk-cancel'); + $cancel_btn->set_can_default(TRUE); #save button - my $save_btn = Gtk2::Button->new_from_stock('gtk-save'); + my $save_btn = Gtk3::Button->new_from_stock('gtk-save'); $warn_dialog->add_action_widget($dsave_btn, 10); $warn_dialog->add_action_widget($cancel_btn, 20); @@ -1256,7 +1272,7 @@ sub quit { $warn_dialog->set_default_response(20); - $warn_dialog->vbox->show_all; + $warn_dialog->get_child->show_all; my $response = $warn_dialog->run; Glib::Source->remove($id); if ($response == 20) { @@ -1293,7 +1309,7 @@ sub quit { delete $self->{$_}; } - Gtk2->main_quit(); + Gtk3->main_quit(); return FALSE; } @@ -1349,10 +1365,10 @@ sub load_settings { $autoscroll_toggle->set_active($settings_xml->{'drawing'}->{'autoscroll'}); #drawing colors - $self->{_fill_color} = Gtk2::Gdk::Color->parse($settings_xml->{'drawing'}->{'fill_color'}); - $self->{_fill_color_alpha} = $settings_xml->{'drawing'}->{'fill_color_alpha'}; - $self->{_stroke_color} = Gtk2::Gdk::Color->parse($settings_xml->{'drawing'}->{'stroke_color'}); - $self->{_stroke_color_alpha} = $settings_xml->{'drawing'}->{'stroke_color_alpha'}; + $self->{_fill_color} = Gtk3::Gdk::RGBA::parse($settings_xml->{'drawing'}->{'fill_color'}) // Gtk3::Gdk::RGBA::parse('black'); + $self->{_fill_color}->alpha($settings_xml->{'drawing'}->{'fill_color_alpha'}); + $self->{_stroke_color} = Gtk3::Gdk::RGBA::parse($settings_xml->{'drawing'}->{'stroke_color'}) // Gtk3::Gdk::RGBA::parse('black'); + $self->{_stroke_color}->alpha($settings_xml->{'drawing'}->{'stroke_color_alpha'}); #line_width $self->{_line_width} = $settings_xml->{'drawing'}->{'line_width'}; @@ -1382,8 +1398,8 @@ sub save_settings { my %settings; #window size and position - if (defined $self->{_drawing_window}->window) { - if ($self->{_drawing_window}->window->get_state eq 'GDK_WINDOW_STATE_MAXIMIZED') { + if (defined $self->{_drawing_window}->get_window) { + if ($self->{_drawing_window}->get_window->get_state eq 'GDK_WINDOW_STATE_MAXIMIZED') { $settings{'drawing'}->{'state'} = 'maximized'; } } @@ -1410,10 +1426,10 @@ sub save_settings { $settings{'drawing'}->{'autoscroll'} = $autoscroll_toggle->get_active(); #drawing colors - $settings{'drawing'}->{'fill_color'} = sprintf("#%04x%04x%04x", $self->{_fill_color}->red, $self->{_fill_color}->green, $self->{_fill_color}->blue); - $settings{'drawing'}->{'fill_color_alpha'} = $self->{_fill_color_alpha}; - $settings{'drawing'}->{'stroke_color'} = sprintf("#%04x%04x%04x", $self->{_stroke_color}->red, $self->{_stroke_color}->green, $self->{_stroke_color}->blue); - $settings{'drawing'}->{'stroke_color_alpha'} = $self->{_stroke_color_alpha}; + $settings{'drawing'}->{'fill_color'} = sprintf("#%04x%04x%04x", $self->{_fill_color}->red * 65535, $self->{_fill_color}->green * 65535, $self->{_fill_color}->blue * 65535); + $settings{'drawing'}->{'fill_color_alpha'} = $self->{_fill_color}->alpha; + $settings{'drawing'}->{'stroke_color'} = sprintf("#%04x%04x%04x", $self->{_stroke_color}->red * 65535, $self->{_stroke_color}->green * 65535, $self->{_stroke_color}->blue * 65535); + $settings{'drawing'}->{'stroke_color_alpha'} = $self->{_stroke_color}->alpha; #line_width $settings{'drawing'}->{'line_width'} = $self->{_line_width}; @@ -1440,7 +1456,7 @@ sub export_to_file { my $self = shift; my $rfiletype = shift; - my $fs = Gtk2::FileChooserDialog->new( + my $fs = Gtk3::FileChooserDialog->new( $self->{_d}->get("Choose a location to save to"), $self->{_drawing_window}, 'save', 'gtk-cancel' => 'reject', @@ -1466,7 +1482,7 @@ sub export_to_file { } #preview widget - my $iprev = Gtk2::Image->new; + my $iprev = Gtk3::Image->new; $fs->set_preview_widget($iprev); $fs->signal_connect( @@ -1490,11 +1506,11 @@ sub export_to_file { $fs->set_current_name($short . "." . $rfiletype); } - my $extra_hbox = Gtk2::HBox->new; + my $extra_hbox = Gtk3::HBox->new; - my $label_save_as_type = Gtk2::Label->new($self->{_d}->get("Image format") . ":"); + my $label_save_as_type = Gtk3::Label->new($self->{_d}->get("Image format") . ":"); - my $combobox_save_as_type = Gtk2::ComboBox->new_text; + my $combobox_save_as_type = Gtk3::ComboBoxText->new; #add supported formats to combobox my $counter = 0; @@ -1515,24 +1531,24 @@ sub export_to_file { #images } else { - foreach (Gtk2::Gdk::Pixbuf->get_formats) { + foreach my $format (Gtk3::Gdk::Pixbuf::get_formats()) { #we don't want svg here - this is a dedicated action in the DrawingTool - next if !defined $rfiletype && $_->{name} =~ /svg/; + next if !defined $rfiletype && $format->get_name =~ /svg/; #we have a requested filetype - nothing else will be offered - next if defined $rfiletype && $_->{name} ne $rfiletype; + next if defined $rfiletype && $format->get_name ne $rfiletype; #we want jpg not jpeg - if ($_->{name} eq "jpeg" || $_->{name} eq "jpg") { - $combobox_save_as_type->insert_text($counter, "jpg" . " - " . $_->{description}); + if ($format->get_name eq "jpeg" || $format->get_name eq "jpg") { + $combobox_save_as_type->insert_text($counter, "jpg" . " - " . $format->get_description); } else { - $combobox_save_as_type->insert_text($counter, $_->{name} . " - " . $_->{description}); + $combobox_save_as_type->insert_text($counter, $format->get_name . " - " . $format->get_description); } #set active when mime_type is matching #loop because multiple mime types are registered for fome file formats - foreach my $mime (@{$_->{mime_types}}) { + foreach my $mime (@{$format->get_mime_types}) { $combobox_save_as_type->set_active($counter) if $mime eq $self->{'_mimetype'} || defined $rfiletype; @@ -1557,7 +1573,7 @@ sub export_to_file { $combobox_save_as_type->signal_connect( 'changed' => sub { - my $filename = $fs->get_filename; + my $filename = $self->{_shf}->utf8_decode($fs->get_filename); my $choosen_format = $combobox_save_as_type->get_active_text; $choosen_format =~ s/ \-.*//; #get png or jpeg (jpg) for example @@ -1575,7 +1591,7 @@ sub export_to_file { $extra_hbox->pack_start($label_save_as_type, FALSE, FALSE, 5); $extra_hbox->pack_start($combobox_save_as_type, FALSE, FALSE, 5); - my $align_save_as_type = Gtk2::Alignment->new(1, 0, 0, 0); + my $align_save_as_type = Gtk3::Alignment->new(1, 0, 0, 0); $align_save_as_type->add($extra_hbox); $align_save_as_type->show_all; @@ -1585,7 +1601,7 @@ sub export_to_file { my $fs_resp = $fs->run; if ($fs_resp eq "accept") { - my $filename = $fs->get_filename; + my $filename = $self->{_shf}->utf8_decode($fs->get_filename); #parse filename my ($short, $folder, $ext) = fileparse($filename, qr/\.[^.]*/); @@ -1610,8 +1626,8 @@ sub export_to_file { #ask the user to replace the image #replace button - my $replace_btn = Gtk2::Button->new_with_mnemonic($self->{_d}->get("_Replace")); - $replace_btn->set_image(Gtk2::Image->new_from_stock('gtk-save-as', 'button')); + my $replace_btn = Gtk3::Button->new_with_mnemonic($self->{_d}->get("_Replace")); + $replace_btn->set_image(Gtk3::Image->new_from_stock('gtk-save-as', 'button')); my $response = $self->{_dialogs}->dlg_warning_message( sprintf($self->{_d}->get("The image already exists in %s. Replacing it will overwrite its contents."), "'" . $folder . "'"), @@ -1685,42 +1701,42 @@ sub save { #we need to support more formats here I think if ($filetype eq 'jpeg' || $filetype eq 'jpg' || $filetype eq 'bmp') { $self->{_canvas_bg_rect}->set( - 'fill-pattern' => $self->create_color($self->{_canvas_bg_rect}{fill_color}, 1.0), + 'fill-color-gdk-rgba' => $self->{_canvas_bg_rect}{fill_color}, 'line-width' => 0, ); - } elsif ($self->{_canvas_bg_rect}{fill_color}->equal(Gtk2::Gdk::Color->parse('gray'))) { + } elsif ($self->{_canvas_bg_rect}{fill_color}->equal(Gtk3::Gdk::RGBA::parse('gray'))) { $self->{_canvas_bg_rect}->set('visibility' => 'hidden'); } else { #ask the user if he wants to save the background color - my $bg_dialog = Gtk2::MessageDialog->new($self->{_drawing_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); + my $bg_dialog = Gtk3::MessageDialog->new($self->{_drawing_window}, [qw/modal destroy-with-parent/], 'other', 'none', undef); #set attributes $bg_dialog->set('text' => $self->{_d}->get("Do you want to save the changed background color?")); $bg_dialog->set('secondary-text' => $self->{_d}->get("The background is likely to be transparent if you decide to ignore the background color.")); - $bg_dialog->set('image' => Gtk2::Image->new_from_stock('gtk-save', 'dialog')); + $bg_dialog->set('image' => Gtk3::Image->new_from_stock('gtk-save', 'dialog')); $bg_dialog->set('title' => $self->{_d}->get("Save Background Color")); #ignore bg button - my $cancel_btn = Gtk2::Button->new_with_mnemonic($self->{_d}->get("_Ignore Background Color")); + my $cancel_btn = Gtk3::Button->new_with_mnemonic($self->{_d}->get("_Ignore Background Color")); #save bg button - my $bg_btn = Gtk2::Button->new_with_mnemonic($self->{_d}->get("_Save Background Color")); - $bg_btn->can_default(TRUE); + my $bg_btn = Gtk3::Button->new_with_mnemonic($self->{_d}->get("_Save Background Color")); + $bg_btn->set_can_default(TRUE); $bg_dialog->add_action_widget($cancel_btn, 10); $bg_dialog->add_action_widget($bg_btn, 20); $bg_dialog->set_default_response(20); - $bg_dialog->vbox->show_all; + $bg_dialog->get_child->show_all; my $response = $bg_dialog->run; if ($response == 10) { $self->{_canvas_bg_rect}->set('visibility' => 'hidden'); } elsif ($response == 20) { $self->{_canvas_bg_rect}->set( - 'fill-pattern' => $self->create_color($self->{_canvas_bg_rect}{fill_color}, 1.0), + 'fill-color-gdk-rgba' => $self->{_canvas_bg_rect}{fill_color}, 'line-width' => 0, ); } @@ -1765,11 +1781,12 @@ sub save { my $cr = Cairo::Context->create($surface); $self->{_canvas}->render($cr, $self->{_canvas_bg_rect}->get_bounds, 1); - my $loader = Gtk2::Gdk::PixbufLoader->new; + my $loader = Gtk3::Gdk::PixbufLoader->new; $surface->write_to_png_stream( sub { my ($closure, $data) = @_; - $loader->write($data); + $loader->write([map ord, split //, $data]); + return TRUE; }); $loader->close; my $pixbuf = $loader->get_pixbuf; @@ -1779,7 +1796,7 @@ sub save { #update the canvas_rect again $self->{_canvas_bg_rect}->set( - 'fill-pattern' => $self->create_color($self->{_canvas_bg_rect}{fill_color}, 1.0), + 'fill-color-gdk-rgba' => $self->{_canvas_bg_rect}{fill_color}, 'line-width' => 1, 'visibility' => 'visible', @@ -1857,7 +1874,7 @@ sub event_item_on_motion_notify { #as does not work when using the censor tool -> deactivate it if ($self->{_current_mode_descr} ne "censor" && $self->{_autoscroll} && ($ev->state >= 'button1-mask' || $ev->state >= 'button2-mask')) { - my ($x, $y, $width, $height, $depth) = $self->{_canvas}->window->get_geometry; + my ($x, $y, $width, $height, $depth) = $self->{_canvas}->get_window->get_geometry; my $s = $self->{_canvas}->get_scale; my $ha = $self->{_scrolled_window}->get_hadjustment->value; my $va = $self->{_scrolled_window}->get_vadjustment->value; @@ -1883,7 +1900,7 @@ sub event_item_on_motion_notify { #move if ($item->{dragging} && ($ev->state >= 'button1-mask' || $ev->state >= 'button2-mask')) { - if ($item->isa('Goo::Canvas::Rect')) { + if ($item->isa('GooCanvas2::CanvasRect')) { my $new_x = $self->{_items}{$item}->get('x') + $ev->x - $item->{drag_x}; my $new_y = $self->{_items}{$item}->get('y') + $ev->y - $item->{drag_y}; @@ -1948,7 +1965,7 @@ sub event_item_on_motion_notify { } - $self->{_items}{$item}->set('points' => Goo::Canvas::Points->new($self->{_items}{$item}{'points'})); + $self->{_items}{$item}->set('points' => points_to_canvas_points(@{$self->{_items}{$item}{'points'}})); #new item is already on the canvas with small initial size #drawing is like resizing, so set up for resizing @@ -1981,7 +1998,13 @@ sub event_item_on_motion_notify { $self->{_items}{$item}{'bottom-right-corner'}->{res_x} = $ev->x; $self->{_items}{$item}{'bottom-right-corner'}->{res_y} = $ev->y; $self->{_items}{$item}{'bottom-right-corner'}->{resizing} = TRUE; - $self->{_canvas}->pointer_grab($self->{_items}{$item}{'bottom-right-corner'}, ['pointer-motion-mask', 'button-release-mask'], undef, $ev->time); + eval { + $self->{_canvas}->pointer_grab($self->{_items}{$item}{'bottom-right-corner'}, ['pointer-motion-mask', 'button-release-mask'], undef, $ev->time); + }; + if ($@) { + # workaround for https://gitlab.gnome.org/GNOME/goocanvas/-/merge_requests/8 + $self->{_canvas}->pointer_grab($self->{_items}{$item}{'bottom-right-corner'}, ['pointer-motion-mask', 'button-release-mask'], Gtk3::Gdk::Cursor->new('left-ptr'), $ev->time); + } #add to undo stack $self->store_to_xdo_stack($item, 'create', 'undo'); @@ -2171,7 +2194,7 @@ sub event_item_on_motion_notify { #set cursor - #~ $self->{_canvas}->window->set_cursor( Gtk2::Gdk::Cursor->new($cursor) ); + #~ $self->{_canvas}->window->set_cursor( Gtk3::Gdk::Cursor->new($cursor) ); #when width or height are too small we switch to opposite rectangle and do the resizing in this way if ($ev->state >= 'control-mask' && $new_width < 1 && $new_height < 1) { @@ -2196,10 +2219,16 @@ sub event_item_on_motion_notify { #~ if($self->{_last_item} && $self->{_current_item} && $self->{_last_item} == $self->{_current_item}){ #~ $self->{_canvas}->pointer_grab( $self->{_items}{$curr_item}{$oppo}, [ 'pointer-motion-mask', 'button-release-mask' ], undef, $ev->time ); #~ }else{ - #~ $self->{_canvas}->pointer_grab( $self->{_items}{$curr_item}{$oppo}, [ 'pointer-motion-mask', 'button-release-mask' ], Gtk2::Gdk::Cursor->new($oppo), $ev->time ); + #~ $self->{_canvas}->pointer_grab( $self->{_items}{$curr_item}{$oppo}, [ 'pointer-motion-mask', 'button-release-mask' ], Gtk3::Gdk::Cursor->new($oppo), $ev->time ); #~ } - $self->{_canvas}->pointer_grab($self->{_items}{$curr_item}{$oppo}, ['pointer-motion-mask', 'button-release-mask'], undef, $ev->time); + eval { + $self->{_canvas}->pointer_grab($self->{_items}{$curr_item}{$oppo}, ['pointer-motion-mask', 'button-release-mask'], undef, $ev->time); + }; + if ($@) { + # workaround for https://gitlab.gnome.org/GNOME/goocanvas/-/merge_requests/8 + $self->{_canvas}->pointer_grab($self->{_items}{$curr_item}{$oppo}, ['pointer-motion-mask', 'button-release-mask'], Gtk3::Gdk::Cursor->new('left-ptr'), $ev->time); + } $self->handle_embedded('mirror', $curr_item, $new_width, $new_height); @@ -2234,7 +2263,7 @@ sub event_item_on_motion_notify { } else { - if ($item->isa('Goo::Canvas::Rect')) { + if ($item->isa('GooCanvas2::CanvasRect')) { #embedded item? my $parent = $self->get_parent_item($item); @@ -2388,18 +2417,19 @@ sub get_pixelated_pixbuf_from_canvas { $self->handle_rects('hide', $item); $self->handle_embedded('hide', $item); - #render the content and load it via Gtk2::Gdk::PixbufLoader + #render the content and load it via Gtk3::Gdk::PixbufLoader $self->{_canvas}->render($cr, $bounds, 1); #show rects again $self->handle_rects('update', $item); #~ print "start loader\n"; - my $loader = Gtk2::Gdk::PixbufLoader->new; + my $loader = Gtk3::Gdk::PixbufLoader->new; $surface->write_to_png_stream( sub { my ($closure, $data) = @_; - $loader->write($data); + $loader->write([map ord, split //, $data]); + return TRUE; }); $loader->close; @@ -2407,14 +2437,14 @@ sub get_pixelated_pixbuf_from_canvas { my ($pixbuf, $target) = (undef, undef); #error icon - my $error = Gtk2::Widget::render_icon(Gtk2::Invisible->new, "gtk-dialog-error", 'menu'); + my $error = Gtk3::Widget::render_icon(Gtk3::Invisible->new, "gtk-dialog-error", 'menu'); eval { $pixbuf = $loader->get_pixbuf; #create target pixbuf - $target = Gtk2::Gdk::Pixbuf->new($pixbuf->get_colorspace, TRUE, 8, $sw, $sh); + $target = Gtk3::Gdk::Pixbuf->new($pixbuf->get_colorspace, TRUE, 8, $sw, $sh); }; unless ($@) { @@ -2510,8 +2540,8 @@ sub abort_current_mode { my ($self) = @_; if ($self->{_current_item}) { - $self->{_canvas}->pointer_ungrab($self->{_current_item}, Gtk2->get_current_event_time); - $self->{_canvas}->keyboard_ungrab($self->{_current_item}, Gtk2->get_current_event_time); + $self->{_canvas}->pointer_ungrab($self->{_current_item}, Gtk3::get_current_event_time()); + $self->{_canvas}->keyboard_ungrab($self->{_current_item}, Gtk3::get_current_event_time()); } #~ print "abort_current_mode\n"; @@ -2569,10 +2599,10 @@ sub store_to_xdo_stack { my %do_info = (); #general properties for ellipse, rectangle, image, text - if ($item->isa('Goo::Canvas::Rect') && $item != $self->{_canvas_bg_rect}) { + if ($item->isa('GooCanvas2::CanvasRect') && $item != $self->{_canvas_bg_rect}) { - my $stroke_pattern = $self->create_color($self->{_items}{$item}{stroke_color}, $self->{_items}{$item}{stroke_color_alpha}) if exists $self->{_items}{$item}{stroke_color}; - my $fill_pattern = $self->create_color($self->{_items}{$item}{fill_color}, $self->{_items}{$item}{fill_color_alpha}) if exists $self->{_items}{$item}{fill_color}; + my $stroke_color = $self->{_items}{$item}{stroke_color}; + my $fill_color = $self->{_items}{$item}{fill_color}; my $line_width = $self->{_items}{$item}->get('line-width'); #line @@ -2633,11 +2663,7 @@ sub store_to_xdo_stack { 'width' => $self->{_items}{$item}->get('width'), 'height' => $self->{_items}{$item}->get('height'), 'stroke_color' => $self->{_items}{$item}{stroke_color}, - 'stroke_color_alpha' => $self->{_items}{$item}{stroke_color_alpha}, 'fill_color' => $self->{_items}{$item}{fill_color}, - 'fill_color_alpha' => $self->{_items}{$item}{fill_color_alpha}, - 'fill-pattern' => $fill_pattern, - 'stroke-pattern' => $stroke_pattern, 'line-width' => $line_width, 'mirrored_w' => $mirrored_w, 'mirrored_h' => $mirrored_h, @@ -2651,7 +2677,7 @@ sub store_to_xdo_stack { 'opt1' => $opt1, ); - } elsif ($item->isa('Goo::Canvas::Image') && $item == $self->{_canvas_bg}) { + } elsif ($item->isa('GooCanvas2::CanvasImage') && $item == $self->{_canvas_bg}) { #canvas_bg_image and bg_rect properties %do_info = ( @@ -2665,7 +2691,7 @@ sub store_to_xdo_stack { 'opt1' => $opt1, ); - } elsif ($item->isa('Goo::Canvas::Rect') && $item == $self->{_canvas_bg_rect}) { + } elsif ($item->isa('GooCanvas2::CanvasRect') && $item == $self->{_canvas_bg_rect}) { #canvas_bg_rect properties %do_info = ( @@ -2679,9 +2705,8 @@ sub store_to_xdo_stack { ); #polyline specific properties to hash - } elsif ($item->isa('Goo::Canvas::Polyline')) { + } elsif ($item->isa('GooCanvas2::CanvasPolyline')) { - my $stroke_pattern = $self->create_color($self->{_items}{$item}{stroke_color}, $self->{_items}{$item}{stroke_color_alpha}); my $transform = $self->{_items}{$item}->get('transform'); my $line_width = $self->{_items}{$item}->get('line-width'); my $points = $self->{_items}{$item}->get('points'); @@ -2690,7 +2715,7 @@ sub store_to_xdo_stack { 'item' => $self->{_items}{$item}, 'action' => $action, 'points' => $points, - 'stroke-pattern' => $stroke_pattern, + 'stroke_color' => $self->{_items}{$item}{stroke_color}, 'line-width' => $line_width, 'transform' => $transform, 'opt1' => $opt1, @@ -2783,9 +2808,9 @@ sub xdo { return FALSE unless $item; return FALSE unless $action; - if ($item->isa('Goo::Canvas::Image') && $item == $self->{_canvas_bg}) { - $opt1->x($do->{'opt1'}->x * -1); - $opt1->y($do->{'opt1'}->y * -1); + if ($item->isa('GooCanvas2::CanvasImage') && $item == $self->{_canvas_bg}) { + $opt1->{x} = $do->{'opt1'}->{x} * -1; + $opt1->{y} = $do->{'opt1'}->{y} * -1; } #create reverse action @@ -2824,7 +2849,7 @@ sub xdo { #finally undo the last event if ($action eq 'modify') { - if ($item->isa('Goo::Canvas::Rect') && $item != $self->{_canvas_bg_rect}) { + if ($item->isa('GooCanvas2::CanvasRect') && $item != $self->{_canvas_bg_rect}) { $self->{_items}{$item}->set( 'x' => $do->{'x'}, @@ -2836,8 +2861,8 @@ sub xdo { if (exists $self->{_items}{$item}{ellipse}) { $self->{_items}{$item}{ellipse}->set( - 'fill-pattern' => $do->{'fill-pattern'}, - 'stroke-pattern' => $do->{'stroke-pattern'}, + 'fill-color-gdk-rgba' => $do->{'fill_color'}, + 'stroke-color-gdk-rgba' => $do->{'stroke_color'}, 'line-width' => $do->{'line-width'}, ); @@ -2845,27 +2870,24 @@ sub xdo { if (exists $self->{_items}{$item}{text}) { $self->{_items}{$item}{text}->set( 'text' => $do->{'text'}, - 'fill-pattern' => $do->{'stroke-pattern'}, + 'fill-color-gdk-rgba' => $do->{'stroke_color'}, ); $self->{_items}{$item}{text}{digit} = $do->{'digit'}; } #restore color and opacity as well $self->{_items}{$item}{fill_color} = $do->{'fill_color'}; - $self->{_items}{$item}{fill_color_alpha} = $do->{'fill_color_alpha'}; $self->{_items}{$item}{stroke_color} = $do->{'stroke_color'}; - $self->{_items}{$item}{stroke_color_alpha} = $do->{'stroke_color_alpha'}; } elsif (exists $self->{_items}{$item}{text}) { $self->{_items}{$item}{text}->set( 'text' => $do->{'text'}, - 'fill-pattern' => $do->{'stroke-pattern'}, + 'fill-color-gdk-rgba' => $do->{'stroke_color'}, ); #restore color and opacity as well $self->{_items}{$item}{stroke_color} = $do->{'stroke_color'}; - $self->{_items}{$item}{stroke_color_alpha} = $do->{'stroke_color_alpha'}; } elsif (exists $self->{_items}{$item}{pixelize}) { @@ -2902,8 +2924,8 @@ sub xdo { $self->{_items}{$item}{arrow_tip_length} = $do->{'arrow-tip-length'}; $self->{_items}{$item}{line}->set( - 'fill-pattern' => $do->{'fill-pattern'}, - 'stroke-pattern' => $do->{'stroke-pattern'}, + 'fill-color-gdk-rgba' => $do->{'fill_color'}, + 'stroke-color-gdk-rgba' => $do->{'stroke_color'}, 'line-width' => $do->{'line-width'}, 'end-arrow' => $self->{_items}{$item}{end_arrow}, 'start-arrow' => $self->{_items}{$item}{start_arrow}, @@ -2917,25 +2939,22 @@ sub xdo { #restore color and opacity as well $self->{_items}{$item}{stroke_color} = $do->{'stroke_color'}; - $self->{_items}{$item}{stroke_color_alpha} = $do->{'stroke_color_alpha'}; } else { $self->{_items}{$item}->set( - 'fill-pattern' => $do->{'fill-pattern'}, - 'stroke-pattern' => $do->{'stroke-pattern'}, + 'fill-color-gdk-rgba' => $do->{'fill_color'}, + 'stroke-color-gdk-rgba' => $do->{'stroke_color'}, 'line-width' => $do->{'line-width'}, ); #restore color and opacity as well $self->{_items}{$item}{fill_color} = $do->{'fill_color'}; - $self->{_items}{$item}{fill_color_alpha} = $do->{'fill_color_alpha'}; $self->{_items}{$item}{stroke_color} = $do->{'stroke_color'}; - $self->{_items}{$item}{stroke_color_alpha} = $do->{'stroke_color_alpha'}; } - } elsif ($item->isa('Goo::Canvas::Image') && $item == $self->{_canvas_bg}) { + } elsif ($item->isa('GooCanvas2::CanvasImage') && $item == $self->{_canvas_bg}) { #~ print "xdo canvas_bg\n"; @@ -2957,9 +2976,9 @@ sub xdo { ); #we need to move the shapes - $self->move_all($opt1->x, $opt1->y); + $self->move_all($opt1->{x}, $opt1->{y}); - } elsif ($item->isa('Goo::Canvas::Rect') && $item == $self->{_canvas_bg_rect}) { + } elsif ($item->isa('GooCanvas2::CanvasRect') && $item == $self->{_canvas_bg_rect}) { #~ print "xdo canvas_bg_rect\n"; @@ -2971,21 +2990,20 @@ sub xdo { ); #polyline specific properties - } elsif ($item->isa('Goo::Canvas::Polyline')) { + } elsif ($item->isa('GooCanvas2::CanvasPolyline')) { #if pattern exists #e.g. censor tool does not have a pattern if ($do->{'stroke-pattern'}) { $self->{_items}{$item}->set( - 'stroke-pattern' => $do->{'stroke-pattern'}, + 'stroke-color-gdk-rgba' => $do->{'stroke_color'}, 'line-width' => $do->{'line-width'}, 'points' => $do->{'points'}, 'transform' => $do->{'transform'}, ); $self->{_items}{$item}{stroke_color} = $do->{'stroke_color'}; - $self->{_items}{$item}{stroke_color_alpha} = $do->{'stroke_color_alpha'}; } else { @@ -3110,10 +3128,8 @@ sub set_and_save_drawing_properties { #remember drawing colors, line width and font settings #maybe we have to restore them - $self->{_last_fill_color} = $self->{_fill_color_w}->get_color; - $self->{_last_fill_color_alpha} = $self->{_fill_color_w}->get_alpha / 65535; - $self->{_last_stroke_color} = $self->{_stroke_color_w}->get_color; - $self->{_last_stroke_color_alpha} = $self->{_stroke_color_w}->get_alpha / 65535; + $self->{_last_fill_color} = $self->{_fill_color_w}->get_rgba; + $self->{_last_stroke_color} = $self->{_stroke_color_w}->get_rgba; $self->{_last_line_width} = $self->{_line_spin_w}->get_value; $self->{_last_font} = $self->{_font_btn_w}->get_font_name; @@ -3133,9 +3149,9 @@ sub set_and_save_drawing_properties { #~ print "set_and_save_drawing_properties3\n"; - if ( $item->isa('Goo::Canvas::Rect') - || $item->isa('Goo::Canvas::Ellipse') - || $item->isa('Goo::Canvas::Polyline')) + if ( $item->isa('GooCanvas2::CanvasRect') + || $item->isa('GooCanvas2::CanvasEllipse') + || $item->isa('GooCanvas2::CanvasPolyline')) { #line width @@ -3147,22 +3163,20 @@ sub set_and_save_drawing_properties { #~ print $self->{_items}{$key}{stroke_color}->to_string, "\n"; - $self->{_stroke_color_w}->set_color($self->{_items}{$key}{stroke_color}); - $self->{_stroke_color_w}->set_alpha(int($self->{_items}{$key}{stroke_color_alpha} * 65535)); + $self->{_stroke_color_w}->set_rgba($self->{_items}{$key}{stroke_color}); } - if ($item->isa('Goo::Canvas::Rect') || $item->isa('Goo::Canvas::Ellipse')) { + if ($item->isa('GooCanvas2::CanvasRect') || $item->isa('GooCanvas2::CanvasEllipse')) { #fill color - $self->{_fill_color_w}->set_color($self->{_items}{$key}{fill_color}); - $self->{_fill_color_w}->set_alpha(int($self->{_items}{$key}{fill_color_alpha} * 65535)); + $self->{_fill_color_w}->set_rgba($self->{_items}{$key}{fill_color}); #numbered shapes if (exists($self->{_items}{$key}{text})) { #determine font description from string - my ($attr_list, $text_raw, $accel_char) = Gtk2::Pango->parse_markup($self->{_items}{$key}{text}->get('text')); - my $font_desc = Gtk2::Pango::FontDescription->from_string($self->{_font}); + my ($attr_list, $text_raw, $accel_char) = Pango->parse_markup($self->{_items}{$key}{text}->get('text')); + my $font_desc = Pango::FontDescription->from_string($self->{_font}); #FIXME, maybe the pango version installed is too old eval { @@ -3170,7 +3184,7 @@ sub set_and_save_drawing_properties { sub { my $attr = shift; $font_desc = $attr->copy->desc - if $attr->isa('Gtk2::Pango::AttrFontDesc'); + if $attr->isa('Pango::AttrFontDesc'); return TRUE; }, ); @@ -3185,11 +3199,11 @@ sub set_and_save_drawing_properties { } } - } elsif ($item->isa('Goo::Canvas::Text')) { + } elsif ($item->isa('GooCanvas2::CanvasText')) { #determine font description from string - my ($attr_list, $text_raw, $accel_char) = Gtk2::Pango->parse_markup($item->get('text')); - my $font_desc = Gtk2::Pango::FontDescription->from_string($self->{_font}); + my ($attr_list, $text_raw, $accel_char) = Pango->parse_markup($item->get('text')); + my $font_desc = Pango::FontDescription->from_string($self->{_font}); #FIXME, maybe the pango version installed is too old eval { @@ -3197,7 +3211,7 @@ sub set_and_save_drawing_properties { sub { my $attr = shift; $font_desc = $attr->copy->desc - if $attr->isa('Gtk2::Pango::AttrFontDesc'); + if $attr->isa('Pango::AttrFontDesc'); return TRUE; }, ); @@ -3207,8 +3221,7 @@ sub set_and_save_drawing_properties { } #font color - $self->{_stroke_color_w}->set_color($self->{_items}{$key}{stroke_color}); - $self->{_stroke_color_w}->set_alpha(int($self->{_items}{$key}{stroke_color_alpha} * 65535)); + $self->{_stroke_color_w}->set_rgba($self->{_items}{$key}{stroke_color}); #apply current font settings to button $self->{_font_btn_w}->set_font_name($self->{_font}); @@ -3217,11 +3230,9 @@ sub set_and_save_drawing_properties { #update global values $self->{_line_width} = $self->{_line_spin_w}->get_value; - $self->{_stroke_color} = $self->{_stroke_color_w}->get_color; - $self->{_stroke_color_alpha} = $self->{_stroke_color_w}->get_alpha / 65535; - $self->{_fill_color} = $self->{_fill_color_w}->get_color; - $self->{_fill_color_alpha} = $self->{_fill_color_w}->get_alpha / 65636; - my $font_descr = Gtk2::Pango::FontDescription->from_string($self->{_font_btn_w}->get_font_name); + $self->{_stroke_color} = $self->{_stroke_color_w}->get_rgba; + $self->{_fill_color} = $self->{_fill_color_w}->get_rgba; + my $font_descr = Pango::FontDescription->from_string($self->{_font_btn_w}->get_font_name); $self->{_font} = $self->{_font_btn_w}->get_font_name; #unblock 'value-change' handlers for widgets @@ -3248,10 +3259,12 @@ sub restore_fixed_properties { if ($mode eq "highlighter") { #highlighter - $self->{_fill_color_w}->set_color(Gtk2::Gdk::Color->parse('#00000000ffff')); - $self->{_fill_color_w}->set_alpha(int(0.234683756771191 * 65535)); - $self->{_stroke_color_w}->set_color(Gtk2::Gdk::Color->parse('#ffffffff0000')); - $self->{_stroke_color_w}->set_alpha(int(0.499992370489052 * 65535)); + my $fill_color = Gtk3::Gdk::RGBA::parse('#00000000ffff'); + $fill_color->alpha(0.234683756771191); + $self->{_fill_color_w}->set_rgba($fill_color); + my $stroke_color = Gtk3::Gdk::RGBA::parse('#ffffffff0000'); + $stroke_color->alpha(0.499992370489052); + $self->{_stroke_color_w}->set_rgba($stroke_color); $self->{_line_spin_w}->set_value(18); } elsif ($mode eq "censor") { @@ -3261,10 +3274,8 @@ sub restore_fixed_properties { #update global values $self->{_line_width} = $self->{_line_spin_w}->get_value; - $self->{_stroke_color} = $self->{_stroke_color_w}->get_color; - $self->{_stroke_color_alpha} = $self->{_stroke_color_w}->get_alpha / 65535; - $self->{_fill_color} = $self->{_fill_color_w}->get_color; - $self->{_fill_color_alpha} = $self->{_fill_color_w}->get_alpha / 65636; + $self->{_stroke_color} = $self->{_stroke_color_w}->get_rgba; + $self->{_fill_color} = $self->{_fill_color_w}->get_rgba; #unblock 'value-change' handlers for widgets $self->{_line_spin_w}->signal_handler_unblock($self->{_line_spin_wh}); @@ -3293,20 +3304,16 @@ sub restore_drawing_properties { $self->{_font_btn_w}->signal_handler_block($self->{_font_btn_wh}); #restore them - $self->{_fill_color_w}->set_color($self->{_last_fill_color}); - $self->{_fill_color_w}->set_alpha(int($self->{_last_fill_color_alpha} * 65535)); - $self->{_stroke_color_w}->set_color($self->{_last_stroke_color}); - $self->{_stroke_color_w}->set_alpha(int($self->{_last_stroke_color_alpha} * 65535)); + $self->{_fill_color_w}->set_rgba($self->{_last_fill_color}); + $self->{_stroke_color_w}->set_rgba($self->{_last_stroke_color}); $self->{_line_spin_w}->set_value($self->{_last_line_width}); $self->{_font_btn_w}->set_font_name($self->{_last_font}); #update global values $self->{_line_width} = $self->{_line_spin_w}->get_value; - $self->{_stroke_color} = $self->{_stroke_color_w}->get_color; - $self->{_stroke_color_alpha} = $self->{_stroke_color_w}->get_alpha / 65535; - $self->{_fill_color} = $self->{_fill_color_w}->get_color; - $self->{_fill_color_alpha} = $self->{_fill_color_w}->get_alpha / 65636; - my $font_descr = Gtk2::Pango::FontDescription->from_string($self->{_font_btn_w}->get_font_name); + $self->{_stroke_color} = $self->{_stroke_color_w}->get_rgba; + $self->{_fill_color} = $self->{_fill_color_w}->get_rgba; + my $font_descr = Pango::FontDescription->from_string($self->{_font_btn_w}->get_font_name); $self->{_font} = $self->{_font_btn_w}->get_font_name; #unblock 'value-change' handlers for widgets @@ -3328,10 +3335,10 @@ sub event_item_on_key_press { if (exists $self->{_items}{$curr_item}) { #construct an motion-notify event - my $mevent = Gtk2::Gdk::Event->new('motion-notify'); - $mevent->set_state('button2-mask'); - $mevent->set_time(Gtk2->get_current_event_time); - $mevent->window($self->{_drawing_window}->window); + my $mevent = Gtk3::Gdk::Event->new('motion-notify'); + $mevent->state('button2-mask'); + $mevent->time(Gtk3::get_current_event_time()); + $mevent->window($self->{_drawing_window}->get_window); #get current x, y values my $old_x = $self->{_items}{$curr_item}->get('x'); @@ -3344,22 +3351,22 @@ sub event_item_on_key_press { $curr_item->{dragging_start} = TRUE; #move with arrow keys - if ($ev->keyval == Gtk2::Gdk->keyval_from_name('Up')) { + if ($ev->keyval == Gtk3::Gdk::keyval_from_name('Up')) { #~ print $ev->keyval," $old_x,$old_y-up\n"; $mevent->x($old_x); $mevent->y($old_y - 1); - } elsif ($ev->keyval == Gtk2::Gdk->keyval_from_name('Down')) { + } elsif ($ev->keyval == Gtk3::Gdk::keyval_from_name('Down')) { #~ print $ev->keyval," $old_x,$old_y-down\n"; $mevent->x($old_x); $mevent->y($old_y + 1); - } elsif ($ev->keyval == Gtk2::Gdk->keyval_from_name('Left')) { + } elsif ($ev->keyval == Gtk3::Gdk::keyval_from_name('Left')) { #~ print $ev->keyval," $old_x,$old_y-left\n"; $mevent->x($old_x - 1); $mevent->y($old_y); - } elsif ($ev->keyval == Gtk2::Gdk->keyval_from_name('Right')) { + } elsif ($ev->keyval == Gtk3::Gdk::keyval_from_name('Right')) { #~ print $ev->keyval," $old_x,$old_y-right\n"; $mevent->x($old_x + 1); @@ -3386,7 +3393,7 @@ sub event_item_on_button_press { #canvas is busy now... $self->{_busy} = TRUE; - my $cursor = Gtk2::Gdk::Cursor->new('left-ptr'); + my $cursor = Gtk3::Gdk::Cursor->new('left-ptr'); #activate item #if it is not activated yet @@ -3480,7 +3487,7 @@ sub event_item_on_button_press { #don't move locked item return TRUE if (exists $self->{_items}{$item} && $self->{_items}{$item}{locked}); - if ($item->isa('Goo::Canvas::Rect')) { + if ($item->isa('GooCanvas2::CanvasRect')) { #real shape => move if (exists $self->{_items}{$item}) { @@ -3489,7 +3496,7 @@ sub event_item_on_button_press { $item->{dragging} = TRUE; $item->{dragging_start} = TRUE; - $cursor = Gtk2::Gdk::Cursor->new('fleur'); + $cursor = Gtk3::Gdk::Cursor->new('fleur'); #resizing shape => resize } else { @@ -3517,8 +3524,7 @@ sub event_item_on_button_press { } #restore style pattern - my $pattern = $self->create_color($self->{_style_bg}, 1); - $item->set('fill-pattern' => $pattern); + $item->set('fill-color-gdk-rgba' => $self->{_style_bg}); } @@ -3541,7 +3547,13 @@ sub event_item_on_button_press { #~ print "grab keyboard and pointer focus for $item\n"; #grab keyboard and pointer focus - $self->{_canvas}->pointer_grab($item, ['pointer-motion-mask', 'button-release-mask'], $cursor, $ev->time); + eval { + $self->{_canvas}->pointer_grab($item, ['pointer-motion-mask', 'button-release-mask'], $cursor, $ev->time); + }; + if ($@) { + # workaround for https://gitlab.gnome.org/GNOME/goocanvas/-/merge_requests/8 + $self->{_canvas}->pointer_grab($item, ['pointer-motion-mask', 'button-release-mask'], Gtk3::Gdk::Cursor->new('left-ptr'), $ev->time); + } $self->{_canvas}->grab_focus($item); #current mode not equal 'select' and no polyline @@ -3549,7 +3561,7 @@ sub event_item_on_button_press { #resizing shape => resize (no real shape) #no polyline modes - if ( $item->isa('Goo::Canvas::Rect') + if ( $item->isa('GooCanvas2::CanvasRect') && !exists $self->{_items}{$item} && $item != $self->{_canvas_bg_rect} && $self->{_current_mode_descr} ne "freehand" @@ -3581,13 +3593,18 @@ sub event_item_on_button_press { } #restore style pattern - my $pattern = $self->create_color($self->{_style_bg}, 1); - $item->set('fill-pattern' => $pattern); + $item->set('fill-color-gdk-rgba' => $self->{_style_bg}); #~ print "grab keyboard and pointer focus for $item\n"; #grab keyboard and pointer focus - $self->{_canvas}->pointer_grab($item, ['pointer-motion-mask', 'button-release-mask'], $cursor, $ev->time); + eval { + $self->{_canvas}->pointer_grab($item, ['pointer-motion-mask', 'button-release-mask'], $cursor, $ev->time); + }; + if ($@) { + # workaround for https://gitlab.gnome.org/GNOME/goocanvas/-/merge_requests/8 + $self->{_canvas}->pointer_grab($item, ['pointer-motion-mask', 'button-release-mask'], Gtk3::Gdk::Cursor->new('left-ptr'), $ev->time); + } $self->{_canvas}->grab_focus($item); #create new item @@ -3692,7 +3709,7 @@ sub event_item_on_button_press { { #some items do not have properties, e.g. images or censor - return FALSE if $item->isa('Goo::Canvas::Image') || !exists($self->{_items}{$key}{stroke_color}); + return FALSE if $item->isa('GooCanvas2::CanvasImage') || !exists($self->{_items}{$key}{stroke_color}); #~ print $item, $parent, $key, "\n"; @@ -3741,25 +3758,20 @@ sub ret_background_menu { my $self = shift; my $item = shift; - my $menu_bg = Gtk2::Menu->new; + my $menu_bg = Gtk3::Menu->new; #properties - my $prop_item = Gtk2::ImageMenuItem->new($self->{_d}->get("Change Background Color...")); - $prop_item->set_image(Gtk2::Image->new_from_stock('gtk-select-color', 'menu')); + my $prop_item = Gtk3::ImageMenuItem->new($self->{_d}->get("Change Background Color...")); + $prop_item->set_image(Gtk3::Image->new_from_stock('gtk-select-color', 'menu')); $prop_item->signal_connect( 'activate' => sub { - my $color_dialog = Gtk2::ColorSelectionDialog->new($self->{_d}->get("Choose fill color")); - - #remove help button - $color_dialog->help_button->destroy; + my $color_dialog = Gtk3::ColorChooserDialog->new($self->{_d}->get("Choose fill color")); #add reset button - my $reset_btn = Gtk2::Button->new_with_mnemonic($self->{_d}->get("_Reset to Default")); + my $reset_btn = Gtk3::Button->new_with_mnemonic($self->{_d}->get("_Reset to Default")); $color_dialog->add_action_widget($reset_btn, 'reject'); - my $col_sel = $color_dialog->colorsel; - $col_sel->set_current_color($self->{_canvas_bg_rect}{fill_color}); - $col_sel->set_current_alpha(65535); + $color_dialog->set_rgba($self->{_canvas_bg_rect}{fill_color}); $color_dialog->show_all; @@ -3770,13 +3782,12 @@ sub ret_background_menu { if ($response eq 'ok') { #apply new color - my $new_fill_pattern = $self->create_color($col_sel->get_current_color, 1.0); - $self->{_canvas_bg_rect}->set('fill-pattern' => $new_fill_pattern); - $self->{_canvas_bg_rect}{fill_color} = $col_sel->get_current_color; + $self->{_canvas_bg_rect}{fill_color} = $color_dialog->get_rgba; + $self->{_canvas_bg_rect}{fill_color}->alpha(1); + $self->{_canvas_bg_rect}->set('fill-color-gdk-rgba', $self->{_canvas_bg_rect}{fill_color}); last; } elsif ($response eq 'reject') { - $col_sel->set_current_color(Gtk2::Gdk::Color->parse('gray')); - $col_sel->set_current_alpha(65535); + $color_dialog->set_rgba(Gtk3::Gdk::RGBA::parse('gray')); } else { last; } @@ -3801,11 +3812,11 @@ sub ret_item_menu { #~ print "ret_item_menu\n"; - my $menu_item = Gtk2::Menu->new; + my $menu_item = Gtk3::Menu->new; #raise - my $raise_item = Gtk2::ImageMenuItem->new($self->{_d}->get("Raise")); - $raise_item->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-raise.png', Gtk2::IconSize->lookup('menu')))); + my $raise_item = Gtk3::ImageMenuItem->new($self->{_d}->get("Raise")); + $raise_item->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-raise.png', Gtk3::IconSize->lookup('menu')))); $raise_item->signal_connect( 'activate' => sub { if ($parent) { @@ -3827,8 +3838,8 @@ sub ret_item_menu { $menu_item->append($raise_item); #lower - my $lower_item = Gtk2::ImageMenuItem->new($self->{_d}->get("Lower")); - $lower_item->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-lower.png', Gtk2::IconSize->lookup('menu')))); + my $lower_item = Gtk3::ImageMenuItem->new($self->{_d}->get("Lower")); + $lower_item->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-lower.png', Gtk3::IconSize->lookup('menu')))); $lower_item->signal_connect( 'activate' => sub { @@ -3852,10 +3863,10 @@ sub ret_item_menu { $menu_item->append($lower_item); - $menu_item->append(Gtk2::SeparatorMenuItem->new); + $menu_item->append(Gtk3::SeparatorMenuItem->new); #copy item - my $copy_item = Gtk2::ImageMenuItem->new_from_stock('gtk-copy'); + my $copy_item = Gtk3::ImageMenuItem->new_from_stock('gtk-copy'); $copy_item->signal_connect( 'activate' => sub { @@ -3869,7 +3880,7 @@ sub ret_item_menu { $menu_item->append($copy_item); #cut item - my $cut_item = Gtk2::ImageMenuItem->new_from_stock('gtk-cut'); + my $cut_item = Gtk3::ImageMenuItem->new_from_stock('gtk-cut'); $cut_item->signal_connect( 'activate' => sub { @@ -3884,7 +3895,7 @@ sub ret_item_menu { $menu_item->append($cut_item); #paste item - my $paste_item = Gtk2::ImageMenuItem->new_from_stock('gtk-paste'); + my $paste_item = Gtk3::ImageMenuItem->new_from_stock('gtk-paste'); $paste_item->signal_connect( 'activate' => sub { @@ -3895,7 +3906,7 @@ sub ret_item_menu { $menu_item->append($paste_item); #delete item - my $remove_item = Gtk2::ImageMenuItem->new_from_stock('gtk-delete'); + my $remove_item = Gtk3::ImageMenuItem->new_from_stock('gtk-delete'); $remove_item->signal_connect( 'activate' => sub { @@ -3904,18 +3915,18 @@ sub ret_item_menu { $menu_item->append($remove_item); - $menu_item->append(Gtk2::SeparatorMenuItem->new); + $menu_item->append(Gtk3::SeparatorMenuItem->new); #add lock/unlock entry if item == background image if ($item == $self->{_canvas_bg}) { my $lock_item = undef; if (exists $self->{_items}{$key} && $self->{_items}{$key}{locked} == TRUE) { - $lock_item = Gtk2::ImageMenuItem->new_with_label($self->{_d}->get("Unlock")); - $lock_item->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-unlocked.png', Gtk2::IconSize->lookup('menu')))); + $lock_item = Gtk3::ImageMenuItem->new_with_label($self->{_d}->get("Unlock")); + $lock_item->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-unlocked.png', Gtk3::IconSize->lookup('menu')))); } elsif (exists $self->{_items}{$key} && $self->{_items}{$key}{locked} == FALSE) { - $lock_item = Gtk2::ImageMenuItem->new_with_label($self->{_d}->get("Lock")); - $lock_item->set_image(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-locked.png', Gtk2::IconSize->lookup('menu')))); + $lock_item = Gtk3::ImageMenuItem->new_with_label($self->{_d}->get("Lock")); + $lock_item->set_image(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-locked.png', Gtk3::IconSize->lookup('menu')))); } #handler @@ -3933,15 +3944,15 @@ sub ret_item_menu { $menu_item->append($lock_item); - $menu_item->append(Gtk2::SeparatorMenuItem->new); + $menu_item->append(Gtk3::SeparatorMenuItem->new); } #properties - my $prop_item = Gtk2::ImageMenuItem->new($self->{_d}->get("Edit Preferences...")); - $prop_item->set_image(Gtk2::Image->new_from_stock('gtk-properties', 'menu')); + my $prop_item = Gtk3::ImageMenuItem->new($self->{_d}->get("Edit Preferences...")); + $prop_item->set_image(Gtk3::Image->new_from_stock('gtk-properties', 'menu')); #some items do not have properties, e.g. images or censor - $prop_item->set_sensitive(FALSE) if $item->isa('Goo::Canvas::Image') || !exists($self->{_items}{$key}{stroke_color}); + $prop_item->set_sensitive(FALSE) if $item->isa('GooCanvas2::CanvasImage') || !exists($self->{_items}{$key}{stroke_color}); $prop_item->signal_connect( 'activate' => sub { @@ -3972,7 +3983,7 @@ sub show_item_properties { #~ print "show_item_properties\n"; #create dialog - my $prop_dialog = Gtk2::Dialog->new( + my $prop_dialog = Gtk3::Dialog->new( $self->{_d}->get("Preferences"), $self->{_drawing_window}, [qw/modal destroy-with-parent/], @@ -4004,27 +4015,27 @@ sub show_item_properties { #RECT OR ELLIPSE OR NUMBER OR POLYLINE #GENERAL SETTINGS - if ( $item->isa('Goo::Canvas::Rect') - || $item->isa('Goo::Canvas::Ellipse') - || $item->isa('Goo::Canvas::Polyline') - || ($item->isa('Goo::Canvas::Text') && defined $self->{_items}{$key}{ellipse})) + if ( $item->isa('GooCanvas2::CanvasRect') + || $item->isa('GooCanvas2::CanvasEllipse') + || $item->isa('GooCanvas2::CanvasPolyline') + || ($item->isa('GooCanvas2::CanvasText') && defined $self->{_items}{$key}{ellipse})) { - my $general_vbox = Gtk2::VBox->new(FALSE, 5); + my $general_vbox = Gtk3::VBox->new(FALSE, 5); - my $label_general = Gtk2::Label->new; + my $label_general = Gtk3::Label->new; $label_general->set_markup("" . $self->{_d}->get("Main") . ""); - my $frame_general = Gtk2::Frame->new(); + my $frame_general = Gtk3::Frame->new(); $frame_general->set_label_widget($label_general); $frame_general->set_shadow_type('none'); $frame_general->set_border_width(5); - $prop_dialog->vbox->add($frame_general); + $prop_dialog->get_child->add($frame_general); #line_width - my $line_hbox = Gtk2::HBox->new(FALSE, 5); + my $line_hbox = Gtk3::HBox->new(FALSE, 5); $line_hbox->set_border_width(5); - my $linew_label = Gtk2::Label->new($self->{_d}->get("Line width") . ":"); - $line_spin = Gtk2::SpinButton->new_with_range(0.5, 20, 0.1); + my $linew_label = Gtk3::Label->new($self->{_d}->get("Line width") . ":"); + $line_spin = Gtk3::SpinButton->new_with_range(0.5, 20, 0.1); $line_spin->set_value($item->get('line-width')); @@ -4032,16 +4043,15 @@ sub show_item_properties { $line_hbox->pack_start($line_spin, TRUE, TRUE, 0); $general_vbox->pack_start($line_hbox, FALSE, FALSE, 0); - if ($item->isa('Goo::Canvas::Rect') || $item->isa('Goo::Canvas::Ellipse')) { + if ($item->isa('GooCanvas2::CanvasRect') || $item->isa('GooCanvas2::CanvasEllipse')) { #fill color - my $fill_color_hbox = Gtk2::HBox->new(FALSE, 5); + my $fill_color_hbox = Gtk3::HBox->new(FALSE, 5); $fill_color_hbox->set_border_width(5); - my $fill_color_label = Gtk2::Label->new($self->{_d}->get("Fill color") . ":"); - $fill_color = Gtk2::ColorButton->new(); + my $fill_color_label = Gtk3::Label->new($self->{_d}->get("Fill color") . ":"); + $fill_color = Gtk3::ColorButton->new(); - $fill_color->set_color($self->{_items}{$key}{fill_color}); - $fill_color->set_alpha(int($self->{_items}{$key}{fill_color_alpha} * 65535)); + $fill_color->set_rgba($self->{_items}{$key}{fill_color}); $fill_color->set_use_alpha(TRUE); $fill_color->set_title($self->{_d}->get("Choose fill color")); @@ -4055,13 +4065,12 @@ sub show_item_properties { if ($self->{_items}{$key}{stroke_color}) { #stroke color - my $stroke_color_hbox = Gtk2::HBox->new(FALSE, 5); + my $stroke_color_hbox = Gtk3::HBox->new(FALSE, 5); $stroke_color_hbox->set_border_width(5); - my $stroke_color_label = Gtk2::Label->new($self->{_d}->get("Stroke color") . ":"); - $stroke_color = Gtk2::ColorButton->new(); + my $stroke_color_label = Gtk3::Label->new($self->{_d}->get("Stroke color") . ":"); + $stroke_color = Gtk3::ColorButton->new(); - $stroke_color->set_color($self->{_items}{$key}{stroke_color}); - $stroke_color->set_alpha(int($self->{_items}{$key}{stroke_color_alpha} * 65535)); + $stroke_color->set_rgba($self->{_items}{$key}{stroke_color}); $stroke_color->set_use_alpha(TRUE); $stroke_color->set_title($self->{_d}->get("Choose stroke color")); @@ -4075,21 +4084,21 @@ sub show_item_properties { #special shapes like numbered ellipse if (defined $self->{_items}{$key}{text}) { - my $numbered_vbox = Gtk2::VBox->new(FALSE, 5); + my $numbered_vbox = Gtk3::VBox->new(FALSE, 5); - my $label_numbered = Gtk2::Label->new; + my $label_numbered = Gtk3::Label->new; $label_numbered->set_markup("" . $self->{_d}->get("Numbering") . ""); - my $frame_numbered = Gtk2::Frame->new(); + my $frame_numbered = Gtk3::Frame->new(); $frame_numbered->set_label_widget($label_numbered); $frame_numbered->set_shadow_type('none'); $frame_numbered->set_border_width(5); - $prop_dialog->vbox->add($frame_numbered); + $prop_dialog->get_child->add($frame_numbered); #current digit - my $number_hbox = Gtk2::HBox->new(FALSE, 5); + my $number_hbox = Gtk3::HBox->new(FALSE, 5); $number_hbox->set_border_width(5); - my $numberw_label = Gtk2::Label->new($self->{_d}->get("Current value") . ":"); - $number_spin = Gtk2::SpinButton->new_with_range(0, 999, 1); + my $numberw_label = Gtk3::Label->new($self->{_d}->get("Current value") . ":"); + $number_spin = Gtk3::SpinButton->new_with_range(0, 999, 1); $number_spin->set_value($self->{_items}{$key}{text}{digit}); @@ -4098,14 +4107,14 @@ sub show_item_properties { $numbered_vbox->pack_start($number_hbox, FALSE, FALSE, 0); #font button - my $font_hbox = Gtk2::HBox->new(FALSE, 5); + my $font_hbox = Gtk3::HBox->new(FALSE, 5); $font_hbox->set_border_width(5); - my $font_label = Gtk2::Label->new($self->{_d}->get("Font") . ":"); - $font_btn = Gtk2::FontButton->new(); + my $font_label = Gtk3::Label->new($self->{_d}->get("Font") . ":"); + $font_btn = Gtk3::FontButton->new(); #determine font description from string - my ($attr_list, $text_raw, $accel_char) = Gtk2::Pango->parse_markup($self->{_items}{$key}{text}->get('text')); - my $font_desc = Gtk2::Pango::FontDescription->from_string($self->{_font}); + my ($attr_list, $text_raw, $accel_char) = Pango->parse_markup($self->{_items}{$key}{text}->get('text')); + my $font_desc = Pango::FontDescription->from_string($self->{_font}); #FIXME, maybe the pango version installed is too old eval { @@ -4113,7 +4122,7 @@ sub show_item_properties { sub { my $attr = shift; $font_desc = $attr->copy->desc - if $attr->isa('Gtk2::Pango::AttrFontDesc'); + if $attr->isa('Pango::AttrFontDesc'); return TRUE; }, ); @@ -4136,25 +4145,25 @@ sub show_item_properties { } #ARROW item - if ( $item->isa('Goo::Canvas::Polyline') + if ( $item->isa('GooCanvas2::CanvasPolyline') && defined $self->{_items}{$key}{end_arrow} && defined $self->{_items}{$key}{start_arrow}) { - my $arrow_vbox = Gtk2::VBox->new(FALSE, 5); + my $arrow_vbox = Gtk3::VBox->new(FALSE, 5); - my $label_arrow = Gtk2::Label->new; + my $label_arrow = Gtk3::Label->new; $label_arrow->set_markup("" . $self->{_d}->get("Arrow") . ""); - my $frame_arrow = Gtk2::Frame->new(); + my $frame_arrow = Gtk3::Frame->new(); $frame_arrow->set_label_widget($label_arrow); $frame_arrow->set_shadow_type('none'); $frame_arrow->set_border_width(5); - $prop_dialog->vbox->add($frame_arrow); + $prop_dialog->get_child->add($frame_arrow); #arrow_width - my $arrow_hbox = Gtk2::HBox->new(FALSE, 5); + my $arrow_hbox = Gtk3::HBox->new(FALSE, 5); $arrow_hbox->set_border_width(5); - my $arroww_label = Gtk2::Label->new($self->{_d}->get("Width") . ":"); - $arrow_spin = Gtk2::SpinButton->new_with_range(0.5, 10, 0.1); + my $arroww_label = Gtk3::Label->new($self->{_d}->get("Width") . ":"); + $arrow_spin = Gtk3::SpinButton->new_with_range(0.5, 10, 0.1); $arrow_spin->set_value($item->get('arrow-width')); @@ -4163,10 +4172,10 @@ sub show_item_properties { $arrow_vbox->pack_start($arrow_hbox, FALSE, FALSE, 0); #arrow_length - my $arrowl_hbox = Gtk2::HBox->new(FALSE, 5); + my $arrowl_hbox = Gtk3::HBox->new(FALSE, 5); $arrowl_hbox->set_border_width(5); - my $arrowl_label = Gtk2::Label->new($self->{_d}->get("Length") . ":"); - $arrowl_spin = Gtk2::SpinButton->new_with_range(0.5, 10, 0.1); + my $arrowl_label = Gtk3::Label->new($self->{_d}->get("Length") . ":"); + $arrowl_spin = Gtk3::SpinButton->new_with_range(0.5, 10, 0.1); $arrowl_spin->set_value($item->get('arrow-length')); @@ -4175,10 +4184,10 @@ sub show_item_properties { $arrow_vbox->pack_start($arrowl_hbox, FALSE, FALSE, 0); #arrow_tip_length - my $arrowt_hbox = Gtk2::HBox->new(FALSE, 5); + my $arrowt_hbox = Gtk3::HBox->new(FALSE, 5); $arrowt_hbox->set_border_width(5); - my $arrowt_label = Gtk2::Label->new($self->{_d}->get("Tip length") . ":"); - $arrowt_spin = Gtk2::SpinButton->new_with_range(0.5, 10, 0.1); + my $arrowt_label = Gtk3::Label->new($self->{_d}->get("Tip length") . ":"); + $arrowt_spin = Gtk3::SpinButton->new_with_range(0.5, 10, 0.1); $arrowt_spin->set_value($item->get('arrow-tip-length')); @@ -4187,15 +4196,15 @@ sub show_item_properties { $arrow_vbox->pack_start($arrowt_hbox, FALSE, FALSE, 0); #checkboxes for start and end arrows - $end_arrow = Gtk2::CheckButton->new($self->{_d}->get("Display an arrow at the end of the line")); + $end_arrow = Gtk3::CheckButton->new($self->{_d}->get("Display an arrow at the end of the line")); $end_arrow->set_active($self->{_items}{$key}{end_arrow}); - $start_arrow = Gtk2::CheckButton->new($self->{_d}->get("Display an arrow at the start of the line")); + $start_arrow = Gtk3::CheckButton->new($self->{_d}->get("Display an arrow at the start of the line")); $start_arrow->set_active($self->{_items}{$key}{start_arrow}); - my $end_arrow_hbox = Gtk2::HBox->new(FALSE, 5); + my $end_arrow_hbox = Gtk3::HBox->new(FALSE, 5); $end_arrow_hbox->set_border_width(5); - my $start_arrow_hbox = Gtk2::HBox->new(FALSE, 5); + my $start_arrow_hbox = Gtk3::HBox->new(FALSE, 5); $start_arrow_hbox->set_border_width(5); $end_arrow_hbox->pack_start($end_arrow, FALSE, TRUE, 12); @@ -4208,29 +4217,29 @@ sub show_item_properties { $frame_arrow->add($arrow_vbox); #simple TEXT item (no numbered ellipse) - } elsif ($item->isa('Goo::Canvas::Text') + } elsif ($item->isa('GooCanvas2::CanvasText') && !defined $self->{_items}{$key}{ellipse}) { - my $text_vbox = Gtk2::VBox->new(FALSE, 5); + my $text_vbox = Gtk3::VBox->new(FALSE, 5); - my $label_text = Gtk2::Label->new; + my $label_text = Gtk3::Label->new; $label_text->set_markup("" . $self->{_d}->get("Text") . ""); - my $frame_text = Gtk2::Frame->new(); + my $frame_text = Gtk3::Frame->new(); $frame_text->set_label_widget($label_text); $frame_text->set_shadow_type('none'); $frame_text->set_border_width(5); - $prop_dialog->vbox->add($frame_text); + $prop_dialog->get_child->add($frame_text); #font button - my $font_hbox = Gtk2::HBox->new(FALSE, 5); + my $font_hbox = Gtk3::HBox->new(FALSE, 5); $font_hbox->set_border_width(5); - my $font_label = Gtk2::Label->new($self->{_d}->get("Font") . ":"); - $font_btn = Gtk2::FontButton->new(); + my $font_label = Gtk3::Label->new($self->{_d}->get("Font") . ":"); + $font_btn = Gtk3::FontButton->new(); #determine font description from string - my ($attr_list, $text_raw, $accel_char) = Gtk2::Pango->parse_markup($item->get('text')); - my $font_desc = Gtk2::Pango::FontDescription->from_string($self->{_font}); + my ($attr_list, $text_raw, $accel_char) = Pango->parse_markup($item->get('text')); + my $font_desc = Pango::FontDescription->from_string($self->{_font}); #FIXME, maybe the pango version installed is too old eval { @@ -4238,7 +4247,7 @@ sub show_item_properties { sub { my $attr = shift; $font_desc = $attr->copy->desc - if $attr->isa('Gtk2::Pango::AttrFontDesc'); + if $attr->isa('Pango::AttrFontDesc'); return TRUE; }, ); @@ -4252,14 +4261,13 @@ sub show_item_properties { $text_vbox->pack_start($font_hbox, FALSE, FALSE, 0); #font color - my $font_color_hbox = Gtk2::HBox->new(FALSE, 5); + my $font_color_hbox = Gtk3::HBox->new(FALSE, 5); $font_color_hbox->set_border_width(5); - my $font_color_label = Gtk2::Label->new($self->{_d}->get("Font color") . ":"); - $font_color = Gtk2::ColorButton->new(); + my $font_color_label = Gtk3::Label->new($self->{_d}->get("Font color") . ":"); + $font_color = Gtk3::ColorButton->new(); $font_color->set_use_alpha(TRUE); - $font_color->set_alpha(int($self->{_items}{$key}{stroke_color_alpha} * 65535)); - $font_color->set_color($self->{_items}{$key}{stroke_color}); + $font_color->set_rgba($self->{_items}{$key}{stroke_color}); $font_color->set_title($self->{_d}->get("Choose font color")); $font_color_hbox->pack_start($font_color_label, FALSE, TRUE, 12); @@ -4268,30 +4276,30 @@ sub show_item_properties { $text_vbox->pack_start($font_color_hbox, FALSE, FALSE, 0); #initial buffer - my $text = Gtk2::TextBuffer->new; + my $text = Gtk3::TextBuffer->new; $text->set_text($text_raw); #textview - my $textview_hbox = Gtk2::HBox->new(FALSE, 5); + my $textview_hbox = Gtk3::HBox->new(FALSE, 5); $textview_hbox->set_border_width(5); - $textview = Gtk2::TextView->new_with_buffer($text); - $textview->can_focus(TRUE); + $textview = Gtk3::TextView->new_with_buffer($text); + $textview->set_can_focus(TRUE); $textview->set_size_request(150, 200); - $textview_hbox->pack_start_defaults($textview); + $textview_hbox->pack_start($textview, TRUE, TRUE, 0); - $text_vbox->pack_start_defaults($textview_hbox); + $text_vbox->pack_start($textview_hbox, TRUE, TRUE, 0); #use font checkbox - my $use_font = Gtk2::CheckButton->new_with_label($self->{_d}->get("Use selected font")); + my $use_font = Gtk3::CheckButton->new_with_label($self->{_d}->get("Use selected font")); $use_font->set_active(FALSE); - $text_vbox->pack_start_defaults($use_font); + $text_vbox->pack_start($use_font, TRUE, TRUE, 0); #use font color checkbox - my $use_font_color = Gtk2::CheckButton->new_with_label($self->{_d}->get("Use selected font color")); + my $use_font_color = Gtk3::CheckButton->new_with_label($self->{_d}->get("Use selected font color")); $use_font_color->set_active(FALSE); - $text_vbox->pack_start_defaults($use_font_color); + $text_vbox->pack_start($use_font_color, TRUE, TRUE, 0); #apply changes directly $use_font->signal_connect( @@ -4457,7 +4465,7 @@ sub show_item_properties { } #layout adjustments - my $sg_prop = Gtk2::SizeGroup->new('horizontal'); + my $sg_prop = Gtk3::SizeGroup->new('horizontal'); foreach ($prop_dialog->get_children->get_children) { if ($_->can('get_children')) { foreach ($_->get_children) { @@ -4465,7 +4473,7 @@ sub show_item_properties { foreach ($_->get_children) { if ($_->can('get_children')) { foreach ($_->get_children) { - if ($_ =~ /Gtk2::Label/) { + if ($_ =~ /Gtk3::Label/) { #~ print $_->get_text, "\n"; $_->set_alignment(0, 0.5); @@ -4559,10 +4567,8 @@ sub apply_properties { && $self->{_items}{$key}{type} ne "censor") { - $self->{_last_fill_color} = $self->{_fill_color_w}->get_color; - $self->{_last_fill_color_alpha} = $self->{_fill_color_w}->get_alpha / 65535; - $self->{_last_stroke_color} = $self->{_stroke_color_w}->get_color; - $self->{_last_stroke_color_alpha} = $self->{_stroke_color_w}->get_alpha / 65535; + $self->{_last_fill_color} = $self->{_fill_color_w}->get_rgba; + $self->{_last_stroke_color} = $self->{_stroke_color_w}->get_rgba; $self->{_last_line_width} = $self->{_line_spin_w}->get_value; $self->{_last_font} = $self->{_font_btn_w}->get_font_name; @@ -4577,14 +4583,12 @@ sub apply_properties { } #apply rect or ellipse options - if ($item->isa('Goo::Canvas::Rect') || $item->isa('Goo::Canvas::Ellipse')) { + if ($item->isa('GooCanvas2::CanvasRect') || $item->isa('GooCanvas2::CanvasEllipse')) { - my $fill_pattern = $self->create_color($fill_color->get_color, $fill_color->get_alpha / 65535); - my $stroke_pattern = $self->create_color($stroke_color->get_color, $stroke_color->get_alpha / 65535); $item->set( 'line-width' => $line_spin->get_value, - 'fill-pattern' => $fill_pattern, - 'stroke-pattern' => $stroke_pattern + 'fill-color-gdk-rgba' => $fill_color->get_rgba, + 'stroke-color-gdk-rgba' => $stroke_color->get_rgba, ); #special shapes like numbered ellipse (digit changed) @@ -4598,17 +4602,17 @@ sub apply_properties { $digit = $self->{_items}{$key}{text}{digit}; } - my $fill_pattern = undef; + my $fill_color = undef; if (defined $font_color) { - $fill_pattern = $self->create_color($font_color->get_color, $font_color->get_alpha / 65535); + $fill_color = $font_color->get_rgba; } elsif (defined $stroke_color) { - $fill_pattern = $self->create_color($stroke_color->get_color, $stroke_color->get_alpha / 65535); + $fill_color = $stroke_color->get_rgba; } - my $font_descr = Gtk2::Pango::FontDescription->from_string($font_btn->get_font_name); + my $font_descr = Pango::FontDescription->from_string($font_btn->get_font_name); $self->{_items}{$key}{text}->set( 'text' => "" . $digit . "", - 'fill-pattern' => $fill_pattern, + 'fill-color-gdk-rgba' => $fill_color, ); #adjust parent rectangle @@ -4637,20 +4641,16 @@ sub apply_properties { } #save color and opacity as well - $self->{_items}{$key}{fill_color} = $fill_color->get_color; - $self->{_items}{$key}{fill_color_alpha} = $fill_color->get_alpha / 65535; - $self->{_items}{$key}{stroke_color} = $stroke_color->get_color; - $self->{_items}{$key}{stroke_color_alpha} = $stroke_color->get_alpha / 65535; + $self->{_items}{$key}{fill_color} = $fill_color->get_rgba; + $self->{_items}{$key}{stroke_color} = $stroke_color->get_rgba; } #apply polyline options (arrow) - if ( $item->isa('Goo::Canvas::Polyline') + if ( $item->isa('GooCanvas2::CanvasPolyline') && defined $self->{_items}{$key}{end_arrow} && defined $self->{_items}{$key}{start_arrow}) { - my $stroke_pattern = $self->create_color($stroke_color->get_color, $stroke_color->get_alpha / 65535); - #these values are only available in the item menu if ( defined $arrowl_spin && defined $arrow_spin @@ -4660,7 +4660,7 @@ sub apply_properties { { $item->set( 'line-width' => $line_spin->get_value, - 'stroke-pattern' => $stroke_pattern, + 'stroke-color-gdk-rgba' => $stroke_color->get_rgba, 'end-arrow' => $end_arrow->get_active, 'start-arrow' => $start_arrow->get_active, 'arrow-length' => $arrowl_spin->get_value, @@ -4671,15 +4671,14 @@ sub apply_properties { } else { $item->set( 'line-width' => $line_spin->get_value, - 'stroke-pattern' => $stroke_pattern, + 'stroke-color-gdk-rgba' => $stroke_color->get_rgba, 'end-arrow' => $self->{_items}{$key}{line}->get('end-arrow'), 'start-arrow' => $self->{_items}{$key}{line}->get('start-arrow'), ); } #save color and opacity as well - $self->{_items}{$key}{stroke_color} = $stroke_color->get_color; - $self->{_items}{$key}{stroke_color_alpha} = $stroke_color->get_alpha / 65535; + $self->{_items}{$key}{stroke_color} = $stroke_color->get_rgba; #save arrow specific properties $self->{_items}{$key}{end_arrow} = $self->{_items}{$key}{line}->get('end-arrow'); @@ -4689,25 +4688,21 @@ sub apply_properties { $self->{_items}{$key}{arrow_tip_length} = $self->{_items}{$key}{line}->get('arrow-tip-length'); #apply polyline options (freehand, highlighter) - } elsif ($item->isa('Goo::Canvas::Polyline') + } elsif ($item->isa('GooCanvas2::CanvasPolyline') && defined $self->{_items}{$key}{stroke_color}) { - my $stroke_pattern = $self->create_color($stroke_color->get_color, $stroke_color->get_alpha / 65535); $item->set( 'line-width' => $line_spin->get_value, - 'stroke-pattern' => $stroke_pattern, + 'stroke-color-gdk-rgba' => $stroke_color->get_rgba, ); #save color and opacity as well - $self->{_items}{$key}{stroke_color} = $stroke_color->get_color; - $self->{_items}{$key}{stroke_color_alpha} = $stroke_color->get_alpha / 65535; + $self->{_items}{$key}{stroke_color} = $stroke_color->get_rgba; } #apply text options - if ($item->isa('Goo::Canvas::Text')) { - my $font_descr = Gtk2::Pango::FontDescription->from_string($font_btn->get_font_name); - - my $fill_pattern = $self->create_color($font_color->get_color, $font_color->get_alpha / 65535); + if ($item->isa('GooCanvas2::CanvasText')) { + my $font_descr = Pango::FontDescription->from_string($font_btn->get_font_name); my $new_text = undef; if ($textview) { @@ -4716,7 +4711,7 @@ sub apply_properties { } else { #determine font description and text from string - my ($attr_list, $text_raw, $accel_char) = Gtk2::Pango->parse_markup($item->get('text')); + my ($attr_list, $text_raw, $accel_char) = Pango->parse_markup($item->get('text')); $new_text = $text_raw; } @@ -4724,7 +4719,7 @@ sub apply_properties { 'text' => "" . Glib::Markup::escape_text($new_text) . "", 'width' => -1, 'use-markup' => TRUE, - 'fill-pattern' => $fill_pattern + 'fill-color-gdk-rgba' => $font_color->get_rgba, ); #adjust parent rectangle @@ -4738,8 +4733,7 @@ sub apply_properties { $self->handle_embedded('update', $parent); #save color and opacity as well - $self->{_items}{$key}{stroke_color} = $font_color->get_color; - $self->{_items}{$key}{stroke_color_alpha} = $font_color->get_alpha / 65535; + $self->{_items}{$key}{stroke_color} = $font_color->get_rgba; } @@ -4754,20 +4748,20 @@ sub modify_text_in_properties { my $use_font = shift; my $use_font_color = shift; - my $font_descr = Gtk2::Pango::FontDescription->from_string($font_btn->get_font_name); - my $texttag = Gtk2::TextTag->new; + my $font_descr = Pango::FontDescription->from_string($font_btn->get_font_name); + my $texttag = Gtk3::TextTag->new; if ($use_font->get_active && $use_font_color->get_active) { - $texttag->set('font-desc' => $font_descr, 'foreground-gdk' => $font_color->get_color); + $texttag->set('font-desc' => $font_descr, 'foreground-rgba' => $font_color->get_rgba); } elsif ($use_font->get_active) { $texttag->set('font-desc' => $font_descr); } elsif ($use_font_color->get_active) { - $texttag->set('foreground-gdk' => $font_color->get_color); + $texttag->set('foreground-rgba' => $font_color->get_rgba); } - my $texttagtable = Gtk2::TextTagTable->new; + my $texttagtable = Gtk3::TextTagTable->new; $texttagtable->add($texttag); - my $text = Gtk2::TextBuffer->new($texttagtable); + my $text = Gtk3::TextBuffer->new($texttagtable); $text->signal_connect( 'changed' => sub { $text->apply_tag($texttag, $text->get_start_iter, $text->get_end_iter); @@ -4794,7 +4788,7 @@ sub move_all { #real shape if (exists $self->{_items}{$item}) { - if ($item->isa('Goo::Canvas::Rect')) { + if ($item->isa('GooCanvas2::CanvasRect')) { $item->set( 'x' => $item->get('x') - $x, @@ -4812,7 +4806,7 @@ sub move_all { $self->handle_rects('update', $item); #pixelizer is treated differently - if ($child && $child->isa('Goo::Canvas::Image')) { + if ($child && $child->isa('GooCanvas2::CanvasImage')) { my $parent = $self->get_parent_item($child); if (exists $self->{_items}{$parent}{pixelize}) { @@ -4937,33 +4931,33 @@ sub handle_embedded { #arrow is always and end-arrow if ($self->{_items}{$item}{mirrored_w} < 0 && $self->{_items}{$item}{mirrored_h} < 0) { $self->{_items}{$item}{line}->set( - 'points' => Goo::Canvas::Points->new([ + 'points' => points_to_canvas_points( $self->{_items}{$item}->get('x') + $self->{_items}{$item}->get('width'), $self->{_items}{$item}->get('y') + $self->{_items}{$item}->get('height'), - $self->{_items}{$item}->get('x'), $self->{_items}{$item}->get('y')] + $self->{_items}{$item}->get('x'), $self->{_items}{$item}->get('y') ), 'visibility' => $visibility ); } elsif ($self->{_items}{$item}{mirrored_w} < 0) { $self->{_items}{$item}{line}->set( - 'points' => Goo::Canvas::Points->new([ + 'points' => points_to_canvas_points( $self->{_items}{$item}->get('x') + $self->{_items}{$item}->get('width'), $self->{_items}{$item}->get('y'), - $self->{_items}{$item}->get('x'), $self->{_items}{$item}->get('y') + $self->{_items}{$item}->get('height')] + $self->{_items}{$item}->get('x'), $self->{_items}{$item}->get('y') + $self->{_items}{$item}->get('height') ), 'visibility' => $visibility ); } elsif ($self->{_items}{$item}{mirrored_h} < 0) { $self->{_items}{$item}{line}->set( - 'points' => Goo::Canvas::Points->new([ + 'points' => points_to_canvas_points( $self->{_items}{$item}->get('x'), $self->{_items}{$item}->get('y') + $self->{_items}{$item}->get('height'), - $self->{_items}{$item}->get('x') + $self->{_items}{$item}->get('width'), $self->{_items}{$item}->get('y')] + $self->{_items}{$item}->get('x') + $self->{_items}{$item}->get('width'), $self->{_items}{$item}->get('y') ), 'visibility' => $visibility ); } else { $self->{_items}{$item}{line}->set( - 'points' => Goo::Canvas::Points->new([ + 'points' => points_to_canvas_points( $self->{_items}{$item}->get('x'), $self->{_items}{$item}->get('y'), - $self->{_items}{$item}->get('x') + $self->{_items}{$item}->get('width'), $self->{_items}{$item}->get('y') + $self->{_items}{$item}->get('height')] + $self->{_items}{$item}->get('x') + $self->{_items}{$item}->get('width'), $self->{_items}{$item}->get('y') + $self->{_items}{$item}->get('height') ), 'visibility' => $visibility ); @@ -5118,23 +5112,22 @@ sub handle_bg_rects { if ($action eq 'create') { - my $pattern = $self->create_color($self->{_style_bg}, 1); - $self->{_canvas_bg_rect}{'bottom-side'} = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, $middle_h, $bottom, 8, 8, - 'fill-pattern' => $pattern, + $self->{_canvas_bg_rect}{'bottom-side'} = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>$middle_h, y=>$bottom, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'line-width' => 1, ); - $self->{_canvas_bg_rect}{'bottom-right-corner'} = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, $right, $bottom, 8, 8, - 'fill-pattern' => $pattern, + $self->{_canvas_bg_rect}{'bottom-right-corner'} = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>$right, y=>$bottom, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'line-width' => 1, ); - $self->{_canvas_bg_rect}{'right-side'} = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, $right, $middle_v, 8, 8, - 'fill-pattern' => $pattern, + $self->{_canvas_bg_rect}{'right-side'} = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>$right, y=>$middle_v, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'line-width' => 1, ); @@ -5202,7 +5195,7 @@ sub handle_rects { #get root item my $root = $self->{_canvas}->get_root_item; - if ($self->{_items}{$item}->isa('Goo::Canvas::Rect')) { + if ($self->{_items}{$item}->isa('GooCanvas2::CanvasRect')) { my $x = $self->{_items}{$item}->get('x'); my $y = $self->{_items}{$item}->get('y'); @@ -5218,68 +5211,66 @@ sub handle_rects { if ($action eq 'create') { - my $pattern = $self->create_color($self->{_style_bg}, 1); - - $self->{_items}{$item}{'top-side'} = Goo::Canvas::Rect->new( - $root, $middle_h, $top, 8, 8, - 'fill-pattern' => $pattern, + $self->{_items}{$item}{'top-side'} = GooCanvas2::CanvasRect->new( + parent=>$root, x=>$middle_h, y=>$top, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'visibility' => 'hidden', 'line-width' => 0.5, ); - $self->{_items}{$item}{'top-left-corner'} = Goo::Canvas::Rect->new( - $root, $left, $top, 8, 8, - 'fill-pattern' => $pattern, + $self->{_items}{$item}{'top-left-corner'} = GooCanvas2::CanvasRect->new( + parent=>$root, x=>$left, y=>$top, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'visibility' => 'hidden', 'line-width' => 0.5, 'radius-x' => 8, 'radius-y' => 8, ); - $self->{_items}{$item}{'top-right-corner'} = Goo::Canvas::Rect->new( - $root, $right, $top, 8, 8, - 'fill-pattern' => $pattern, + $self->{_items}{$item}{'top-right-corner'} = GooCanvas2::CanvasRect->new( + parent=>$root, x=>$right, y=>$top, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'visibility' => 'hidden', 'line-width' => 0.5, 'radius-x' => 8, 'radius-y' => 8, ); - $self->{_items}{$item}{'bottom-side'} = Goo::Canvas::Rect->new( - $root, $middle_h, $bottom, 8, 8, - 'fill-pattern' => $pattern, + $self->{_items}{$item}{'bottom-side'} = GooCanvas2::CanvasRect->new( + parent=>$root, x=>$middle_h, y=>$bottom, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'visibility' => 'hidden', 'line-width' => 0.5, ); - $self->{_items}{$item}{'bottom-left-corner'} = Goo::Canvas::Rect->new( - $root, $left, $bottom, 8, 8, - 'fill-pattern' => $pattern, + $self->{_items}{$item}{'bottom-left-corner'} = GooCanvas2::CanvasRect->new( + parent=>$root, x=>$left, y=>$bottom, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'visibility' => 'hidden', 'line-width' => 0.5, 'radius-x' => 8, 'radius-y' => 8, ); - $self->{_items}{$item}{'bottom-right-corner'} = Goo::Canvas::Rect->new( - $root, $right, $bottom, 8, 8, - 'fill-pattern' => $pattern, + $self->{_items}{$item}{'bottom-right-corner'} = GooCanvas2::CanvasRect->new( + parent=>$root, x=>$right, y=>$bottom, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'visibility' => 'hidden', 'line-width' => 0.5, 'radius-x' => 8, 'radius-y' => 8, ); - $self->{_items}{$item}{'left-side'} = Goo::Canvas::Rect->new( - $root, $left - 8, $middle_v, 8, 8, - 'fill-pattern' => $pattern, + $self->{_items}{$item}{'left-side'} = GooCanvas2::CanvasRect->new( + parent=>$root, x=>$left - 8, y=>$middle_v, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'visibility' => 'hidden', 'line-width' => 0.5, ); - $self->{_items}{$item}{'right-side'} = Goo::Canvas::Rect->new( - $root, $right, $middle_v, 8, 8, - 'fill-pattern' => $pattern, + $self->{_items}{$item}{'right-side'} = GooCanvas2::CanvasRect->new( + parent=>$root, x=>$right, y=>$middle_v, width=>8, height=>8, + 'fill-color-gdk-rgba' => $self->{_style_bg}, 'visibility' => 'hidden', 'line-width' => 0.5, ); @@ -5466,7 +5457,7 @@ sub event_item_on_button_release { my $deleted = FALSE; #set minimum sizes - if ($nitem->isa('Goo::Canvas::Rect')) { + if ($nitem->isa('GooCanvas2::CanvasRect')) { #real shape if (exists $self->{_items}{$nitem}) { @@ -5576,9 +5567,9 @@ sub event_item_on_button_release { #~ print "item $oitem found at ",$ev->x,", ",$ev->y,"\n"; #turn into a button-press-event - my $initevent = Gtk2::Gdk::Event->new('button-press'); - $initevent->set_time(Gtk2->get_current_event_time); - $initevent->window($self->{_drawing_window}->window); + my $initevent = Gtk3::Gdk::Event->new('button-press'); + $initevent->time(Gtk3::get_current_event_time()); + $initevent->window($self->{_drawing_window}->get_window); $initevent->x($ev->x); $initevent->y($ev->y); $self->event_item_on_button_press($oitem, undef, $initevent, TRUE); @@ -5612,7 +5603,7 @@ sub event_item_on_button_release { #those items would not be visible on the canvas #we delete them here my $citem = $self->{_current_item}; - if ($citem && $citem->isa('Goo::Canvas::Rect')) { + if ($citem && $citem->isa('GooCanvas2::CanvasRect')) { if (exists $self->{_items}{$citem}) { if ($self->{_items}{$citem}->get('visibility') eq 'hidden') { if (my $nint = $self->{_canvas}->get_root_item->find_child($citem)) { @@ -5654,7 +5645,7 @@ sub event_item_on_button_release { #see handle_embedded my $child = $self->get_child_item($self->{_current_item}); - if ($child && $child->isa('Goo::Canvas::Image')) { + if ($child && $child->isa('GooCanvas2::CanvasImage')) { my $parent = $self->get_parent_item($child); if (exists $self->{_items}{$parent}{pixelize}) { @@ -5717,7 +5708,7 @@ sub event_item_on_enter_notify { return TRUE if $self->{_busy}; if ( - ($item->isa('Goo::Canvas::Rect') || $item->isa('Goo::Canvas::Ellipse') || $item->isa('Goo::Canvas::Text') || $item->isa('Goo::Canvas::Image') || $item->isa('Goo::Canvas::Polyline')) + ($item->isa('GooCanvas2::CanvasRect') || $item->isa('GooCanvas2::CanvasEllipse') || $item->isa('GooCanvas2::CanvasText') || $item->isa('GooCanvas2::CanvasImage') || $item->isa('GooCanvas2::CanvasPolyline')) && ( $self->{_current_mode_descr} ne "freehand" && $self->{_current_mode_descr} ne "highlighter" && $self->{_current_mode_descr} ne "censor") @@ -5740,14 +5731,12 @@ sub event_item_on_enter_notify { || $self->{_canvas_bg_rect}{'bottom-right-corner'} == $item) { - my $pattern = $self->create_color('red', 1); - $item->set('fill-pattern' => $pattern); + $item->set('fill-color' => 'red'); #resizing shape } else { - my $pattern = $self->create_color('red', 1); - $item->set('fill-pattern' => $pattern); + $item->set('fill-color' => 'red'); } } @@ -5761,7 +5750,7 @@ sub event_item_on_leave_notify { return TRUE if $self->{_busy}; if ( - ($item->isa('Goo::Canvas::Rect') || $item->isa('Goo::Canvas::Ellipse') || $item->isa('Goo::Canvas::Text') || $item->isa('Goo::Canvas::Image') || $item->isa('Goo::Canvas::Polyline')) + ($item->isa('GooCanvas2::CanvasRect') || $item->isa('GooCanvas2::CanvasEllipse') || $item->isa('GooCanvas2::CanvasText') || $item->isa('GooCanvas2::CanvasImage') || $item->isa('GooCanvas2::CanvasPolyline')) && ( $self->{_current_mode_descr} ne "freehand" && $self->{_current_mode_descr} ne "highlighter" && $self->{_current_mode_descr} ne "censor") @@ -5784,14 +5773,12 @@ sub event_item_on_leave_notify { || $self->{_canvas_bg_rect}{'bottom-right-corner'} == $item) { - my $pattern = $self->create_color($self->{_style_bg}, 1); - $item->set('fill-pattern' => $pattern); + $item->set('fill-color-gdk-rgba' => $self->{_style_bg}); #resizing shape } else { - my $pattern = $self->create_color($self->{_style_bg}, 1); - $item->set('fill-pattern' => $pattern); + $item->set('fill-color-gdk-rgba' => $self->{_style_bg}); } } @@ -5799,73 +5786,27 @@ sub event_item_on_leave_notify { return TRUE; } -sub create_stipple { - my $self = shift; - - our @stipples; - my ($color_name, $stipple_data) = @_; - my $color = Gtk2::Gdk::Color->parse($color_name); - $stipple_data->[2] = $stipple_data->[14] = $color->red >> 8; - $stipple_data->[1] = $stipple_data->[13] = $color->green >> 8; - $stipple_data->[0] = $stipple_data->[12] = $color->blue >> 8; - my $stipple_str = join('', map { chr } @$stipple_data); - push @stipples, \$stipple_str; # make $stipple_str refcnt increase - my $surface = Cairo::ImageSurface->create_for_data($stipple_str, 'argb32', 2, 2, 8); - my $pattern = Cairo::SurfacePattern->create($surface); - $pattern->set_extend('repeat'); - - return Goo::Cairo::Pattern->new($pattern); -} - -sub create_alpha { - my $self = shift; - my $pattern = Cairo::SolidPattern->create_rgba(0, 0, 0, 0); - return Goo::Cairo::Pattern->new($pattern); -} - -sub create_color { - my $self = shift; - my $color_name = shift; - my $alpha = shift; - - return FALSE unless defined $color_name; - return FALSE unless defined $alpha; - - my $color; - - #if it is a color, we do not need to parse it - unless ($color_name->isa('Gtk2::Gdk::Color')) { - $color = Gtk2::Gdk::Color->parse($color_name); - } else { - $color = $color_name; - } - - my $pattern = Cairo::SolidPattern->create_rgba($color->red / 257 / 255, $color->green / 257 / 255, $color->blue / 257 / 255, $alpha); - - return Goo::Cairo::Pattern->new($pattern); -} - #ui related stuff sub setup_uimanager { my $self = shift; - $self->{_factory} = Gtk2::IconFactory->new(); - $self->{_factory}->add('shutter-ellipse', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-ellipse.png'))); - $self->{_factory}->add('shutter-eraser', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-eraser.png'))); - $self->{_factory}->add('shutter-freehand', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-freehand.png'))); - $self->{_factory}->add('shutter-highlighter', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-highlighter.png'))); - $self->{_factory}->add('shutter-pointer', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-pointer.png'))); - $self->{_factory}->add('shutter-rectangle', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-rectangle.png'))); - $self->{_factory}->add('shutter-line', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-line.png'))); - $self->{_factory}->add('shutter-arrow', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-arrow.png'))); - $self->{_factory}->add('shutter-text', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-text.png'))); - $self->{_factory}->add('shutter-censor', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-censor.png'))); - $self->{_factory}->add('shutter-pixelize', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-pixelize.png'))); - $self->{_factory}->add('shutter-number', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-number.png'))); - $self->{_factory}->add('shutter-crop', Gtk2::IconSet->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/transform-crop.png'))); - - #~ $self->{_factory}->add( 'shutter-mime-pdf', Gtk2::IconSet->new_from_pixbuf( Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons}.'/mime-pdf.svg') ) ); - #~ $self->{_factory}->add( 'shutter-mime-svg', Gtk2::IconSet->new_from_pixbuf( Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons}.'/mime-svg.svg') ) ); + $self->{_factory} = Gtk3::IconFactory->new(); + $self->{_factory}->add('shutter-ellipse', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-ellipse.png'))); + $self->{_factory}->add('shutter-eraser', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-eraser.png'))); + $self->{_factory}->add('shutter-freehand', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-freehand.png'))); + $self->{_factory}->add('shutter-highlighter', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-highlighter.png'))); + $self->{_factory}->add('shutter-pointer', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-pointer.png'))); + $self->{_factory}->add('shutter-rectangle', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-rectangle.png'))); + $self->{_factory}->add('shutter-line', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-line.png'))); + $self->{_factory}->add('shutter-arrow', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-arrow.png'))); + $self->{_factory}->add('shutter-text', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-text.png'))); + $self->{_factory}->add('shutter-censor', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-censor.png'))); + $self->{_factory}->add('shutter-pixelize', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-pixelize.png'))); + $self->{_factory}->add('shutter-number', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-number.png'))); + $self->{_factory}->add('shutter-crop', Gtk3::IconSet->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/transform-crop.png'))); + + #~ $self->{_factory}->add( 'shutter-mime-pdf', Gtk3::IconSet->new_from_pixbuf( Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons}.'/mime-pdf.svg') ) ); + #~ $self->{_factory}->add( 'shutter-mime-svg', Gtk3::IconSet->new_from_pixbuf( Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons}.'/mime-svg.svg') ) ); $self->{_factory}->add_default(); my @main_actions = ( @@ -6150,22 +6091,22 @@ sub setup_uimanager { ["Number", 'shutter-number', $self->{_d}->get("Number"), "9", $self->{_d}->get("Add an auto-increment shape to the screenshot"), 110], ["Crop", 'shutter-crop', $self->{_d}->get("Crop"), "c", $self->{_d}->get("Crop your screenshot"), 120]); - my $uimanager = Gtk2::UIManager->new(); + my $uimanager = Gtk3::UIManager->new(); #keyboard accel_group my $accelgroup = $uimanager->get_accel_group; $self->{_drawing_window}->add_accel_group($accelgroup); # Setup the main group. - my $main_group = Gtk2::ActionGroup->new("main"); + my $main_group = Gtk3::ActionGroup->new("main"); $main_group->add_actions(\@main_actions); #setup the menu toggle group - my $toggle_group = Gtk2::ActionGroup->new("toggle"); + my $toggle_group = Gtk3::ActionGroup->new("toggle"); $toggle_group->add_toggle_actions(\@toggle_actions); # Setup the drawing group. - my $drawing_group = Gtk2::ActionGroup->new("drawing"); + my $drawing_group = Gtk3::ActionGroup->new("drawing"); $drawing_group->add_radio_actions(\@drawing_actions, 10, sub { my $action = shift; $self->change_drawing_tool_cb($action); }); $uimanager->insert_action_group($main_group, 0); @@ -6272,18 +6213,20 @@ sub setup_uimanager { sub import_from_dnd { my ($self, $widget, $context, $x, $y, $selection, $info, $time) = @_; - my $type = $selection->target->name; - my $data = $selection->data; + my $type = $selection->get_target->name; return unless $type eq 'text/uri-list'; + my $data = $selection->get_data; + $data = join('', map { chr } @$data); my @files = grep defined($_), split /[\r\n]+/, $data; my @valid_files; - foreach (@files) { - my ($mime_type) = Glib::Object::Introspection->invoke('Gio', undef, 'content_type_guess', $_); + foreach my $file (@files) { + my $giofile = Glib::IO::File::new_for_uri($file); + my ($mime_type) = Glib::Object::Introspection->invoke('Gio', undef, 'content_type_guess', $giofile->get_path); $mime_type =~ s/image\/x\-apple\-ios\-png/image\/png/; #FIXME if ($mime_type && $self->check_valid_mime_type($mime_type)) { - push @valid_files, $_; + push @valid_files, $file; } } @@ -6297,17 +6240,17 @@ sub import_from_dnd { foreach (@valid_files) { #transform uri to path - my $new_uri = Glib::IO::File::new_for_uri($self->utf8_decode(main::unescape_string($_))); - my $new_file = $self->utf8_decode(main::unescape_string($new_uri->get_path)); + my $new_uri = Glib::IO::File::new_for_uri($_); + my $new_file = $new_uri->get_path; $self->{_current_pixbuf} = $self->{_lp}->load($new_file, undef, undef, undef, TRUE); if ($self->{_current_pixbuf}) { $self->{_current_pixbuf_filename} = $new_file; #construct an event and create a new image object - my $initevent = Gtk2::Gdk::Event->new('motion-notify'); - $initevent->set_time(Gtk2->get_current_event_time); - $initevent->window($self->{_drawing_window}->window); + my $initevent = Gtk3::Gdk::Event->new('motion-notify'); + $initevent->time(Gtk3::get_current_event_time()); + $initevent->window($self->{_drawing_window}->get_window); $initevent->x($x); $initevent->y($y); @@ -6330,11 +6273,11 @@ sub import_from_dnd { $self->{_current_new_item} = undef; } else { - $context->finish(0, 0, $time); + Gtk3::drag_finish($context, 0, 0, $time); return FALSE; } - $context->finish(1, 0, $time); + Gtk3::drag_finish($context, 1, 0, $time); return TRUE; } @@ -6352,9 +6295,9 @@ sub check_valid_mime_type { my $self = shift; my $mime_type = shift; - foreach (Gtk2::Gdk::Pixbuf->get_formats) { - foreach (@{$_->{mime_types}}) { - return TRUE if $_ eq $mime_type; + foreach my $format (Gtk3::Gdk::Pixbuf::get_formats()) { + foreach my $mime (@{$format->get_mime_types}) { + return TRUE if $mime_type eq $mime_type; last; } } @@ -6370,7 +6313,7 @@ sub import_from_filesystem { my $parent = shift; my $directory = shift; - my $menu_objects = Gtk2::Menu->new; + my $menu_objects = Gtk3::Menu->new; my $dobjects = $directory || $self->{_sc}->get_root . "/share/shutter/resources/icons/drawing_tool/objects"; @@ -6391,18 +6334,18 @@ sub import_from_filesystem { #objects from each directory are sorted (files first) #we display a separator when the first directory is listed if ($fd && $ff) { - $menu_objects->append(Gtk2::SeparatorMenuItem->new); + $menu_objects->append(Gtk3::SeparatorMenuItem->new); $fd = FALSE; } #objects from directory $name - my $subdir_item = Gtk2::ImageMenuItem->new_with_label($short); - $subdir_item->set('always_show_image' => TRUE) if Gtk2->CHECK_VERSION(2, 16, 0); - $subdir_item->set_image(Gtk2::Image->new_from_stock('gtk-directory', 'menu')); + my $subdir_item = Gtk3::ImageMenuItem->new_with_label($short); + $subdir_item->set('always_show_image' => TRUE); + $subdir_item->set_image(Gtk3::Image->new_from_stock('gtk-directory', 'menu')); #add empty menu first - my $menu_empty = Gtk2::Menu->new; - my $empty_item = Gtk2::MenuItem->new_with_label($self->{_d}->get("No icon was found")); + my $menu_empty = Gtk3::Menu->new; + my $empty_item = Gtk3::MenuItem->new_with_label($self->{_d}->get("No icon was found")); $empty_item->set_sensitive(FALSE); $menu_empty->append($empty_item); $subdir_item->set_submenu($menu_empty); @@ -6410,7 +6353,7 @@ sub import_from_filesystem { #and populate later (performance) $subdir_item->{'nid'} = $subdir_item->signal_connect( 'activate' => sub { - $subdir_item->set_image(Gtk2::Image->new_from_file($self->{_icons} . "/throbber_16x16.gif")); + $subdir_item->set_image(Gtk3::Image->new_from_file($self->{_icons} . "/throbber_16x16.gif")); my $submenu = $self->import_from_filesystem($button, $subdir_item, $dobjects . "/$short"); if ($submenu->get_children) { @@ -6419,7 +6362,7 @@ sub import_from_filesystem { } else { - $subdir_item->set_image(Gtk2::Image->new_from_stock('gtk-directory', 'menu')); + $subdir_item->set_image(Gtk3::Image->new_from_stock('gtk-directory', 'menu')); } @@ -6442,8 +6385,8 @@ sub import_from_filesystem { $ff = TRUE; #init item with filename first - my $new_item = Gtk2::ImageMenuItem->new_with_label($short); - $new_item->set('always_show_image' => TRUE) if Gtk2->CHECK_VERSION(2, 16, 0); + my $new_item = Gtk3::ImageMenuItem->new_with_label($short); + $new_item->set('always_show_image' => TRUE); $menu_objects->append($new_item); #sfsdc @@ -6455,29 +6398,29 @@ sub import_from_filesystem { #top level call unless ($directory) { - $menu_objects->append(Gtk2::SeparatorMenuItem->new); + $menu_objects->append(Gtk3::SeparatorMenuItem->new); #~ #objects from icontheme - #~ if ( Gtk2->CHECK_VERSION( 2, 12, 0 ) ) { - #~ my $icontheme = Gtk2::IconTheme->get_default; + #~ if ( Gtk3->CHECK_VERSION( 2, 12, 0 ) ) { + #~ my $icontheme = Gtk3::IconTheme::get_default(); #~ - #~ my $utheme_item = Gtk2::ImageMenuItem->new_with_label( $self->{_d}->get("Import from current theme...") ); - #~ $utheme_item->set( 'always_show_image' => TRUE ) if Gtk2->CHECK_VERSION( 2, 16, 0 ); + #~ my $utheme_item = Gtk3::ImageMenuItem->new_with_label( $self->{_d}->get("Import from current theme...") ); + #~ $utheme_item->set( 'always_show_image' => TRUE ) if Gtk3->CHECK_VERSION( 2, 16, 0 ); #~ if ( $icontheme->has_icon('preferences-desktop-theme') ) { - #~ $utheme_item->set_image( Gtk2::Image->new_from_icon_name( 'preferences-desktop-theme', 'menu' ) ); + #~ $utheme_item->set_image( Gtk3::Image->new_from_icon_name( 'preferences-desktop-theme', 'menu' ) ); #~ } #~ #~ $utheme_item->set_submenu( $self->import_from_utheme( $icontheme, $button ) ); #~ #~ $menu_objects->append($utheme_item); #~ - #~ $menu_objects->append( Gtk2::SeparatorMenuItem->new ); + #~ $menu_objects->append( Gtk3::SeparatorMenuItem->new ); #~ } #objects from session - my $session_menu_item = Gtk2::ImageMenuItem->new_with_label($self->{_d}->get("Import from session...")); - $session_menu_item->set('always_show_image' => TRUE) if Gtk2->CHECK_VERSION(2, 16, 0); - $session_menu_item->set_image(Gtk2::Image->new_from_stock('gtk-index', 'menu')); + my $session_menu_item = Gtk3::ImageMenuItem->new_with_label($self->{_d}->get("Import from session...")); + $session_menu_item->set('always_show_image' => TRUE); + $session_menu_item->set_image(Gtk3::Image->new_from_stock('gtk-index', 'menu')); $session_menu_item->set_submenu($self->import_from_session($button)); #gen thumbnails in an idle callback @@ -6486,13 +6429,13 @@ sub import_from_filesystem { $menu_objects->append($session_menu_item); #objects from filesystem - my $filesystem_menu_item = Gtk2::ImageMenuItem->new_with_label($self->{_d}->get("Import from filesystem...")); - $filesystem_menu_item->set('always_show_image' => TRUE) if Gtk2->CHECK_VERSION(2, 16, 0); - $filesystem_menu_item->set_image(Gtk2::Image->new_from_stock('gtk-open', 'menu')); + my $filesystem_menu_item = Gtk3::ImageMenuItem->new_with_label($self->{_d}->get("Import from filesystem...")); + $filesystem_menu_item->set('always_show_image' => TRUE); + $filesystem_menu_item->set_image(Gtk3::Image->new_from_stock('gtk-open', 'menu')); $filesystem_menu_item->signal_connect( 'activate' => sub { - my $fs = Gtk2::FileChooserDialog->new( + my $fs = Gtk3::FileChooserDialog->new( $self->{_d}->get("Choose file to open"), $self->{_drawing_window}, 'open', 'gtk-cancel' => 'reject', 'gtk-open' => 'accept' @@ -6501,7 +6444,7 @@ sub import_from_filesystem { $fs->set_select_multiple(FALSE); #preview widget - my $iprev = Gtk2::Image->new; + my $iprev = Gtk3::Image->new; $fs->set_preview_widget($iprev); $fs->signal_connect( @@ -6519,18 +6462,18 @@ sub import_from_filesystem { } }); - my $filter_all = Gtk2::FileFilter->new; + my $filter_all = Gtk3::FileFilter->new; $filter_all->set_name($self->{_d}->get("All compatible image formats")); $fs->add_filter($filter_all); - foreach (Gtk2::Gdk::Pixbuf->get_formats) { - my $filter = Gtk2::FileFilter->new; - $filter->set_name($_->{name} . " - " . $_->{description}); - foreach (@{$_->{extensions}}) { - $filter->add_pattern("*." . uc $_); - $filter_all->add_pattern("*." . uc $_); - $filter->add_pattern("*." . $_); - $filter_all->add_pattern("*." . $_); + foreach my $format (Gtk3::Gdk::Pixbuf::get_formats()) { + my $filter = Gtk3::FileFilter->new; + $filter->set_name($format->get_name . " - " . $format->get_description); + foreach my $ext (@{$format->get_extensions}) { + $filter->add_pattern("*." . uc $ext); + $filter_all->add_pattern("*." . uc $ext); + $filter->add_pattern("*." . $ext); + $filter_all->add_pattern("*." . $ext); } $fs->add_filter($filter); } @@ -6547,9 +6490,9 @@ sub import_from_filesystem { $self->{_current_pixbuf} = $self->{_lp}->load($new_file, undef, undef, undef, TRUE); if ($self->{_current_pixbuf}) { $self->{_current_pixbuf_filename} = $new_file; - $button->set_icon_widget(Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-image.svg', Gtk2::IconSize->lookup('menu')))); + $button->set_icon_widget(Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size($self->{_dicons} . '/draw-image.svg', Gtk3::IconSize->lookup('menu')))); $button->show_all; - $self->{_canvas}->window->set_cursor($self->change_cursor_to_current_pixbuf); + $self->{_canvas}->get_window->set_cursor($self->change_cursor_to_current_pixbuf); } else { $self->abort_current_mode; } @@ -6579,18 +6522,18 @@ sub import_from_utheme { my $icontheme = shift; my $button = shift; - my $menu_ctxt = Gtk2::Menu->new; + my $menu_ctxt = Gtk3::Menu->new; foreach my $context (sort $icontheme->list_contexts) { #objects from current theme (contexts) - my $utheme_ctxt = Gtk2::ImageMenuItem->new_with_label($context); - $utheme_ctxt->set('always_show_image' => TRUE) if Gtk2->CHECK_VERSION(2, 16, 0); - $utheme_ctxt->set_image(Gtk2::Image->new_from_stock('gtk-directory', 'menu')); + my $utheme_ctxt = Gtk3::ImageMenuItem->new_with_label($context); + $utheme_ctxt->set('always_show_image' => TRUE); + $utheme_ctxt->set_image(Gtk3::Image->new_from_stock('gtk-directory', 'menu')); #add empty menu first - my $menu_empty = Gtk2::Menu->new; - my $empty_item = Gtk2::MenuItem->new_with_label($self->{_d}->get("No icon was found")); + my $menu_empty = Gtk3::Menu->new; + my $empty_item = Gtk3::MenuItem->new_with_label($self->{_d}->get("No icon was found")); $empty_item->set_sensitive(FALSE); $menu_empty->append($empty_item); $utheme_ctxt->set_submenu($menu_empty); @@ -6600,7 +6543,7 @@ sub import_from_utheme { $utheme_ctxt->{'nid'} = $utheme_ctxt->signal_connect( 'activate' => sub { - $utheme_ctxt->set_image(Gtk2::Image->new_from_file($self->{_icons} . "/throbber_16x16.gif")); + $utheme_ctxt->set_image(Gtk3::Image->new_from_file($self->{_icons} . "/throbber_16x16.gif")); my $context_submenu = $self->import_from_utheme_ctxt($icontheme, $context, $button); if ($context_submenu->get_children) { @@ -6611,7 +6554,7 @@ sub import_from_utheme { $self->gen_thumbnail_on_idle('gtk-directory', $utheme_ctxt, $button, TRUE, $utheme_ctxt->get_submenu->get_children); } else { - $utheme_ctxt->set_image(Gtk2::Image->new_from_stock('gtk-directory', 'menu')); + $utheme_ctxt->set_image(Gtk3::Image->new_from_stock('gtk-directory', 'menu')); } return TRUE; @@ -6640,15 +6583,15 @@ sub import_from_utheme_ctxt { my $context = shift; my $button = shift; - my $menu_ctxt_items = Gtk2::Menu->new; + my $menu_ctxt_items = Gtk3::Menu->new; - my $size = Gtk2::IconSize->lookup('dialog'); + my $size = Gtk3::IconSize->lookup('dialog'); foreach my $icon (sort $icontheme->list_icons($context)) { #objects from current theme (icons for specific contexts) - my $utheme_ctxt_item = Gtk2::ImageMenuItem->new_with_label($icon); - $utheme_ctxt_item->set('always_show_image' => TRUE) if Gtk2->CHECK_VERSION(2, 16, 0); + my $utheme_ctxt_item = Gtk3::ImageMenuItem->new_with_label($icon); + $utheme_ctxt_item->set('always_show_image' => TRUE); my $iconinfo = $icontheme->lookup_icon($icon, $size, 'generic-fallback'); #save filename and generate thumbnail later @@ -6667,7 +6610,7 @@ sub import_from_session { my $self = shift; my $button = shift; - my $menu_session_objects = Gtk2::Menu->new; + my $menu_session_objects = Gtk3::Menu->new; my %import_hash = %{$self->{_import_hash}}; @@ -6677,8 +6620,8 @@ sub import_from_session { next unless defined $import_hash{$key}->{'short'}; #init item with filename - my $screen_menu_item = Gtk2::ImageMenuItem->new_with_label($import_hash{$key}->{'short'}); - $screen_menu_item->set('always_show_image' => TRUE) if Gtk2->CHECK_VERSION(2, 16, 0); + my $screen_menu_item = Gtk3::ImageMenuItem->new_with_label($import_hash{$key}->{'short'}); + $screen_menu_item->set('always_show_image' => TRUE); #set sensitive == FALSE if image eq current file $screen_menu_item->set_sensitive(FALSE) @@ -6719,7 +6662,7 @@ sub gen_thumbnail_on_idle { #no valid item - stop the idle handler unless ($child) { - $parent->set_image(Gtk2::Image->new_from_stock($stock, 'menu')) if $parent; + $parent->set_image(Gtk3::Image->new_from_stock($stock, 'menu')) if $parent; return FALSE; } @@ -6727,7 +6670,7 @@ sub gen_thumbnail_on_idle { #no valid item - stop the idle handler unless ($name) { - $parent->set_image(Gtk2::Image->new_from_stock($stock, 'menu')) if $parent; + $parent->set_image(Gtk3::Image->new_from_stock($stock, 'menu')) if $parent; return FALSE; } @@ -6743,19 +6686,19 @@ sub gen_thumbnail_on_idle { if (exists $child->{'giofile'}) { my $thumb; unless ($child->{'no_thumbnail'}) { - $thumb = $self->{_lp_ne}->load($shutter_hfunct->utf8_decode($child->{'giofile'}->get_path), Gtk2::IconSize->lookup('small-toolbar')); + $thumb = $self->{_lp_ne}->load($shutter_hfunct->utf8_decode($child->{'giofile'}->get_path), Gtk3::IconSize->lookup('small-toolbar')); } else { - $thumb = Gtk2::Gdk::Pixbuf->new('rgb', TRUE, 8, 5, 5); + $thumb = Gtk3::Gdk::Pixbuf->new('rgb', TRUE, 8, 5, 5); $thumb->fill(0x00000000); } - $small_image = Gtk2::Image->new_from_pixbuf($thumb); + $small_image = Gtk3::Image->new_from_pixbuf($thumb); } else { my $pixbuf = $self->{_lp_ne}->load($name, undef, undef, undef, TRUE); #16x16 is minimum size if ($pixbuf->get_width >= 16 && $pixbuf->get_height >= 16) { - $small_image = Gtk2::Image->new_from_pixbuf($pixbuf->scale_simple(Gtk2::IconSize->lookup('menu'), 'bilinear')); + $small_image = Gtk3::Image->new_from_pixbuf($pixbuf->scale_simple(Gtk3::IconSize->lookup('menu'), 'bilinear')); } } }; @@ -6766,7 +6709,7 @@ sub gen_thumbnail_on_idle { #init when toplevel unless ($no_init) { unless ($button->get_icon_widget) { - $button->set_icon_widget(Gtk2::Image->new_from_pixbuf($small_image->get_pixbuf)); + $button->set_icon_widget(Gtk3::Image->new_from_pixbuf($small_image->get_pixbuf)); $self->{_current_pixbuf_filename} = $name; $button->show_all; } @@ -6775,9 +6718,9 @@ sub gen_thumbnail_on_idle { $child->signal_connect( 'activate' => sub { $self->{_current_pixbuf_filename} = $name; - $button->set_icon_widget(Gtk2::Image->new_from_pixbuf($small_image->get_pixbuf)); + $button->set_icon_widget(Gtk3::Image->new_from_pixbuf($small_image->get_pixbuf)); $button->show_all; - $self->{_canvas}->window->set_cursor($self->change_cursor_to_current_pixbuf); + $self->{_canvas}->get_window->set_cursor($self->change_cursor_to_current_pixbuf); }); } else { $child->destroy; @@ -6804,7 +6747,7 @@ sub set_drawing_action { #skip separators #we only want to activate tools - next if $item->isa('Gtk2::SeparatorToolItem'); + next if $item->isa('Gtk3::SeparatorToolItem'); #add 1 to item index $item_index++; @@ -6833,7 +6776,7 @@ sub change_cursor_to_current_pixbuf { #load file $self->{_current_pixbuf} = $self->{_lp}->load($self->{_current_pixbuf_filename}, undef, undef, undef, TRUE); unless ($self->{_current_pixbuf}) { - $cursor = Gtk2::Gdk::Cursor->new_from_pixbuf(Gtk2::Gdk::Display->get_default, Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-image.svg'), Gtk2::IconSize->lookup('menu')); + $cursor = Gtk3::Gdk::Cursor->new_from_pixbuf(Gtk3::Gdk::Display::get_default(), Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-image.svg'), Gtk3::IconSize->lookup('menu')); } #very big images usually don't work as a cursor (no error though??) @@ -6844,15 +6787,15 @@ sub change_cursor_to_current_pixbuf { eval { #maximum cursor size - my ($cw, $ch) = Gtk2::Gdk::Display->get_default->get_maximal_cursor_size; + my ($cw, $ch) = Gtk3::Gdk::Display::get_default->get_maximal_cursor_size; #images smaller than max cursor size? # => don't scale to a bigger size if ($cw > $pb_w || $ch > $pb_w) { - $cursor = Gtk2::Gdk::Cursor->new_from_pixbuf(Gtk2::Gdk::Display->get_default, $self->{_current_pixbuf}, int($pb_w / 2), int($pb_h / 2)); + $cursor = Gtk3::Gdk::Cursor->new_from_pixbuf(Gtk3::Gdk::Display::get_default(), $self->{_current_pixbuf}, int($pb_w / 2), int($pb_h / 2)); } else { my $cpixbuf = $self->{_lp}->load($self->{_current_pixbuf_filename}, $cw, $ch, TRUE, TRUE); - $cursor = Gtk2::Gdk::Cursor->new_from_pixbuf(Gtk2::Gdk::Display->get_default, $cpixbuf, int($cpixbuf->get_width / 2), int($cpixbuf->get_height / 2)); + $cursor = Gtk3::Gdk::Cursor->new_from_pixbuf(Gtk3::Gdk::Display::get_default(), $cpixbuf, int($cpixbuf->get_width / 2), int($cpixbuf->get_height / 2)); } }; @@ -6865,7 +6808,7 @@ sub change_cursor_to_current_pixbuf { $self->abort_current_mode; } } else { - $cursor = Gtk2::Gdk::Cursor->new_from_pixbuf(Gtk2::Gdk::Display->get_default, Gtk2::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-image.svg'), Gtk2::IconSize->lookup('menu')); + $cursor = Gtk3::Gdk::Cursor->new_from_pixbuf(Gtk3::Gdk::Display::get_default(), Gtk3::Gdk::Pixbuf->new_from_file($self->{_dicons} . '/draw-image.svg'), Gtk3::IconSize->lookup('menu')); } return $cursor; @@ -6897,9 +6840,9 @@ sub paste_item { $self->{_current_pixbuf_filename} = $tmpfilename; #construct an event and create a new image object - my $initevent = Gtk2::Gdk::Event->new('motion-notify'); - $initevent->set_time(Gtk2->get_current_event_time); - $initevent->window($self->{_drawing_window}->window); + my $initevent = Gtk3::Gdk::Event->new('motion-notify'); + $initevent->time(Gtk3::get_current_event_time()); + $initevent->window($self->{_drawing_window}->get_window); #calculate coordinates $initevent->x(int($self->{_canvas_bg_rect}->get('width') / 2)); @@ -6928,35 +6871,35 @@ sub paste_item { my $child = $self->get_child_item($item); my $new_item = undef; - if ($item->isa('Goo::Canvas::Rect') && !$child) { + if ($item->isa('GooCanvas2::CanvasRect') && !$child) { #~ print "Creating Rectangle...\n"; $new_item = $self->create_rectangle(undef, $item); - } elsif ($item->isa('Goo::Canvas::Polyline') && !$child) { + } elsif ($item->isa('GooCanvas2::CanvasPolyline') && !$child) { #~ print "Creating Polyline...\n"; $new_item = $self->create_polyline(undef, $item); - } elsif ($child->isa('Goo::Canvas::Polyline') && exists $self->{_items}{$item}{stroke_color}) { + } elsif ($child->isa('GooCanvas2::CanvasPolyline') && exists $self->{_items}{$item}{stroke_color}) { #~ print "Creating Line...\n"; $new_item = $self->create_line(undef, $item); - } elsif ($child->isa('Goo::Canvas::Polyline')) { + } elsif ($child->isa('GooCanvas2::CanvasPolyline')) { #~ print "Creating Censor...\n"; $new_item = $self->create_censor(undef, $item); - } elsif ($child->isa('Goo::Canvas::Ellipse')) { + } elsif ($child->isa('GooCanvas2::CanvasEllipse')) { #~ print "Creating Ellipse...\n"; $new_item = $self->create_ellipse(undef, $item); - } elsif ($child->isa('Goo::Canvas::Text')) { + } elsif ($child->isa('GooCanvas2::CanvasText')) { #~ print "Creating Text...\n"; $new_item = $self->create_text(undef, $item); - } elsif ($child->isa('Goo::Canvas::Image') && exists $self->{_items}{$item}{pixelize}) { + } elsif ($child->isa('GooCanvas2::CanvasImage') && exists $self->{_items}{$item}{pixelize}) { #~ print "Creating Pixelize...\n"; $new_item = $self->create_pixel_image(undef, $item); - } elsif ($child->isa('Goo::Canvas::Image')) { + } elsif ($child->isa('GooCanvas2::CanvasImage')) { #~ print "Creating Image...\n"; $new_item = $self->create_image(undef, $item); @@ -6987,7 +6930,7 @@ sub create_polyline { my $highlighter = shift; my @points = (); - my $stroke_pattern = $self->create_color($self->{_stroke_color}, $self->{_stroke_color_alpha}); + my $stroke_color = $self->{_stroke_color}; my $transform; my $line_width = $self->{_line_width}; @@ -7001,25 +6944,27 @@ sub create_polyline { push @points, $_ + 20; } - $stroke_pattern = $self->create_color($self->{_items}{$copy_item}{stroke_color}, $self->{_items}{$copy_item}{stroke_color_alpha}); + $stroke_color = $self->{_items}{$copy_item}{stroke_color}; $transform = $self->{_items}{$copy_item}->get('transform'); $line_width = $self->{_items}{$copy_item}->get('line_width'); } my $item = undef; if ($highlighter) { - $item = Goo::Canvas::Polyline->new_line( - $self->{_canvas}->get_root_item, $points[0], $points[1], $points[2], $points[3], - 'stroke-pattern' => $self->create_color(Gtk2::Gdk::Color->parse('#FFFF00'), 0.5), + $stroke_color = Gtk3::Gdk::RGBA::parse('#FFFF00'); + $stroke_color->alpha(0.5); + $item = GooCanvas2::CanvasPolyline->new( + parent=>$self->{_canvas}->get_root_item, close_path=>FALSE, + 'stroke-color-gdk-rgba' => $stroke_color, 'line-width' => 18, 'fill-rule' => 'CAIRO_FILL_RULE_EVEN_ODD', 'line-cap' => 'CAIRO_LINE_CAP_SQUARE', 'line-join' => 'CAIRO_LINE_JOIN_BEVEL', ); } else { - $item = Goo::Canvas::Polyline->new_line( - $self->{_canvas}->get_root_item, $points[0], $points[1], $points[2], $points[3], - 'stroke-pattern' => $stroke_pattern, + $item = GooCanvas2::CanvasPolyline->new( + parent=>$self->{_canvas}->get_root_item, close_path=>FALSE, + 'stroke-color-gdk-rgba' => $stroke_color, 'line-width' => $line_width, 'line-cap' => 'CAIRO_LINE_CAP_ROUND', 'line-join' => 'CAIRO_LINE_JOIN_ROUND', @@ -7031,7 +6976,7 @@ sub create_polyline { #need at least 2 points push @{$self->{_items}{$item}{'points'}}, @points; - $self->{_items}{$item}->set(points => Goo::Canvas::Points->new($self->{_items}{$item}{'points'})); + $self->{_items}{$item}->set(points => points_to_canvas_points(@{$self->{_items}{$item}{'points'}})); $self->{_items}{$item}->set(transform => $transform) if $transform; if ($highlighter) { @@ -7039,15 +6984,14 @@ sub create_polyline { #set type flag $self->{_items}{$item}{type} = 'highlighter'; $self->{_items}{$item}{uid} = $self->{_uid}++; - $self->{_items}{$item}{stroke_color} = Gtk2::Gdk::Color->parse('#FFFF00'); - $self->{_items}{$item}{stroke_color_alpha} = 0.5; + $self->{_items}{$item}{stroke_color} = Gtk3::Gdk::RGBA::parse('#FFFF00'); + $self->{_items}{$item}{stroke_color}->alpha(0.5); } else { #set type flag $self->{_items}{$item}{type} = 'freehand'; $self->{_items}{$item}{uid} = $self->{_uid}++; $self->{_items}{$item}{stroke_color} = $self->{_stroke_color}; - $self->{_items}{$item}{stroke_color_alpha} = $self->{_stroke_color_alpha}; } $self->setup_item_signals($self->{_items}{$item}); @@ -7076,12 +7020,9 @@ sub create_censor { $transform = $self->{_items}{$copy_item}->get('transform'); } - my @stipple_data = (255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255); - my $stroke_pattern = $self->create_stipple('black', \@stipple_data); - - my $item = Goo::Canvas::Polyline->new_line( - $self->{_canvas}->get_root_item, $points[0], $points[1], $points[2], $points[3], - 'stroke-pattern' => $stroke_pattern, + my $item = GooCanvas2::CanvasPolyline->new( + parent=>$self->{_canvas}->get_root_item, close_path=>FALSE, + 'stroke-pixbuf' => $self->{_stipple_pixbuf}, 'line-width' => 14, 'line-cap' => 'CAIRO_LINE_CAP_ROUND', 'line-join' => 'CAIRO_LINE_JOIN_ROUND', @@ -7096,7 +7037,7 @@ sub create_censor { #need at least 2 points push @{$self->{_items}{$item}{'points'}}, @points; - $self->{_items}{$item}->set(points => Goo::Canvas::Points->new($self->{_items}{$item}{'points'})); + $self->{_items}{$item}->set(points => points_to_canvas_points(@{$self->{_items}{$item}{'points'}})); $self->{_items}{$item}->set(transform => $transform) if $transform; $self->setup_item_signals($self->{_items}{$item}); @@ -7110,22 +7051,25 @@ sub create_pixel_image { my $ev = shift; my $copy_item = shift; - my @dimensions = (0, 0, 0, 0); + my ($x, $y, $width, $height) = (0, 0, 0, 0); #use event coordinates and selected color if ($ev) { - @dimensions = ($ev->x, $ev->y, 0, 0); + $x = $ev->x; + $y = $ev->y; #use source item coordinates and item color } elsif ($copy_item) { - @dimensions = ($copy_item->get('x') + 20, $copy_item->get('y') + 20, $copy_item->get('width'), $copy_item->get('height')); + $x = $copy_item->get('x') + 20; + $y = $copy_item->get('y') + 20; + $width = $copy_item->get('width'); + $height = $copy_item->get('height'); } - my $pattern = $self->create_alpha; - my $item = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, @dimensions, - 'fill-pattern' => $pattern, - 'line-dash' => Goo::Canvas::LineDash->new([5, 5]), + my $item = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>$x, y=>$y, width=>$width, height=>$height, + 'fill-color-rgba' => 0, + 'line-dash' => GooCanvas2::CanvasLineDash->newv([5, 5]), 'line-width' => 1, 'stroke-color' => 'gray', ); @@ -7134,16 +7078,16 @@ sub create_pixel_image { $self->{_items}{$item} = $item; #blank pixbuf - my $blank = Gtk2::Gdk::Pixbuf->new('rgb', TRUE, 8, 2, 2); + my $blank = Gtk3::Gdk::Pixbuf->new('rgb', TRUE, 8, 2, 2); #whole pixbuf is transparent $blank->fill(0x00000000); - $self->{_items}{$item}{pixelize} = Goo::Canvas::Image->new( - $self->{_canvas}->get_root_item, - $blank, - $item->get('x'), - $item->get('y'), + $self->{_items}{$item}{pixelize} = GooCanvas2::CanvasImage->new( + parent=>$self->{_canvas}->get_root_item, + pixbuf=>$blank, + x=>$item->get('x'), + y=>$item->get('y'), 'width' => 2, 'height' => 2, ); @@ -7182,7 +7126,7 @@ sub create_image { my $copy_item = shift; my $force_orig_size_init = shift; - my @dimensions = (0, 0, 0, 0); + my ($x, $y, $width, $height) = (0, 0, 0, 0); #use event coordinates if ($ev) { @@ -7191,26 +7135,27 @@ sub create_image { #and use the original image size #dnd for example if ($force_orig_size_init) { - @dimensions = ( - $ev->x - int($self->{_current_pixbuf}->get_width / 2), - $ev->y - int($self->{_current_pixbuf}->get_height / 2), - $self->{_current_pixbuf}->get_width, - $self->{_current_pixbuf}->get_height - ); + $x = $ev->x - int($self->{_current_pixbuf}->get_width / 2); + $y = $ev->y - int($self->{_current_pixbuf}->get_height / 2); + $width = $self->{_current_pixbuf}->get_width; + $height = $self->{_current_pixbuf}->get_height; } else { - @dimensions = ($ev->x, $ev->y, 0, 0); + $x = $ev->x; + $y = $ev->y; } #use source item coordinates } elsif ($copy_item) { - @dimensions = ($copy_item->get('x') + 20, $copy_item->get('y') + 20, $self->{_items}{$copy_item}->get('width'), $self->{_items}{$copy_item}->get('height')); + $x = $copy_item->get('x') + 20; + $y = $copy_item->get('y') + 20; + $width = $self->{_items}{$copy_item}->get('width'); + $height = $self->{_items}{$copy_item}->get('height'); } - my $pattern = $self->create_alpha; - my $item = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, @dimensions, - 'fill-pattern' => $pattern, - 'line-dash' => Goo::Canvas::LineDash->new([5, 5]), + my $item = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>$x, y=>$y, width=>$width, height=>$height, + 'fill-color-rgba' => 0, + 'line-dash' => GooCanvas2::CanvasLineDash->newv([5, 5]), 'line-width' => 1, 'stroke-color' => 'gray', ); @@ -7226,11 +7171,11 @@ sub create_image { $self->{_items}{$item}{orig_pixbuf_filename} = $self->{_items}{$copy_item}{orig_pixbuf_filename}; } - $self->{_items}{$item}{image} = Goo::Canvas::Image->new( - $self->{_canvas}->get_root_item, - $self->{_items}{$item}{orig_pixbuf}, - $item->get('x'), - $item->get('y'), + $self->{_items}{$item}{image} = GooCanvas2::CanvasImage->new( + parent=>$self->{_canvas}->get_root_item, + pixbuf=>$self->{_items}{$item}{orig_pixbuf}, + x=>$item->get('x'), + y=>$item->get('y'), 'width' => 2, 'height' => 2, ); @@ -7275,28 +7220,31 @@ sub create_text { my $ev = shift; my $copy_item = shift; - my @dimensions = (0, 0, 0, 0); - my $stroke_pattern = $self->create_color($self->{_stroke_color}, $self->{_stroke_color_alpha}); + my ($x, $y, $width, $height) = (0, 0, 0, 0); + my $stroke_color = $self->{_stroke_color}; my $text = $self->{_d}->get('New text...'); my $line_width = $self->{_line_width}; #use event coordinates and selected color if ($ev) { - @dimensions = ($ev->x, $ev->y, 0, 0); + $x = $ev->x; + $y = $ev->y; #use source item coordinates and item color } elsif ($copy_item) { - @dimensions = ($copy_item->get('x') + 20, $copy_item->get('y') + 20, $copy_item->get('width'), $copy_item->get('height')); - $stroke_pattern = $self->create_color($self->{_items}{$copy_item}{stroke_color}, $self->{_items}{$copy_item}{stroke_color_alpha}); + $x = $copy_item->get('x') + 20; + $y = $copy_item->get('y') + 20; + $width = $copy_item->get('width'); + $height = $copy_item->get('height'); + $stroke_color = $self->{_items}{$copy_item}{stroke_color}; $text = $self->{_items}{$copy_item}{text}->get('text'); $line_width = $self->{_items}{$copy_item}{text}->get('line-width'); } - my $pattern = $self->create_alpha; - my $item = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, @dimensions, - 'fill-pattern' => $pattern, - 'line-dash' => Goo::Canvas::LineDash->new([5, 5]), + my $item = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>$x, y=>$y, width=>$width, height=>$height, + 'fill-color-rgba' => 0, + 'line-dash' => GooCanvas2::CanvasLineDash->newv([5, 5]), 'line-width' => 1, 'stroke-color' => 'gray', ); @@ -7304,14 +7252,14 @@ sub create_text { $self->{_current_new_item} = $item unless ($copy_item); $self->{_items}{$item} = $item; - $self->{_items}{$item}{text} = Goo::Canvas::Text->new( - $self->{_canvas}->get_root_item, "" . $text . "", - $item->get('x'), - $item->get('y'), - -1, - 'nw', + $self->{_items}{$item}{text} = GooCanvas2::CanvasText->new( + parent=>$self->{_canvas}->get_root_item, text=>"" . $text . "", + x=>$item->get('x'), + y=>$item->get('y'), + width=>-1, + anchor=>'nw', 'use-markup' => TRUE, - 'fill-pattern' => $stroke_pattern, + 'fill-color-gdk-rgba' => $stroke_color, 'line-width' => $line_width, ); @@ -7346,7 +7294,6 @@ sub create_text { $self->{_items}{$item}{uid} = $self->{_uid}++; $self->{_items}{$item}{stroke_color} = $self->{_stroke_color}; - $self->{_items}{$item}{stroke_color_alpha} = $self->{_stroke_color_alpha}; #create rectangles $self->handle_rects('create', $item); @@ -7371,8 +7318,8 @@ sub create_line { my $end_arrow = shift; my $start_arrow = shift; - my @dimensions = (0, 0, 0, 0); - my $stroke_pattern = $self->create_color($self->{_stroke_color}, $self->{_stroke_color_alpha}); + my ($x, $y, $width, $height) = (0, 0, 0, 0); + my $stroke_color = $self->{_stroke_color}; my $line_width = $self->{_line_width}; my $mirrored_w = 0; my $mirrored_h = 0; @@ -7384,12 +7331,16 @@ sub create_line { #use event coordinates and selected color if ($ev) { - @dimensions = ($ev->x, $ev->y, 0, 0); + $x = $ev->x; + $y = $ev->y; #use source item coordinates and item color } elsif ($copy_item) { - @dimensions = ($copy_item->get('x') + 20, $copy_item->get('y') + 20, $copy_item->get('width'), $copy_item->get('height')); - $stroke_pattern = $self->create_color($self->{_items}{$copy_item}{stroke_color}, $self->{_items}{$copy_item}{stroke_color_alpha}); + $x = $copy_item->get('x') + 20; + $y = $copy_item->get('y') + 20; + $width = $copy_item->get('width'); + $height = $copy_item->get('height'); + $stroke_color = $self->{_items}{$copy_item}{stroke_color}; $line_width = $self->{_items}{$copy_item}{line}->get('line-width'); $mirrored_w = $self->{_items}{$copy_item}{mirrored_w}; $mirrored_h = $self->{_items}{$copy_item}{mirrored_h}; @@ -7402,11 +7353,10 @@ sub create_line { $arrow_tip_length = $self->{_items}{$copy_item}{arrow_tip_length}; } - my $pattern = $self->create_alpha; - my $item = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, @dimensions, - 'fill-pattern' => $pattern, - 'line-dash' => Goo::Canvas::LineDash->new([5, 5]), + my $item = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>$x, y=>$y, width=>$width, height=>$height, + 'fill-color-rgba' => 0, + 'line-dash' => GooCanvas2::CanvasLineDash->newv([5, 5]), 'line-width' => 1, 'stroke-color' => 'gray', ); @@ -7414,13 +7364,16 @@ sub create_line { $self->{_current_new_item} = $item unless ($copy_item); $self->{_items}{$item} = $item; - $self->{_items}{$item}{line} = Goo::Canvas::Polyline->new_line( - $self->{_canvas}->get_root_item, - $item->get('x'), - $item->get('y'), - $item->get('x') + $item->get('width'), - $item->get('y') + $item->get('height'), - 'stroke-pattern' => $stroke_pattern, + $self->{_items}{$item}{line} = GooCanvas2::CanvasPolyline->new( + parent=>$self->{_canvas}->get_root_item, + close_path=>FALSE, + points=>points_to_canvas_points( + $item->get('x'), + $item->get('y'), + $item->get('x') + $item->get('width'), + $item->get('y') + $item->get('height'), + ), + 'stroke-color-gdk-rgba' => $stroke_color, 'line-width' => $line_width, 'line-cap' => 'CAIRO_LINE_CAP_ROUND', 'line-join' => 'CAIRO_LINE_JOIN_ROUND', @@ -7450,7 +7403,6 @@ sub create_line { $self->{_items}{$item}{mirrored_h} = $mirrored_h; $self->{_items}{$item}{stroke_color} = $self->{_stroke_color}; - $self->{_items}{$item}{stroke_color_alpha} = $self->{_stroke_color_alpha}; #create rectangles $self->handle_rects('create', $item); @@ -7474,29 +7426,32 @@ sub create_ellipse { my $copy_item = shift; my $numbered = shift; - my @dimensions = (0, 0, 0, 0); - my $stroke_pattern = $self->create_color($self->{_stroke_color}, $self->{_stroke_color_alpha}); - my $fill_pattern = $self->create_color($self->{_fill_color}, $self->{_fill_color_alpha}); + my ($x, $y, $width, $height) = (0, 0, 0, 0); + my $stroke_color = $self->{_stroke_color}; + my $fill_color = $self->{_fill_color}; my $line_width = $self->{_line_width}; #use event coordinates and selected color if ($ev) { - @dimensions = ($ev->x, $ev->y, 0, 0); + $x = $ev->x; + $y = $ev->y; #use source item coordinates and item color } elsif ($copy_item) { - @dimensions = ($copy_item->get('x') + 20, $copy_item->get('y') + 20, $copy_item->get('width'), $copy_item->get('height')); - $stroke_pattern = $self->create_color($self->{_items}{$copy_item}{stroke_color}, $self->{_items}{$copy_item}{stroke_color_alpha}); - $fill_pattern = $self->create_color($self->{_items}{$copy_item}{fill_color}, $self->{_items}{$copy_item}{fill_color_alpha}); + $x = $copy_item->get('x') + 20; + $y = $copy_item->get('y') + 20; + $width = $copy_item->get('width'); + $height = $copy_item->get('height'); + $stroke_color = $self->{_items}{$copy_item}{stroke_color}; + $fill_color = $self->{_items}{$copy_item}{fill_color}; $line_width = $self->{_items}{$copy_item}{ellipse}->get('line-width'); $numbered = TRUE if exists $self->{_items}{$copy_item}{text}; } - my $pattern = $self->create_alpha; - my $item = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, @dimensions, - 'fill-pattern' => $pattern, - 'line-dash' => Goo::Canvas::LineDash->new([5, 5]), + my $item = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>$x, y=>$y, width=>$width, height=>$height, + 'fill-color-rgba' => 0, + 'line-dash' => GooCanvas2::CanvasLineDash->newv([5, 5]), 'line-width' => 1, 'stroke-color' => 'gray', ); @@ -7504,11 +7459,11 @@ sub create_ellipse { $self->{_current_new_item} = $item unless ($copy_item); $self->{_items}{$item} = $item; - $self->{_items}{$item}{ellipse} = Goo::Canvas::Ellipse->new( - $self->{_canvas}->get_root_item, $item->get('x'), $item->get('y'), $item->get('width'), - $item->get('height'), - 'fill-pattern' => $fill_pattern, - 'stroke-pattern' => $stroke_pattern, + $self->{_items}{$item}{ellipse} = GooCanvas2::CanvasEllipse->new( + parent=>$self->{_canvas}->get_root_item, x=>$item->get('x'), y=>$item->get('y'), width=>$item->get('width'), + height=>$item->get('height'), + 'fill-color-gdk-rgba' => $fill_color, + 'stroke-color-gdk-rgba' => $stroke_color, 'line-width' => $line_width, ); @@ -7518,14 +7473,14 @@ sub create_ellipse { my $number = $self->get_highest_auto_digit(); $number++; - $self->{_items}{$item}{text} = Goo::Canvas::Text->new( - $self->{_canvas}->get_root_item, "" . $number . "", - $self->{_items}{$item}{ellipse}->get('center-x'), - $self->{_items}{$item}{ellipse}->get('center-y'), - -1, - 'GTK_ANCHOR_CENTER', + $self->{_items}{$item}{text} = GooCanvas2::CanvasText->new( + parent=>$self->{_canvas}->get_root_item, text=>"" . $number . "", + x=>$self->{_items}{$item}{ellipse}->get('center-x'), + y=>$self->{_items}{$item}{ellipse}->get('center-y'), + width=>-1, + anchor=> 'center', 'use-markup' => TRUE, - 'fill-pattern' => $stroke_pattern, + 'fill-color-gdk-rgba' => $stroke_color, 'line-width' => $line_width, ); @@ -7575,9 +7530,7 @@ sub create_ellipse { #save color and opacity as well $self->{_items}{$item}{fill_color} = $self->{_fill_color}; - $self->{_items}{$item}{fill_color_alpha} = $self->{_fill_color_alpha}; $self->{_items}{$item}{stroke_color} = $self->{_stroke_color}; - $self->{_items}{$item}{stroke_color_alpha} = $self->{_stroke_color_alpha}; #create rectangles $self->handle_rects('create', $item); @@ -7605,27 +7558,31 @@ sub create_rectangle { my $ev = shift; my $copy_item = shift; - my @dimensions = (0, 0, 0, 0); - my $stroke_pattern = $self->create_color($self->{_stroke_color}, $self->{_stroke_color_alpha}); - my $fill_pattern = $self->create_color($self->{_fill_color}, $self->{_fill_color_alpha}); + my ($x, $y, $width, $height) = (0, 0, 0, 0); + my $stroke_color = $self->{_stroke_color}; + my $fill_color = $self->{_fill_color}; my $line_width = $self->{_line_width}; #use event coordinates and selected color if ($ev) { - @dimensions = ($ev->x, $ev->y, 0, 0); + $x = $ev->x; + $y = $ev->y; #use source item coordinates and item color } elsif ($copy_item) { - @dimensions = ($copy_item->get('x') + 20, $copy_item->get('y') + 20, $copy_item->get('width'), $copy_item->get('height')); - $stroke_pattern = $self->create_color($self->{_items}{$copy_item}{stroke_color}, $self->{_items}{$copy_item}{stroke_color_alpha}); - $fill_pattern = $self->create_color($self->{_items}{$copy_item}{fill_color}, $self->{_items}{$copy_item}{fill_color_alpha}); + $x = $copy_item->get('x') + 20; + $y = $copy_item->get('y') + 20; + $width = $copy_item->get('width'); + $height = $copy_item->get('height'); + $stroke_color = $self->{_items}{$copy_item}{stroke_color}; + $fill_color = $self->{_items}{$copy_item}{fill_color}; $line_width = $self->{_items}{$copy_item}->get('line-width'); } - my $item = Goo::Canvas::Rect->new( - $self->{_canvas}->get_root_item, @dimensions, - 'fill-pattern' => $fill_pattern, - 'stroke-pattern' => $stroke_pattern, + my $item = GooCanvas2::CanvasRect->new( + parent=>$self->{_canvas}->get_root_item, x=>$x, y=>$y, width=>$width, height=>$height, + 'fill-color-gdk-rgba' => $fill_color, + 'stroke-color-gdk-rgba' => $stroke_color, 'line-width' => $line_width, ); @@ -7637,9 +7594,7 @@ sub create_rectangle { $self->{_items}{$item}{uid} = $self->{_uid}++; $self->{_items}{$item}{fill_color} = $self->{_fill_color}; - $self->{_items}{$item}{fill_color_alpha} = $self->{_fill_color_alpha}; $self->{_items}{$item}{stroke_color} = $self->{_stroke_color}; - $self->{_items}{$item}{stroke_color_alpha} = $self->{_stroke_color_alpha}; #create rectangles $self->handle_rects('create', $item); @@ -7650,5 +7605,15 @@ sub create_rectangle { return $item; } +sub points_to_canvas_points { + my @points = @_; + my $num_points = scalar(@points) / 2; + my $result = GooCanvas2::CanvasPoints::new(num_points=>$num_points); + for (my $i = 0; $i < @points; $i += 2) { + $result->set_point($i / 2, $points[$i], $points[$i+1]); + } + return $result; +} + 1; diff --git a/share/shutter/resources/modules/Shutter/Geometry/Region.pm b/share/shutter/resources/modules/Shutter/Geometry/Region.pm index 728dd98f7..be13a4724 100644 --- a/share/shutter/resources/modules/Shutter/Geometry/Region.pm +++ b/share/shutter/resources/modules/Shutter/Geometry/Region.pm @@ -28,7 +28,7 @@ use utf8; use strict; use warnings; -use Gtk2; +use Gtk3; #Glib use Glib qw/TRUE FALSE/; @@ -51,25 +51,26 @@ sub get_clipbox { my $clip = undef; #calculate clipbox - foreach my $rect ($region->get_rectangles) { + my $len = $region->num_rectangles-1; + for my $i (0..$len) { + my $rect = $region->get_rectangle($i); - #~ print $rect->x, " - ", $rect->y, " - ", $rect->width, " - ", $rect->height, "\n"; unless (defined $clip) { - $clip = Gtk2::Gdk::Rectangle->new($rect->x, $rect->y, $rect->width, $rect->height); + $clip = $rect; } else { - if ($rect->x < $clip->x) { - $clip->width($clip->width + $clip->x); - $clip->x($rect->x); + if ($rect->{x} < $clip->{x}) { + $clip->{width} = $clip->{width} + $clip->{x}; + $clip->{x} = $rect->{x}; } - if ($rect->y < $clip->y) { - $clip->height($clip->height + $clip->y); - $clip->y($rect->y); + if ($rect->{y} < $clip->{y}) { + $clip->{height} = $clip->{height} + $clip->{y}; + $clip->{y} = $rect->{y}; } - if ($rect->x + $rect->width > $clip->x + $clip->width) { - $clip->width($rect->x + $rect->width - $clip->x); + if ($rect->{x} + $rect->{width} > $clip->{x} + $clip->{width}) { + $clip->{width} = $rect->{x} + $rect->{width} - $clip->{x}; } - if ($rect->y + $rect->height > $clip->y + $clip->height) { - $clip->height($rect->y + $rect->height - $clip->y); + if ($rect->{y} + $rect->{height} > $clip->{y} + $clip->{height}) { + $clip->{height} = $rect->{y} + $rect->{height} - $clip->{y}; } } } @@ -78,7 +79,7 @@ sub get_clipbox { if (defined $clip) { return $clip; } else { - return Gtk2::Gdk::Rectangle->new(0, 0, 0, 0); + return {x=>0, y=>0, width=>0, height=>0}; } } diff --git a/share/shutter/resources/modules/Shutter/Pixbuf/Border.pm b/share/shutter/resources/modules/Shutter/Pixbuf/Border.pm index 60e80af25..806fa898b 100644 --- a/share/shutter/resources/modules/Shutter/Pixbuf/Border.pm +++ b/share/shutter/resources/modules/Shutter/Pixbuf/Border.pm @@ -28,7 +28,7 @@ use utf8; use strict; use warnings; -use Gtk2; +use Gtk3; #Glib use Glib qw/TRUE FALSE/; @@ -57,7 +57,7 @@ sub create_border { my $color = shift; #create new pixbuf - my $tmp_pbuf = Gtk2::Gdk::Pixbuf->new('rgb', TRUE, 8, $pixbuf->get_width + 2 * $width, $pixbuf->get_height + 2 * $width); + my $tmp_pbuf = Gtk3::Gdk::Pixbuf->new('rgb', TRUE, 8, $pixbuf->get_width + 2 * $width, $pixbuf->get_height + 2 * $width); #Create a pixel specification my $pixel = 0; diff --git a/share/shutter/resources/modules/Shutter/Pixbuf/Load.pm b/share/shutter/resources/modules/Shutter/Pixbuf/Load.pm index 5c40e0e8e..3deb7a25e 100644 --- a/share/shutter/resources/modules/Shutter/Pixbuf/Load.pm +++ b/share/shutter/resources/modules/Shutter/Pixbuf/Load.pm @@ -28,7 +28,7 @@ use utf8; use strict; use warnings; -use Gtk2; +use Gtk3; #fileparse and tempfile use File::Basename qw/ fileparse dirname basename /; @@ -61,11 +61,11 @@ sub load { my $pixbuf = undef; eval { if (defined $width && defined $height && defined $sratio) { - $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_scale($filename, $width, $height, $sratio); + $pixbuf = Gtk3::Gdk::Pixbuf->new_from_file_at_scale($filename, $width, $height, $sratio); } elsif (defined $width && defined $height) { - $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_size($filename, $width, $height); + $pixbuf = Gtk3::Gdk::Pixbuf->new_from_file_at_size($filename, $width, $height); } else { - $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($filename); + $pixbuf = Gtk3::Gdk::Pixbuf->new_from_file($filename); } }; diff --git a/share/shutter/resources/modules/Shutter/Pixbuf/Save.pm b/share/shutter/resources/modules/Shutter/Pixbuf/Save.pm index f1822eaa4..55c8e0586 100644 --- a/share/shutter/resources/modules/Shutter/Pixbuf/Save.pm +++ b/share/shutter/resources/modules/Shutter/Pixbuf/Save.pm @@ -28,7 +28,7 @@ use utf8; use strict; use warnings; -use Gtk2; +use Gtk3; #fileparse and tempfile use File::Basename qw/ fileparse dirname basename /; @@ -140,7 +140,7 @@ sub save_pixbuf_to_file { my $surface = Cairo::PdfSurface->create($filename, $pixbuf->get_width * 0.8, $pixbuf->get_height * 0.8); my $cr = Cairo::Context->create($surface); $cr->scale(0.8, 0.8); - Gtk2::Gdk::Cairo::Context::set_source_pixbuf($cr, $pixbuf, 0, 0); + Gtk3::Gdk::cairo_set_source_pixbuf($cr, $pixbuf, 0, 0); $cr->paint; $cr->show_page; @@ -155,7 +155,7 @@ sub save_pixbuf_to_file { my $surface = Cairo::PsSurface->create($filename, $pixbuf->get_width * 0.8, $pixbuf->get_height * 0.8); my $cr = Cairo::Context->create($surface); $cr->scale(0.8, 0.8); - Gtk2::Gdk::Cairo::Context::set_source_pixbuf($cr, $pixbuf, 0, 0); + Gtk3::Gdk::cairo_set_source_pixbuf($cr, $pixbuf, 0, 0); $cr->paint; $cr->show_page; @@ -170,7 +170,7 @@ sub save_pixbuf_to_file { my $surface = Cairo::SvgSurface->create($filename, $pixbuf->get_width * 0.8, $pixbuf->get_height * 0.8); my $cr = Cairo::Context->create($surface); $cr->scale(0.8, 0.8); - Gtk2::Gdk::Cairo::Context::set_source_pixbuf($cr, $pixbuf, 0, 0); + Gtk3::Gdk::cairo_set_source_pixbuf($cr, $pixbuf, 0, 0); $cr->paint; $cr->show_page; diff --git a/share/shutter/resources/modules/Shutter/Screenshot/Main.pm b/share/shutter/resources/modules/Shutter/Screenshot/Main.pm index c3d169962..5619c05ae 100644 --- a/share/shutter/resources/modules/Shutter/Screenshot/Main.pm +++ b/share/shutter/resources/modules/Shutter/Screenshot/Main.pm @@ -48,8 +48,11 @@ sub new { _notify_timeout => shift, }; + my $window = Gtk3::Window->new('toplevel'); #root window - $self->{_root} = Gtk2::Gdk->get_default_root_window; + $self->{_root} = Gtk3::GdkX11::X11Window::lookup_for_display( + $window->get_display, + Gtk3::GdkX11::x11_get_default_root_xwindow()); ($self->{_root}->{x}, $self->{_root}->{y}, $self->{_root}->{w}, $self->{_root}->{h}) = $self->{_root}->get_geometry; ($self->{_root}->{x}, $self->{_root}->{y}) = $self->{_root}->get_origin; @@ -61,11 +64,11 @@ sub new { require Shutter::Geometry::Region; #wnck screen - $self->{_wnck_screen} = Gnome2::Wnck::Screen->get_default; + $self->{_wnck_screen} = Wnck::Screen::get_default(); $self->{_wnck_screen}->force_update(); #gdk screen - $self->{_gdk_screen} = Gtk2::Gdk::Screen->get_default; + $self->{_gdk_screen} = Gtk3::Gdk::Screen::get_default(); #gdk display $self->{_gdk_display} = $self->{_gdk_screen}->get_display; @@ -117,9 +120,9 @@ sub get_root_and_geometry { sub get_root_and_current_monitor_geometry { my $self = shift; - my $mainwindow = $self->{_sc}->get_mainwindow->window || $self->{_root}; + my $mainwindow = $self->{_root}; my $mon1 = $self->{_gdk_screen}->get_monitor_geometry($self->{_gdk_screen}->get_monitor_at_window($mainwindow)); - return ($self->{_root}, $mon1->x, $mon1->y, $mon1->width, $mon1->height); + return ($self->{_root}, $mon1->{x}, $mon1->{y}, $mon1->{width}, $mon1->{height}); } sub get_current_monitor { @@ -131,7 +134,7 @@ sub get_current_monitor { sub get_monitor_region { my $self = shift; - my $region = Gtk2::Gdk::Region->new; + my $region = Gtk3::Gdk::Region->new; for (my $i = 0 ; $i < $self->{_gdk_screen}->get_n_monitors ; $i++) { $region->union_with_rect($self->{_gdk_screen}->get_monitor_geometry($i)); } @@ -142,13 +145,16 @@ sub ungrab_pointer_and_keyboard { my ($self, $ungrab_server, $quit_event_handler, $quit_main) = @_; #ungrab pointer and keyboard - Gtk2::Gdk::X11->ungrab_server if $ungrab_server; - Gtk2::Gdk->pointer_ungrab(Gtk2->get_current_event_time); - Gtk2::Gdk->keyboard_ungrab(Gtk2->get_current_event_time); - Gtk2::Gdk::Event->handler_set(undef, undef) if $quit_event_handler; - Gtk2->main_quit if $quit_main; - - return TRUE unless Gtk2::Gdk->pointer_is_grabbed; + Gtk3::Gdk::X11->ungrab_server if $ungrab_server; + Gtk3::Gdk::pointer_ungrab(Gtk3::get_current_event_time()); + Gtk3::Gdk::keyboard_ungrab(Gtk3::get_current_event_time()); + Gtk3::Gdk::Event::handler_set(sub { + my $event = shift; + Gtk3::main_do_event($event); + }) if $quit_event_handler; + Gtk3->main_quit if $quit_main; + + return TRUE unless Gtk3::Gdk::pointer_is_grabbed(); return FALSE; } @@ -204,7 +210,7 @@ sub ungrab_pointer_and_keyboard { #~ #~ my $append_res = `$append_cmd`; #~ -#~ my $app_pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($tmpfilename_fin); +#~ my $app_pixbuf = Gtk3::Gdk::Pixbuf->new_from_file($tmpfilename_fin); #~ print $app_pixbuf."\n"; #~ return ($app_pixbuf, 0, 0, 0, 0); #~ @@ -306,11 +312,12 @@ sub get_pixbuf_from_drawable { #get the pixbuf from drawable and save the file eval { if ($width > 0 && $height > 0) { - $pixbuf = Gtk2::Gdk::Pixbuf->get_from_drawable($drawable, undef, $x, $y, 0, 0, $width, $height); + $pixbuf = Gtk3::Gdk::pixbuf_get_from_window($drawable, $x, $y, $width, $height); } }; if ($@) { $pixbuf = 5; + Gtk3->main_quit; return FALSE; } @@ -328,10 +335,10 @@ sub get_pixbuf_from_drawable { #~ my $clipbox = $region->get_clipbox; my $clipbox = $self->get_clipbox($region); - #~ print "Clipbox: ", $clipbox->width, " - ", $clipbox->height, "\n"; + #print "Clipbox: ", Dumper($region, $clipbox); #create target pixbuf with dimension of clipbox - my $target = Gtk2::Gdk::Pixbuf->new($pixbuf->get_colorspace, TRUE, 8, $clipbox->width, $clipbox->height); + my $target = Gtk3::Gdk::Pixbuf->new($pixbuf->get_colorspace, TRUE, 8, $clipbox->{width}, $clipbox->{height}); #whole pixbuf is transparent $target->fill(0x00000000); @@ -339,25 +346,28 @@ sub get_pixbuf_from_drawable { #determine low x and y my $small_x = $self->{_root}->{w}; my $small_y = $self->{_root}->{h}; - foreach my $r ($region->get_rectangles) { - $small_x = $r->x if $r->x < $small_x; - $small_y = $r->y if $r->y < $small_y; + my $len = $region->num_rectangles-1; + for my $i (0..$len) { + my $r = $region->get_rectangle($i); + $small_x = $r->{x} if $r->{x} < $small_x; + $small_y = $r->{y} if $r->{y} < $small_y; } #copy each rectangle - foreach my $r ($region->get_rectangles) { + for my $i (0..$len) { + my $r = $region->get_rectangle($i); #~ print $r->x, " - ", $r->y, " - ", $r->width, " - ", $r->height, "\n"; - $pixbuf->copy_area($r->x - $small_x, $r->y - $small_y, $r->width, $r->height, $target, $r->x - $small_x, $r->y - $small_y); + $pixbuf->copy_area($r->{x} - $small_x, $r->{y} - $small_y, $r->{width}, $r->{height}, $target, $r->{x} - $small_x, $r->{y} - $small_y); } $pixbuf = $target->copy; } - Gtk2->main_quit; + Gtk3->main_quit; return FALSE; }); - Gtk2->main(); + Gtk3->main(); return ($pixbuf, $l_cropped, $r_cropped, $t_cropped, $b_cropped); } @@ -414,7 +424,7 @@ sub include_cursor { } if ($width > 1 && $height > 1) { - $cursor_pixbuf = Gtk2::Gdk::Pixbuf->new_from_data($data, 'rgb', 1, 8, $width, $height - 1, 4 * $width); + $cursor_pixbuf = Gtk3::Gdk::Pixbuf->new_from_data($data, 'rgb', 1, 8, $width, $height - 1, 4 * $width); $cursor_pixbuf_xhot = $xhot; $cursor_pixbuf_yhot = $yhot; @@ -431,14 +441,14 @@ sub include_cursor { my ($window_at_pointer, $root_x, $root_y, $mask) = $gdk_window->get_pointer; - my $cursor = Gtk2::Gdk::Cursor->new('GDK_LEFT_PTR'); + my $cursor = Gtk3::Gdk::Cursor->new('GDK_LEFT_PTR'); $cursor_pixbuf = $cursor->get_image; #try to use default cursor if there was an error unless ($cursor_pixbuf) { warn "WARNING: There was an error while getting the default cursor image - using one of our image files\n"; my $icons_path = $self->{_sc}->get_root . "/share/shutter/resources/icons"; - eval { $cursor_pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($icons_path . "/Normal.cur"); }; + eval { $cursor_pixbuf = Gtk3::Gdk::Pixbuf->new_from_file($icons_path . "/Normal.cur"); }; if ($@) { warn "ERROR: There was an error while loading the image file: $@\n"; } @@ -461,7 +471,7 @@ sub include_cursor { my $y = $cursor_pixbuf_yroot; #screenshot dimensions saved in a rect (global x, y) - my $scshot = Gtk2::Gdk::Rectangle->new($xp, $yp, $widthp, $heightp); + my $scshot = {x=>$xp, y=>$yp, width=>$widthp, height=>$heightp}; #see 'man xcursor' for a detailed description #of these values @@ -469,7 +479,7 @@ sub include_cursor { my $yhot = $cursor_pixbuf_yhot; #cursor dimensions (global x, y and width and height of the pixbuf) - my $cursor = Gtk2::Gdk::Rectangle->new($x, $y, $cursor_pixbuf->get_width, $cursor_pixbuf->get_height); + my $cursor = {x=>$x, y=>$y, width=>$cursor_pixbuf->get_width, height=>$cursor_pixbuf->get_height}; #is the cursor visible in the current screenshot? #(do the rects intersect?) @@ -487,7 +497,7 @@ sub include_cursor { $dest_x = 0 if $dest_x < 0; $dest_y = 0 if $dest_y < 0; - $cursor_pixbuf->composite($pixbuf, $dest_x, $dest_y, $cursor->width, $cursor->height, $x - $xp - $xhot, $y - $yp - $yhot, 1.0, 1.0, 'bilinear', 255); + $cursor_pixbuf->composite($pixbuf, $dest_x, $dest_y, $cursor->{width}, $cursor->{height}, $x - $xp - $xhot, $y - $yp - $yhot, 1.0, 1.0, 'bilinear', 255); } } diff --git a/share/shutter/resources/modules/Shutter/Screenshot/SelectorAdvanced.pm b/share/shutter/resources/modules/Shutter/Screenshot/SelectorAdvanced.pm index d1eb57c6e..332b89c69 100644 --- a/share/shutter/resources/modules/Shutter/Screenshot/SelectorAdvanced.pm +++ b/share/shutter/resources/modules/Shutter/Screenshot/SelectorAdvanced.pm @@ -30,8 +30,9 @@ use utf8; use strict; use warnings; -use Gtk2::ImageView; -use Gnome2::Canvas; +use Gtk3::ImageView; +use GooCanvas2; +use GooCanvas2::CairoTypes; use Shutter::Screenshot::Main; use Shutter::Screenshot::History; @@ -59,11 +60,13 @@ sub new { $self->{_init_w} = shift; $self->{_init_h} = shift; + $self->{_dpi_scale} = Gtk3::Window->new('toplevel')->get('scale-factor'); + #view, selector, dragger - $self->{_view} = Gtk2::ImageView->new; - $self->{_selector} = Gtk2::ImageView::Tool::Selector->new($self->{_view}); - $self->{_dragger} = Gtk2::ImageView::Tool::Dragger->new($self->{_view}); - $self->{_view}->set_interpolation('tiles'); + $self->{_view} = Gtk3::ImageView->new; + $self->{_selector} = Gtk3::ImageView::Tool::Selector->new($self->{_view}); + #$self->{_dragger} = Gtk3::ImageView::Tool::Dragger->new($self->{_view}); + $self->{_view}->set_interpolation('nearest'); $self->{_view}->set_tool($self->{_selector}); #WORKAROUND @@ -101,7 +104,7 @@ sub select_advanced { my $d = $self->{_sc}->get_gettext; #create pixbuf (root window) - my $clean_pixbuf = Gtk2::Gdk::Pixbuf->get_from_drawable($self->{_root}, undef, 0, 0, 0, 0, $self->{_root}->{w}, $self->{_root}->{h}); + my $clean_pixbuf = Gtk3::Gdk::pixbuf_get_from_window($self->{_root}, 0, 0, $self->{_root}->{w}, $self->{_root}->{h}); $self->{_view}->set_pixbuf($clean_pixbuf); @@ -117,26 +120,25 @@ sub select_advanced { #right in the middle of both screens, this is pretty ugly my $mon1 = $self->get_current_monitor; - print "Using monitor: " . $mon1->x . " - " . $mon1->y . " - " . $mon1->width . " - " . $mon1->height . "\n" + print "Using monitor: " . $mon1->{x} . " - " . $mon1->{y} . " - " . $mon1->{width} . " - " . $mon1->{height} . "\n" if $self->{_sc}->get_debug; #obtain current colors and font_desc from the main window - my $style = $self->{_sc}->get_mainwindow->get_style; - my $sel_bg = Gtk2::Gdk::Color->parse('#131313'); - my $sel_tx = $style->text('selected'); - my $font_fam = $style->font_desc->get_family; - my $font_size = $style->font_desc->get_size / Gtk2::Pango->scale; + my $style = $self->{_sc}->get_mainwindow->get_style_context; + my $sel_bg = Gtk3::Gdk::RGBA::parse('#131313'); + my $font_fam = $style->get_font('normal')->get_family; + my $font_size = $style->get_font('normal')->get_size * $self->{_dpi_scale} / Pango->scale; #create cairo context und layout - my $surface = Cairo::ImageSurface->create('argb32', $self->{_root}->{w}, $self->{_root}->{h}); + my $surface = Cairo::ImageSurface->create('argb32', $self->{_root}->{w}*$self->{_dpi_scale}, $self->{_root}->{h}*$self->{_dpi_scale}); my $cr = Cairo::Context->create($surface); #set_source_pixbuf - Gtk2::Gdk::Cairo::Context::set_source_pixbuf($cr, $clean_pixbuf, 0, 0); + Gtk3::Gdk::cairo_set_source_pixbuf($cr, $clean_pixbuf, 0, 0); $cr->paint; - my $layout = Gtk2::Pango::Cairo::create_layout($cr); - $layout->set_width(int($mon1->width / 2) * Gtk2::Pango->scale); + my $layout = Pango::Cairo::create_layout($cr); + $layout->set_width(int($mon1->{width} * $self->{_dpi_scale} / 2) * Pango->scale); $layout->set_alignment('left'); $layout->set_wrap('word'); @@ -151,7 +153,7 @@ sub select_advanced { my $text3 = $d->get("shift/right-click → selection dialog on/off") . "\n" - . $d->get("ctrl + scrollwheel → zoom in/out") . "\n" + . $d->get("scrollwheel → zoom in/out") . "\n" . $d->get("space → zoom window on/off") . "\n" . $d->get("cursor keys → move cursor") . "\n" . $d->get("cursor keys + alt → move selection") . "\n" @@ -163,15 +165,15 @@ sub select_advanced { ); #draw the rectangle - $cr->set_source_rgba($sel_bg->red / 257 / 255, $sel_bg->green / 257 / 255, $sel_bg->blue / 257 / 255, 0.85); + $cr->set_source_rgba($sel_bg->red, $sel_bg->green, $sel_bg->blue, 0.85); my ($lw, $lh) = $layout->get_pixel_size; my $w = $lw + $size1 * 2; my $h = $lh + $size1 * 2; - my $x = int(($mon1->width - $w) / 2) + $mon1->x; - my $y = int(($mon1->height - $h) / 2) + $mon1->y; - my $r = 20; + my $x = int(($mon1->{width}*$self->{_dpi_scale} - $w) / 2) + $mon1->{x}; + my $y = int(($mon1->{height}*$self->{_dpi_scale} - $h) / 2) + $mon1->{y}; + my $r = 20*$self->{_dpi_scale}; $cr->move_to($x + $r, $y); $cr->line_to($x + $w - $r, $y); @@ -187,14 +189,15 @@ sub select_advanced { $cr->move_to($x + $size1, $y + $size1); #draw the pango layout - Gtk2::Pango::Cairo::show_layout($cr, $layout); + Pango::Cairo::show_layout($cr, $layout); #write surface to pixbuf - my $loader = Gtk2::Gdk::PixbufLoader->new; + my $loader = Gtk3::Gdk::PixbufLoader->new; $surface->write_to_png_stream( sub { my ($closure, $data) = @_; - $loader->write($data); + $loader->write([map ord, split //, $data]); + return TRUE; }); $loader->close; @@ -208,7 +211,7 @@ sub select_advanced { } #define zoom window - $self->{_zoom_window} = Gtk2::Window->new('popup'); + $self->{_zoom_window} = Gtk3::Window->new('popup'); $self->{_zoom_window}->set_decorated(FALSE); $self->{_zoom_window}->set_skip_taskbar_hint(TRUE); $self->{_zoom_window}->set_skip_pager_hint(TRUE); @@ -216,56 +219,57 @@ sub select_advanced { $self->{_zoom_window}->set_accept_focus(FALSE); #pack canvas to a scrolled window - my $scwin = Gtk2::ScrolledWindow->new(); + my $scwin = Gtk3::ScrolledWindow->new(); $scwin->set_policy('never', 'never'); #define and setup the canvas - my $canvas = Gnome2::Canvas->new(); + my $canvas = GooCanvas2::Canvas->new(); $canvas->set_size_request(105, 105); - $canvas->modify_bg('normal', Gtk2::Gdk::Color->new(65535, 65535, 65535)); - $canvas->set_pixels_per_unit(5); + $canvas->modify_bg('normal', Gtk3::Gdk::RGBA::parse('#00000000')); + $canvas->set_bounds(-10*$self->{_dpi_scale}, -10*$self->{_dpi_scale}, ($self->{_root}->{w}+10)*$self->{_dpi_scale}, ($self->{_root}->{h}+10)*$self->{_dpi_scale}); + $canvas->set_scale(5); - my $canvas_root = $canvas->root(); + my $canvas_root = $canvas->get_root_item(); $scwin->add($canvas); - my $xlabel = Gtk2::Label->new("X: "); - my $ylabel = Gtk2::Label->new("Y: "); - my $rlabel = Gtk2::Label->new("0 x 0"); + my $xlabel = Gtk3::Label->new("X: "); + my $ylabel = Gtk3::Label->new("Y: "); + my $rlabel = Gtk3::Label->new("0 x 0"); $ylabel->set_max_width_chars(10); $xlabel->set_max_width_chars(10); $rlabel->set_max_width_chars(10); - my $zoom_vbox = Gtk2::VBox->new; - $zoom_vbox->pack_start_defaults($scwin); - $zoom_vbox->pack_start_defaults($xlabel); - $zoom_vbox->pack_start_defaults($ylabel); - $zoom_vbox->pack_start_defaults($rlabel); + my $zoom_vbox = Gtk3::VBox->new; + $zoom_vbox->pack_start($scwin, TRUE, TRUE, 0); + $zoom_vbox->pack_start($xlabel, TRUE, TRUE, 0); + $zoom_vbox->pack_start($ylabel, TRUE, TRUE, 0); + $zoom_vbox->pack_start($rlabel, TRUE, TRUE, 0); #do some packing $self->{_zoom_window}->add($zoom_vbox); $self->{_zoom_window}->move($self->{_root}->{x}, $self->{_root}->{y}); #define shutter cursor (frame) - my $shutter_cursor_pixbuf_frame = Gtk2::Gdk::Pixbuf->new_from_file($self->{_sc}->get_root . "/share/shutter/resources/icons/shutter_cursor_frame.png"); + my $shutter_cursor_pixbuf_frame = Gtk3::Gdk::Pixbuf->new_from_file($self->{_sc}->get_root . "/share/shutter/resources/icons/shutter_cursor_frame.png"); #create root... - my $root_item = Gnome2::Canvas::Item->new( - $canvas_root, - "Gnome2::Canvas::Pixbuf", + my $root_item = GooCanvas2::CanvasImage->new( + parent => $canvas_root, x => 0, y => 0, pixbuf => $clean_pixbuf ); + GooCanvas2::CairoTypes::cairoize_pattern($root_item->get('pattern'))->set_filter('nearest'); #...and cursor icon - my $cursor_item = Gnome2::Canvas::Item->new( - $canvas_root, - "Gnome2::Canvas::Pixbuf", + my $cursor_item = GooCanvas2::CanvasImage->new( + parent => $canvas_root, x => 0, y => 0, pixbuf => $shutter_cursor_pixbuf_frame, ); + GooCanvas2::CairoTypes::cairoize_pattern($cursor_item->get('pattern'))->set_filter('nearest'); #starting point my ($window_at_pointer, $xinit, $yinit, $mask) = $self->{_root}->get_pointer; @@ -277,17 +281,17 @@ sub select_advanced { ); #scroll region - $canvas->set_scroll_region($xinit - 9, $yinit - 9, $xinit + 10, $yinit + 10); + #$canvas->set_scroll_region($xinit - 9, $yinit - 9, $xinit + 10, $yinit + 10); + $canvas->scroll_to($xinit - 10, $yinit - 10); #window to manipulate the selection $self->{_prop_window} = $self->select_dialog(); $self->{_prop_active} = FALSE; #window that contains the imageview widget - $self->{_select_window} = Gtk2::Window->new('popup'); + $self->{_select_window} = Gtk3::Window->new('popup'); $self->{_select_window}->set_type_hint('splashscreen'); - $self->{_select_window}->set_has_frame(FALSE); - $self->{_select_window}->can_focus(TRUE); + $self->{_select_window}->set_can_focus(TRUE); $self->{_select_window}->set_accept_focus(TRUE); $self->{_select_window}->set_modal(TRUE); $self->{_select_window}->set_decorated(FALSE); @@ -329,16 +333,18 @@ sub select_advanced { #ignore zoom values smaller 1 $self->{_view_zoom_handler} = $self->{_view}->signal_connect( 'zoom-changed' => sub { - if ($self->{_view}->get_zoom < 1) { - $self->{_view}->set_zoom(1); - } elsif ($self->{_view}->get_zoom > 10) { - $self->{_view}->set_zoom(10); - } elsif ($self->{_view}->get_zoom > 1) { - if ($self->{_zoom_active}) { - $self->{_zoom_window}->hide_all; - } + my ($view, $zoom) = @_; + if ($zoom >= 1) { + $view->set_interpolation('nearest'); + $view->set_zoom(10) if $zoom > 10; } else { - if ($self->{_zoom_active}) { + $view->set_interpolation('bilinear'); + $view->set_zoom(1); + } + if ($self->{_zoom_active}) { + if ($zoom > 1) { + $self->{_zoom_window}->hide; + } else { $self->{_zoom_window}->show_all; $self->zoom_check_pos(); } @@ -346,7 +352,7 @@ sub select_advanced { #hide help text when zoomed if ($self->{_selector_init_zoom} == 1) { - $self->{_view}->set_pixbuf($clean_pixbuf, FALSE); + $view->set_pixbuf($clean_pixbuf, FALSE); $self->{_selector_init} = FALSE; } else { $self->{_selector_init_zoom}++; @@ -358,7 +364,7 @@ sub select_advanced { Glib::Idle->add( sub { if ($self->{_init_w} && $self->{_init_h}) { - $self->{_selector}->set_selection(Gtk2::Gdk::Rectangle->new($self->{_init_x}, $self->{_init_y}, $self->{_init_w}, $self->{_init_h})); + $self->{_selector}->set_selection({x=>$self->{_init_x}, y=>$self->{_init_y}, width=>$self->{_init_w}, height=>$self->{_init_h}}); } return FALSE; }); @@ -392,10 +398,10 @@ sub select_advanced { Glib::Timeout->add( $self->{_hide_time}, sub { - Gtk2->main_quit; + Gtk3->main_quit; return FALSE; }); - Gtk2->main(); + Gtk3->main(); $output = $self->take_screenshot($s, $clean_pixbuf); $self->quit; @@ -427,17 +433,17 @@ sub select_advanced { if ($event->button == 3) { if ($self->{_prop_active}) { - Gtk2::Gdk->keyboard_ungrab(Gtk2->get_current_event_time); - $self->{_prop_window}->hide_all; + Gtk3::Gdk::keyboard_ungrab(Gtk3::get_current_event_time()); + $self->{_prop_window}->hide; $self->{_prop_active} = FALSE; - Gtk2::Gdk->keyboard_grab($self->{_select_window}->window, 0, Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_grab($self->{_select_window}->get_window, 0, Gtk3::get_current_event_time()); } else { - Gtk2::Gdk->keyboard_ungrab(Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_ungrab(Gtk3::get_current_event_time()); my ($window_at_pointer, $x, $y, $mask) = $self->{_root}->get_pointer; $self->{_prop_window}->move($x, $y); $self->{_prop_window}->show_all; $self->{_prop_active} = TRUE; - Gtk2::Gdk->keyboard_grab($self->{_prop_window}->window, 0, Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_grab($self->{_prop_window}->get_window, 0, Gtk3::get_current_event_time()); } } @@ -453,51 +459,53 @@ sub select_advanced { my ($window_at_pointer, $x, $y, $mask) = $self->{_root}->get_pointer; #event coordinates - my $ev_x = int($v->x / $self->{_view}->get_zoom + $x / $self->{_view}->get_zoom); - my $ev_y = int($v->y / $self->{_view}->get_zoom + $y / $self->{_view}->get_zoom); + my $zoom = $self->{_view}->get_zoom; + my $ev_x = int($v->{x} / $zoom + $x * $self->{_dpi_scale} / $zoom); + my $ev_y = int($v->{y} / $zoom + $y * $self->{_dpi_scale} / $zoom); #sync cursor with selection - my $cursor = $self->{_selector}->cursor_at_point($x, $y); - if (defined $s) { + if (0 && defined $s) { + my $cursor = $self->{_selector}->cursor_at_point($x, $y)->get_cursor_type; + print Dumper($cursor); - my $sx = $s->x; - my $sy = $s->y; - my $sw = $s->width; - my $sh = $s->height; + my $sx = $s->{x}; + my $sy = $s->{y}; + my $sw = $s->{width}; + my $sh = $s->{height}; - if ($cursor->type eq 'bottom-right-corner') { + if ($cursor eq 'bottom-right-corner') { $ev_x = $sx + $sw - 1; $ev_y = $sy + $sh - 1; - } elsif ($cursor->type eq 'right-side') { + } elsif ($cursor eq 'right-side') { $ev_x = $sx + $sw - 1; - } elsif ($cursor->type eq 'top-right-corner') { + } elsif ($cursor eq 'top-right-corner') { $ev_x = $sx + $sw - 1; $ev_y = $sy; - } elsif ($cursor->type eq 'top-side') { + } elsif ($cursor eq 'top-side') { $ev_y = $sy; - } elsif ($cursor->type eq 'top-left-corner') { + } elsif ($cursor eq 'top-left-corner') { $ev_x = $sx; $ev_y = $sy; - } elsif ($cursor->type eq 'left-side') { + } elsif ($cursor eq 'left-side') { $ev_x = $sx; - } elsif ($cursor->type eq 'bottom-left-corner') { + } elsif ($cursor eq 'bottom-left-corner') { $ev_x = $sx; $ev_y = $sy + $sh - 1; - } elsif ($cursor->type eq 'bottom-side') { + } elsif ($cursor eq 'bottom-side') { $ev_y = $sy + $sh - 1; @@ -521,11 +529,12 @@ sub select_advanced { #update scroll region #this is significantly faster than #scroll_to - $canvas->set_scroll_region($ev_x - 9, $ev_y - 9, $ev_x + 10, $ev_y + 10); + #$canvas->set_scroll_region($ev_x - 9, $ev_y - 9, $ev_x + 10, $ev_y + 10); + $canvas->scroll_to($ev_x - 10, $ev_y - 10); #update zoom_window text if (defined $s) { - $rlabel->set_text($s->width . " x " . $s->height); + $rlabel->set_text($s->{width} . " x " . $s->{height}); } else { $rlabel->set_text("0 x 0"); } @@ -533,16 +542,23 @@ sub select_advanced { } #zoom active #handle key-press - } elsif ($event->type eq 'key-press') { + } + }); + + $self->{_key_handler} = $self->{_select_window}->signal_connect( + 'key-press-event' => sub { + my ($window, $event) = @_; + return FALSE unless defined $event; + my $s = $self->{_selector}->get_selection; #where is the pointer currently? my ($window_at_pointer, $x, $y, $mask) = $self->{_root}->get_pointer; #toggle zoom window - if ($event->keyval == Gtk2::Gdk->keyval_from_name('space')) { + if ($event->keyval == Gtk3::Gdk::keyval_from_name('space')) { if ($self->{_zoom_active}) { - $self->{_zoom_window}->hide_all; + $self->{_zoom_window}->hide; $self->{_zoom_active} = FALSE; } elsif ($self->{_view}->get_zoom == 1) { $self->zoom_check_pos(); @@ -550,94 +566,94 @@ sub select_advanced { } #toggle prop dialog - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('Shift_L') || $event->keyval == Gtk2::Gdk->keyval_from_name('Shift_R')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('Shift_L') || $event->keyval == Gtk3::Gdk::keyval_from_name('Shift_R')) { if ($self->{_prop_active}) { - Gtk2::Gdk->keyboard_ungrab(Gtk2->get_current_event_time); - $self->{_prop_window}->hide_all; + Gtk3::Gdk::keyboard_ungrab(Gtk3::get_current_event_time()); + $self->{_prop_window}->hide; $self->{_prop_active} = FALSE; - Gtk2::Gdk->keyboard_grab($self->{_select_window}->window, 0, Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_grab($self->{_select_window}->get_window, 0, Gtk3::get_current_event_time()); } else { - Gtk2::Gdk->keyboard_ungrab(Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_ungrab(Gtk3::get_current_event_time()); my ($window_at_pointer, $x, $y, $mask) = $self->{_root}->get_pointer; $self->{_prop_window}->move($x, $y); $self->{_prop_window}->show_all; $self->{_prop_active} = TRUE; - Gtk2::Gdk->keyboard_grab($self->{_prop_window}->window, 0, Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_grab($self->{_prop_window}->get_window, 0, Gtk3::get_current_event_time()); } #abort screenshot - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('Escape')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('Escape')) { $self->quit; #move / resize selector - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('Up')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('Up')) { if ($event->state >= 'control-mask' && $s) { - $s->height($s->height - 1); + $s->{height} -= 1; $self->{_selector}->set_selection($s); - $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->width + $s->x, $s->height + $s->y); + $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->{width} + $s->{x}, $s->{height} + $s->{y}); } elsif ($event->state >= 'mod1-mask' && $s) { - $s->y($s->y - 1); + $s->{y} -= 1; $self->{_selector}->set_selection($s); - $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->x, $s->y); + $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->{x}, $s->{y}); } else { $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $x, $y - 1); } - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('Down')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('Down')) { if ($event->state >= 'control-mask' && $s) { - $s->height($s->height + 1); + $s->{height} += 1; $self->{_selector}->set_selection($s); - $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->width + $s->x, $s->height + $s->y); + $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->{width} + $s->{x}, $s->{height} + $s->{y}); } elsif ($event->state >= 'control-mask') { - $self->{_selector}->set_selection(Gtk2::Gdk::Rectangle->new($x, $y, 1, 2)); + $self->{_selector}->set_selection({x=>$x, y=>$y, width=>1, height=>2}); $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $x + 1, $y + 2); } elsif ($event->state >= 'mod1-mask' && $s) { - $s->y($s->y + 1); + $s->{y} += 1; $self->{_selector}->set_selection($s); - $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->x, $s->y); + $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->{x}, $s->{y}); } else { $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $x, $y + 1); } - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('Left')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('Left')) { if ($event->state >= 'control-mask' && $s) { - $s->width($s->width - 1); + $s->{width} -= 1; $self->{_selector}->set_selection($s); - $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->width + $s->x, $s->height + $s->y); + $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->{width} + $s->{x}, $s->{height} + $s->{y}); } elsif ($event->state >= 'mod1-mask' && $s) { - $s->x($s->x - 1); + $s->{x} -= 1; $self->{_selector}->set_selection($s); - $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->x, $s->y); + $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->{x}, $s->{y}); } else { $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $x - 1, $y); } - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('Right')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('Right')) { if ($event->state >= 'control-mask' && $s) { - $s->width($s->width + 1); + $s->{width} += 1; $self->{_selector}->set_selection($s); - $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->width + $s->x, $s->height + $s->y); + $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->{width} + $s->{x}, $s->{height} + $s->{y}); } elsif ($event->state >= 'control-mask') { - $self->{_selector}->set_selection(Gtk2::Gdk::Rectangle->new($x, $y, 2, 1)); + $self->{_selector}->set_selection({x=>$x, y=>$y, width=>2, height=>1}); $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $x + 2, $y + 1); } elsif ($event->state >= 'mod1-mask' && $s) { - $s->x($s->x + 1); + $s->{x} += 1; $self->{_selector}->set_selection($s); - $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->x, $s->y); + $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $s->{x}, $s->{y}); } else { $self->{_gdk_display}->warp_pointer($self->{_gdk_screen}, $x + 1, $y); } #zoom in - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('KP_Add') - || $event->keyval == Gtk2::Gdk->keyval_from_name('plus') - || $event->keyval == Gtk2::Gdk->keyval_from_name('equal')) + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('KP_Add') + || $event->keyval == Gtk3::Gdk::keyval_from_name('plus') + || $event->keyval == Gtk3::Gdk::keyval_from_name('equal')) { if ($event->state >= 'control-mask') { @@ -645,8 +661,8 @@ sub select_advanced { } #zoom out - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('KP_Subtract') - || $event->keyval == Gtk2::Gdk->keyval_from_name('minus')) + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('KP_Subtract') + || $event->keyval == Gtk3::Gdk::keyval_from_name('minus')) { if ($event->state >= 'control-mask') { @@ -654,14 +670,14 @@ sub select_advanced { } #zoom normal - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('0')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('0')) { if ($event->state >= 'control-mask') { $self->{_view}->set_zoom(1); } #take screenshot - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('Return') || $event->keyval == Gtk2::Gdk->keyval_from_name('KP_Enter')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('Return') || $event->keyval == Gtk3::Gdk::keyval_from_name('KP_Enter')) { $self->{_select_window}->hide; $self->{_zoom_window}->hide; @@ -672,28 +688,27 @@ sub select_advanced { Glib::Timeout->add( $self->{_hide_time}, sub { - Gtk2->main_quit; + Gtk3->main_quit; return FALSE; }); - Gtk2->main(); + Gtk3->main(); $output = $self->take_screenshot($s, $clean_pixbuf); $self->quit; } - } }); - my $status = Gtk2::Gdk->keyboard_grab($self->{_select_window}->window, 0, Gtk2->get_current_event_time); + my $status = Gtk3::Gdk::keyboard_grab($self->{_select_window}->get_window, 0, Gtk3::get_current_event_time()); #~ if($status eq 'success'){ if ($self->{_zoom_active}) { $self->{_zoom_window}->show_all; - $self->{_zoom_window}->window->set_override_redirect(TRUE); + $self->{_zoom_window}->get_window->set_override_redirect(TRUE); $self->zoom_check_pos(); - $self->{_zoom_window}->window->raise; + $self->{_zoom_window}->get_window->raise; } - Gtk2->main(); + Gtk3->main(); #~ }else{ #~ $output = 1; @@ -714,36 +729,40 @@ sub zoom_check_pos { my ($window_at_pointer, $x, $y, $mask) = $self->{_root}->get_pointer; #event coordinates - my $ev_x = int($v->x / $self->{_view}->get_zoom + $x / $self->{_view}->get_zoom); - my $ev_y = int($v->y / $self->{_view}->get_zoom + $y / $self->{_view}->get_zoom); + my $zoom = $self->{_view}->get_zoom; + my $ev_x = int($v->{x} / $zoom + $x * $self->{_dpi_scale} / $zoom); + my $ev_y = int($v->{y} / $zoom + $y * $self->{_dpi_scale} / $zoom); my ($zw, $zh) = $self->{_zoom_window}->get_size; my ($zx, $zy) = $self->{_zoom_window}->get_position; + my $distance = 50 * $self->{_dpi_scale}; + my $zzw = $zw * $self->{_dpi_scale} + $distance; + my $zzh = $zh * $self->{_dpi_scale} + $distance; + my $sregion = undef; if (defined $s) { - $sregion = Gtk2::Gdk::Region->rectangle(Gtk2::Gdk::Rectangle->new($s->x - 50, $s->y - 50, $s->width + 50, $s->height + 50)); + $sregion = Cairo::Region->create({x=>$s->{x}, y=>$s->{y}, width=>$s->{width} + $distance, height=>$s->{height} + $distance}); } else { - $sregion = Gtk2::Gdk::Region->rectangle(Gtk2::Gdk::Rectangle->new($ev_x - 50, $ev_y - 50, 50, 50)); + $sregion = Cairo::Region->create({x=>$ev_x, y=>$ev_y, width=>$distance, height=>$distance}); } - my $otype = $sregion->rect_in(Gtk2::Gdk::Rectangle->new($zx - 50, $zy - 50, $zw + 50, $zh + 50)); - if ($otype eq 'in' || $otype eq 'part' || !$self->{_zoom_window}->visible) { + my $otype = $sregion->contains_rectangle({x=>$zx, y=>$zy, width=>$zzw, height=>$zzh}); + if ($otype eq 'in' || $otype eq 'part' || !$self->{_zoom_window}->get_visible) { my $moved = FALSE; #possible positions if we need to move the zoom window my @pos = ( - Gtk2::Gdk::Rectangle->new($self->{_root}->{x}, $self->{_root}->{y}, 0, 0), - Gtk2::Gdk::Rectangle->new(0, $self->{_root}->{h} - $zh, 0, 0), - Gtk2::Gdk::Rectangle->new($self->{_root}->{w} - $zw, $self->{_root}->{y}, 0, 0), - Gtk2::Gdk::Rectangle->new($self->{_root}->{w} - $zw, $self->{_root}->{h} - $zh, 0, 0)); + {x=>$self->{_root}->{x}, y=>$self->{_root}->{y}, }, + {x=>$self->{_root}->{x}, y=>$self->{_root}->{h} - $zh}, + {x=>$self->{_root}->{w} - $zw, y=>$self->{_root}->{y}, }, + {x=>$self->{_root}->{w} - $zw, y=>$self->{_root}->{h} - $zh}); foreach (@pos) { - - my $otypet = $sregion->rect_in(Gtk2::Gdk::Rectangle->new($_->x - 50, $_->y - 50, $zw + 50, $zh + 50)); + my $otypet = $sregion->contains_rectangle({x=>$_->{x}*$self->{_dpi_scale}, y=>$_->{y}*$self->{_dpi_scale}, width=>$zzw, height=>$zzh}); if ($otypet eq 'out') { - $self->{_zoom_window}->move($_->x, $_->y); + $self->{_zoom_window}->move($_->{x}, $_->{y}); $self->{_zoom_window}->show_all; $moved = TRUE; last; @@ -754,7 +773,7 @@ sub zoom_check_pos { #if window could not be moved without covering the selection area unless ($moved) { $moved = FALSE; - $self->{_zoom_window}->hide_all; + $self->{_zoom_window}->hide; } } @@ -773,17 +792,17 @@ sub adjust_prop_values { my $s = $self->{_selector}->get_selection; if ($s) { - $self->{_x_spin_w}->set_value($s->x); - $self->{_x_spin_w}->set_range(0, $self->{_root}->{w} - $s->width); + $self->{_x_spin_w}->set_value($s->{x}); + $self->{_x_spin_w}->set_range(0, $self->{_root}->{w} - $s->{width}); - $self->{_y_spin_w}->set_value($s->y); - $self->{_y_spin_w}->set_range(0, $self->{_root}->{h} - $s->height); + $self->{_y_spin_w}->set_value($s->{y}); + $self->{_y_spin_w}->set_range(0, $self->{_root}->{h} - $s->{height}); - $self->{_width_spin_w}->set_value($s->width); - $self->{_width_spin_w}->set_range(0, $self->{_root}->{w} - $s->x); + $self->{_width_spin_w}->set_value($s->{width}); + $self->{_width_spin_w}->set_range(0, $self->{_root}->{w} - $s->{x}); - $self->{_height_spin_w}->set_value($s->height); - $self->{_height_spin_w}->set_range(0, $self->{_root}->{h} - $s->y); + $self->{_height_spin_w}->set_value($s->{height}); + $self->{_height_spin_w}->set_range(0, $self->{_root}->{h} - $s->{y}); } #unblock 'value-change' handlers for widgets @@ -810,69 +829,62 @@ sub select_dialog { my $sh = 0; if (defined $s) { - $sx = $s->x; - $sy = $s->y; - $sw = $s->width; - $sh = $s->height; + $sx = $s->{x}; + $sy = $s->{y}; + $sw = $s->{width}; + $sh = $s->{height}; + } + + sub value_callback { + $self->{_selector} + ->set_selection({x=>$self->{_x_spin_w}->get_value, y=>$self->{_y_spin_w}->get_value, width=>$self->{_width_spin_w}->get_value, height=>$self->{_height_spin_w}->get_value}); } #X - my $xw_label = Gtk2::Label->new($d->get("X") . ":"); - $self->{_x_spin_w} = Gtk2::SpinButton->new_with_range(0, $self->{_root}->{w}, 1); + my $xw_label = Gtk3::Label->new($d->get("X") . ":"); + $self->{_x_spin_w} = Gtk3::SpinButton->new_with_range(0, $self->{_root}->{w}, 1); $self->{_x_spin_w}->set_value($sx); $self->{_x_spin_w_handler} = $self->{_x_spin_w}->signal_connect( - 'value-changed' => sub { - $self->{_selector} - ->set_selection(Gtk2::Gdk::Rectangle->new($self->{_x_spin_w}->get_value, $self->{_y_spin_w}->get_value, $self->{_width_spin_w}->get_value, $self->{_height_spin_w}->get_value)); - }); + 'value-changed' => \&value_callback); - my $xw_hbox = Gtk2::HBox->new(FALSE, 5); + my $xw_hbox = Gtk3::HBox->new(FALSE, 5); $xw_hbox->pack_start($xw_label, FALSE, FALSE, 5); $xw_hbox->pack_start($self->{_x_spin_w}, FALSE, FALSE, 5); #y - my $yw_label = Gtk2::Label->new($d->get("Y") . ":"); - $self->{_y_spin_w} = Gtk2::SpinButton->new_with_range(0, $self->{_root}->{h}, 1); + my $yw_label = Gtk3::Label->new($d->get("Y") . ":"); + $self->{_y_spin_w} = Gtk3::SpinButton->new_with_range(0, $self->{_root}->{h}, 1); $self->{_y_spin_w}->set_value($sy); $self->{_y_spin_w_handler} = $self->{_y_spin_w}->signal_connect( - 'value-changed' => sub { - $self->{_selector} - ->set_selection(Gtk2::Gdk::Rectangle->new($self->{_x_spin_w}->get_value, $self->{_y_spin_w}->get_value, $self->{_width_spin_w}->get_value, $self->{_height_spin_w}->get_value)); - }); + 'value-changed' => \&value_callback); - my $yw_hbox = Gtk2::HBox->new(FALSE, 5); + my $yw_hbox = Gtk3::HBox->new(FALSE, 5); $yw_hbox->pack_start($yw_label, FALSE, FALSE, 5); $yw_hbox->pack_start($self->{_y_spin_w}, FALSE, FALSE, 5); #width - my $widthw_label = Gtk2::Label->new($d->get("Width") . ":"); - $self->{_width_spin_w} = Gtk2::SpinButton->new_with_range(0, $self->{_root}->{w}, 1); + my $widthw_label = Gtk3::Label->new($d->get("Width") . ":"); + $self->{_width_spin_w} = Gtk3::SpinButton->new_with_range(0, $self->{_root}->{w}, 1); $self->{_width_spin_w}->set_value($sw); $self->{_width_spin_w_handler} = $self->{_width_spin_w}->signal_connect( - 'value-changed' => sub { - $self->{_selector} - ->set_selection(Gtk2::Gdk::Rectangle->new($self->{_x_spin_w}->get_value, $self->{_y_spin_w}->get_value, $self->{_width_spin_w}->get_value, $self->{_height_spin_w}->get_value)); - }); + 'value-changed' => \&value_callback); - my $ww_hbox = Gtk2::HBox->new(FALSE, 5); + my $ww_hbox = Gtk3::HBox->new(FALSE, 5); $ww_hbox->pack_start($widthw_label, FALSE, FALSE, 5); $ww_hbox->pack_start($self->{_width_spin_w}, FALSE, FALSE, 5); #height - my $heightw_label = Gtk2::Label->new($d->get("Height") . ":"); - $self->{_height_spin_w} = Gtk2::SpinButton->new_with_range(0, $self->{_root}->{h}, 1); + my $heightw_label = Gtk3::Label->new($d->get("Height") . ":"); + $self->{_height_spin_w} = Gtk3::SpinButton->new_with_range(0, $self->{_root}->{h}, 1); $self->{_height_spin_w}->set_value($sh); $self->{_height_spin_w_handler} = $self->{_height_spin_w}->signal_connect( - 'value-changed' => sub { - $self->{_selector} - ->set_selection(Gtk2::Gdk::Rectangle->new($self->{_x_spin_w}->get_value, $self->{_y_spin_w}->get_value, $self->{_width_spin_w}->get_value, $self->{_height_spin_w}->get_value)); - }); + 'value-changed' => \&value_callback); - my $hw_hbox = Gtk2::HBox->new(FALSE, 5); + my $hw_hbox = Gtk3::HBox->new(FALSE, 5); $hw_hbox->pack_start($heightw_label, FALSE, FALSE, 5); $hw_hbox->pack_start($self->{_height_spin_w}, FALSE, FALSE, 5); - my $prop_dialog = Gtk2::Window->new('toplevel'); + my $prop_dialog = Gtk3::Window->new('toplevel'); $prop_dialog->set_modal(TRUE); $prop_dialog->set_decorated(FALSE); $prop_dialog->set_skip_taskbar_hint(TRUE); @@ -887,10 +899,10 @@ sub select_dialog { my $event = shift; #toggle zoom window - if ($event->keyval == Gtk2::Gdk->keyval_from_name('Space')) { + if ($event->keyval == Gtk3::Gdk::keyval_from_name('Space')) { if ($self->{_zoom_active}) { - $self->{_zoom_window}->hide_all; + $self->{_zoom_window}->hide; $self->{_zoom_active} = FALSE; } elsif ($self->{_view}->get_zoom == 1) { $self->zoom_check_pos(); @@ -898,24 +910,24 @@ sub select_dialog { } #toggle prop dialog - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('Shift_L') || $event->keyval == Gtk2::Gdk->keyval_from_name('Shift_R')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('Shift_L') || $event->keyval == Gtk3::Gdk::keyval_from_name('Shift_R')) { if ($self->{_prop_active}) { - Gtk2::Gdk->keyboard_ungrab(Gtk2->get_current_event_time); - $self->{_prop_window}->hide_all; + Gtk3::Gdk::keyboard_ungrab(Gtk3::get_current_event_time()); + $self->{_prop_window}->hide; $self->{_prop_active} = FALSE; - Gtk2::Gdk->keyboard_grab($self->{_select_window}->window, 0, Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_grab($self->{_select_window}->get_window, 0, Gtk3::get_current_event_time()); } else { - Gtk2::Gdk->keyboard_ungrab(Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_ungrab(Gtk3::get_current_event_time()); my ($window_at_pointer, $x, $y, $mask) = $self->{_root}->get_pointer; $self->{_prop_window}->move($x, $y); $self->{_prop_window}->show_all; $self->{_prop_active} = TRUE; - Gtk2::Gdk->keyboard_grab($self->{_prop_window}->window, 0, Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_grab($self->{_prop_window}->get_window, 0, Gtk3::get_current_event_time()); } #abort screenshot - } elsif ($event->keyval == Gtk2::Gdk->keyval_from_name('Escape')) { + } elsif ($event->keyval == Gtk3::Gdk::keyval_from_name('Escape')) { $self->quit; @@ -923,15 +935,15 @@ sub select_dialog { }); - my $hide_btn = Gtk2::Button->new_with_mnemonic($d->get("_Hide")); - $hide_btn->set_image(Gtk2::Image->new_from_stock('gtk-close', 'button')); - $hide_btn->can_default(TRUE); + my $hide_btn = Gtk3::Button->new_with_mnemonic($d->get("_Hide")); + $hide_btn->set_image(Gtk3::Image->new_from_stock('gtk-close', 'button')); + $hide_btn->set_can_default(TRUE); $hide_btn->signal_connect( 'clicked' => sub { - Gtk2::Gdk->keyboard_ungrab(Gtk2->get_current_event_time); - $prop_dialog->hide_all; + Gtk3::Gdk::keyboard_ungrab(Gtk3::get_current_event_time()); + $prop_dialog->hide; $self->{_prop_active} = FALSE; - Gtk2::Gdk->keyboard_grab($self->{_select_window}->window, 0, Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_grab($self->{_select_window}->get_window, 0, Gtk3::get_current_event_time()); }); #final_packing @@ -941,13 +953,13 @@ sub select_dialog { $widthw_label->set_alignment(0, 0.5); $heightw_label->set_alignment(0, 0.5); - my $sg_main = Gtk2::SizeGroup->new('horizontal'); + my $sg_main = Gtk3::SizeGroup->new('horizontal'); $sg_main->add_widget($xw_label); $sg_main->add_widget($yw_label); $sg_main->add_widget($widthw_label); $sg_main->add_widget($heightw_label); - my $vbox = Gtk2::VBox->new(FALSE, 5); + my $vbox = Gtk3::VBox->new(FALSE, 5); $vbox->pack_start($xw_hbox, FALSE, FALSE, 3); $vbox->pack_start($yw_hbox, FALSE, FALSE, 3); $vbox->pack_start($ww_hbox, FALSE, FALSE, 3); @@ -955,10 +967,10 @@ sub select_dialog { $vbox->pack_start($hide_btn, FALSE, FALSE, 3); #nice frame as well - my $frame_label = Gtk2::Label->new; + my $frame_label = Gtk3::Label->new; $frame_label->set_markup("" . $d->get("Selection") . ""); - my $frame = Gtk2::Frame->new(); + my $frame = Gtk3::Frame->new(); $frame->set_border_width(5); $frame->set_label_widget($frame_label); $frame->set_shadow_type('none'); @@ -969,7 +981,7 @@ sub select_dialog { $prop_dialog->realize; $prop_dialog->set_transient_for($self->{_select_window}); - $prop_dialog->window->set_override_redirect(TRUE); + $prop_dialog->get_window->set_override_redirect(TRUE); return $prop_dialog; } @@ -985,16 +997,16 @@ sub take_screenshot { #no delay? then we take a subsection of the pixbuf in memory if ($s && $clean_pixbuf && $self->{_delay} == 0) { - $output = $clean_pixbuf->new_subpixbuf($s->x, $s->y, $s->width, $s->height); + $output = $clean_pixbuf->new_subpixbuf($s->{x}, $s->{y}, $s->{width}, $s->{height}); #include cursor if ($self->{_include_cursor}) { - $output = $self->include_cursor($s->x, $s->y, $s->width, $s->height, $self->{_root}, $output); + $output = $self->include_cursor($s->{x}, $s->{y}, $s->{width}, $s->{height}, $self->{_root}, $output); } #if there is a delay != 0 set, we have to wait and get a new pixbuf from the root window } elsif ($s && $self->{_delay} != 0) { - ($output) = $self->get_pixbuf_from_drawable($self->{_root}, $s->x, $s->y, $s->width, $s->height); + ($output) = $self->get_pixbuf_from_drawable($self->{_root}, $s->{x}, $s->{y}, $s->{width}, $s->{height}); #section not valid } else { @@ -1002,13 +1014,13 @@ sub take_screenshot { } #we don't have a useful string for wildcards (e.g. $name) - if ($output =~ /Gtk2/) { + if ($output =~ /Gtk3/) { $self->{_action_name} = $d->get("Selection"); } #set history object if ($s) { - $self->{_history} = Shutter::Screenshot::History->new($self->{_sc}, $self->{_root}, $s->x, $s->y, $s->width, $s->height); + $self->{_history} = Shutter::Screenshot::History->new($self->{_sc}, $self->{_root}, $s->{x}, $s->{y}, $s->{width}, $s->{height}); } return $output; @@ -1052,6 +1064,7 @@ sub clean { $self->{_view}->signal_handler_disconnect($self->{_view_zoom_handler}); $self->{_view}->signal_handler_disconnect($self->{_view_button_handler}); $self->{_view}->signal_handler_disconnect($self->{_view_event_handler}); + $self->{_select_window}->signal_handler_disconnect($self->{_key_handler}); $self->{_select_window}->destroy; $self->{_zoom_window}->destroy; $self->{_prop_window}->destroy; diff --git a/share/shutter/resources/modules/Shutter/Screenshot/SelectorAuto.pm b/share/shutter/resources/modules/Shutter/Screenshot/SelectorAuto.pm index 9001a3d21..43803f7ba 100644 --- a/share/shutter/resources/modules/Shutter/Screenshot/SelectorAuto.pm +++ b/share/shutter/resources/modules/Shutter/Screenshot/SelectorAuto.pm @@ -68,7 +68,7 @@ sub select_auto { } #we don't have a useful string for wildcards (e.g. $name) - if ($output =~ /Gtk2/) { + if ($output =~ /Gtk3/) { $self->{_action_name} = $d->get("Selection"); } diff --git a/share/shutter/resources/modules/Shutter/Screenshot/Web.pm b/share/shutter/resources/modules/Shutter/Screenshot/Web.pm index f8252dc6b..28635a17d 100644 --- a/share/shutter/resources/modules/Shutter/Screenshot/Web.pm +++ b/share/shutter/resources/modules/Shutter/Screenshot/Web.pm @@ -37,19 +37,21 @@ use Time::HiRes qw/ time usleep /; use Shutter::Screenshot::History; -#Glib and Gtk2 -use Gtk2; +#Glib and Gtk3 +use Gtk3; use Glib qw/TRUE FALSE/; #-------------------------------------- sub new { my $class = shift; + my $sc = shift; my $self = { - _sc => shift, + _sc => $sc, _timeout => shift, _width => shift, + _shf => Shutter::App::HelperFunctions->new($sc), }; bless $self, $class; @@ -101,7 +103,7 @@ sub dlg_website { #~ $web_process->redirect_output ("$ENV{'HOME'}/shutter-debug-stdout.log", "$ENV{'HOME'}/shutter-debug-err.log"); $web_process->redirect_output($tmpfilename_stdout, $tmpfilename_sterr); - my $website_dialog = Gtk2::MessageDialog->new($self->{_sc}->get_mainwindow, [qw/modal destroy-with-parent/], 'other', 'none', undef); + my $website_dialog = Gtk3::MessageDialog->new($self->{_sc}->get_mainwindow, [qw/modal destroy-with-parent/], 'other', 'none', undef); $website_dialog->set_title("Shutter"); @@ -110,30 +112,30 @@ sub dlg_website { $website_dialog->set('secondary-text' => $d->get("URL to capture") . ": "); if ($self->{_sc}->get_theme->has_icon('web-browser')) { - $website_dialog->set('image' => Gtk2::Image->new_from_icon_name('web-browser', 'dialog')); + $website_dialog->set('image' => Gtk3::Image->new_from_icon_name('web-browser', 'dialog')); } else { $website_dialog->set('image' => - Gtk2::Image->new_from_pixbuf(Gtk2::Gdk::Pixbuf->new_from_file_at_size($self->{_sc}->get_root . "/share/shutter/resources/icons/web_image.svg", Gtk2::IconSize->lookup('dialog')))); + Gtk3::Image->new_from_pixbuf(Gtk3::Gdk::Pixbuf->new_from_file_at_size($self->{_sc}->get_root . "/share/shutter/resources/icons/web_image.svg", $self->{_shf}->icon_size('dialog')))); } #cancel button - my $cancel_btn = Gtk2::Button->new_from_stock('gtk-cancel'); + my $cancel_btn = Gtk3::Button->new_from_stock('gtk-cancel'); #capture button - my $execute_btn = Gtk2::Button->new_with_mnemonic($d->get("C_apture")); - $execute_btn->set_image(Gtk2::Image->new_from_stock('gtk-execute', 'button')); + my $execute_btn = Gtk3::Button->new_with_mnemonic($d->get("C_apture")); + $execute_btn->set_image(Gtk3::Image->new_from_stock('gtk-execute', 'button')); $execute_btn->set_sensitive(FALSE); - $execute_btn->can_default(TRUE); + $execute_btn->set_can_default(TRUE); $website_dialog->add_action_widget($cancel_btn, 'cancel'); $website_dialog->add_action_widget($execute_btn, 'accept'); $website_dialog->set_default_response('accept'); - my $website_hbox = Gtk2::HBox->new(); - my $website_hbox2 = Gtk2::HBox->new(); + my $website_hbox = Gtk3::HBox->new(); + my $website_hbox2 = Gtk3::HBox->new(); - my $website = Gtk2::Entry->new; + my $website = Gtk3::Entry->new; $website->set_activates_default(TRUE); #check if url is valid @@ -147,7 +149,7 @@ sub dlg_website { return FALSE; }); - my $clipboard = Gtk2::Clipboard->get(Gtk2::Gdk->SELECTION_CLIPBOARD); + my $clipboard = Gtk3::Clipboard::get($Gtk3::Gdk::SELECTION_CLIPBOARD); my $clipboard_string = $clipboard->wait_for_text; print "Content of clipboard is: $clipboard_string\n" if $self->{_sc}->get_debug and defined $clipboard_string; @@ -169,15 +171,15 @@ sub dlg_website { } $website_hbox->pack_start($website, TRUE, TRUE, 12); - $website_dialog->vbox->add($website_hbox); + $website_dialog->get_child->add($website_hbox); - my $website_progress = Gtk2::ProgressBar->new; + my $website_progress = Gtk3::ProgressBar->new; $website_progress->set_no_show_all(TRUE); $website_progress->set_ellipsize('middle'); - $website_progress->set_orientation('left-to-right'); + $website_progress->set_orientation('horizontal'); $website_progress->set_fraction(0); $website_hbox2->pack_start($website_progress, TRUE, TRUE, 12); - $website_dialog->vbox->add($website_hbox2); + $website_dialog->get_child->add($website_hbox2); $website_dialog->show_all; @@ -249,7 +251,7 @@ sub dlg_website { $website_progress->set_fraction(2 / 3); $self->update_gui(); - eval { $output = Gtk2::Gdk::Pixbuf->new_from_file($tmpfilename) }; + eval { $output = Gtk3::Gdk::Pixbuf->new_from_file($tmpfilename) }; if ($@) { #reading stdout from file @@ -310,10 +312,10 @@ sub dlg_website { sub update_gui { my $self = shift; - while (Gtk2->events_pending) { - Gtk2->main_iteration; + while (Gtk3::events_pending()) { + Gtk3::main_iteration(); } - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); return TRUE; } diff --git a/share/shutter/resources/modules/Shutter/Screenshot/Window.pm b/share/shutter/resources/modules/Shutter/Screenshot/Window.pm index b6292d6ba..e84789557 100644 --- a/share/shutter/resources/modules/Shutter/Screenshot/Window.pm +++ b/share/shutter/resources/modules/Shutter/Screenshot/Window.pm @@ -37,7 +37,7 @@ use Data::Dumper; our @ISA = qw(Shutter::Screenshot::Main); #Glib -use Gtk2; +use Gtk3; use Glib qw/TRUE FALSE/; #-------------------------------------- @@ -68,6 +68,7 @@ sub new { #main window $self->{_main_gtk_window} = $self->{_sc}->get_mainwindow; + $self->{_dpi_scale} = $self->{_main_gtk_window}->get('scale-factor'); #only used when selecting a window if (defined $self->{_mode} && $self->{_mode} =~ m/(window|section)/ig) { @@ -76,9 +77,13 @@ sub new { my $compos = $self->{_main_gtk_window}->get_screen->is_composited; #higlighter (borderless gtk window) - $self->{_highlighter} = Gtk2::Window->new('popup'); + $self->{_highlighter} = Gtk3::Window->new('popup'); if ($compos) { - $self->{_highlighter}->set_colormap($self->{_main_gtk_window}->get_screen->get_rgba_colormap); + my $screen = $self->{_main_gtk_window}->get_screen; + # Glib::Object::Introspection doesn't support method call via + # cross-package inheritance, call it as a free function instead + # (X11Screen inherits from Screen) + $self->{_highlighter}->set_visual(Gtk3::Gdk::Screen::get_rgba_visual($screen) || Gtk3::Gdb::Screen::get_system_visual($screen)); } $self->{_highlighter}->set_app_paintable(TRUE); @@ -89,22 +94,20 @@ sub new { $self->{_highlighter}->set_accept_focus(FALSE); #obtain current colors and font_desc from the main window - my $style = $self->{_main_gtk_window}->get_style; - my $sel_bg = $style->bg('selected'); - my $sel_tx = $style->text('selected'); - my $font_fam = $style->font_desc->get_family; - my $font_size = $style->font_desc->get_size / Gtk2::Pango->scale; + my $style = $self->{_main_gtk_window}->get_style_context; + my $sel_bg = $style->get_background_color('selected'); + my $font_fam = $style->get_font('normal')->get_family; + my $font_size = $style->get_font('normal')->get_size / Pango->scale; #get current monitor my $mon = $self->get_current_monitor; $self->{_highlighter_expose} = $self->{_highlighter}->signal_connect( - 'expose-event' => sub { - - return FALSE unless $self->{_highlighter}->window; + 'draw' => sub { + return FALSE unless $self->{_highlighter}->get_window; #Place window and resize it - $self->{_highlighter}->window->move_resize($self->{_c}{'cw'}{'x'} - 3, $self->{_c}{'cw'}{'y'} - 3, $self->{_c}{'cw'}{'width'} + 6, $self->{_c}{'cw'}{'height'} + 6); + $self->{_highlighter}->get_window->move_resize($self->{_c}{'cw'}{'x'} / $self->{_dpi_scale} - 3, $self->{_c}{'cw'}{'y'} / $self->{_dpi_scale} - 3, $self->{_c}{'cw'}{'width'} / $self->{_dpi_scale} + 6, $self->{_c}{'cw'}{'height'} / $self->{_dpi_scale} + 6); print $self->{_c}{'cw'}{'window'}->get_name, "\n" if $self->{_sc}->get_debug; @@ -121,11 +124,11 @@ sub new { my $icon = $self->{_c}{'cw'}{'window'}->get_icon; #create cairo context - my $cr = Gtk2::Gdk::Cairo::Context->create($self->{_highlighter}->window); + my $cr = $_[1]; #pango layout - my $layout = Gtk2::Pango::Cairo::create_layout($cr); - $layout->set_width(($w - $icon->get_width - $font_size * 3) * Gtk2::Pango->scale); + my $layout = Pango::Cairo::create_layout($cr); + $layout->set_width(($w - $icon->get_width - $font_size * 3) * Pango->scale); $layout->set_alignment('left'); $layout->set_wrap('char'); @@ -133,11 +136,11 @@ sub new { #when we are in section mode and #a toplevel window was already selected if ($self->{_c}{'ws'}) { - my $xwindow = $self->{_c}{'ws'}->XWINDOW; + my $xwindow = $self->{_c}{'ws'}->get_xid; if (scalar @{$self->{_c}{'cw'}{$xwindow}} <= 1) { #error icon - $icon = Gtk2::Widget::render_icon(Gtk2::Invisible->new, "gtk-dialog-error", 'dialog'); + $icon = Gtk3::Widget::render_icon(Gtk3::Invisible->new, "gtk-dialog-error", 'dialog'); #error message my $d = $self->{_sc}->get_gettext; @@ -172,7 +175,7 @@ sub new { #fill window $cr->set_operator('source'); - $cr->set_source_rgba($sel_bg->red / 257 / 255, $sel_bg->green / 257 / 255, $sel_bg->blue / 257 / 255, 0.3); + $cr->set_source_rgba($sel_bg->red, $sel_bg->green, $sel_bg->blue, 0.3); $cr->paint; #Parent window with text and icon @@ -181,7 +184,7 @@ sub new { $cr->set_operator('over'); #create small frame (window outlines) - $cr->set_source_rgba($sel_bg->red / 257 / 255, $sel_bg->green / 257 / 255, $sel_bg->blue / 257 / 255, 0.75); + $cr->set_source_rgba($sel_bg->red, $sel_bg->green, $sel_bg->blue, 0.75); $cr->set_line_width(6); $cr->rectangle(0, 0, $w, $h); $cr->stroke; @@ -201,19 +204,19 @@ sub new { $cr->fill; #app icon - Gtk2::Gdk::Cairo::Context::set_source_pixbuf($cr, $icon, $xi + $font_size, $yi + $font_size); + Gtk3::Gdk::cairo_set_source_pixbuf($cr, $icon, $xi + $font_size, $yi + $font_size); $cr->paint; #draw the pango layout $cr->move_to($xi + $font_size * 2 + $icon->get_width, $yi + $font_size); - Gtk2::Pango::Cairo::show_layout($cr, $layout); + Pango::Cairo::show_layout($cr, $layout); } } else { #create small frame - $cr->set_source_rgba($sel_bg->red / 257 / 255, $sel_bg->green / 257 / 255, $sel_bg->blue / 257 / 255, 0.75); + $cr->set_source_rgba($sel_bg->red, $sel_bg->green, $sel_bg->blue, 0.75); $cr->set_line_width(6); $cr->rectangle(0, 0, $w, $h); $cr->stroke; @@ -224,7 +227,7 @@ sub new { #fill window $cr->set_operator('over'); - $cr->set_source_rgb($sel_bg->red / 257 / 255, $sel_bg->green / 257 / 255, $sel_bg->blue / 257 / 255); + $cr->set_source_rgba($sel_bg->red, $sel_bg->green, $sel_bg->blue, 0.75); $cr->paint; #Parent window with text and icon @@ -233,22 +236,25 @@ sub new { if ($lw <= $w && $lh <= $h) { #app icon - Gtk2::Gdk::Cairo::Context::set_source_pixbuf($cr, $icon, $xi + $font_size, $yi + $font_size); + Gtk3::Gdk::cairo_set_source_pixbuf($cr, $icon, $xi + $font_size, $yi + $font_size); $cr->paint; #draw the pango layout $cr->move_to($xi + $font_size * 2 + $icon->get_width, $yi + $font_size); - Gtk2::Pango::Cairo::show_layout($cr, $layout); + Pango::Cairo::show_layout($cr, $layout); } } - my $rectangle1 = Gtk2::Gdk::Rectangle->new(0, 0, $w, $h); - my $rectangle2 = Gtk2::Gdk::Rectangle->new(3, 3, $w - 6, $h - 6); - my $rectangle3 = Gtk2::Gdk::Rectangle->new($xi, $yi, $wi, $hi); - my $shape_region1 = Gtk2::Gdk::Region->rectangle($rectangle1); - my $shape_region2 = Gtk2::Gdk::Region->rectangle($rectangle2); - my $shape_region3 = Gtk2::Gdk::Region->rectangle($rectangle3); + my $shape_region1 = Cairo::Region->create({ + x=>0, y=>0, width=>$w, height=>$h, + }); + my $shape_region2 = Cairo::Region->create({ + x=>3, y=>3, width=>$w - 6, height=>$h - 6, + }); + my $shape_region3 = Cairo::Region->create({ + x=>$xi, y=>$yi, width=>$wi, height=>$hi, + }); #Parent window with text and icon if ($self->{_c}{'cw'}{'is_parent'}) { @@ -258,7 +264,7 @@ sub new { } $shape_region1->subtract($shape_region2); - $self->{_highlighter}->window->shape_combine_region($shape_region1, 0, 0); + $self->{_highlighter}->get_window->shape_combine_region($shape_region1, 0, 0); } @@ -369,7 +375,7 @@ sub get_shape { } #create a region from the bounding rectangles - my $bregion = Gtk2::Gdk::Region->new; + my $bregion = Cairo::Region->create; foreach my $r (@r) { my @rect = @{$r}; @@ -392,29 +398,31 @@ sub get_shape { } print "Current $rect[0],$rect[1],$rect[2],$rect[3]\n" if $self->{_sc}->get_debug; - $bregion->union_with_rect(Gtk2::Gdk::Rectangle->new($rect[0], $rect[1], $rect[2], $rect[3])); + $bregion->union_rectangle({x=>$rect[0], y=>$rect[1], width=>$rect[2], height=>$rect[3]}); } if (defined $orig) { #create target pixbuf with dimensions if selected/current window - my $target = Gtk2::Gdk::Pixbuf->new($orig->get_colorspace, TRUE, 8, $orig->get_width, $orig->get_height); + my $target = Gtk3::Gdk::Pixbuf->new($orig->get_colorspace, TRUE, 8, $orig->get_width, $orig->get_height); #whole pixbuf is transparent $target->fill(0x00000000); #copy all rectangles of bounding region to the target pixbuf - foreach my $r ($bregion->get_rectangles) { - print $r->x . " " . $r->y . " " . $r->width . " " . $r->height . "\n" if $self->{_sc}->get_debug; + my $len = $bregion->num_rectangles-1; + for my $i (0..$len) { + my $r = $bregion->get_rectangle($i); + print $r->{x} . " " . $r->{y} . " " . $r->{width} . " " . $r->{height} . "\n" if $self->{_sc}->get_debug; - next if ($r->x > $orig->get_width); - next if ($r->y > $orig->get_height); + next if ($r->{x} > $orig->get_width); + next if ($r->{y} > $orig->get_height); - $r->width($orig->get_width - $r->x) if ($r->x + $r->width > $orig->get_width); - $r->height($orig->get_height - $r->y) if ($r->y + $r->height > $orig->get_height); + $r->{width} = $orig->get_width - $r->{x} if ($r->{x} + $r->{width} > $orig->get_width); + $r->{height} = $orig->get_height - $r->{y} if ($r->{y} + $r->{height} > $orig->get_height); - if ($r->x >= 0 && $r->x + $r->width <= $orig->get_width && $r->y >= 0 && $r->y + $r->height <= $orig->get_height) { - $orig->copy_area($r->x, $r->y, $r->width, $r->height, $target, $r->x, $r->y); + if ($r->{x} >= 0 && $r->{x} + $r->{width} <= $orig->get_width && $r->{y} >= 0 && $r->{y} + $r->{height} <= $orig->get_height) { + $orig->copy_area($r->{x}, $r->{y}, $r->{width}, $r->{height}, $target, $r->{x}, $r->{y}); } else { warn "WARNING: There was an error while calculating the window shape\n"; return $orig; @@ -446,10 +454,10 @@ sub get_window_size { Glib::Timeout->add( $self->{_hide_time}, sub { - Gtk2->main_quit; + Gtk3->main_quit; return FALSE; }); - Gtk2->main(); + Gtk3->main(); my ($xc, $yc, $wc, $hc) = $self->get_window_size($wnck_window, $gdk_window, $border, TRUE); @@ -470,10 +478,10 @@ sub get_window_size { Glib::Timeout->add( $self->{_hide_time}, sub { - Gtk2->main_quit; + Gtk3->main_quit; return FALSE; }); - Gtk2->main(); + Gtk3->main(); } } } @@ -499,7 +507,7 @@ sub update_highlighter { $self->{_highlighter}->show_all; $self->{_highlighter}->queue_draw; - Gtk2::Gdk->keyboard_grab($self->{_highlighter}->window, 0, Gtk2->get_current_event_time); + Gtk3::Gdk::keyboard_grab($self->{_highlighter}->get_window, 0, Gtk3::get_current_event_time()); #save last window objects $self->{_c}{'lw'}{'window'} = $self->{_c}{'cw'}{'window'}; @@ -515,7 +523,7 @@ sub find_current_parent_window { my $active_workspace = shift; #get all toplevel windows - my @wnck_windows = $self->{_wnck_screen}->get_windows_stacked; + my @wnck_windows = @{$self->{_wnck_screen}->get_windows_stacked}; #show user-visible windows only when selecting a window if (defined $self->{_show_visible} && $self->{_show_visible}) { @@ -524,20 +532,22 @@ sub find_current_parent_window { foreach my $cwdow (@wnck_windows) { - my $drawable = Gtk2::Gdk::Window->foreign_new($cwdow->get_xid); + my $drawable = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), $cwdow->get_xid); if (defined $drawable) { #do not detect shutter window when it is hidden - if ($self->{_main_gtk_window}->window && $self->{_is_hidden}) { - next if ($cwdow->get_xid == $self->{_main_gtk_window}->window->get_xid); + if ($self->{_main_gtk_window}->get_window && $self->{_is_hidden}) { + next if ($cwdow->get_xid == $self->{_main_gtk_window}->get_window->get_xid); } my ($xp, $yp, $wp, $hp) = $self->get_window_size($cwdow, $drawable, $self->{_include_border}, TRUE); - my $wr = Gtk2::Gdk::Region->rectangle(Gtk2::Gdk::Rectangle->new($xp, $yp, $wp, $hp)); + my $wr = Cairo::Region->create({ + x=>$xp, y=>$yp, width=>$wp, height=>$hp, + }); if ( $cwdow->is_visible_on_workspace($active_workspace) - && $wr->point_in($event->x, $event->y) + && $wr->contains_point($event->x * $self->{_dpi_scale}, $event->y * $self->{_dpi_scale}) && $wp * $hp <= $self->{_min_size}) { @@ -592,7 +602,7 @@ sub find_current_child_window { foreach my $kid (reverse @qkids) { - my $gdk_window = Gtk2::Gdk::Window->foreign_new($kid); + my $gdk_window = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), $kid); if (defined $gdk_window) { #window needs to be viewable and visible @@ -612,9 +622,9 @@ sub find_current_child_window { ($xp, $yp) = $gdk_window->get_origin; next if ($wp * $hp < 4); - my $sr = Gtk2::Gdk::Region->rectangle(Gtk2::Gdk::Rectangle->new($xp, $yp, $wp, $hp)); + my $sr = Cairo::Region->create({x=>$xp, y=>$yp, width=>$wp, height=>$hp}); - if ($sr->point_in($event->x, $event->y) && $wp * $hp <= $self->{_min_size}) { + if ($sr->contains_point($event->x, $event->y) && $wp * $hp <= $self->{_min_size}) { $self->{_c}{'cw'}{'gdk_window'} = $gdk_window; $self->{_c}{'cw'}{'x'} = $xp; @@ -630,8 +640,8 @@ sub find_current_child_window { #~ $self->{_c}{'cw'}{'height'}, " \n " if $self->{_sc}->get_debug; #check next depth - unless ($gdk_window->XWINDOW == $xwindow) { - $self->find_current_child_window($event, $gdk_window->XWINDOW, $xparent, $depth++, $limit, $type_hint); + unless ($gdk_window->get_xid == $xwindow) { + $self->find_current_child_window($event, $gdk_window->get_xid, $xparent, $depth++, $limit, $type_hint); } else { last; } @@ -651,7 +661,7 @@ sub find_active_window { my $gdk_window = $self->{_gdk_screen}->get_active_window; if (defined $gdk_window) { - my $wnck_window = Gnome2::Wnck::Window->get($gdk_window->get_xid); + my $wnck_window = Wnck::Window::get($gdk_window->get_xid); if (defined $wnck_window) { return ($wnck_window, $gdk_window); } @@ -668,7 +678,7 @@ sub find_region_for_window_type { foreach my $kid (reverse @qkids) { - my $gdk_window = Gtk2::Gdk::Window->foreign_new($kid); + my $gdk_window = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), $kid); if (defined $gdk_window) { @@ -693,25 +703,23 @@ sub find_region_for_window_type { #~ print $xp, " - ", $yp, " - ", $wp, " - ", $hp, "\n"; #create region - my $sr = Gtk2::Gdk::Region->rectangle(Gtk2::Gdk::Rectangle->new($xp, $yp, $wp, $hp)); + my $sr = Cairo::Region->create({x=>$xp, y=>$yp, width=>$wp * $self->{_dpi_scale}, height=>$hp * $self->{_dpi_scale}}); #init region unless (defined $self->{_c}{'cw'}{'window_region'}) { - $self->{_c}{'cw'}{'window_region'} = Gtk2::Gdk::Region->new; - $self->{_c}{'cw'}{'window_region'}->union($sr); - } else { - $self->{_c}{'cw'}{'window_region'}->union($sr); + $self->{_c}{'cw'}{'window_region'} = Cairo::Region->create; } + $self->{_c}{'cw'}{'window_region'}->union($sr); #store clipbox geometry #~ my $cbox = $self->{_c}{'cw'}{'window_region'}->get_clipbox; my $cbox = $self->get_clipbox($self->{_c}{'cw'}{'window_region'}); $self->{_c}{'cw'}{'gdk_window'} = $gdk_window; - $self->{_c}{'cw'}{'x'} = $cbox->x; - $self->{_c}{'cw'}{'y'} = $cbox->y; - $self->{_c}{'cw'}{'width'} = $cbox->width; - $self->{_c}{'cw'}{'height'} = $cbox->height; + $self->{_c}{'cw'}{'x'} = $cbox->{x}; + $self->{_c}{'cw'}{'y'} = $cbox->{y}; + $self->{_c}{'cw'}{'width'} = $cbox->{width}; + $self->{_c}{'cw'}{'height'} = $cbox->{height}; $self->{_c}{'cw'}{'is_parent'} = FALSE; #~ print $self->{_c}{'cw'}{'x'}, " - ", @@ -735,7 +743,7 @@ sub select_window { my $type_hint = shift; #root window size is minimum at startup - $self->{_min_size} = $self->{_root}->{w} * $self->{_root}->{h}; + $self->{_min_size} = $self->{_root}->{w} * $self->{_root}->{h} * $self->{_dpi_scale} * $self->{_dpi_scale}; #if there is no window already selected unless ($self->{_c}{'ws'}) { @@ -745,14 +753,13 @@ sub select_window { #parent window selected/no grab, search for children now } elsif (($self->{_mode} eq "section" || $self->{_mode} eq "tray_section") && $self->{_c}{'ws'}) { - $self->find_current_child_window($event, $self->{_c}{'ws'}->XWINDOW, $self->{_c}{'ws'}->XWINDOW, $depth, $limit, $type_hint); + $self->find_current_child_window($event, $self->{_c}{'ws'}->get_xid, $self->{_c}{'ws'}->get_xid, $depth, $limit, $type_hint); } #draw highlighter if needed - if ( (Gtk2::Gdk->pointer_is_grabbed && ($self->{_c}{'lw'}{'gdk_window'} ne $self->{_c}{'cw'}{'gdk_window'})) - || (Gtk2::Gdk->pointer_is_grabbed && $self->{_c}{'ws_init'})) + if ( (Gtk3::Gdk::pointer_is_grabbed() && ($self->{_c}{'lw'}{'gdk_window'} ne $self->{_c}{'cw'}{'gdk_window'})) + || (Gtk3::Gdk::pointer_is_grabbed() && $self->{_c}{'ws_init'})) { - $self->update_highlighter(); #reset flag @@ -791,9 +798,9 @@ sub window { $self->{_highlighter}->realize; my $grab_counter = 0; - while (!Gtk2::Gdk->pointer_is_grabbed && $grab_counter < 100) { - Gtk2::Gdk->pointer_grab($self->{_root}, FALSE, [qw/pointer-motion-mask button-press-mask button-release-mask/], undef, Gtk2::Gdk::Cursor->new('GDK_HAND2'), Gtk2->get_current_event_time); - Gtk2::Gdk->keyboard_grab($self->{_highlighter}->window, 0, Gtk2->get_current_event_time); + while (!Gtk3::Gdk::pointer_is_grabbed() && $grab_counter < 100) { + Gtk3::Gdk::pointer_grab($self->{_root}, FALSE, [qw/pointer-motion-mask button-press-mask button-release-mask/], undef, Gtk3::Gdk::Cursor->new('GDK_HAND2'), Gtk3::get_current_event_time()); + Gtk3::Gdk::keyboard_grab($self->{_highlighter}->get_window, 0, Gtk3::get_current_event_time()); $grab_counter++; } @@ -806,7 +813,7 @@ sub window { $self->{_c}{'lw'}{'gdk_window'} = 0; #root window size is minimum at startup - $self->{_min_size} = $self->{_root}->{w} * $self->{_root}->{h}; + $self->{_min_size} = $self->{_root}->{w} * $self->{_root}->{h} * $self->{_dpi_scale} * $self->{_dpi_scale}; $self->{_c}{'cw'}{'gdk_window'} = $self->{_root}; $self->{_c}{'cw'}{'x'} = $self->{_root}->{x}; $self->{_c}{'cw'}{'y'} = $self->{_root}->{y}; @@ -817,14 +824,14 @@ sub window { my ($window_at_pointer, $initx, $inity, $mask) = $self->{_root}->get_pointer; #create event for current coordinates - my $initevent = Gtk2::Gdk::Event->new('motion-notify'); - $initevent->set_time(Gtk2->get_current_event_time); + my $initevent = Gtk3::Gdk::Event->new('motion-notify'); + $initevent->time(Gtk3::get_current_event_time()); $initevent->window($self->{_root}); $initevent->x($initx); $initevent->y($inity); if ( - Gtk2::Gdk->pointer_is_grabbed + Gtk3::Gdk::pointer_is_grabbed() && !( $self->{_mode} eq "menu" || $self->{_mode} eq "tray_menu" @@ -838,7 +845,7 @@ sub window { #simulate mouse movement $self->select_window($initevent, $active_workspace); - Gtk2::Gdk::Event->handler_set( + Gtk3::Gdk::Event::handler_set( sub { my ($event, $data) = @_; return FALSE unless defined $event; @@ -847,7 +854,7 @@ sub window { if ($event->type eq 'key-press') { next unless defined $event->keyval; - if ($event->keyval == Gtk2::Gdk->keyval_from_name('Escape')) { + if ($event->keyval == Gtk3::Gdk::keyval_from_name('Escape')) { #destroy highlighter window $self->{_highlighter}->destroy; @@ -886,7 +893,7 @@ sub window { #focus selected window (maybe it is hidden) $self->{_c}{'lw'}{'gdk_window'}->focus($event->time); - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); #something went wrong here, no window on screen detected } else { @@ -925,13 +932,13 @@ sub window { Glib::Timeout->add( $self->{_hide_time}, sub { - Gtk2->main_quit; + Gtk3->main_quit; return FALSE; }); - Gtk2->main(); + Gtk3->main(); my ($output_new, $l_cropped, $r_cropped, $t_cropped, $b_cropped) = - $self->get_pixbuf_from_drawable($self->{_root}, $self->{_c}{'cw'}{'x'}, $self->{_c}{'cw'}{'y'}, $self->{_c}{'cw'}{'width'}, $self->{_c}{'cw'}{'height'}); + $self->get_pixbuf_from_drawable($self->{_root}, $self->{_c}{'cw'}{'x'} / $self->{_dpi_scale}, $self->{_c}{'cw'}{'y'} / $self->{_dpi_scale}, $self->{_c}{'cw'}{'width'}/$self->{_dpi_scale}, $self->{_c}{'cw'}{'height'}/$self->{_dpi_scale}); #save return value to current $output variable #-> ugly but fastest and safest solution now @@ -942,7 +949,7 @@ sub window { my $xid = $self->{_c}{'cw'}{'gdk_window'}->get_xid; #do not try this for child windows - foreach my $win ($self->{_wnck_screen}->get_windows) { + foreach my $win (@{$self->{_wnck_screen}->get_windows}) { if ($win->get_xid == $xid) { $output = $self->get_shape($xid, $output, $l_cropped, $r_cropped, $t_cropped, $b_cropped); last; @@ -965,7 +972,7 @@ sub window { #set name of the captured window #e.g. for use in wildcards - if ($output =~ /Gtk2/ && defined $self->{_c}{'cw'}{'window'}) { + if ($output =~ /Gtk3/ && defined $self->{_c}{'cw'}{'window'}) { $self->{_action_name} = $self->{_c}{'cw'}{'window'}->get_name; } @@ -987,11 +994,11 @@ sub window { $self->select_window($event, $active_workspace); } else { - Gtk2->main_do_event($event); + Gtk3::main_do_event($event); } }); - Gtk2->main; + Gtk3->main; #pointer not grabbed } else { @@ -1024,13 +1031,13 @@ sub window { } elsif (($self->{_mode} eq "menu" || $self->{_mode} eq "tray_menu")) { #and select current menu - $self->find_region_for_window_type($self->{_root}->XWINDOW, 'menu'); + $self->find_region_for_window_type($self->{_root}->get_xid, 'menu'); #no window with type_hint eq 'menu' detected unless (defined $self->{_c}{'cw'}{'window_region'}) { if ($self->{_ignore_type}) { warn "WARNING: No window with type hint 'menu' detected -> window type hint will be ignored, because workaround is enabled\n"; - $self->find_region_for_window_type($self->{_root}->XWINDOW); + $self->find_region_for_window_type($self->{_root}->get_xid); } else { return 2; } @@ -1039,13 +1046,13 @@ sub window { } elsif (($self->{_mode} eq "tooltip" || $self->{_mode} eq "tray_tooltip")) { #and select current tooltip - $self->find_region_for_window_type($self->{_root}->XWINDOW, 'tooltip'); + $self->find_region_for_window_type($self->{_root}->get_xid, 'tooltip'); #no window with type_hint eq 'tooltip' detected unless (defined $self->{_c}{'cw'}{'window_region'}) { if ($self->{_ignore_type}) { warn "WARNING: No window with type hint 'tooltip' detected -> window type hint will be ignored, because workaround is enabled\n"; - $self->find_region_for_window_type($self->{_root}->XWINDOW); + $self->find_region_for_window_type($self->{_root}->get_xid); } else { return 2; } @@ -1079,7 +1086,7 @@ sub window { my $xid = $self->{_c}{'cw'}{'gdk_window'}->get_xid; #do not try this for child windows - foreach my $win ($self->{_wnck_screen}->get_windows) { + foreach my $win (@{$self->{_wnck_screen}->get_windows}) { if ($win->get_xid == $xid) { $output = $self->get_shape($xid, $output, $l_cropped, $r_cropped, $t_cropped, $b_cropped); last; @@ -1107,25 +1114,25 @@ sub window { if (($self->{_mode} eq "window" || $self->{_mode} eq "tray_window" || $self->{_mode} eq "awindow" || $self->{_mode} eq "tray_awindow")) { - if ($output =~ /Gtk2/ && defined $self->{_c}{'cw'}{'window'}) { + if ($output =~ /Gtk3/ && defined $self->{_c}{'cw'}{'window'}) { $self->{_action_name} = $self->{_c}{'cw'}{'window'}->get_name; } } elsif (($self->{_mode} eq "section" || $self->{_mode} eq "tray_section")) { - if ($output =~ /Gtk2/ && defined $self->{_c}{'cw'}{'window'}) { + if ($output =~ /Gtk3/ && defined $self->{_c}{'cw'}{'window'}) { $self->{_action_name} = $self->{_action_name} = $self->{_c}{'cw'}{'window'}->get_name; } } elsif (($self->{_mode} eq "menu" || $self->{_mode} eq "tray_menu")) { - if ($output =~ /Gtk2/) { + if ($output =~ /Gtk3/) { $self->{_action_name} = $d->get("Menu"); } } elsif (($self->{_mode} eq "tooltip" || $self->{_mode} eq "tray_tooltip")) { - if ($output =~ /Gtk2/) { + if ($output =~ /Gtk3/) { $self->{_action_name} = $d->get("Tooltip"); } @@ -1173,8 +1180,8 @@ sub redo_capture { if (defined $gxid && defined $wxid) { #create windows - my $gdk_window = Gtk2::Gdk::Window->foreign_new($gxid); - my $wnck_window = Gnome2::Wnck::Window->get($wxid); + my $gdk_window = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), $gxid); + my $wnck_window = Wnck::Window::get($wxid); if (defined $gdk_window && defined $wnck_window) { @@ -1188,12 +1195,12 @@ sub redo_capture { #find parent window my $pxid = $self->find_wm_window($gxid); - my $parent = Gtk2::Gdk::Window->foreign_new($pxid); + my $parent = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), $pxid); if (defined $parent && $parent) { #and focus parent window (maybe it is hidden) - $parent->focus(Gtk2->get_current_event_time); - Gtk2::Gdk->flush; + $parent->focus(Gtk3::get_current_event_time()); + Gtk3::Gdk::flush(); } } elsif ($self->{_mode} eq "window" || $self->{_mode} eq "tray_window" || $self->{_mode} eq "awindow" || $self->{_mode} eq "tray_awindow") { @@ -1205,18 +1212,18 @@ sub redo_capture { } #focus selected window (maybe it is hidden) - $gdk_window->focus(Gtk2->get_current_event_time); - Gtk2::Gdk->flush; + $gdk_window->focus(Gtk3::get_current_event_time()); + Gtk3::Gdk::flush(); #A short timeout to give the server a chance to #redraw the area Glib::Timeout->add( $self->{_hide_time}, sub { - Gtk2->main_quit; + Gtk3->main_quit; return FALSE; }); - Gtk2->main(); + Gtk3->main(); my ($output_new, $l_cropped, $r_cropped, $t_cropped, $b_cropped) = $self->get_pixbuf_from_drawable($self->{_root}, $xp, $yp, $wp, $hp); @@ -1279,7 +1286,7 @@ sub quit { my $self = shift; $self->ungrab_pointer_and_keyboard(FALSE, TRUE, TRUE); - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); } @@ -1287,7 +1294,7 @@ sub quit_eventh_only { my $self = shift; $self->ungrab_pointer_and_keyboard(FALSE, TRUE, FALSE); - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); } diff --git a/share/shutter/resources/modules/Shutter/Screenshot/WindowName.pm b/share/shutter/resources/modules/Shutter/Screenshot/WindowName.pm index 75991aca1..a90587b5b 100644 --- a/share/shutter/resources/modules/Shutter/Screenshot/WindowName.pm +++ b/share/shutter/resources/modules/Shutter/Screenshot/WindowName.pm @@ -32,8 +32,8 @@ use Shutter::Screenshot::WindowXid; use Data::Dumper; our @ISA = qw(Shutter::Screenshot::WindowXid); -#Glib and Gtk2 -use Gtk2; +#Glib and Gtk3 +use Gtk3; use Glib qw/TRUE FALSE/; #-------------------------------------- @@ -62,11 +62,11 @@ sub window_find_by_name { #cycle through all windows my $output = 7; - foreach my $win ($self->{_wnck_screen}->get_windows_stacked) { + foreach my $win (@{$self->{_wnck_screen}->get_windows_stacked}) { #ignore shutter window - if ($self->{_sc}->get_mainwindow->window) { - next if ($win->get_xid == $self->{_sc}->get_mainwindow->window->get_xid); + if ($self->{_sc}->get_mainwindow->get_window) { + next if ($win->get_xid == $self->{_sc}->get_mainwindow->get_window->get_xid); } #check if window is on active workspace diff --git a/share/shutter/resources/modules/Shutter/Screenshot/WindowXid.pm b/share/shutter/resources/modules/Shutter/Screenshot/WindowXid.pm index ee763fe05..90e9301d7 100644 --- a/share/shutter/resources/modules/Shutter/Screenshot/WindowXid.pm +++ b/share/shutter/resources/modules/Shutter/Screenshot/WindowXid.pm @@ -32,8 +32,8 @@ use Shutter::Screenshot::Window; use Data::Dumper; our @ISA = qw(Shutter::Screenshot::Window); -#Glib and Gtk2 -use Gtk2; +#Glib and Gtk3 +use Gtk3; use Glib qw/TRUE FALSE/; #-------------------------------------- @@ -58,10 +58,13 @@ sub window_by_xid { my $self = shift; my $xid = shift; - my $gdk_window = Gtk2::Gdk::Window->foreign_new($xid); - my $wnck_window = Gnome2::Wnck::Window->get($xid); + my $dummy_window = Gtk3::Window->new('toplevel'); + my $gdk_window = Gtk3::GdkX11::X11Window->foreign_new_for_display( + $dummy_window->get_display, $xid); - #~ print $xid, " - ", $gdk_window, " - ", $wnck_window, "\n"; + my $wnck_window = Wnck::Window::get($xid); + + print $xid, " - ", $gdk_window, " - ", $wnck_window, "\n"; my $output = 0; if (defined $gdk_window && defined $wnck_window) { @@ -70,18 +73,18 @@ sub window_by_xid { my ($xp, $yp, $wp, $hp) = $self->get_window_size($wnck_window, $gdk_window, $self->{_include_border}); #focus selected window (maybe it is hidden) - $gdk_window->focus(Gtk2->get_current_event_time); - Gtk2::Gdk->flush; + $gdk_window->focus(Gtk3::get_current_event_time()); + Gtk3::Gdk::flush(); #A short timeout to give the server a chance to #redraw the area Glib::Timeout->add( $self->{_hide_time}, sub { - Gtk2->main_quit; + Gtk3->main_quit; return FALSE; }); - Gtk2->main(); + Gtk3->main(); my ($output_new, $l_cropped, $r_cropped, $t_cropped, $b_cropped) = $self->get_pixbuf_from_drawable($self->{_root}, $xp, $yp, $wp, $hp); @@ -109,7 +112,7 @@ sub window_by_xid { #set name of the captured window #e.g. for use in wildcards - if ($output =~ /Gtk2/) { + if ($output =~ /Gtk3/) { $self->{_action_name} = $wnck_window->get_name; } @@ -154,7 +157,7 @@ sub quit { my $self = shift; $self->ungrab_pointer_and_keyboard(FALSE, TRUE, FALSE); - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); } diff --git a/share/shutter/resources/modules/Shutter/Screenshot/Workspace.pm b/share/shutter/resources/modules/Shutter/Screenshot/Workspace.pm index a98e0b19d..119fa72db 100644 --- a/share/shutter/resources/modules/Shutter/Screenshot/Workspace.pm +++ b/share/shutter/resources/modules/Shutter/Screenshot/Workspace.pm @@ -78,7 +78,7 @@ sub workspaces { my $output = undef; my $pixbuf = undef; - my $wspaces_region = Gtk2::Gdk::Region->new; + my $wspaces_region = Gtk3::Gdk::Region->new; my @pixbuf_array; my @rects_array; my $row = 0; @@ -115,7 +115,7 @@ sub workspaces { #capture viewport $pixbuf = $self->workspace(TRUE, TRUE); - my $rect = Gtk2::Gdk::Rectangle->new($width, $height, $pixbuf->get_width, $pixbuf->get_height); + my $rect = {x=>$width, y=>$height, width=>$pixbuf->get_width, height=>$pixbuf->get_height}; $wspaces_region->union_with_rect($rect); push @pixbuf_array, $pixbuf; push @rects_array, $rect; @@ -128,7 +128,7 @@ sub workspaces { #next row # > set height to clipbox-height # > set width to 0, because we start in column 0 again - $height = $sr->get_clipbox($wspaces_region)->height; + $height = $sr->get_clipbox($wspaces_region)->{height}; $width = 0; } @@ -149,10 +149,10 @@ sub workspaces { } $column = $space->get_layout_column; - $height = $sr->get_clipbox($wspaces_region)->height if ($row != $space->get_layout_row); + $height = $sr->get_clipbox($wspaces_region)->{height} if ($row != $space->get_layout_row); $row = $space->get_layout_row; - my $rect = Gtk2::Gdk::Rectangle->new($width, $height, $pixbuf->get_width, $pixbuf->get_height); + my $rect = {x=>$width, y=>$height, width=>$pixbuf->get_width, height=>$pixbuf->get_height}; $wspaces_region->union_with_rect($rect); push @pixbuf_array, $pixbuf; push @rects_array, $rect; @@ -161,14 +161,14 @@ sub workspaces { } - if ($wspaces_region->get_rectangles) { - $output = Gtk2::Gdk::Pixbuf->new('rgb', TRUE, 8, $sr->get_clipbox($wspaces_region)->width, $sr->get_clipbox($wspaces_region)->height); + if ($wspaces_region->num_rectangles) { + $output = Gtk3::Gdk::Pixbuf->new('rgb', TRUE, 8, $sr->get_clipbox($wspaces_region)->{width}, $sr->get_clipbox($wspaces_region)->{height}); $output->fill(0x00000000); #copy images to the blank pixbuf my $rect_counter = 0; foreach my $pixbuf (@pixbuf_array) { - $pixbuf->copy_area(0, 0, $pixbuf->get_width, $pixbuf->get_height, $output, $rects_array[$rect_counter]->x, $rects_array[$rect_counter]->y); + $pixbuf->copy_area(0, 0, $pixbuf->get_width, $pixbuf->get_height, $output, $rects_array[$rect_counter]->{x}, $rects_array[$rect_counter]->{y}); $rect_counter++; } } @@ -181,7 +181,7 @@ sub workspaces { #set name of the captured workspace #e.g. for use in wildcards - if ($output =~ /Gtk2/) { + if ($output =~ /Gtk3/) { $self->{_action_name} = $d->get("Workspaces"); } @@ -191,7 +191,7 @@ sub workspaces { #metacity etc. } else { - $active_workspace->activate(Gtk2->get_current_event_time); + $active_workspace->activate(Gtk3::get_current_event_time()); } return $output; @@ -219,7 +219,7 @@ sub workspace { if ($self->{_selected_workspace} == $space->get_number && ($no_active_check || $self->{_selected_workspace} != $active_workspace->get_number)) { - $space->activate(Gtk2->get_current_event_time); + $space->activate(Gtk3::get_current_event_time()); $wrksp_changed = TRUE; } } @@ -239,7 +239,6 @@ sub workspace { my $output = undef; if ($self->{_current_monitor_only} || $self->{_gdk_screen}->get_n_monitors <= 1) { - ($output) = $self->get_pixbuf_from_drawable($self->get_root_and_current_monitor_geometry); #When there are multiple monitors with different resolutions, the visible area @@ -263,13 +262,13 @@ sub workspace { #set name of the captured workspace #e.g. for use in wildcards - if ($output =~ /Gtk2/) { + if ($output =~ /Gtk3/) { $self->{_action_name} = $self->{_wnck_screen}->get_active_workspace->get_name; } #metacity etc if ($self->{_selected_workspace}) { - $active_workspace->activate(Gtk2->get_current_event_time) if $wrksp_changed; + $active_workspace->activate(Gtk3::get_current_event_time()) if $wrksp_changed; #compiz } else { diff --git a/share/shutter/resources/modules/Shutter/Upload/Shared.pm b/share/shutter/resources/modules/Shutter/Upload/Shared.pm index 6b277a484..da6b4572d 100644 --- a/share/shutter/resources/modules/Shutter/Upload/Shared.pm +++ b/share/shutter/resources/modules/Shutter/Upload/Shared.pm @@ -50,8 +50,7 @@ sub new { $self->{_username} = undef; $self->{_password} = undef; - $self->{_notebook} = Gtk2::Notebook->new; - $self->{_notebook}->set(homogeneous => 1); + $self->{_notebook} = Gtk3::Notebook->new; $self->{_notebook}->set_scrollable(TRUE); bless $self, $class; @@ -61,10 +60,10 @@ sub new { sub create_tab { my $self = shift; - my $upload_vbox = Gtk2::VBox->new(FALSE, 0); + my $upload_vbox = Gtk3::VBox->new(FALSE, 0); #sizegroup for all labels - my $sg = Gtk2::SizeGroup->new('horizontal'); + my $sg = Gtk3::SizeGroup->new('horizontal'); #create entry for each link foreach (sort keys %{$self->{_links}}) { @@ -80,22 +79,19 @@ sub create_entry_for_notebook { my ($self, $field, $value, $sg) = @_; #Clipboard - my $clipboard = Gtk2::Clipboard->get(Gtk2::Gdk->SELECTION_CLIPBOARD); + my $clipboard = Gtk3::Clipboard::get($Gtk3::Gdk::SELECTION_CLIPBOARD); - #Tooltips - my $tooltips = Gtk2::Tooltips->new; - - my $upload_hbox1 = Gtk2::HBox->new(FALSE, 10); - my $upload_hbox2 = Gtk2::HBox->new(FALSE, 10); + my $upload_hbox1 = Gtk3::HBox->new(FALSE, 10); + my $upload_hbox2 = Gtk3::HBox->new(FALSE, 10); #prepare $field $field =~ s/_/ /ig; $field = ucfirst $field; - my $label = Gtk2::Label->new($field); + my $label = Gtk3::Label->new($field); $label->set_alignment(0, 0.5); $sg->add_widget($label); - my $entry = Gtk2::Entry->new(); + my $entry = Gtk3::Entry->new(); $entry->set_text($value); $entry->signal_connect( 'button-release-event' => sub { @@ -104,10 +100,10 @@ sub create_entry_for_notebook { return FALSE; }); - my $upload_copy = Gtk2::Button->new; + my $upload_copy = Gtk3::Button->new; $upload_copy->set_tooltip_text($self->{_gettext_object}->get("Copy this code to clipboard")); - $upload_copy->set_image(Gtk2::Image->new_from_stock('gtk-copy', 'menu')); + $upload_copy->set_image(Gtk3::Image->new_from_stock('gtk-copy', 'menu')); $upload_copy->signal_connect( 'clicked' => sub { my ($widget, $entry) = @_; @@ -131,10 +127,10 @@ sub show_all { return FALSE if $self->{_notebook}->get_n_pages < 1; my $dlg_header = sprintf($self->{_gettext_object}->get("Upload - %s - %s"), $self->{_host}, $self->{_username}); - my $upload_dialog = Gtk2::Dialog->new($dlg_header, $self->{_main_gtk_window}, [qw/modal destroy-with-parent/], 'gtk-ok' => 'accept'); + my $upload_dialog = Gtk3::Dialog->new($dlg_header, $self->{_main_gtk_window}, [qw/modal destroy-with-parent/], 'gtk-ok' => 'accept'); $upload_dialog->set_default_response('accept'); - $upload_dialog->vbox->add($self->{_notebook}); + $upload_dialog->get_child->add($self->{_notebook}); $upload_dialog->show_all; my $upload_response = $upload_dialog->run; @@ -150,11 +146,8 @@ sub show_all { sub show { my $self = shift; - #Tooltips - my $tooltips = Gtk2::Tooltips->new; - #Create label for each notebook page - my $fnlabel = Gtk2::Label->new($self->{_filename}); + my $fnlabel = Gtk3::Label->new($self->{_filename}); $fnlabel->set_ellipsize('middle'); $fnlabel->set_width_chars(20); $fnlabel->set_tooltip_text($self->{_filename}); diff --git a/share/shutter/resources/system/plugins/perl/spbardistortion/spbardistortion b/share/shutter/resources/system/plugins/perl/spbardistortion/spbardistortion index d1dc4197f..2c04bdbe0 100755 --- a/share/shutter/resources/system/plugins/perl/spbardistortion/spbardistortion +++ b/share/shutter/resources/system/plugins/perl/spbardistortion/spbardistortion @@ -25,7 +25,17 @@ use utf8; use strict; use warnings; -use Gtk2 '-init'; + +BEGIN { + use Glib::Object::Introspection; + Glib::Object::Introspection->setup( + basename => 'GdkX11', + version => '3.0', + package => 'Gtk3::GdkX11', + ); +} + +use Gtk3 '-init'; use Image::Magick; use POSIX qw/setlocale/; use Locale::gettext; @@ -55,7 +65,7 @@ $d->dir( $ENV{'SHUTTER_INTL'} ); #icontheme to determine if icons exist or not #in some cases we deliver fallback icons -my $icontheme = Gtk2::IconTheme->get_default; +my $icontheme = Gtk3::IconTheme::get_default(); $icontheme->append_search_path($ENV{'SHUTTER_ROOT'} . "/share/icons"); #shutter will ask for some infos @@ -80,149 +90,137 @@ my $filetype = $ARGV[ 4 ]; #decode filename utf8::decode $filename; -my $plug = Gtk2::Plug->new( $socket_id ); -$plug->set_default_icon_name( 'shutter' ); +my $plug = Gtk3::Plug->new( $socket_id ); $plug->set_border_width( 10 ); -$plug->signal_connect( destroy => sub { Gtk2->main_quit } ); - -#tooltips -my $tooltips = Gtk2::Tooltips->new; +$plug->signal_connect( destroy => sub { Gtk3->main_quit } ); #configure buttons and other needed controls -my $c1_label = Gtk2::Label->new( $d->get( "A:" ) ); -my $c1_sbutton = Gtk2::SpinButton->new_with_range( -1, 1, 0.1 ); +my $c1_label = Gtk3::Label->new( $d->get( "A:" ) ); +my $c1_sbutton = Gtk3::SpinButton->new_with_range( -1, 1, 0.1 ); $c1_sbutton->set_value( 0.2 ); -my $c2_label = Gtk2::Label->new( $d->get( "B:" ) ); -my $c2_sbutton = Gtk2::SpinButton->new_with_range( -1, 1, 0.1 ); +my $c2_label = Gtk3::Label->new( $d->get( "B:" ) ); +my $c2_sbutton = Gtk3::SpinButton->new_with_range( -1, 1, 0.1 ); $c2_sbutton->set_value( 0 ); -my $c3_label = Gtk2::Label->new( $d->get( "C:" ) ); -my $c3_sbutton = Gtk2::SpinButton->new_with_range( -1, 1, 0.1 ); +my $c3_label = Gtk3::Label->new( $d->get( "C:" ) ); +my $c3_sbutton = Gtk3::SpinButton->new_with_range( -1, 1, 0.1 ); $c3_sbutton->set_value( 0 ); -my $c4_label = Gtk2::Label->new( $d->get( "D:" ) ); -my $c4_sbutton = Gtk2::SpinButton->new_with_range( -1, 1, 0.1 ); +my $c4_label = Gtk3::Label->new( $d->get( "D:" ) ); +my $c4_sbutton = Gtk3::SpinButton->new_with_range( -1, 1, 0.1 ); $c4_sbutton->set_value( 1.0 ); -$tooltips->set_tip( - $c1_label, +$c1_label->set_tooltip_text( $d->get( "The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center.\n\nDefined by Barrel Correction Distortion, by Helmut Dersch.\nhttp://www.all-in-one.ee/~dersch/barrel/barrel.html" ) ); -$tooltips->set_tip( - $c1_sbutton, + $c1_sbutton->set_tooltip_text( $d->get( "The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center.\n\nDefined by Barrel Correction Distortion, by Helmut Dersch.\nhttp://www.all-in-one.ee/~dersch/barrel/barrel.html" ) ); -$tooltips->set_tip( - $c2_label, + $c2_label->set_tooltip_text( $d->get( "The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center.\n\nDefined by Barrel Correction Distortion, by Helmut Dersch.\nhttp://www.all-in-one.ee/~dersch/barrel/barrel.html" ) ); -$tooltips->set_tip( - $c2_sbutton, + $c2_sbutton->set_tooltip_text( $d->get( "The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center.\n\nDefined by Barrel Correction Distortion, by Helmut Dersch.\nhttp://www.all-in-one.ee/~dersch/barrel/barrel.html" ) ); -$tooltips->set_tip( - $c3_label, + $c3_label->set_tooltip_text( $d->get( "The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center.\n\nDefined by Barrel Correction Distortion, by Helmut Dersch.\nhttp://www.all-in-one.ee/~dersch/barrel/barrel.html" ) ); -$tooltips->set_tip( - $c3_sbutton, + $c3_sbutton->set_tooltip_text( $d->get( "The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center.\n\nDefined by Barrel Correction Distortion, by Helmut Dersch.\nhttp://www.all-in-one.ee/~dersch/barrel/barrel.html" ) ); -$tooltips->set_tip( - $c4_label, + $c4_label->set_tooltip_text( $d->get( "The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center.\n\nDefined by Barrel Correction Distortion, by Helmut Dersch.\nhttp://www.all-in-one.ee/~dersch/barrel/barrel.html" ) ); -$tooltips->set_tip( - $c4_sbutton, + $c4_sbutton->set_tooltip_text( $d->get( "The parameter d describes the linear scaling of the image. Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d-values scales the image by that amount. a,b and c distort the image. Using negative values shifts distant points away from the center.\n\nDefined by Barrel Correction Distortion, by Helmut Dersch.\nhttp://www.all-in-one.ee/~dersch/barrel/barrel.html" ) ); -my $back_color_label = Gtk2::Label->new( $d->get("Background color"). ":" ); -my $back_color = Gtk2::ColorButton->new(); -$back_color->set_color( Gtk2::Gdk::Color->parse('gray') ); +my $back_color_label = Gtk3::Label->new( $d->get("Background color"). ":" ); +my $back_color = Gtk3::ColorButton->new(); +$back_color->set_rgba( Gtk3::Gdk::RGBA::parse('gray') ); $back_color->set_alpha( int( 0 * 65535 ) ); $back_color->set_use_alpha(TRUE); $back_color->set_title( $d->get("Choose background color") ); #all labels on the left side #need to have the same size -my $sgl = Gtk2::SizeGroup->new ('both'); +my $sgl = Gtk3::SizeGroup->new ('both'); $sgl->set ('ignore-hidden' => FALSE); $sgl->add_widget($c1_label); $sgl->add_widget($c2_label); $sgl->add_widget($c3_label); $sgl->add_widget($c4_label); -#we define two Gtk2::Image widgets +#we define two Gtk3::Image widgets #to store the screenshot #and a throbber that is shown while the changes are processed my $preview = - Gtk2::Image->new_from_pixbuf( - Gtk2::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); + Gtk3::Image->new_from_pixbuf( + Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); my $preview_throb = - Gtk2::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); + Gtk3::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); -my $sg = Gtk2::SizeGroup->new ('both'); +my $sg = Gtk3::SizeGroup->new ('both'); $sg->set ('ignore-hidden' => FALSE); $sg->add_widget($preview); $sg->add_widget($preview_throb); -#we define three Gtk2::Button widgets +#we define three Gtk3::Button widgets #to refresh, save and cancel the plugin's work -my $refresh_btn = Gtk2::Button->new_from_stock( 'gtk-refresh' ); +my $refresh_btn = Gtk3::Button->new_from_stock( 'gtk-refresh' ); $refresh_btn->signal_connect( 'clicked', \&fct_imagemagick_bardistortion, 'refresh' ); -my $save_btn = Gtk2::Button->new_from_stock( 'gtk-save' ); +my $save_btn = Gtk3::Button->new_from_stock( 'gtk-save' ); $save_btn->signal_connect( 'clicked', \&fct_imagemagick_bardistortion, 'save' ); -my $cancel_btn = Gtk2::Button->new_from_stock( 'gtk-cancel' ); -$cancel_btn->signal_connect( 'clicked' => sub { Gtk2->main_quit; exit 2; }, 'cancel' ); +my $cancel_btn = Gtk3::Button->new_from_stock( 'gtk-cancel' ); +$cancel_btn->signal_connect( 'clicked' => sub { Gtk3->main_quit; exit 2; }, 'cancel' ); #define the gui layout -my $hbox1 = Gtk2::HBox->new( FALSE, 8 ); -my $hbox2 = Gtk2::HBox->new( FALSE, 8 ); -my $hbox3 = Gtk2::HBox->new( FALSE, 8 ); -my $hbox4 = Gtk2::HBox->new( FALSE, 8 ); -my $hbox5 = Gtk2::HBox->new( FALSE, 8 ); +my $hbox1 = Gtk3::HBox->new( FALSE, 8 ); +my $hbox2 = Gtk3::HBox->new( FALSE, 8 ); +my $hbox3 = Gtk3::HBox->new( FALSE, 8 ); +my $hbox4 = Gtk3::HBox->new( FALSE, 8 ); +my $hbox5 = Gtk3::HBox->new( FALSE, 8 ); -my $hbox_row1 = Gtk2::HBox->new( TRUE, 8 ); -my $hbox_row2 = Gtk2::HBox->new( FALSE, 8 ); +my $hbox_row1 = Gtk3::HBox->new( TRUE, 8 ); +my $hbox_row2 = Gtk3::HBox->new( FALSE, 8 ); -my $vbox_param = Gtk2::VBox->new( FALSE, 8 ); -my $vbox_left = Gtk2::VBox->new( FALSE, 8 ); -my $vbox_right = Gtk2::VBox->new( FALSE, 8 ); +my $vbox_param = Gtk3::VBox->new( FALSE, 8 ); +my $vbox_left = Gtk3::VBox->new( FALSE, 8 ); +my $vbox_right = Gtk3::VBox->new( FALSE, 8 ); -my $hbox_btn = Gtk2::HBox->new( TRUE, 8 ); -my $vbox_btn = Gtk2::VBox->new( FALSE, 8 ); -my $vbox_main = Gtk2::VBox->new( FALSE, 8 ); +my $hbox_btn = Gtk3::HBox->new( TRUE, 8 ); +my $vbox_btn = Gtk3::VBox->new( FALSE, 8 ); +my $vbox_main = Gtk3::VBox->new( FALSE, 8 ); #packing $hbox1->pack_start( $c1_label, FALSE, TRUE, 5 ); @@ -241,21 +239,21 @@ $hbox5->pack_start( $back_color_label, FALSE, TRUE, 5 ); $hbox5->pack_start( $back_color, TRUE, TRUE, 5 ); #row 1 -$hbox_row1->pack_start_defaults( $hbox5 ); +$hbox_row1->pack_start( $hbox5, TRUE, TRUE, 0 ); #controls on the left side -$vbox_left->pack_start_defaults( $hbox1 ); -$vbox_left->pack_start_defaults( $hbox2 ); -$vbox_left->pack_start_defaults( $hbox3 ); -$vbox_left->pack_start_defaults( $hbox4 ); +$vbox_left->pack_start( $hbox1, TRUE, TRUE, 0 ); +$vbox_left->pack_start( $hbox2, TRUE, TRUE, 0 ); +$vbox_left->pack_start( $hbox3, TRUE, TRUE, 0 ); +$vbox_left->pack_start( $hbox4 , TRUE, TRUE, 0); #preview -$vbox_right->pack_start_defaults( $preview ); -$vbox_right->pack_start_defaults( $preview_throb ); +$vbox_right->pack_start( $preview, TRUE, TRUE, 0 ); +$vbox_right->pack_start( $preview_throb, TRUE, TRUE, 0 ); #row 2 -$hbox_row2->pack_start_defaults( $vbox_left ); -$hbox_row2->pack_start_defaults( $vbox_right ); +$hbox_row2->pack_start( $vbox_left, TRUE, TRUE, 0 ); +$hbox_row2->pack_start( $vbox_right, TRUE, TRUE, 0 ); $vbox_param->pack_start( $hbox_row1, TRUE, TRUE, 5 ); $vbox_param->pack_start( $hbox_row2, TRUE, TRUE, 5 ); @@ -273,7 +271,7 @@ $plug->add( $vbox_main ); $plug->show_all; #hide the preview widget at startup -$preview->hide_all; +$preview->hide; #create tempfile my ( $tmpfh, $tmpfilename ) = tempfile(); @@ -296,7 +294,7 @@ Glib::Idle->add ( undef); #lets'start -Gtk2->main; +Gtk3->main; sub fct_imagemagick_bardistortion { my ( $widget, $data ) = @_; @@ -312,11 +310,11 @@ sub fct_imagemagick_bardistortion { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; return TRUE; } else { - $preview->hide_all; + $preview->hide; $preview_throb->show_all; $process->start( @@ -333,7 +331,7 @@ sub fct_imagemagick_bardistortion { } eval{ - $preview->set_from_pixbuf( Gtk2::Gdk::Pixbuf->new_from_file_at_scale( + $preview->set_from_pixbuf( Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $tmpfilename, 300, 300, TRUE) ); }; @@ -355,7 +353,7 @@ sub fct_imagemagick_bardistortion { require X11::Protocol; my $x11 = X11::Protocol->new( $ENV{ 'DISPLAY' } ); - my $plugp = Gtk2::Gdk::Window->foreign_new( &find_wm_window( $x11, $plug->get_id )); + my $plugp = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), find_wm_window( $x11, $plug->get_id )); #show error message my $shutter_dialog = Shutter::App::SimpleDialogs->new($plug, $plugp); @@ -370,13 +368,13 @@ sub fct_imagemagick_bardistortion { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; exit 1; } $save_btn->set_sensitive(TRUE); $preview->show_all; - $preview_throb->hide_all; + $preview_throb->hide; return TRUE; } @@ -398,10 +396,10 @@ sub apply_effect { sub fct_update_gui { - while ( Gtk2->events_pending ) { - Gtk2->main_iteration; + while ( Gtk3::events_pending() ) { + Gtk3::main_iteration(); } - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); return TRUE; } diff --git a/share/shutter/resources/system/plugins/perl/spnegate/spnegate b/share/shutter/resources/system/plugins/perl/spnegate/spnegate index b70d39f9d..35f688df1 100755 --- a/share/shutter/resources/system/plugins/perl/spnegate/spnegate +++ b/share/shutter/resources/system/plugins/perl/spnegate/spnegate @@ -25,7 +25,17 @@ use utf8; use strict; use warnings; -use Gtk2 '-init'; + +BEGIN { + use Glib::Object::Introspection; + Glib::Object::Introspection->setup( + basename => 'GdkX11', + version => '3.0', + package => 'Gtk3::GdkX11', + ); +} + +use Gtk3 '-init'; use Image::Magick; use POSIX qw/setlocale/; use Locale::gettext; @@ -55,7 +65,7 @@ $d->dir( $ENV{'SHUTTER_INTL'} ); #icontheme to determine if icons exist or not #in some cases we deliver fallback icons -my $icontheme = Gtk2::IconTheme->get_default; +my $icontheme = Gtk3::IconTheme::get_default(); $icontheme->append_search_path($ENV{'SHUTTER_ROOT'} . "/share/icons"); #shutter will ask for some infos @@ -80,27 +90,26 @@ my $filetype = $ARGV[4]; #decode filename utf8::decode $filename; -my $plug = Gtk2::Plug->new( $socket_id ); -$plug->set_default_icon_name( 'shutter' ); +my $plug = Gtk3::Plug->new( $socket_id ); $plug->set_border_width( 10 );; -$plug->signal_connect( destroy => sub { Gtk2->main_quit } ); +$plug->signal_connect( destroy => sub { Gtk3->main_quit } ); #variables used in this plugin my $width_preview = 0; my $height_preview = 0; #define the gui layout -my $hbox = Gtk2::HBox->new( 0, 10 ); -my $hbox_btn = Gtk2::HBox->new( 0, 10 ); -my $vbox_lbl = Gtk2::VBox->new( 0, 10 ); -my $vbox_btn = Gtk2::VBox->new( 0, 10 ); -my $vbox_main = Gtk2::VBox->new( 0, 10 ); +my $hbox = Gtk3::HBox->new( 0, 10 ); +my $hbox_btn = Gtk3::HBox->new( 0, 10 ); +my $vbox_lbl = Gtk3::VBox->new( 0, 10 ); +my $vbox_btn = Gtk3::VBox->new( 0, 10 ); +my $vbox_main = Gtk3::VBox->new( 0, 10 ); #configure buttons and other needed controls -my $negate_label = Gtk2::Label->new( $d->get("Channel") ); +my $negate_label = Gtk3::Label->new( $d->get("Channel") ); -my $negate_channel = Gtk2::ComboBox->new_text; +my $negate_channel = Gtk3::ComboBoxText->new; $negate_channel->insert_text( 0, "All" ); $negate_channel->insert_text( 1, "Alpha" ); $negate_channel->insert_text( 2, "Black" ); @@ -115,33 +124,33 @@ $negate_channel->insert_text( 10, "Red" ); $negate_channel->insert_text( 11, "Yellow" ); $negate_channel->set_active(0); -#we define two Gtk2::Image widgets +#we define two Gtk3::Image widgets #to store the screenshot #and a throbber that is shown while the changes are processed my $preview = - Gtk2::Image->new_from_pixbuf( - Gtk2::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); + Gtk3::Image->new_from_pixbuf( + Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); my $preview_throb = - Gtk2::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); + Gtk3::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); -my $sg = Gtk2::SizeGroup->new ('both'); +my $sg = Gtk3::SizeGroup->new ('both'); $sg->set ('ignore-hidden' => FALSE); $sg->add_widget($preview); $sg->add_widget($preview_throb); -#we define three Gtk2::Button widgets +#we define three Gtk3::Button widgets #to refresh, save and cancel the plugin's work -my $refresh_btn = Gtk2::Button->new_from_stock( 'gtk-refresh' ); +my $refresh_btn = Gtk3::Button->new_from_stock( 'gtk-refresh' ); $refresh_btn->signal_connect( 'clicked', \&fct_imagemagick_negate, 'refresh' ); -my $save_btn = Gtk2::Button->new_from_stock( 'gtk-save' ); +my $save_btn = Gtk3::Button->new_from_stock( 'gtk-save' ); $save_btn->signal_connect( 'clicked', \&fct_imagemagick_negate, 'save' ); -my $cancel_btn = Gtk2::Button->new_from_stock( 'gtk-cancel' ); -$cancel_btn->signal_connect( 'clicked' => sub { Gtk2->main_quit; exit 2; }, 'cancel' ); +my $cancel_btn = Gtk3::Button->new_from_stock( 'gtk-cancel' ); +$cancel_btn->signal_connect( 'clicked' => sub { Gtk3->main_quit; exit 2; }, 'cancel' ); #packing $hbox->pack_start( $negate_label, FALSE, TRUE, 0 ); @@ -161,7 +170,7 @@ $plug->add($vbox_main); $plug->show_all; #hide the preview widget at startup -$preview->hide_all; +$preview->hide; #create tempfile my ( $tmpfh, $tmpfilename ) = tempfile(); @@ -184,7 +193,7 @@ Glib::Idle->add ( undef); #lets'start -Gtk2->main; +Gtk3->main; ####define your functions here sub value_changed { @@ -207,12 +216,12 @@ sub fct_imagemagick_negate { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; return TRUE; } else { - $preview->hide_all; + $preview->hide; $preview_throb->show_all; $process->start( @@ -229,7 +238,7 @@ sub fct_imagemagick_negate { } eval{ - $preview->set_from_pixbuf( Gtk2::Gdk::Pixbuf->new_from_file_at_scale( + $preview->set_from_pixbuf( Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $tmpfilename, 300, 300, TRUE) ); }; @@ -251,7 +260,7 @@ sub fct_imagemagick_negate { require X11::Protocol; my $x11 = X11::Protocol->new( $ENV{ 'DISPLAY' } ); - my $plugp = Gtk2::Gdk::Window->foreign_new( &find_wm_window( $x11, $plug->get_id )); + my $plugp = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), find_wm_window( $x11, $plug->get_id )); #show error message my $shutter_dialog = Shutter::App::SimpleDialogs->new($plug, $plugp); @@ -266,13 +275,13 @@ sub fct_imagemagick_negate { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; exit 1; } $save_btn->set_sensitive(TRUE); $preview->show_all; - $preview_throb->hide_all; + $preview_throb->hide; return TRUE; } @@ -289,7 +298,7 @@ sub apply_effect { #~ sub fct_imagemagick_to_pixbuf { #~ my ($blob) = @_; - #~ my $pixbufloader = Gtk2::Gdk::PixbufLoader->new; + #~ my $pixbufloader = Gtk3::Gdk::PixbufLoader->new; #~ $pixbufloader->set_size( $width_preview, $height_preview ); #~ $pixbufloader->write($blob); #~ $pixbufloader->close; @@ -300,10 +309,10 @@ sub apply_effect { sub fct_update_gui { - while ( Gtk2->events_pending ) { - Gtk2->main_iteration; + while ( Gtk3::events_pending() ) { + Gtk3::main_iteration(); } - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); return TRUE; } diff --git a/share/shutter/resources/system/plugins/perl/sppolaroid/sppolaroid b/share/shutter/resources/system/plugins/perl/sppolaroid/sppolaroid index d84407bd9..7abde9250 100755 --- a/share/shutter/resources/system/plugins/perl/sppolaroid/sppolaroid +++ b/share/shutter/resources/system/plugins/perl/sppolaroid/sppolaroid @@ -25,7 +25,17 @@ use utf8; use strict; use warnings; -use Gtk2 '-init'; + +BEGIN { + use Glib::Object::Introspection; + Glib::Object::Introspection->setup( + basename => 'GdkX11', + version => '3.0', + package => 'Gtk3::GdkX11', + ); +} + +use Gtk3 '-init'; use Image::Magick; use POSIX qw/setlocale strftime/; use Locale::gettext; @@ -55,7 +65,7 @@ $d->dir( $ENV{'SHUTTER_INTL'} ); #icontheme to determine if icons exist or not #in some cases we deliver fallback icons -my $icontheme = Gtk2::IconTheme->get_default; +my $icontheme = Gtk3::IconTheme::get_default(); $icontheme->append_search_path($ENV{'SHUTTER_ROOT'} . "/share/icons"); #shutter will ask for some infos @@ -86,39 +96,33 @@ if ( `convert --help | grep caption` =~ /caption/ ) { $use_caption = TRUE; } -my $plug = Gtk2::Plug->new( $socket_id ); -$plug->set_default_icon_name( 'shutter' ); +my $plug = Gtk3::Plug->new( $socket_id ); $plug->set_border_width( 10 ); -$plug->signal_connect( destroy => sub { Gtk2->main_quit } ); - -#tooltips -my $tooltips = Gtk2::Tooltips->new; +$plug->signal_connect( destroy => sub { Gtk3->main_quit } ); #configure buttons and other needed controls -my $caption_label = Gtk2::Label->new( $d->get( "Text:" ) ); -my $caption_entry = Gtk2::Entry->new(); +my $caption_label = Gtk3::Label->new( $d->get( "Text:" ) ); +my $caption_entry = Gtk3::Entry->new(); $caption_entry->set_text( "%c - $filename" ); -$tooltips->set_tip( - $caption_label, + $caption_label->set_tooltip_text( $d->get( "There are several wild-cards available, like\n%Y = year\n%m = month\n%d = day\n%T = time" ) ); -$tooltips->set_tip( - $caption_entry, + $caption_entry->set_tooltip_text( $d->get( "There are several wild-cards available, like\n%Y = year\n%m = month\n%d = day\n%T = time" ) ); -my $pointsize_label = Gtk2::Label->new( $d->get( "Font size:" ) ); -my $pointsize_sbutton = Gtk2::SpinButton->new_with_range( 1, 200, 1 ); +my $pointsize_label = Gtk3::Label->new( $d->get( "Font size:" ) ); +my $pointsize_sbutton = Gtk3::SpinButton->new_with_range( 1, 200, 1 ); $pointsize_sbutton->set_value( 20 ); -my $gravity_label = Gtk2::Label->new( $d->get( "Gravity:" ) ); -my $gravity_combo = Gtk2::ComboBox->new_text; +my $gravity_label = Gtk3::Label->new( $d->get( "Gravity:" ) ); +my $gravity_combo = Gtk3::ComboBoxText->new; $gravity_combo->insert_text( 0, "NorthWest" ); $gravity_combo->insert_text( 1, "North" ); $gravity_combo->insert_text( 2, "NorthEast" ); @@ -130,59 +134,59 @@ $gravity_combo->insert_text( 7, "South" ); $gravity_combo->insert_text( 8, "SouthEast" ); $gravity_combo->set_active( 4 ); -my $angle_label = Gtk2::Label->new( $d->get( "Rotation:" ) ); -my $angle_sbutton = Gtk2::SpinButton->new_with_range( -90, 90, 1 ); +my $angle_label = Gtk3::Label->new( $d->get( "Rotation:" ) ); +my $angle_sbutton = Gtk3::SpinButton->new_with_range( -90, 90, 1 ); $angle_sbutton->set_value( -5 ); -my $stroke_color_label = Gtk2::Label->new( $d->get("Stroke color"). ":" ); -my $stroke_color = Gtk2::ColorButton->new(); -$stroke_color->set_color( Gtk2::Gdk::Color->parse('black') ); +my $stroke_color_label = Gtk3::Label->new( $d->get("Stroke color"). ":" ); +my $stroke_color = Gtk3::ColorButton->new(); +$stroke_color->set_rgba( Gtk3::Gdk::RGBA::parse('black') ); $stroke_color->set_alpha( int( 1.0 * 65535 ) ); $stroke_color->set_use_alpha(TRUE); $stroke_color->set_title( $d->get("Choose stroke color") ); -#we define two Gtk2::Image widgets +#we define two Gtk3::Image widgets #to store the screenshot #and a throbber that is shown while the changes are processed my $preview = - Gtk2::Image->new_from_pixbuf( - Gtk2::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); + Gtk3::Image->new_from_pixbuf( + Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); my $preview_throb = - Gtk2::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); + Gtk3::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); -my $sg = Gtk2::SizeGroup->new ('both'); +my $sg = Gtk3::SizeGroup->new ('both'); $sg->set ('ignore-hidden' => FALSE); $sg->add_widget($preview); $sg->add_widget($preview_throb); -#we define three Gtk2::Button widgets +#we define three Gtk3::Button widgets #to refresh, save and cancel the plugin's work -my $refresh_btn = Gtk2::Button->new_from_stock( 'gtk-refresh' ); +my $refresh_btn = Gtk3::Button->new_from_stock( 'gtk-refresh' ); $refresh_btn->signal_connect( 'clicked', \&fct_imagemagick_polaroid, 'refresh' ); -my $save_btn = Gtk2::Button->new_from_stock( 'gtk-save' ); +my $save_btn = Gtk3::Button->new_from_stock( 'gtk-save' ); $save_btn->signal_connect( 'clicked', \&fct_imagemagick_polaroid, 'save' ); -my $cancel_btn = Gtk2::Button->new_from_stock( 'gtk-cancel' ); -$cancel_btn->signal_connect( 'clicked' => sub { Gtk2->main_quit; exit 2; }, 'cancel' ); +my $cancel_btn = Gtk3::Button->new_from_stock( 'gtk-cancel' ); +$cancel_btn->signal_connect( 'clicked' => sub { Gtk3->main_quit; exit 2; }, 'cancel' ); #define the gui layout -my $vbox_param = Gtk2::VBox->new( TRUE, 10 ); -my $hbox1 = Gtk2::HBox->new( FALSE, 10 ); -my $hbox2 = Gtk2::HBox->new( FALSE, 10 ); -my $hbox3 = Gtk2::HBox->new( FALSE, 10 ); -my $hbox4 = Gtk2::HBox->new( FALSE, 10 ); -my $hbox5 = Gtk2::HBox->new( FALSE, 10 ); +my $vbox_param = Gtk3::VBox->new( TRUE, 10 ); +my $hbox1 = Gtk3::HBox->new( FALSE, 10 ); +my $hbox2 = Gtk3::HBox->new( FALSE, 10 ); +my $hbox3 = Gtk3::HBox->new( FALSE, 10 ); +my $hbox4 = Gtk3::HBox->new( FALSE, 10 ); +my $hbox5 = Gtk3::HBox->new( FALSE, 10 ); -my $hbox_row1 = Gtk2::HBox->new( TRUE, 10 ); -my $hbox_row2 = Gtk2::HBox->new( TRUE, 10 ); +my $hbox_row1 = Gtk3::HBox->new( TRUE, 10 ); +my $hbox_row2 = Gtk3::HBox->new( TRUE, 10 ); -my $hbox_btn = Gtk2::HBox->new( TRUE, 10 ); -my $vbox_btn = Gtk2::VBox->new( FALSE, 10 ); -my $vbox_main = Gtk2::VBox->new( FALSE, 10 ); +my $hbox_btn = Gtk3::HBox->new( TRUE, 10 ); +my $vbox_btn = Gtk3::VBox->new( FALSE, 10 ); +my $vbox_main = Gtk3::VBox->new( FALSE, 10 ); #packing if ( $use_caption ) { @@ -201,12 +205,12 @@ if ( $use_caption ) { $hbox5->pack_start( $stroke_color_label, FALSE, TRUE, 5 ); $hbox5->pack_start( $stroke_color, FALSE, TRUE, 5 ); - $hbox_row1->pack_start_defaults( $hbox1 ); - $hbox_row1->pack_start_defaults( $hbox2 ); + $hbox_row1->pack_start( $hbox1, TRUE, TRUE, 0 ); + $hbox_row1->pack_start( $hbox2, TRUE, TRUE, 0 ); - $hbox_row2->pack_start_defaults( $hbox3 ); - $hbox_row2->pack_start_defaults( $hbox4 ); - $hbox_row2->pack_start_defaults( $hbox5 ); + $hbox_row2->pack_start( $hbox3 , TRUE, TRUE, 0); + $hbox_row2->pack_start( $hbox4, TRUE, TRUE, 0 ); + $hbox_row2->pack_start( $hbox5, TRUE, TRUE, 0 ); $vbox_param->pack_start( $hbox_row1, TRUE, TRUE, 5 ); @@ -214,7 +218,7 @@ if ( $use_caption ) { $hbox4->pack_start( $angle_label, FALSE, TRUE, 5 ); $hbox4->pack_start( $angle_sbutton, TRUE, TRUE, 5 ); - $hbox_row2->pack_start_defaults( $hbox4 ); + $hbox_row2->pack_start( $hbox4, TRUE, TRUE, 0 ); } @@ -235,7 +239,7 @@ $plug->add( $vbox_main ); $plug->show_all; #hide the preview widget at startup -$preview->hide_all; +$preview->hide; #create tempfile my ( $tmpfh, $tmpfilename ) = tempfile(); @@ -258,7 +262,7 @@ Glib::Idle->add ( undef); #lets'start -Gtk2->main; +Gtk3->main; ####define your functions here @@ -277,11 +281,11 @@ sub fct_imagemagick_polaroid { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; return TRUE; } else { - $preview->hide_all; + $preview->hide; $preview_throb->show_all; $process->start( @@ -298,7 +302,7 @@ sub fct_imagemagick_polaroid { } eval{ - $preview->set_from_pixbuf( Gtk2::Gdk::Pixbuf->new_from_file_at_scale( + $preview->set_from_pixbuf( Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $tmpfilename, 300, 300, TRUE) ); }; @@ -320,7 +324,7 @@ sub fct_imagemagick_polaroid { require X11::Protocol; my $x11 = X11::Protocol->new( $ENV{ 'DISPLAY' } ); - my $plugp = Gtk2::Gdk::Window->foreign_new( &find_wm_window( $x11, $plug->get_id )); + my $plugp = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), find_wm_window( $x11, $plug->get_id )); #show error message my $shutter_dialog = Shutter::App::SimpleDialogs->new($plug, $plugp); @@ -335,13 +339,13 @@ sub fct_imagemagick_polaroid { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; exit 1; } $save_btn->set_sensitive(TRUE); $preview->show_all; - $preview_throb->hide_all; + $preview_throb->hide; return TRUE; } @@ -393,10 +397,10 @@ sub apply_effect { sub fct_update_gui { - while ( Gtk2->events_pending ) { - Gtk2->main_iteration; + while ( Gtk3::events_pending() ) { + Gtk3::main_iteration(); } - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); return TRUE; } diff --git a/share/shutter/resources/system/plugins/perl/spresize/spresize b/share/shutter/resources/system/plugins/perl/spresize/spresize index c6ac69153..bf15e435d 100755 --- a/share/shutter/resources/system/plugins/perl/spresize/spresize +++ b/share/shutter/resources/system/plugins/perl/spresize/spresize @@ -25,7 +25,7 @@ use utf8; use strict; use warnings; -use Gtk2 '-init'; +use Gtk3 '-init'; use Image::Magick; use POSIX qw/setlocale/; use Locale::gettext; @@ -64,10 +64,10 @@ my $filetype = $ARGV[4]; #decode filename utf8::decode $filename; -my $plug = Gtk2::Plug->new($socket_id); +my $plug = Gtk3::Plug->new($socket_id); $plug->set_border_width(10); -$plug->signal_connect( destroy => sub { Gtk2->main_quit } ); +$plug->signal_connect( destroy => sub { Gtk3->main_quit } ); #variables used in this plugin my $ratio = $width / $height; @@ -75,20 +75,20 @@ my $last_width = $width; my $last_height = $height; #define the gui layout -my $hbox = Gtk2::HBox->new( 0, 10 ); -my $hbox_btn = Gtk2::HBox->new( 0, 10 ); -my $vbox_lbl = Gtk2::VBox->new( 0, 10 ); -my $vbox_btn = Gtk2::VBox->new( 0, 10 ); -my $vbox_main = Gtk2::VBox->new( 0, 10 ); +my $hbox = Gtk3::HBox->new( 0, 10 ); +my $hbox_btn = Gtk3::HBox->new( 0, 10 ); +my $vbox_lbl = Gtk3::VBox->new( 0, 10 ); +my $vbox_btn = Gtk3::VBox->new( 0, 10 ); +my $vbox_main = Gtk3::VBox->new( 0, 10 ); #configure buttons and other needed controls -my $aspect_btn = Gtk2::ToggleButton->new; -$aspect_btn->set_image( Gtk2::Image->new_from_file("$Bin/Locked.svg") ); +my $aspect_btn = Gtk3::ToggleButton->new; +$aspect_btn->set_image( Gtk3::Image->new_from_file("$Bin/Locked.svg") ); $aspect_btn->set_active(TRUE); $aspect_btn->signal_connect( 'toggled', \&aspect_toggled, 'toggled' ); -my $width_btn = Gtk2::SpinButton->new_with_range( 1, 10000, 1 ); -my $height_btn = Gtk2::SpinButton->new_with_range( 1, 10000, 1 ); +my $width_btn = Gtk3::SpinButton->new_with_range( 1, 10000, 1 ); +my $height_btn = Gtk3::SpinButton->new_with_range( 1, 10000, 1 ); #set initial values delivered by gscrot $width_btn->set_value($width); @@ -100,7 +100,7 @@ my $w_sign = my $h_sign = $height_btn->signal_connect( 'value-changed', \&value_changed, 'height' ); -my $resize_operator = Gtk2::ComboBox->new_text; +my $resize_operator = Gtk3::ComboBoxText->new; $resize_operator->insert_text( 0, "Resize" ); $resize_operator->insert_text( 1, "Thumbnail" ); $resize_operator->insert_text( 2, "Sample" ); @@ -108,15 +108,15 @@ $resize_operator->insert_text( 3, "Scale" ); $resize_operator->insert_text( 4, "AdaptiveResize" ); $resize_operator->set_active(0); -my $save_btn = Gtk2::Button->new_from_stock('gtk-save'); +my $save_btn = Gtk3::Button->new_from_stock('gtk-save'); $save_btn->signal_connect( 'clicked', \&fct_imagemagick_resize, 'save' ); -my $cancel_btn = Gtk2::Button->new_from_stock('gtk-cancel'); -$cancel_btn->signal_connect( 'clicked' => sub { Gtk2->main_quit }, 'cancel' ); +my $cancel_btn = Gtk3::Button->new_from_stock('gtk-cancel'); +$cancel_btn->signal_connect( 'clicked' => sub { Gtk3->main_quit }, 'cancel' ); #packing -$vbox_lbl->pack_start( Gtk2::Label->new("Width:"), TRUE, TRUE, 0 ); -$vbox_lbl->pack_start( Gtk2::Label->new("Height:"), TRUE, TRUE, 0 ); +$vbox_lbl->pack_start( Gtk3::Label->new("Width:"), TRUE, TRUE, 0 ); +$vbox_lbl->pack_start( Gtk3::Label->new("Height:"), TRUE, TRUE, 0 ); $vbox_btn->pack_start( $width_btn, TRUE, TRUE, 0 ); $vbox_btn->pack_start( $height_btn, TRUE, TRUE, 0 ); $hbox->pack_start( $vbox_lbl, TRUE, TRUE, 0 ); @@ -134,7 +134,7 @@ $plug->add($vbox_main); $plug->show_all; #lets'start -Gtk2->main; +Gtk3->main; ####define your functions here sub value_changed { @@ -165,10 +165,10 @@ sub value_changed { sub aspect_toggled { if ( $aspect_btn->get_active ) { - $aspect_btn->set_image( Gtk2::Image->new_from_file("$Bin/Locked.svg") ); + $aspect_btn->set_image( Gtk3::Image->new_from_file("$Bin/Locked.svg") ); return TRUE; } - $aspect_btn->set_image( Gtk2::Image->new_from_file("$Bin/Unlocked.svg") ); + $aspect_btn->set_image( Gtk3::Image->new_from_file("$Bin/Unlocked.svg") ); return TRUE; } @@ -183,7 +183,7 @@ sub fct_imagemagick_resize { undef $image; - Gtk2->main_quit; + Gtk3->main_quit; return TRUE; } diff --git a/share/shutter/resources/system/plugins/perl/spsepia/spsepia b/share/shutter/resources/system/plugins/perl/spsepia/spsepia index 24c71f0ed..2db498dc9 100755 --- a/share/shutter/resources/system/plugins/perl/spsepia/spsepia +++ b/share/shutter/resources/system/plugins/perl/spsepia/spsepia @@ -34,7 +34,17 @@ use utf8; use strict; use warnings; -use Gtk2 '-init'; + +BEGIN { + use Glib::Object::Introspection; + Glib::Object::Introspection->setup( + basename => 'GdkX11', + version => '3.0', + package => 'Gtk3::GdkX11', + ); +} + +use Gtk3 '-init'; use Image::Magick; use POSIX qw/setlocale/; use Locale::gettext; @@ -64,7 +74,7 @@ $d->dir( $ENV{'SHUTTER_INTL'} ); #icontheme to determine if icons exist or not #in some cases we deliver fallback icons -my $icontheme = Gtk2::IconTheme->get_default; +my $icontheme = Gtk3::IconTheme::get_default(); $icontheme->append_search_path($ENV{'SHUTTER_ROOT'} . "/share/icons"); #shutter will ask for some infos @@ -89,57 +99,56 @@ my $filetype = $ARGV[4]; #decode filename utf8::decode $filename; -my $plug = Gtk2::Plug->new( $socket_id ); -$plug->set_default_icon_name( 'shutter' ); +my $plug = Gtk3::Plug->new( $socket_id ); $plug->set_border_width( 10 ); -$plug->signal_connect( destroy => sub { Gtk2->main_quit } ); +$plug->signal_connect( destroy => sub { Gtk3->main_quit } ); #variables used in this plugin my $width_preview = 0; my $height_preview = 0; #define the gui layout -my $hbox = Gtk2::HBox->new( 0, 10 ); -my $hbox_btn = Gtk2::HBox->new( 0, 10 ); -my $vbox_lbl = Gtk2::VBox->new( 0, 10 ); -my $vbox_btn = Gtk2::VBox->new( 0, 10 ); -my $vbox_main = Gtk2::VBox->new( 0, 10 ); +my $hbox = Gtk3::HBox->new( 0, 10 ); +my $hbox_btn = Gtk3::HBox->new( 0, 10 ); +my $vbox_lbl = Gtk3::VBox->new( 0, 10 ); +my $vbox_btn = Gtk3::VBox->new( 0, 10 ); +my $vbox_main = Gtk3::VBox->new( 0, 10 ); #configure buttons and other needed controls -my $sepia_label = Gtk2::Label->new( $d->get("Sepia tone") ); +my $sepia_label = Gtk3::Label->new( $d->get("Sepia tone") ); -my $sepia_tone = Gtk2::HScale->new_with_range( 10, 100, 1 ); +my $sepia_tone = Gtk3::HScale->new_with_range( 10, 100, 1 ); $sepia_tone->set_value_pos('right'); $sepia_tone->set_value(80); -#we define two Gtk2::Image widgets +#we define two Gtk3::Image widgets #to store the screenshot #and a throbber that is shown while the changes are processed my $preview = - Gtk2::Image->new_from_pixbuf( - Gtk2::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); + Gtk3::Image->new_from_pixbuf( + Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); my $preview_throb = - Gtk2::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); + Gtk3::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); -my $sg = Gtk2::SizeGroup->new ('both'); +my $sg = Gtk3::SizeGroup->new ('both'); $sg->set ('ignore-hidden' => FALSE); $sg->add_widget($preview); $sg->add_widget($preview_throb); -#we define three Gtk2::Button widgets +#we define three Gtk3::Button widgets #to refresh, save and cancel the plugin's work -my $refresh_btn = Gtk2::Button->new_from_stock( 'gtk-refresh' ); +my $refresh_btn = Gtk3::Button->new_from_stock( 'gtk-refresh' ); $refresh_btn->signal_connect( 'clicked', \&fct_imagemagick_sepia, 'refresh' ); -my $save_btn = Gtk2::Button->new_from_stock( 'gtk-save' ); +my $save_btn = Gtk3::Button->new_from_stock( 'gtk-save' ); $save_btn->signal_connect( 'clicked', \&fct_imagemagick_sepia, 'save' ); -my $cancel_btn = Gtk2::Button->new_from_stock( 'gtk-cancel' ); -$cancel_btn->signal_connect( 'clicked' => sub { Gtk2->main_quit; exit 2; }, 'cancel' ); +my $cancel_btn = Gtk3::Button->new_from_stock( 'gtk-cancel' ); +$cancel_btn->signal_connect( 'clicked' => sub { Gtk3->main_quit; exit 2; }, 'cancel' ); #packing $hbox->pack_start( $sepia_label, FALSE, TRUE, 0 ); @@ -159,7 +168,7 @@ $plug->add($vbox_main); $plug->show_all; #hide the preview widget at startup -$preview->hide_all; +$preview->hide; #create tempfile my ( $tmpfh, $tmpfilename ) = tempfile(); @@ -182,7 +191,7 @@ Glib::Idle->add ( undef); #lets'start -Gtk2->main; +Gtk3->main; ####define your functions here sub value_changed { @@ -205,12 +214,12 @@ sub fct_imagemagick_sepia { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; return TRUE; } else { - $preview->hide_all; + $preview->hide; $preview_throb->show_all; $process->start( @@ -227,7 +236,7 @@ sub fct_imagemagick_sepia { } eval{ - $preview->set_from_pixbuf( Gtk2::Gdk::Pixbuf->new_from_file_at_scale( + $preview->set_from_pixbuf( Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $tmpfilename, 300, 300, TRUE) ); }; @@ -249,7 +258,7 @@ sub fct_imagemagick_sepia { require X11::Protocol; my $x11 = X11::Protocol->new( $ENV{ 'DISPLAY' } ); - my $plugp = Gtk2::Gdk::Window->foreign_new( &find_wm_window( $x11, $plug->get_id )); + my $plugp = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), find_wm_window( $x11, $plug->get_id )); #show error message my $shutter_dialog = Shutter::App::SimpleDialogs->new($plug, $plugp); @@ -264,13 +273,13 @@ sub fct_imagemagick_sepia { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; exit 1; } $save_btn->set_sensitive(TRUE); $preview->show_all; - $preview_throb->hide_all; + $preview_throb->hide; return TRUE; } @@ -287,7 +296,7 @@ sub apply_effect { #~ sub fct_imagemagick_to_pixbuf { #~ my ($blob) = @_; - #~ my $pixbufloader = Gtk2::Gdk::PixbufLoader->new; + #~ my $pixbufloader = Gtk3::Gdk::PixbufLoader->new; #~ $pixbufloader->set_size( $width_preview, $height_preview ); #~ $pixbufloader->write($blob); #~ $pixbufloader->close; @@ -298,10 +307,10 @@ sub apply_effect { sub fct_update_gui { - while ( Gtk2->events_pending ) { - Gtk2->main_iteration; + while ( Gtk3::events_pending() ) { + Gtk3::main_iteration(); } - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); return TRUE; } diff --git a/share/shutter/resources/system/plugins/perl/spshadow/spshadow b/share/shutter/resources/system/plugins/perl/spshadow/spshadow index 736813fb3..f6bea62af 100755 --- a/share/shutter/resources/system/plugins/perl/spshadow/spshadow +++ b/share/shutter/resources/system/plugins/perl/spshadow/spshadow @@ -25,7 +25,17 @@ use utf8; use strict; use warnings; -use Gtk2 '-init'; + +BEGIN { + use Glib::Object::Introspection; + Glib::Object::Introspection->setup( + basename => 'GdkX11', + version => '3.0', + package => 'Gtk3::GdkX11', + ); +} + +use Gtk3 '-init'; use Image::Magick; use POSIX qw/setlocale/; use Locale::gettext; @@ -56,7 +66,7 @@ $d->dir( $ENV{'SHUTTER_INTL'} ); #icontheme to determine if icons exist or not #in some cases we deliver fallback icons -my $icontheme = Gtk2::IconTheme->get_default; +my $icontheme = Gtk3::IconTheme::get_default(); $icontheme->append_search_path($ENV{'SHUTTER_ROOT'} . "/share/icons"); #shutter will ask for some infos @@ -81,18 +91,14 @@ my $filetype = $ARGV[ 4 ]; #decode filename utf8::decode $filename; -my $plug = Gtk2::Plug->new( $socket_id ); -$plug->set_default_icon_name( 'shutter' ); +my $plug = Gtk3::Plug->new( $socket_id ); $plug->set_border_width( 10 ); -$plug->signal_connect( destroy => sub { Gtk2->main_quit } ); - -#tooltips -my $tooltips = Gtk2::Tooltips->new; +$plug->signal_connect( destroy => sub { Gtk3->main_quit } ); #configure buttons and other needed controls -my $direction_label = Gtk2::Label->new( $d->get( "Direction" ). ":" ); -my $direction_combo = Gtk2::ComboBox->new_text; +my $direction_label = Gtk3::Label->new( $d->get( "Direction" ). ":" ); +my $direction_combo = Gtk3::ComboBoxText->new; $direction_combo->insert_text( 0, "NorthWest" ); $direction_combo->insert_text( 1, "North" ); $direction_combo->insert_text( 2, "NorthEast" ); @@ -104,36 +110,32 @@ $direction_combo->insert_text( 7, "South" ); $direction_combo->insert_text( 8, "SouthEast" ); $direction_combo->set_active( 8 ); -$tooltips->set_tip( - $direction_label, + $direction_label->set_tooltip_text( $d->get( "The direction of the shadow" ) ); -$tooltips->set_tip( - $direction_combo, + $direction_combo->set_tooltip_text( $d->get( "The direction of the shadow" ) ); -my $shadow_color_label = Gtk2::Label->new( $d->get("Color"). ":" ); -my $shadow_color = Gtk2::ColorButton->new(); -$shadow_color->set_color( Gtk2::Gdk::Color->parse('#5F5F5F') ); +my $shadow_color_label = Gtk3::Label->new( $d->get("Color"). ":" ); +my $shadow_color = Gtk3::ColorButton->new(); +$shadow_color->set_rgba( Gtk3::Gdk::RGBA::parse('#5F5F5F') ); $shadow_color->set_alpha( int( 1 * 65535 ) ); $shadow_color->set_use_alpha(FALSE); $shadow_color->set_title( $d->get("Choose color") ); -$tooltips->set_tip( - $shadow_color_label, + $shadow_color_label->set_tooltip_text( $d->get( "The color of the shadow" ) ); -$tooltips->set_tip( - $shadow_color, + $shadow_color->set_tooltip_text( $d->get( "The color of the shadow" ) @@ -144,50 +146,50 @@ $tooltips->set_tip( $direction_label->set_alignment( 0, 0.5 ); $shadow_color_label->set_alignment( 0, 0.5 ); -my $sgl = Gtk2::SizeGroup->new ('both'); +my $sgl = Gtk3::SizeGroup->new ('both'); $sgl->set ('ignore-hidden' => FALSE); $sgl->add_widget($direction_label); $sgl->add_widget($shadow_color_label); -#we define two Gtk2::Image widgets +#we define two Gtk3::Image widgets #to store the screenshot #and a throbber that is shown while the changes are processed my $preview = - Gtk2::Image->new_from_pixbuf( - Gtk2::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); + Gtk3::Image->new_from_pixbuf( + Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); my $preview_throb = - Gtk2::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); + Gtk3::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); -my $sg = Gtk2::SizeGroup->new ('both'); +my $sg = Gtk3::SizeGroup->new ('both'); $sg->set ('ignore-hidden' => FALSE); $sg->add_widget($preview); $sg->add_widget($preview_throb); -#we define three Gtk2::Button widgets +#we define three Gtk3::Button widgets #to refresh, save and cancel the plugin's work -my $refresh_btn = Gtk2::Button->new_from_stock( 'gtk-refresh' ); +my $refresh_btn = Gtk3::Button->new_from_stock( 'gtk-refresh' ); $refresh_btn->signal_connect( 'clicked', \&fct_imagemagick_shadow, 'refresh' ); -my $save_btn = Gtk2::Button->new_from_stock( 'gtk-save' ); +my $save_btn = Gtk3::Button->new_from_stock( 'gtk-save' ); $save_btn->signal_connect( 'clicked', \&fct_imagemagick_shadow, 'save' ); -my $cancel_btn = Gtk2::Button->new_from_stock( 'gtk-cancel' ); -$cancel_btn->signal_connect( 'clicked' => sub { Gtk2->main_quit; exit 2; }, 'cancel' ); +my $cancel_btn = Gtk3::Button->new_from_stock( 'gtk-cancel' ); +$cancel_btn->signal_connect( 'clicked' => sub { Gtk3->main_quit; exit 2; }, 'cancel' ); #define the gui layout -my $hbox1 = Gtk2::HBox->new( FALSE, 8 ); -my $hbox2 = Gtk2::HBox->new( FALSE, 8 ); +my $hbox1 = Gtk3::HBox->new( FALSE, 8 ); +my $hbox2 = Gtk3::HBox->new( FALSE, 8 ); -my $hbox_row1 = Gtk2::HBox->new( TRUE, 8 ); +my $hbox_row1 = Gtk3::HBox->new( TRUE, 8 ); -my $vbox_param = Gtk2::VBox->new( FALSE, 8 ); -my $vbox_left = Gtk2::VBox->new( FALSE, 8 ); -my $vbox_right = Gtk2::VBox->new( FALSE, 8 ); +my $vbox_param = Gtk3::VBox->new( FALSE, 8 ); +my $vbox_left = Gtk3::VBox->new( FALSE, 8 ); +my $vbox_right = Gtk3::VBox->new( FALSE, 8 ); -my $hbox_btn = Gtk2::HBox->new( TRUE, 8 ); -my $vbox_btn = Gtk2::VBox->new( FALSE, 8 ); -my $vbox_main = Gtk2::VBox->new( FALSE, 8 ); +my $hbox_btn = Gtk3::HBox->new( TRUE, 8 ); +my $vbox_btn = Gtk3::VBox->new( FALSE, 8 ); +my $vbox_main = Gtk3::VBox->new( FALSE, 8 ); #packing $hbox1->pack_start( $shadow_color_label, FALSE, TRUE, 5 ); @@ -201,12 +203,12 @@ $vbox_left->pack_start( $hbox1, FALSE, FALSE, 5); $vbox_left->pack_start( $hbox2, FALSE, FALSE, 5); #preview -$vbox_right->pack_start_defaults( $preview ); -$vbox_right->pack_start_defaults( $preview_throb ); +$vbox_right->pack_start( $preview,TRUE,TRUE,0 ); +$vbox_right->pack_start( $preview_throb,TRUE,TRUE,0 ); #row 1 -$hbox_row1->pack_start_defaults( $vbox_left ); -$hbox_row1->pack_start_defaults( $vbox_right ); +$hbox_row1->pack_start( $vbox_left,TRUE,TRUE,0 ); +$hbox_row1->pack_start( $vbox_right,TRUE,TRUE,0 ); $vbox_param->pack_start( $hbox_row1, TRUE, TRUE, 5 ); @@ -223,7 +225,7 @@ $plug->add( $vbox_main ); $plug->show_all; #hide the preview widget at startup -$preview->hide_all; +$preview->hide; #create tempfile my ( $tmpfh, $tmpfilename ) = tempfile(); @@ -246,7 +248,7 @@ Glib::Idle->add ( undef); #lets'start -Gtk2->main; +Gtk3->main; sub fct_imagemagick_shadow { @@ -263,11 +265,11 @@ sub fct_imagemagick_shadow { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; return TRUE; } else { - $preview->hide_all; + $preview->hide; $preview_throb->show_all; $process->start( @@ -284,7 +286,7 @@ sub fct_imagemagick_shadow { } eval{ - $preview->set_from_pixbuf( Gtk2::Gdk::Pixbuf->new_from_file_at_scale( + $preview->set_from_pixbuf( Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $tmpfilename, 300, 300, TRUE) ); }; @@ -306,7 +308,7 @@ sub fct_imagemagick_shadow { require X11::Protocol; my $x11 = X11::Protocol->new( $ENV{ 'DISPLAY' } ); - my $plugp = Gtk2::Gdk::Window->foreign_new( &find_wm_window( $x11, $plug->get_id )); + my $plugp = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), find_wm_window( $x11, $plug->get_id )); #show error message my $shutter_dialog = Shutter::App::SimpleDialogs->new($plug, $plugp); @@ -321,13 +323,13 @@ sub fct_imagemagick_shadow { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; exit 1; } $save_btn->set_sensitive(TRUE); $preview->show_all; - $preview_throb->hide_all; + $preview_throb->hide; return TRUE; } @@ -390,10 +392,10 @@ sub apply_effect { sub fct_update_gui { - while ( Gtk2->events_pending ) { - Gtk2->main_iteration; + while ( Gtk3::events_pending() ) { + Gtk3::main_iteration(); } - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); return TRUE; } diff --git a/share/shutter/resources/system/plugins/perl/spwatermark/spwatermark b/share/shutter/resources/system/plugins/perl/spwatermark/spwatermark index bb8321b15..640ce0590 100755 --- a/share/shutter/resources/system/plugins/perl/spwatermark/spwatermark +++ b/share/shutter/resources/system/plugins/perl/spwatermark/spwatermark @@ -25,7 +25,17 @@ use utf8; use strict; use warnings; -use Gtk2 '-init'; + +BEGIN { + use Glib::Object::Introspection; + Glib::Object::Introspection->setup( + basename => 'GdkX11', + version => '3.0', + package => 'Gtk3::GdkX11', + ); +} + +use Gtk3 '-init'; use Image::Magick; use POSIX qw/setlocale strftime/; use Locale::gettext; @@ -55,7 +65,7 @@ $d->dir( $ENV{'SHUTTER_INTL'} ); #icontheme to determine if icons exist or not #in some cases we deliver fallback icons -my $icontheme = Gtk2::IconTheme->get_default; +my $icontheme = Gtk3::IconTheme::get_default(); $icontheme->append_search_path($ENV{'SHUTTER_ROOT'} . "/share/icons"); #shutter will ask for some infos @@ -80,39 +90,33 @@ my $filetype = $ARGV[ 4 ]; #decode filename utf8::decode $filename; -my $plug = Gtk2::Plug->new( $socket_id ); -$plug->set_default_icon_name( 'shutter' ); +my $plug = Gtk3::Plug->new( $socket_id ); $plug->set_border_width( 10 ); -$plug->signal_connect( destroy => sub { Gtk2->main_quit } ); - -#tooltips -my $tooltips = Gtk2::Tooltips->new; +$plug->signal_connect( destroy => sub { Gtk3->main_quit } ); #configure buttons and other needed controls -my $caption_label = Gtk2::Label->new( $d->get( "Text:" ) ); -my $caption_entry = Gtk2::Entry->new(); +my $caption_label = Gtk3::Label->new( $d->get( "Text:" ) ); +my $caption_entry = Gtk3::Entry->new(); $caption_entry->set_text( "© %Y $ENV{ 'USER' }" ); -$tooltips->set_tip( - $caption_label, + $caption_label->set_tooltip_text( $d->get( "There are several wild-cards available, like\n%Y = year\n%m = month\n%d = day\n%T = time" ) ); -$tooltips->set_tip( - $caption_entry, + $caption_entry->set_tooltip_text( $d->get( "There are several wild-cards available, like\n%Y = year\n%m = month\n%d = day\n%T = time" ) ); -my $pointsize_label = Gtk2::Label->new( $d->get( "Font size:" ) ); -my $pointsize_sbutton = Gtk2::SpinButton->new_with_range( 1, 200, 1 ); +my $pointsize_label = Gtk3::Label->new( $d->get( "Font size:" ) ); +my $pointsize_sbutton = Gtk3::SpinButton->new_with_range( 1, 200, 1 ); $pointsize_sbutton->set_value( int ($width * 0.1) ); -my $gravity_label = Gtk2::Label->new( $d->get( "Gravity:" ) ); -my $gravity_combo = Gtk2::ComboBox->new_text; +my $gravity_label = Gtk3::Label->new( $d->get( "Gravity:" ) ); +my $gravity_combo = Gtk3::ComboBoxText->new; $gravity_combo->insert_text( 0, "NorthWest" ); $gravity_combo->insert_text( 1, "North" ); $gravity_combo->insert_text( 2, "NorthEast" ); @@ -124,58 +128,58 @@ $gravity_combo->insert_text( 7, "South" ); $gravity_combo->insert_text( 8, "SouthEast" ); $gravity_combo->set_active( 4 ); -my $angle_label = Gtk2::Label->new( $d->get( "Rotation:" ) ); -my $angle_sbutton = Gtk2::SpinButton->new_with_range( -90, 90, 1 ); +my $angle_label = Gtk3::Label->new( $d->get( "Rotation:" ) ); +my $angle_sbutton = Gtk3::SpinButton->new_with_range( -90, 90, 1 ); $angle_sbutton->set_value( 0 ); -my $stroke_color_label = Gtk2::Label->new( $d->get("Stroke color"). ":" ); -my $stroke_color = Gtk2::ColorButton->new(); -$stroke_color->set_color( Gtk2::Gdk::Color->parse('gray') ); +my $stroke_color_label = Gtk3::Label->new( $d->get("Stroke color"). ":" ); +my $stroke_color = Gtk3::ColorButton->new(); +$stroke_color->set_rgba( Gtk3::Gdk::RGBA::parse('gray') ); $stroke_color->set_alpha( int( 0.5 * 65535 ) ); $stroke_color->set_use_alpha(TRUE); $stroke_color->set_title( $d->get("Choose stroke color") ); -#we define two Gtk2::Image widgets +#we define two Gtk3::Image widgets #to store the screenshot #and a throbber that is shown while the changes are processed my $preview = - Gtk2::Image->new_from_pixbuf( - Gtk2::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); + Gtk3::Image->new_from_pixbuf( + Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $filename, 300, 300, TRUE ) ); my $preview_throb = - Gtk2::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); + Gtk3::Image->new_from_file( $ENV{'SHUTTER_ROOT'}."/share/shutter/resources/icons/throbber.gif" ); -my $sg = Gtk2::SizeGroup->new ('both'); +my $sg = Gtk3::SizeGroup->new ('both'); $sg->set ('ignore-hidden' => FALSE); $sg->add_widget($preview); $sg->add_widget($preview_throb); -#we define three Gtk2::Button widgets +#we define three Gtk3::Button widgets #to refresh, save and cancel the plugin's work -my $refresh_btn = Gtk2::Button->new_from_stock( 'gtk-refresh' ); +my $refresh_btn = Gtk3::Button->new_from_stock( 'gtk-refresh' ); $refresh_btn->signal_connect( 'clicked', \&fct_imagemagick_watermark, 'refresh' ); -my $save_btn = Gtk2::Button->new_from_stock( 'gtk-save' ); +my $save_btn = Gtk3::Button->new_from_stock( 'gtk-save' ); $save_btn->signal_connect( 'clicked', \&fct_imagemagick_watermark, 'save' ); -my $cancel_btn = Gtk2::Button->new_from_stock( 'gtk-cancel' ); -$cancel_btn->signal_connect( 'clicked' => sub { Gtk2->main_quit; exit 2; }, 'cancel' ); +my $cancel_btn = Gtk3::Button->new_from_stock( 'gtk-cancel' ); +$cancel_btn->signal_connect( 'clicked' => sub { Gtk3->main_quit; exit 2; }, 'cancel' ); #define the gui layout -my $vbox_param = Gtk2::VBox->new( TRUE, 10 ); -my $hbox1 = Gtk2::HBox->new( FALSE, 10 ); -my $hbox2 = Gtk2::HBox->new( FALSE, 10 ); -my $hbox3 = Gtk2::HBox->new( FALSE, 10 ); -my $hbox4 = Gtk2::HBox->new( FALSE, 10 ); -my $hbox5 = Gtk2::HBox->new( FALSE, 10 ); +my $vbox_param = Gtk3::VBox->new( TRUE, 10 ); +my $hbox1 = Gtk3::HBox->new( FALSE, 10 ); +my $hbox2 = Gtk3::HBox->new( FALSE, 10 ); +my $hbox3 = Gtk3::HBox->new( FALSE, 10 ); +my $hbox4 = Gtk3::HBox->new( FALSE, 10 ); +my $hbox5 = Gtk3::HBox->new( FALSE, 10 ); -my $hbox_row1 = Gtk2::HBox->new( TRUE, 10 ); -my $hbox_row2 = Gtk2::HBox->new( TRUE, 10 ); +my $hbox_row1 = Gtk3::HBox->new( TRUE, 10 ); +my $hbox_row2 = Gtk3::HBox->new( TRUE, 10 ); -my $hbox_btn = Gtk2::HBox->new( TRUE, 10 ); -my $vbox_btn = Gtk2::VBox->new( FALSE, 10 ); -my $vbox_main = Gtk2::VBox->new( FALSE, 10 ); +my $hbox_btn = Gtk3::HBox->new( TRUE, 10 ); +my $vbox_btn = Gtk3::VBox->new( FALSE, 10 ); +my $vbox_main = Gtk3::VBox->new( FALSE, 10 ); #packing $hbox1->pack_start( $caption_label, FALSE, TRUE, 5 ); @@ -193,12 +197,12 @@ $hbox4->pack_start( $angle_sbutton, TRUE, TRUE, 5 ); $hbox5->pack_start( $stroke_color_label, FALSE, TRUE, 5 ); $hbox5->pack_start( $stroke_color, FALSE, TRUE, 5 ); -$hbox_row1->pack_start_defaults( $hbox1 ); -$hbox_row1->pack_start_defaults( $hbox2 ); +$hbox_row1->pack_start( $hbox1, TRUE, TRUE, 0 ); +$hbox_row1->pack_start( $hbox2, TRUE, TRUE, 0 ); -$hbox_row2->pack_start_defaults( $hbox3 ); -$hbox_row2->pack_start_defaults( $hbox4 ); -$hbox_row2->pack_start_defaults( $hbox5 ); +$hbox_row2->pack_start( $hbox3, TRUE, TRUE, 0 ); +$hbox_row2->pack_start( $hbox4 , TRUE, TRUE, 0); +$hbox_row2->pack_start( $hbox5, TRUE, TRUE, 0 ); $vbox_param->pack_start( $hbox_row1, TRUE, TRUE, 5 ); $vbox_param->pack_start( $hbox_row2, TRUE, TRUE, 5 ); @@ -218,7 +222,7 @@ $plug->add( $vbox_main ); $plug->show_all; #hide the preview widget at startup -$preview->hide_all; +$preview->hide; #create tempfile my ( $tmpfh, $tmpfilename ) = tempfile(); @@ -244,7 +248,7 @@ Glib::Idle->add ( undef); #lets'start -Gtk2->main; +Gtk3->main; sub fct_imagemagick_watermark { @@ -264,11 +268,11 @@ sub fct_imagemagick_watermark { unlink $tmpfilename; unlink $tmpfilename2; - Gtk2->main_quit; + Gtk3->main_quit; return TRUE; } else { - $preview->hide_all; + $preview->hide; $preview_throb->show_all; $process->start( @@ -285,7 +289,7 @@ sub fct_imagemagick_watermark { } eval{ - $preview->set_from_pixbuf( Gtk2::Gdk::Pixbuf->new_from_file_at_scale( + $preview->set_from_pixbuf( Gtk3::Gdk::Pixbuf->new_from_file_at_scale( $tmpfilename2, 300, 300, TRUE) ); }; @@ -307,7 +311,7 @@ sub fct_imagemagick_watermark { require X11::Protocol; my $x11 = X11::Protocol->new( $ENV{ 'DISPLAY' } ); - my $plugp = Gtk2::Gdk::Window->foreign_new( &find_wm_window( $x11, $plug->get_id )); + my $plugp = Gtk3::GdkX11::X11Window->foreign_new_for_display(Gtk3::Gdk::Display::get_default(), find_wm_window( $x11, $plug->get_id )); #show error message my $shutter_dialog = Shutter::App::SimpleDialogs->new($plug, $plugp); @@ -322,13 +326,13 @@ sub fct_imagemagick_watermark { #delete temp files unlink $tmpfilename; - Gtk2->main_quit; + Gtk3->main_quit; exit 1; } $save_btn->set_sensitive(TRUE); $preview->show_all; - $preview_throb->hide_all; + $preview_throb->hide; return TRUE; } @@ -369,10 +373,10 @@ sub apply_effect { sub fct_update_gui { - while ( Gtk2->events_pending ) { - Gtk2->main_iteration; + while ( Gtk3::events_pending() ) { + Gtk3::main_iteration(); } - Gtk2::Gdk->flush; + Gtk3::Gdk::flush(); return TRUE; } diff --git a/share/shutter/resources/system/upload_plugins/upload/Dropbox.pm b/share/shutter/resources/system/upload_plugins/upload/Dropbox.pm index d0a704273..13c57eb9a 100755 --- a/share/shutter/resources/system/upload_plugins/upload/Dropbox.pm +++ b/share/shutter/resources/system/upload_plugins/upload/Dropbox.pm @@ -130,7 +130,7 @@ sub setup { my $response = $sd->dlg_info_message( $d->get("Please click on the button below to authorize with Dropbox. Press 'Apply' when you are done."), $d->get("Authorize with Dropbox"), - 'gtk-cancel', 'gtk-apply', undef, undef, undef, undef, undef, undef, Gtk2::LinkButton->new($login_link, $d->get("Authorize")), + 'gtk-cancel', 'gtk-apply', undef, undef, undef, undef, undef, undef, Gtk3::LinkButton->new($login_link, $d->get("Authorize")), ); if ($response == 20) { diff --git a/share/shutter/resources/system/upload_plugins/upload/Imgur.pm b/share/shutter/resources/system/upload_plugins/upload/Imgur.pm index db8441f73..6c326c03c 100755 --- a/share/shutter/resources/system/upload_plugins/upload/Imgur.pm +++ b/share/shutter/resources/system/upload_plugins/upload/Imgur.pm @@ -124,7 +124,7 @@ sub setup { #Authentication my $login_link = 'https://api.imgur.com/oauth2/authorize?response_type=pin&client_id=' . $self->{_config}->{client_id}; - my $pin_entry = Gtk2::Entry->new(); + my $pin_entry = Gtk3::Entry->new(); my $pin = ''; $pin_entry->signal_connect( changed => sub { @@ -134,7 +134,7 @@ sub setup { my $response = $sd->dlg_info_message( $d->get("Please click on the button below to authorize with Imgur. Input the PIN you receive and press 'Apply' when you are done."), $d->get("Authorize with Imgur"), - 'gtk-cancel', 'gtk-apply', undef, undef, undef, undef, undef, undef, Gtk2::LinkButton->new($login_link, $d->get("Authorize")), $pin_entry, + 'gtk-cancel', 'gtk-apply', undef, undef, undef, undef, undef, undef, Gtk3::LinkButton->new($login_link, $d->get("Authorize")), $pin_entry, ); if ($response == 20) {