Skip to content

Commit

Permalink
paste-into-file@anaximeno: Version 1.4.0 (#374)
Browse files Browse the repository at this point in the history
* Update AUI to Version 0.5
  • Loading branch information
anaximeno authored May 14, 2024
1 parent 390a388 commit accb994
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 9 deletions.
64 changes: 56 additions & 8 deletions paste-into-file@anaximeno/files/paste-into-file@anaximeno/aui.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Action UI - Basic GTK Based UI Toolkit for Nemo Actions.
@Author: Anaxímeno Brito <[email protected]>
@Url: https://github.com/anaximeno/aui
@Version: 0.4
@Version: 0.5
@License: BSD 3-Clause License
Copyright (c) 2024, Anaxímeno Brito
Expand Down Expand Up @@ -46,7 +46,7 @@
ICON_FILENAME = "icon.png"


def get_action_icon_path(uuid: str, use_dev_icon_if_found = None) -> str:
def get_action_icon_path(uuid: str, use_dev_icon_if_found=None) -> str:
"""Returns the path of the `icon.png` file of the action.
#### Params:
Expand Down Expand Up @@ -92,14 +92,37 @@ def __init__(
title: str = None,
width: int,
height: int,
expander_label: str = "",
expanded_text: str = "",
**kwargs,
) -> None:
super().__init__(*args, title=title, **kwargs)
self.add_buttons(Gtk.STOCK_OK, Gtk.ResponseType.OK)
self._box = Gtk.VBox()
self.label = Gtk.Label()
self.label.set_margin_top(10)
self.label.set_margin_bottom(10)
self.label.set_margin_start(10)
self.label.set_margin_end(10)
self.label.set_halign(Gtk.Align.CENTER)
self.label.set_valign(Gtk.Align.CENTER)
self.label.set_markup(message)

self._box.pack_start(self.label, True, True, 0)

self.expander_label = None
self.expanded_text = None

if expander_label:
self.expander = Gtk.Expander(label=expander_label)
self.expanded_text_label = Gtk.Label()
self.expanded_text_label.set_markup(expanded_text)
self.expanded_text_label.set_halign(Gtk.Align.START)
self.expanded_text_label.set_margin_top(5)
self.expanded_text_label.set_margin_start(10)
self.expander.add(self.expanded_text_label)
self._box.pack_start(self.expander, True, True, 10)

self._content_area = self.get_content_area()
self._content_area.add(self._box)
self.set_default_size(width, height)
Expand All @@ -114,6 +137,8 @@ def __init__(
window_icon_path: str = None,
width: int = 360,
height: int = 120,
expander_label: str = "",
expanded_text: str = "",
) -> None:
super().__init__(title=title, icon_path=window_icon_path)
self.dialog = _InfoDialog(
Expand All @@ -123,6 +148,8 @@ def __init__(
message=message,
width=width,
height=height,
expander_label=expander_label,
expanded_text=expanded_text,
)


Expand Down Expand Up @@ -180,10 +207,16 @@ def __init__(

if label is not None:
self._label = Gtk.Label(xalign=0)
self._label.set_margin_top(2)
self._label.set_margin_start(5)
self._label.set_margin_end(5)
self._label.set_markup(label)
self._box.pack_start(self._label, False, False, 5)

self.entry = Gtk.Entry(text=default_text)
self.entry.set_margin_bottom(2)
self.entry.set_margin_start(5)
self.entry.set_margin_end(5)
self._box.pack_start(self.entry, True, True, 0)

self._content_area = self.get_content_area()
Expand Down Expand Up @@ -230,8 +263,8 @@ def __init__(
self,
title: str = None,
message: str = None,
expander_label: str = None,
expanded_text: str = None,
expander_label: str = "",
expanded_text: str = "",
width: int = 360,
height: int = 120,
**kwargs,
Expand All @@ -240,17 +273,28 @@ def __init__(
self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
self.box = Gtk.VBox(spacing=15)
self.progressbar = Gtk.ProgressBar()
self.progressbar.set_margin_top(10)
self.progressbar.set_margin_start(5)
self.progressbar.set_margin_end(5)

if message:
self.progressbar.set_text(message)
self.progressbar.set_show_text(True)

self.box.pack_start(self.progressbar, True, True, 0)

self.expander = None
self.expanded_text_label = None
if expander_label:
self.expander = Gtk.Expander(label=expander_label)
self.expanded_text = Gtk.Label(label=expanded_text)
self.expander.add(self.expanded_text)
self.expander.set_margin_start(5)
self.expander.set_margin_end(5)
self.expanded_text_label = Gtk.Label()
self.expanded_text_label.set_markup(expanded_text)
self.expanded_text_label.set_halign(Gtk.Align.START)
self.expanded_text_label.set_margin_top(5)
self.expanded_text_label.set_margin_start(10)
self.expander.add(self.expanded_text_label)
self.box.pack_start(self.expander, True, True, 0)

self._content_area = self.get_content_area()
Expand All @@ -266,8 +310,8 @@ def __init__(
timeout_ms: int = 50,
title: str = None,
message: str = None,
expander_label: str = None,
expanded_text: str = None,
expander_label: str = "",
expanded_text: str = "",
window_icon_path: str = None,
width: int = 360,
height: int = 120,
Expand Down Expand Up @@ -317,6 +361,10 @@ def destroy(self):
self.stop()
super().destroy()

def set_expanded_text(self, text: str):
if self.dialog.expanded_text_label is not None:
self.dialog.expanded_text_label.set_markup(text)


class RadioChoiceButton:
def __init__(self, id: str, label: str, on_toggled_cb: Callable = None) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"uuid": "paste-into-file@anaximeno",
"name": "Paste into file",
"author": "anaximeno",
"version": "1.3.0"
"version": "1.4.0"
}

0 comments on commit accb994

Please sign in to comment.