From 55fde142179cd0017680dee8699dfdb60576d12c Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 16 Feb 2023 12:42:21 +0800 Subject: [PATCH] Update GTK hinting methods. --- core/tests/widgets/test_divider.py | 2 +- core/tests/widgets/test_label.py | 2 +- dummy/src/toga_dummy/widgets/datepicker.py | 3 --- dummy/src/toga_dummy/widgets/divider.py | 3 --- dummy/src/toga_dummy/widgets/label.py | 3 --- dummy/src/toga_dummy/widgets/selection.py | 3 --- dummy/src/toga_dummy/widgets/slider.py | 3 --- dummy/src/toga_dummy/widgets/switch.py | 3 --- dummy/src/toga_dummy/widgets/textinput.py | 3 --- dummy/src/toga_dummy/widgets/timepicker.py | 3 --- gtk/src/toga_gtk/widgets/canvas.py | 2 +- gtk/src/toga_gtk/widgets/divider.py | 2 +- gtk/src/toga_gtk/widgets/imageview.py | 2 +- gtk/src/toga_gtk/widgets/label.py | 2 +- gtk/src/toga_gtk/widgets/multilinetextinput.py | 2 +- gtk/src/toga_gtk/widgets/numberinput.py | 2 +- gtk/src/toga_gtk/widgets/selection.py | 2 +- gtk/src/toga_gtk/widgets/slider.py | 2 +- gtk/src/toga_gtk/widgets/switch.py | 2 +- gtk/src/toga_gtk/widgets/textinput.py | 2 +- gtk/src/toga_gtk/widgets/webview.py | 2 +- 21 files changed, 13 insertions(+), 37 deletions(-) diff --git a/core/tests/widgets/test_divider.py b/core/tests/widgets/test_divider.py index 56d50973cc..f09e26af05 100644 --- a/core/tests/widgets/test_divider.py +++ b/core/tests/widgets/test_divider.py @@ -16,4 +16,4 @@ def test_update_direction(self): self.divider.direction = new_direction self.assertEqual(self.divider.direction, new_direction) self.assertValueSet(self.divider, "direction", new_direction) - self.assertActionPerformed(self.divider, "rehint Divider") + self.assertActionPerformed(self.divider, "rehint") diff --git a/core/tests/widgets/test_label.py b/core/tests/widgets/test_label.py index c794fef62b..b1444832f2 100644 --- a/core/tests/widgets/test_label.py +++ b/core/tests/widgets/test_label.py @@ -19,7 +19,7 @@ def test_update_label_text(self): self.label.text = new_text self.assertEqual(self.label.text, new_text) self.assertValueSet(self.label, "text", new_text) - self.assertActionPerformed(self.label, "rehint Label") + self.assertActionPerformed(self.label, "rehint") self.label.text = None self.assertEqual(self.label.text, "") diff --git a/dummy/src/toga_dummy/widgets/datepicker.py b/dummy/src/toga_dummy/widgets/datepicker.py index 3de8b85d78..bafca7be84 100644 --- a/dummy/src/toga_dummy/widgets/datepicker.py +++ b/dummy/src/toga_dummy/widgets/datepicker.py @@ -17,8 +17,5 @@ def set_min_date(self, value): def set_max_date(self, value): return self._set_value("max date", value) - def rehint(self): - self._action("rehint DatePicker") - def set_on_change(self, handler): self._set_value("on_change", handler) diff --git a/dummy/src/toga_dummy/widgets/divider.py b/dummy/src/toga_dummy/widgets/divider.py index 53cab28128..a437fe140e 100644 --- a/dummy/src/toga_dummy/widgets/divider.py +++ b/dummy/src/toga_dummy/widgets/divider.py @@ -5,8 +5,5 @@ class Divider(Widget): def create(self): self._action("create Divider") - def rehint(self): - self._action("rehint Divider") - def set_direction(self, value): self._set_value("direction", value) diff --git a/dummy/src/toga_dummy/widgets/label.py b/dummy/src/toga_dummy/widgets/label.py index 0f781cc653..9fb28f1972 100644 --- a/dummy/src/toga_dummy/widgets/label.py +++ b/dummy/src/toga_dummy/widgets/label.py @@ -10,6 +10,3 @@ def set_alignment(self, value): def set_text(self, value): self._set_value("text", self.interface._text) - - def rehint(self): - self._action("rehint Label") diff --git a/dummy/src/toga_dummy/widgets/selection.py b/dummy/src/toga_dummy/widgets/selection.py index ec35cac790..1f11f1b145 100644 --- a/dummy/src/toga_dummy/widgets/selection.py +++ b/dummy/src/toga_dummy/widgets/selection.py @@ -19,6 +19,3 @@ def get_selected_item(self): def set_on_select(self, handler): self._set_value("on_select", handler) - - def rehint(self): - self._action("rehint Selection") diff --git a/dummy/src/toga_dummy/widgets/slider.py b/dummy/src/toga_dummy/widgets/slider.py index dd56bb454e..decfc24f88 100644 --- a/dummy/src/toga_dummy/widgets/slider.py +++ b/dummy/src/toga_dummy/widgets/slider.py @@ -17,9 +17,6 @@ def set_range(self, range): def set_tick_count(self, tick_count): self._set_value("tick_count", tick_count) - def rehint(self): - self._action("rehint Slider") - def set_on_change(self, handler): self._set_value("on_change", handler) diff --git a/dummy/src/toga_dummy/widgets/switch.py b/dummy/src/toga_dummy/widgets/switch.py index ce760443c6..49656d24d7 100644 --- a/dummy/src/toga_dummy/widgets/switch.py +++ b/dummy/src/toga_dummy/widgets/switch.py @@ -14,8 +14,5 @@ def set_value(self, value): def get_value(self): return self._get_value("value") - def rehint(self): - self._action("rehint Switch") - def set_on_change(self, handler): self._set_value("on_change", handler) diff --git a/dummy/src/toga_dummy/widgets/textinput.py b/dummy/src/toga_dummy/widgets/textinput.py index e947eb79e6..cab68f0e04 100644 --- a/dummy/src/toga_dummy/widgets/textinput.py +++ b/dummy/src/toga_dummy/widgets/textinput.py @@ -23,9 +23,6 @@ def set_font(self, font): def set_alignment(self, value): self._set_value("alignment", value) - def rehint(self): - self._action("rehint TextInput") - def set_on_change(self, handler): self._set_value("on_change", handler) diff --git a/dummy/src/toga_dummy/widgets/timepicker.py b/dummy/src/toga_dummy/widgets/timepicker.py index 7e7d3e3415..0c6fcc1694 100644 --- a/dummy/src/toga_dummy/widgets/timepicker.py +++ b/dummy/src/toga_dummy/widgets/timepicker.py @@ -17,8 +17,5 @@ def set_min_time(self, value): def set_max_time(self, value): return self._set_value("max time", value) - def rehint(self): - self._action("rehint TimePicker") - def set_on_change(self, handler): self._set_value("on_change", handler) diff --git a/gtk/src/toga_gtk/widgets/canvas.py b/gtk/src/toga_gtk/widgets/canvas.py index 20bf1372be..90b39bea70 100644 --- a/gtk/src/toga_gtk/widgets/canvas.py +++ b/gtk/src/toga_gtk/widgets/canvas.py @@ -235,7 +235,7 @@ def get_image_data(self): # Rehint - def rehint(self): + def gtk_rehint(self): # print("REHINT", self, self.native.get_preferred_width(), self.native.get_preferred_height()) # width = self.native.get_preferred_width() # height = self.native.get_preferred_height() diff --git a/gtk/src/toga_gtk/widgets/divider.py b/gtk/src/toga_gtk/widgets/divider.py index c505da5fa8..a8bb289747 100644 --- a/gtk/src/toga_gtk/widgets/divider.py +++ b/gtk/src/toga_gtk/widgets/divider.py @@ -9,7 +9,7 @@ def create(self): self.native = Gtk.Separator() self.native.interface = self.interface - def rehint(self): + def gtk_rehint(self): width = self.native.get_preferred_width() height = self.native.get_preferred_height() diff --git a/gtk/src/toga_gtk/widgets/imageview.py b/gtk/src/toga_gtk/widgets/imageview.py index 56e4039421..298bb8acae 100644 --- a/gtk/src/toga_gtk/widgets/imageview.py +++ b/gtk/src/toga_gtk/widgets/imageview.py @@ -18,7 +18,7 @@ def set_bounds(self, x, y, width, height): # rehint to update scaling of pixbuf self.rehint() - def rehint(self): + def gtk_rehint(self): if self._pixbuf: height, width = self._resize_max( original_height=self._pixbuf.get_height(), diff --git a/gtk/src/toga_gtk/widgets/label.py b/gtk/src/toga_gtk/widgets/label.py index 906edb396e..149568f89d 100644 --- a/gtk/src/toga_gtk/widgets/label.py +++ b/gtk/src/toga_gtk/widgets/label.py @@ -26,7 +26,7 @@ def set_text(self, value): # corner and only jumps back at its place after resizing the window. self.native.set_text(self.interface._text) - def rehint(self): + def gtk_rehint(self): # print("REHINT", self, # self.native.get_preferred_width(), self.native.get_preferred_height(), # getattr(self, '_fixed_height', False), getattr(self, '_fixed_width', False) diff --git a/gtk/src/toga_gtk/widgets/multilinetextinput.py b/gtk/src/toga_gtk/widgets/multilinetextinput.py index cfc04346f5..40d0ba11d1 100644 --- a/gtk/src/toga_gtk/widgets/multilinetextinput.py +++ b/gtk/src/toga_gtk/widgets/multilinetextinput.py @@ -68,7 +68,7 @@ def gtk_on_focus_out(self, *args): ) # make the placeholder text gray. return False - def rehint(self): + def gtk_rehint(self): self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH) self.interface.intrinsic.height = at_least(self.interface.MIN_HEIGHT) diff --git a/gtk/src/toga_gtk/widgets/numberinput.py b/gtk/src/toga_gtk/widgets/numberinput.py index d646891761..1809269dd8 100644 --- a/gtk/src/toga_gtk/widgets/numberinput.py +++ b/gtk/src/toga_gtk/widgets/numberinput.py @@ -60,7 +60,7 @@ def set_alignment(self, value): def set_font(self, font): self.interface.factory.not_implemented("NumberInput.set_font()") - def rehint(self): + def gtk_rehint(self): width = self.native.get_preferred_width() height = self.native.get_preferred_height() if width and height: diff --git a/gtk/src/toga_gtk/widgets/selection.py b/gtk/src/toga_gtk/widgets/selection.py index d7ba56146d..e587854cff 100644 --- a/gtk/src/toga_gtk/widgets/selection.py +++ b/gtk/src/toga_gtk/widgets/selection.py @@ -32,7 +32,7 @@ def select_item(self, item): def get_selected_item(self): return self.native.get_active_text() - def rehint(self): + def gtk_rehint(self): # width = self.native.get_preferred_width() height = self.native.get_preferred_height() diff --git a/gtk/src/toga_gtk/widgets/slider.py b/gtk/src/toga_gtk/widgets/slider.py index 698685975f..2d9bb200be 100644 --- a/gtk/src/toga_gtk/widgets/slider.py +++ b/gtk/src/toga_gtk/widgets/slider.py @@ -41,7 +41,7 @@ def set_range(self, range): def set_tick_count(self, tick_count): self.interface.factory.not_implemented("Slider.tick_count()") - def rehint(self): + def gtk_rehint(self): # print("REHINT", self, self.native.get_preferred_width(), self.native.get_preferred_height()) height = self.native.get_preferred_height() diff --git a/gtk/src/toga_gtk/widgets/switch.py b/gtk/src/toga_gtk/widgets/switch.py index 35d38fd5af..f7c9aa9002 100644 --- a/gtk/src/toga_gtk/widgets/switch.py +++ b/gtk/src/toga_gtk/widgets/switch.py @@ -35,7 +35,7 @@ def get_value(self): def set_value(self, value): self.switch.set_active(value) - def rehint(self): + def gtk_rehint(self): # print("REHINT", self, self.native.get_preferred_width(), self.native.get_preferred_height()) width = self.native.get_preferred_width() height = self.native.get_preferred_height() diff --git a/gtk/src/toga_gtk/widgets/textinput.py b/gtk/src/toga_gtk/widgets/textinput.py index 6b8251485e..8afed1a719 100644 --- a/gtk/src/toga_gtk/widgets/textinput.py +++ b/gtk/src/toga_gtk/widgets/textinput.py @@ -33,7 +33,7 @@ def get_value(self): def set_value(self, value): self.native.set_text(value) - def rehint(self): + def gtk_rehint(self): # print("REHINT", self, # self._impl.get_preferred_width(), self._impl.get_preferred_height(), # getattr(self, '_fixed_height', False), getattr(self, '_fixed_width', False) diff --git a/gtk/src/toga_gtk/widgets/webview.py b/gtk/src/toga_gtk/widgets/webview.py index 23556dd730..b500a78222 100644 --- a/gtk/src/toga_gtk/widgets/webview.py +++ b/gtk/src/toga_gtk/widgets/webview.py @@ -96,6 +96,6 @@ def invoke_javascript(self, javascript): # Invoke the javascript without a callback. self.native.run_javascript(javascript, None, None) - def rehint(self): + def gtk_rehint(self): self.interface.intrinsic.width = at_least(self.interface.MIN_WIDTH) self.interface.intrinsic.height = at_least(self.interface.MIN_HEIGHT)