diff --git a/bin/shutter b/bin/shutter index 4e73695e..a2d307f1 100755 --- a/bin/shutter +++ b/bin/shutter @@ -314,6 +314,9 @@ my $delay_status; my $delay_vlabel; my $delay; my $delete_on_close_active; +my $drawing_tool_auto_icons_active; +my $drawing_tool_dark_icons_active; +my $drawing_tool_light_icons_active; my $filename; my $fname_autocopy_active; my $fs_active; @@ -811,19 +814,23 @@ sub STARTUP { 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); + my $drawing_tool_icons_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); + my $drawing_tool_light_icons_box = Gtk3::HBox->new(FALSE, 0); + my $drawing_tool_dark_icons_box = Gtk3::HBox->new(FALSE, 0); + my $drawing_tool_auto_icons_box = Gtk3::HBox->new(FALSE, 0); #actions my $actions_vbox = Gtk3::VBox->new(FALSE, 0); @@ -1130,6 +1137,13 @@ sub STARTUP { $capture_frame->set_label_widget($capture_frame_label); $capture_frame->set_shadow_type('none'); + my $drawing_tool_frame_label = Gtk3::Label->new; + $drawing_tool_frame_label->set_markup("" . $d->get("Drawing Tool") . ""); + + my $drawing_tool_frame = Gtk3::Frame->new(); + $drawing_tool_frame->set_label_widget($drawing_tool_frame_label); + $drawing_tool_frame->set_shadow_type('none'); + my $sel_capture_frame_label = Gtk3::Label->new; $sel_capture_frame_label->set_markup("" . $d->get("Selection Capture") . ""); @@ -1476,6 +1490,43 @@ sub STARTUP { #end - cursor #-------------------------------------- + #drawing tool custom icons + #-------------------------------------- + $drawing_tool_light_icons_active = Gtk3::RadioButton->new_with_label(undef, $d->get("Use light icons in the Drawing Tool, for dark themes")); + $drawing_tool_light_icons_box->pack_start($drawing_tool_light_icons_active, FALSE, TRUE, 12); + + $drawing_tool_light_icons_active->set_tooltip_text($d->get("Use light icons in the Drawing Tool (for dark backgrounds)")); + + $drawing_tool_dark_icons_active = Gtk3::RadioButton->new_with_label($drawing_tool_light_icons_active, $d->get("Use dark icons in the Drawing Tool, for light themes")); + $drawing_tool_dark_icons_box->pack_start($drawing_tool_dark_icons_active, FALSE, TRUE, 12); + + $drawing_tool_dark_icons_active->set_tooltip_text($d->get("Use dark icons in the Drawing Tool (for light backgrounds)")); + + $drawing_tool_auto_icons_active = Gtk3::RadioButton->new_with_label($drawing_tool_light_icons_active, $d->get("Automatically detect which icons to use in the Drawing Tool")); + $drawing_tool_auto_icons_box->pack_start($drawing_tool_auto_icons_active, FALSE, TRUE, 12); + + $drawing_tool_auto_icons_active->set_tooltip_text($d->get("Automatically detect which icons to use in the Drawing Tool (guess the background color)")); + + #default state + $drawing_tool_light_icons_active->set_active(FALSE); + $drawing_tool_dark_icons_active->set_active(FALSE); + $drawing_tool_auto_icons_active->set_active(TRUE); + + if (defined $settings_xml->{'general'}->{'drawing_tool_light_icons'}) { + $drawing_tool_light_icons_active->set_active($settings_xml->{'general'}->{'drawing_tool_light_icons'}); + } + + if (defined $settings_xml->{'general'}->{'drawing_tool_dark_icons'}) { + $drawing_tool_dark_icons_active->set_active($settings_xml->{'general'}->{'drawing_tool_dark_icons'}); + } + + if (defined $settings_xml->{'general'}->{'drawing_tool_auto_icons'}) { + $drawing_tool_auto_icons_active->set_active($settings_xml->{'general'}->{'drawing_tool_auto_icons'}); + } + + #end - drawing tool custom icons + #-------------------------------------- + #program #-------------------------------------- my $model = fct_get_program_model(); @@ -1527,7 +1578,7 @@ sub STARTUP { #im_colors #-------------------------------------- - $combobox_im_colors = Gtk3::ComboBoxText->new; + $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) ")); @@ -2415,6 +2466,11 @@ sub STARTUP { $capture_vbox->pack_start($delay_box, TRUE, TRUE, 3); $capture_frame->add($capture_vbox); + $drawing_tool_icons_vbox->pack_start($drawing_tool_light_icons_box, TRUE, TRUE, 3); + $drawing_tool_icons_vbox->pack_start($drawing_tool_dark_icons_box, TRUE, TRUE, 3); + $drawing_tool_icons_vbox->pack_start($drawing_tool_auto_icons_box, TRUE, TRUE, 3); + $drawing_tool_frame->add($drawing_tool_icons_vbox); + #all labels = one size $scale_label->set_alignment(0, 0.5); $filetype_label->set_alignment(0, 0.5); @@ -2427,9 +2483,10 @@ sub STARTUP { $sg_main->add_widget($filename_label); $sg_main->add_widget($saveDir_label); - $vbox_basic->pack_start($file_frame, FALSE, TRUE, 3); - $vbox_basic->pack_start($save_frame, FALSE, TRUE, 3); - $vbox_basic->pack_start($capture_frame, FALSE, TRUE, 3); + $vbox_basic->pack_start($file_frame, FALSE, TRUE, 3); + $vbox_basic->pack_start($save_frame, FALSE, TRUE, 3); + $vbox_basic->pack_start($capture_frame, FALSE, TRUE, 3); + $vbox_basic->pack_start($drawing_tool_frame, FALSE, TRUE, 3); $vbox_basic->set_border_width(5); #settings actions tab @@ -4643,15 +4700,17 @@ sub STARTUP { #~ print "Pfad ".$saveDir_button->get_filename()."\n"; #~ print "Pfad ".$saveDir_button->get_uri()."\n"; - $settings{'general'}->{'save_auto'} = $save_auto_active->get_active(); - $settings{'general'}->{'save_ask'} = $save_ask_active->get_active(); - $settings{'general'}->{'save_no'} = $save_no_active->get_active(); - $settings{'general'}->{'image_autocopy'} = $image_autocopy_active->get_active(); - $settings{'general'}->{'fname_autocopy'} = $fname_autocopy_active->get_active(); - $settings{'general'}->{'no_autocopy'} = $no_autocopy_active->get_active(); - $settings{'general'}->{'cursor'} = $cursor_active->get_active(); - $settings{'general'}->{'delay'} = $delay->get_value(); - + $settings{'general'}->{'save_auto'} = $save_auto_active->get_active(); + $settings{'general'}->{'save_ask'} = $save_ask_active->get_active(); + $settings{'general'}->{'save_no'} = $save_no_active->get_active(); + $settings{'general'}->{'image_autocopy'} = $image_autocopy_active->get_active(); + $settings{'general'}->{'fname_autocopy'} = $fname_autocopy_active->get_active(); + $settings{'general'}->{'no_autocopy'} = $no_autocopy_active->get_active(); + $settings{'general'}->{'cursor'} = $cursor_active->get_active(); + $settings{'general'}->{'delay'} = $delay->get_value(); + $settings{'general'}->{'drawing_tool_light_icons'} = $drawing_tool_light_icons_active->get_active(); + $settings{'general'}->{'drawing_tool_dark_icons'} = $drawing_tool_dark_icons_active->get_active(); + $settings{'general'}->{'drawing_tool_auto_icons'} = $drawing_tool_auto_icons_active->get_active(); #wrksp -> submenu if ($x11_supported) { $settings{'general'}->{'current_monitor_active'} = $current_monitor_active->get_active; @@ -4867,6 +4926,10 @@ sub STARTUP { $cursor_active->set_active($settings_xml->{'general'}->{'cursor'}); $delay->set_value($settings_xml->{'general'}->{'delay'}); + $drawing_tool_light_icons_active->set_active($settings_xml->{'general'}->{'drawing_tool_light_icons'}); + $drawing_tool_dark_icons_active->set_active($settings_xml->{'general'}->{'drawing_tool_dark_icons'}); + $drawing_tool_auto_icons_active->set_active($settings_xml->{'general'}->{'drawing_tool_auto_icons'}); + #FIXME #this is a dirty hack to force the setting to be enabled in session tab #at the moment i simply dont know why the filechooser "caches" the old value @@ -6011,11 +6074,24 @@ sub STARTUP { } #open drawing tool + + my $drawing_tool_icons; + + if ($drawing_tool_light_icons_active->get_active()) { + $drawing_tool_icons = "light"; + } elsif ($drawing_tool_dark_icons_active->get_active()) { + $drawing_tool_icons = "dark"; + } elsif ($drawing_tool_auto_icons_active->get_active()) { + $drawing_tool_icons = "auto"; + } + + foreach my $key (@draw_array) { my $drawing_tool = Shutter::Draw::DrawingTool->new($sc); $drawing_tool->show( $session_screens{$key}->{'long'}, $session_screens{$key}->{'filetype'}, $session_screens{$key}->{'mime_type'}, - $session_screens{$key}->{'name'}, $session_screens{$key}->{'is_unsaved'}, \%session_screens + $session_screens{$key}->{'name'}, $session_screens{$key}->{'is_unsaved'}, \%session_screens, + $drawing_tool_icons ); } diff --git a/share/shutter/resources/icons/drawing_tool_dark/cursor b/share/shutter/resources/icons/drawing_tool_dark/cursor new file mode 120000 index 00000000..30c057d6 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/cursor @@ -0,0 +1 @@ +../drawing_tool/cursor \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-arrow.png b/share/shutter/resources/icons/drawing_tool_dark/draw-arrow.png new file mode 100644 index 00000000..2660380b Binary files /dev/null and b/share/shutter/resources/icons/drawing_tool_dark/draw-arrow.png differ diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-backtext.png b/share/shutter/resources/icons/drawing_tool_dark/draw-backtext.png new file mode 120000 index 00000000..a81e6e19 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-backtext.png @@ -0,0 +1 @@ +../drawing_tool/draw-backtext.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-callouts.png b/share/shutter/resources/icons/drawing_tool_dark/draw-callouts.png new file mode 120000 index 00000000..eab72f46 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-callouts.png @@ -0,0 +1 @@ +../drawing_tool/draw-callouts.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-censor.png b/share/shutter/resources/icons/drawing_tool_dark/draw-censor.png new file mode 100644 index 00000000..166826ab Binary files /dev/null and b/share/shutter/resources/icons/drawing_tool_dark/draw-censor.png differ diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-ellipse.png b/share/shutter/resources/icons/drawing_tool_dark/draw-ellipse.png new file mode 120000 index 00000000..c8276a07 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-ellipse.png @@ -0,0 +1 @@ +../drawing_tool/draw-ellipse.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-eraser.png b/share/shutter/resources/icons/drawing_tool_dark/draw-eraser.png new file mode 120000 index 00000000..de44047a --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-eraser.png @@ -0,0 +1 @@ +../drawing_tool/draw-eraser.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-freehand.png b/share/shutter/resources/icons/drawing_tool_dark/draw-freehand.png new file mode 120000 index 00000000..a40ee160 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-freehand.png @@ -0,0 +1 @@ +../drawing_tool/draw-freehand.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-highlighter.png b/share/shutter/resources/icons/drawing_tool_dark/draw-highlighter.png new file mode 120000 index 00000000..455e2d68 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-highlighter.png @@ -0,0 +1 @@ +../drawing_tool/draw-highlighter.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-image.svg b/share/shutter/resources/icons/drawing_tool_dark/draw-image.svg new file mode 120000 index 00000000..5f7916b5 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-image.svg @@ -0,0 +1 @@ +../drawing_tool/draw-image.svg \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-line.png b/share/shutter/resources/icons/drawing_tool_dark/draw-line.png new file mode 100644 index 00000000..d7fc19e0 Binary files /dev/null and b/share/shutter/resources/icons/drawing_tool_dark/draw-line.png differ diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-locked.png b/share/shutter/resources/icons/drawing_tool_dark/draw-locked.png new file mode 120000 index 00000000..e1e38f13 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-locked.png @@ -0,0 +1 @@ +../drawing_tool/draw-locked.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-lower.png b/share/shutter/resources/icons/drawing_tool_dark/draw-lower.png new file mode 120000 index 00000000..a0e3ac47 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-lower.png @@ -0,0 +1 @@ +../drawing_tool/draw-lower.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-number.png b/share/shutter/resources/icons/drawing_tool_dark/draw-number.png new file mode 100644 index 00000000..fca94965 Binary files /dev/null and b/share/shutter/resources/icons/drawing_tool_dark/draw-number.png differ diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-pixelize.png b/share/shutter/resources/icons/drawing_tool_dark/draw-pixelize.png new file mode 120000 index 00000000..b7b4172f --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-pixelize.png @@ -0,0 +1 @@ +../drawing_tool/draw-pixelize.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-pointer.png b/share/shutter/resources/icons/drawing_tool_dark/draw-pointer.png new file mode 120000 index 00000000..87736cff --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-pointer.png @@ -0,0 +1 @@ +../drawing_tool/draw-pointer.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-raise.png b/share/shutter/resources/icons/drawing_tool_dark/draw-raise.png new file mode 120000 index 00000000..6f2b2fb2 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-raise.png @@ -0,0 +1 @@ +../drawing_tool/draw-raise.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-rectangle.png b/share/shutter/resources/icons/drawing_tool_dark/draw-rectangle.png new file mode 120000 index 00000000..b19c7d46 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-rectangle.png @@ -0,0 +1 @@ +../drawing_tool/draw-rectangle.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-text.png b/share/shutter/resources/icons/drawing_tool_dark/draw-text.png new file mode 100644 index 00000000..f6c027bf Binary files /dev/null and b/share/shutter/resources/icons/drawing_tool_dark/draw-text.png differ diff --git a/share/shutter/resources/icons/drawing_tool_dark/draw-unlocked.png b/share/shutter/resources/icons/drawing_tool_dark/draw-unlocked.png new file mode 120000 index 00000000..252d18cf --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/draw-unlocked.png @@ -0,0 +1 @@ +../drawing_tool/draw-unlocked.png \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/objects b/share/shutter/resources/icons/drawing_tool_dark/objects new file mode 120000 index 00000000..c21cc298 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/objects @@ -0,0 +1 @@ +../drawing_tool/objects \ No newline at end of file diff --git a/share/shutter/resources/icons/drawing_tool_dark/transform-crop.png b/share/shutter/resources/icons/drawing_tool_dark/transform-crop.png new file mode 120000 index 00000000..d7341575 --- /dev/null +++ b/share/shutter/resources/icons/drawing_tool_dark/transform-crop.png @@ -0,0 +1 @@ +../drawing_tool/transform-crop.png \ No newline at end of file diff --git a/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm b/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm index ae8ef372..8d4bcc73 100644 --- a/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm +++ b/share/shutter/resources/modules/Shutter/Draw/DrawingTool.pm @@ -205,13 +205,11 @@ sub show { $self->{_name} = shift; $self->{_is_unsaved} = shift; $self->{_import_hash} = shift; + my $icon_theme = shift; #gettext $self->{_d} = $self->{_sc}->get_gettext; - #define own icons - $self->{_dicons} = $self->{_sc}->get_root . "/share/shutter/resources/icons/drawing_tool"; - $self->{_icons} = $self->{_sc}->get_root . "/share/shutter/resources/icons"; #MAIN WINDOW #------------------------------------------------- @@ -241,6 +239,26 @@ sub show { $self->{_lp} = Shutter::Pixbuf::Load->new($self->{_sc}, $self->{_drawing_window}); $self->{_lp_ne} = Shutter::Pixbuf::Load->new($self->{_sc}, $self->{_drawing_window}, TRUE); + #define own icons + if ($icon_theme eq 'auto') { + # Heuristic to detect whether GTK theme is light or dark + my $context = $self->{_drawing_window}->get_style_context(); + my $bg = $context->get_background_color('normal'); + my $avg_color = ($bg->red + $bg->green + $bg->blue) / 3.0; + if ($avg_color > 0.5) { + $icon_theme = 'dark'; + } else { + $icon_theme = 'light'; + } + } + if ($icon_theme eq 'dark') { + $self->{_dicons} = $self->{_sc}->get_root . "/share/shutter/resources/icons/drawing_tool"; + } else { + $self->{_dicons} = $self->{_sc}->get_root . "/share/shutter/resources/icons/drawing_tool_dark"; + } + + $self->{_icons} = $self->{_sc}->get_root . "/share/shutter/resources/icons"; + #setup cursor-hash # #cursors borrowed from inkscape