2022-07-30 21:03:15 +00:00
|
|
|
from native_ui import abstract
|
|
|
|
from . import Gtk
|
|
|
|
from pathlib import Path
|
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
platform = Path(__file__).parent.name
|
|
|
|
|
|
|
|
|
|
|
|
class Button(abstract.Button):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs, platform=platform)
|
|
|
|
|
|
|
|
def changed_gnome(self, property_name: str, index: int = None):
|
2022-07-30 23:13:00 +00:00
|
|
|
match property_name:
|
|
|
|
case "label": self.set_label_gnome()
|
2022-07-30 21:03:15 +00:00
|
|
|
|
|
|
|
def called_gnome(self, property_name: str, res: Any, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
|
2022-07-30 23:13:00 +00:00
|
|
|
def set_label_gnome(self):
|
|
|
|
if self.label is not None:
|
|
|
|
self.native.set_label(self.label)
|
|
|
|
|
2022-07-30 21:03:15 +00:00
|
|
|
def clicked(self, _native_button):
|
2022-07-30 23:13:00 +00:00
|
|
|
self.call("press")
|
2022-07-30 21:03:15 +00:00
|
|
|
|
|
|
|
def build_gnome(self):
|
2022-07-30 23:13:00 +00:00
|
|
|
self.native = Gtk.Button()
|
2022-07-30 21:03:15 +00:00
|
|
|
self.native.connect('clicked', self.clicked)
|
2022-07-30 23:13:00 +00:00
|
|
|
self.set_label_gnome()
|
2022-07-30 21:03:15 +00:00
|
|
|
return self.native
|