-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clone-git-repo@anaximeno: Version 1.4.0 (#535)
* Remove expander from the progress bar during the cloning * Update text and translation * Show message dialog if cloned folder could not be opened
- Loading branch information
Showing
18 changed files
with
545 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,28 @@ | ||
"""Action UI - Basic GTK Based UI Toolkit for Nemo Actions. | ||
@Author: Anaxímeno Brito <[email protected]> | ||
@Url: https://github.com/anaximeno/aui | ||
@Version: 0.5-patch1 | ||
@License: BSD 3-Clause License | ||
@Version: 0.6 | ||
@License: MIT License | ||
Copyright (c) 2024, Anaxímeno Brito | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
""" | ||
|
||
import os | ||
|
@@ -503,3 +496,101 @@ def run(self) -> str | None: | |
if btn.gtk_button.get_active(): | ||
return btn.id | ||
return None | ||
|
||
|
||
class ActionableButton: | ||
_id_counter = 0 | ||
|
||
def __init__(self, text: str, on_click_action: Callable) -> None: | ||
self._id = self._get_id() | ||
self._on_click_action = on_click_action | ||
self._text = text | ||
|
||
@classmethod | ||
def _get_id(cls): | ||
cls._id_counter += 1 | ||
return cls._id_counter | ||
|
||
@property | ||
def id(self) -> str: | ||
return self._id | ||
|
||
@property | ||
def text(self) -> str: | ||
return self._text | ||
|
||
@property | ||
def on_click_action(self) -> Callable: | ||
return self._on_click_action | ||
|
||
def trigger_on_click_action(self, *args, **kwargs) -> None: | ||
self._on_click_action(*args, **kwargs) | ||
|
||
|
||
class _ActionableDialog(Gtk.Dialog): | ||
def __init__( | ||
self, | ||
*args, | ||
title: str = None, | ||
message: str, | ||
buttons: Iterable[ActionableButton], | ||
width: int, | ||
height: int, | ||
**kwargs, | ||
) -> None: | ||
super().__init__(*args, title=title, **kwargs) | ||
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._content_area = self.get_content_area() | ||
self._content_area.add(self._box) | ||
self._buttons = buttons | ||
|
||
for button in self._buttons: | ||
self.add_button(button.text, button.id) | ||
|
||
self.set_default_size(width, height) | ||
self.show_all() | ||
|
||
|
||
class ActionableDialogWindow(DialogWindow): | ||
def __init__( | ||
self, | ||
*args, | ||
title: str, | ||
message: str, | ||
buttons: Iterable[ActionableButton], | ||
width: int = 360, | ||
height: int = 120, | ||
window_icon_path: str = None, | ||
**kwargs, | ||
) -> None: | ||
super().__init__( | ||
*args, | ||
title=title, | ||
icon_path=window_icon_path, | ||
**kwargs, | ||
) | ||
self.buttons = buttons | ||
self.dialog = _ActionableDialog( | ||
flags=0, | ||
transient_for=self, | ||
message=message, | ||
buttons=buttons, | ||
width=width, | ||
height=height, | ||
) | ||
|
||
def run(self) -> None: | ||
response = super().run() | ||
for button in self.buttons: | ||
if response == button.id: | ||
button.trigger_on_click_action() | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# CLONE GIT REPO | ||
# This file is put in the public domain. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# anaximeno, 2024 | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: clone-git-repo@anaximeno 1.2.1\n" | ||
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-actions/" | ||
"issues\n" | ||
"POT-Creation-Date: 2024-06-08 21:03-0100\n" | ||
"POT-Creation-Date: 2024-10-04 01:20-0100\n" | ||
"PO-Revision-Date: 2024-07-24 00:45+0200\n" | ||
"Last-Translator: Odyssey <[email protected]>\n" | ||
"Language-Team: \n" | ||
|
@@ -18,31 +18,31 @@ msgstr "" | |
"Content-Transfer-Encoding: 8bit\n" | ||
"X-Generator: Poedit 3.4.2\n" | ||
|
||
#: text.py:14 | ||
#. text.py:14 | ||
msgid "Clone a repository" | ||
msgstr "Clona un repositori" | ||
|
||
#: text.py:16 | ||
#. text.py:16 | ||
msgid "git urls" | ||
msgstr "urls de git" | ||
|
||
#: text.py:18 | ||
#. text.py:18 | ||
msgid "Enter the name for the cloned folder:" | ||
msgstr "Introdueix el nom per la carpeta clonada:" | ||
|
||
#: text.py:21 | ||
#. text.py:21 | ||
msgid "" | ||
"The entered name is invalid.\n" | ||
"Please choose a name that follows folder naming rules." | ||
msgstr "" | ||
"El nom introduït és invàlid.\n" | ||
"Si us plau, tria un nom que segueixi les convencions de nom de carpetes." | ||
|
||
#: text.py:28 | ||
#. text.py:28 | ||
msgid "Repository Address:" | ||
msgstr "Adreça del repositori:" | ||
|
||
#: text.py:32 | ||
#. text.py:32 | ||
#, python-format | ||
msgid "" | ||
"The given Git address has an unrecognized format.\n" | ||
|
@@ -51,22 +51,30 @@ msgstr "" | |
"L'adreça git facilitada té un format desconegut.\n" | ||
"Si us plau, revisa els formats suportats a %s i prova-ho de nou." | ||
|
||
#: text.py:38 | ||
#. text.py:38 | ||
#, python-format | ||
msgid "Cloning %s" | ||
msgstr "Clonant %s" | ||
|
||
#: text.py:40 | ||
#, python-format | ||
msgid "Repository successfully cloned to %s" | ||
msgstr "El repositori s'ha clonat correctament a %s" | ||
#. text.py:40 | ||
msgid "Repository successfully cloned!" | ||
msgstr "El repositori s'ha clonat correctamen!" | ||
|
||
#. text.py:42 | ||
msgid "Open" | ||
msgstr "" | ||
|
||
#. text.py:44 | ||
#, fuzzy | ||
msgid "Couldn't open the cloned folder!" | ||
msgstr "Introdueix el nom per la carpeta clonada:" | ||
|
||
#: text.py:42 | ||
#. text.py:46 | ||
#, python-format | ||
msgid "Error cloning repository %s !" | ||
msgstr "Error clonant el repositori %s!" | ||
|
||
#: text.py:45 | ||
#. text.py:49 | ||
#, python-format | ||
msgid "" | ||
"A folder named %s already exists in this location.\n" | ||
|
@@ -75,15 +83,15 @@ msgstr "" | |
"Ja hi ha una carpeta anomenada %s a aquesta ruta.\n" | ||
"Si us plau, tria un nom diferent o elimina la carpeta ja existent." | ||
|
||
#: text.py:49 | ||
#. text.py:53 | ||
msgid "Cloning info" | ||
msgstr "Informació de la clonació" | ||
|
||
#: text.py:51 | ||
#. text.py:55 | ||
msgid "More info" | ||
msgstr "Més informació" | ||
|
||
#: text.py:54 | ||
#. text.py:58 | ||
msgid "" | ||
"The clone operation was canceled, leaving behind a residual folder. Should " | ||
"this folder be sent to the trash? Please note that due to the cancellation, " | ||
|
Oops, something went wrong.