Debian Codegraph @

src/optionsbars/transform/optionsbar_crop.py

raw symbols SCIP
1 # optionsbar_crop.py
2 #
3 # Copyright 2018-2023 Romain F. T.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 from gi.repository import Gtk
19 from .abstract_optionsbar import AbstractOptionsBar
20 from .utilities_units import utilities_add_unit_to_spinbtn
21
22 class OptionsBarCrop(AbstractOptionsBar):
23 __gtype_name__ = 'OptionsBarCrop'
24
25 def __init__(self):
26 super().__init__()
27
28 self._build_ui('transform/abstract-optionsbar-transform.ui')
29 builder = self._hydrate_transform_tool('transform/optionsbar-crop.ui')
30
31 self.height_btn = builder.get_object('height_btn')
32 self.width_btn = builder.get_object('width_btn')
33 utilities_add_unit_to_spinbtn(self.height_btn, 4, 'px')
34 utilities_add_unit_to_spinbtn(self.width_btn, 4, 'px')
35 # XXX top/bottom/left/right ?
36
37 self.width_label = builder.get_object('width_label')
38 self.height_label = builder.get_object('height_label')
39 self.separator = builder.get_object('separator')
40
41 def init_adaptability(self):
42 super().init_adaptability()
43 temp_limit_size = self.centered_box.get_preferred_width()[0] + \
44 self.cancel_btn.get_preferred_width()[0] + \
45 self.options_btn.get_preferred_width()[0] + \
46 self.help_btn.get_preferred_width()[0] + \
47 self.apply_btn.get_preferred_width()[0]
48 self._set_limit_size(temp_limit_size)
49
50 def set_compact(self, state):
51 super().set_compact(state)
52 if state:
53 self.centered_box.set_orientation(Gtk.Orientation.VERTICAL)
54 else:
55 self.centered_box.set_orientation(Gtk.Orientation.HORIZONTAL)
56 self.width_label.set_visible(not state)
57 self.height_label.set_visible(not state)
58 self.separator.set_visible(not state)
59
60 # if self.crop_tool.apply_to_selection:
61 # self.???.set_visible(state)
62 # else:
63 # self.???.set_visible(state)
64
65 ############################################################################
66 ################################################################################
67