Debian Codegraph @

src/optionsbars/transform/optionsbar_skew.py

raw symbols SCIP
1 # optionsbar_skew.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 OptionsBarSkew(AbstractOptionsBar):
23 __gtype_name__ = 'OptionsBarSkew'
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-skew.ui')
30
31 self.xy_label = builder.get_object('xy_label')
32 self.yx_label = builder.get_object('yx_label')
33 self.separator = builder.get_object('separator')
34
35 self.yx_spinbtn = builder.get_object('yx_spinbtn')
36 self.xy_spinbtn = builder.get_object('xy_spinbtn')
37 utilities_add_unit_to_spinbtn(self.yx_spinbtn, 3, '%')
38 utilities_add_unit_to_spinbtn(self.xy_spinbtn, 3, '%')
39
40 def init_adaptability(self):
41 super().init_adaptability()
42 temp_limit_size = self.centered_box.get_preferred_width()[0] + \
43 self.cancel_btn.get_preferred_width()[0] + \
44 self.options_btn.get_preferred_width()[0] + \
45 self.help_btn.get_preferred_width()[0] + \
46 self.apply_btn.get_preferred_width()[0]
47 self._set_limit_size(temp_limit_size)
48
49 def update_for_new_tool(self, tool):
50 self.set_compact(self._is_narrow)
51
52 def set_compact(self, state):
53 super().set_compact(state)
54 if state:
55 self.centered_box.set_orientation(Gtk.Orientation.VERTICAL)
56 else:
57 self.centered_box.set_orientation(Gtk.Orientation.HORIZONTAL)
58 self.xy_label.set_visible(not state)
59 self.yx_label.set_visible(not state)
60 self.separator.set_visible(not state)
61
62 ############################################################################
63 ################################################################################
64