Compare commits

..

No commits in common. "main" and "v1.0" have entirely different histories.
main ... v1.0

6 changed files with 87 additions and 161 deletions

View file

@ -1,58 +0,0 @@
name: Test
on:
push:
workflow_dispatch:
pull_request:
jobs:
syntax:
name: Check syntax
runs-on: alpine
steps:
- uses: https://git.swee.codes/swee/setup-alpine@main
with:
additional: python3 libxml2-utils
- uses: actions/checkout@v4
- name: Check syntax of Python file
run: python3 -m py_compile sweecrypt-gtk.py
- name: Check syntax of XML file
run: xmllint --format sweecrypt-gtk.ui
x11:
name: Test the application
runs-on: alpine
needs: syntax
steps:
- uses: https://git.swee.codes/swee/setup-alpine@main
with:
additional: tigervnc py3-gobject3 py3-xdg py3-pip gtk+3.0 apk-gtk3 openbox scrot font-noto-all
- uses: actions/checkout@v4
- name: Install dependencies
run: pip install --break-system-packages sweecrypt
- name: Set VNC password
run: echo -e "sweecrypt\nsweecrypt\n" | vncpasswd
- name: Start an X11 server
run: USER=root vncserver :5 &
- name: Start the app
run: DISPLAY=:5 python3 sweecrypt-gtk.py &
- name: Wait 5 secs
run: sleep 5
- name: Take a screenshot
run: DISPLAY=:5 scrot screenshot.png
- name: Upload screenshot
uses: actions/upload-artifact@v3
with:
path: screenshot.png
apt:
name: Build Debian Package
runs-on: docker
needs: syntax
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Generate DEB
run: |
python3 generate-deb.py
- uses: actions/upload-artifact@v3
with:
path: sweecrypt-gtk.deb

View file

@ -1,5 +1,5 @@
Package: sweecrypt-gtk Package: sweecrypt-gtk
Version: 1.2 Version: 1.0
Section: utils Section: utils
Priority: optional Priority: optional
Architecture: all Architecture: all

View file

@ -1,6 +1,8 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os import os
print("Creating Debian package...") print("Creating Debian package...")
if os.name != "posix":
print("WARNING: Machine is not running Linux (value of os.name is not \"posix\"), the script will not try to auto-build the .deb file. You might need to manually `chmod 1777` the binary.")
file = open("sweecrypt-gtk.py").read().split("\n") file = open("sweecrypt-gtk.py").read().split("\n")
open("dpkg/opt/sweecrypt-gtk.ui",'w').write(open("sweecrypt-gtk.ui").read()) open("dpkg/opt/sweecrypt-gtk.ui",'w').write(open("sweecrypt-gtk.ui").read())
file[3] = 'UI_FILE = "/opt/sweecrypt-gtk.ui"' file[3] = 'UI_FILE = "/opt/sweecrypt-gtk.ui"'
@ -8,4 +10,5 @@ file.insert(0, "#!/usr/bin/env python3")
file = "\n".join(file) file = "\n".join(file)
open("dpkg/usr/bin/sweecrypt-gtk",'w').write(file) open("dpkg/usr/bin/sweecrypt-gtk",'w').write(file)
os.system("chmod 1777 dpkg/usr/bin/sweecrypt-gtk") os.system("chmod 1777 dpkg/usr/bin/sweecrypt-gtk")
os.system("dpkg-deb --root-owner-group --build dpkg sweecrypt-gtk.deb") if os.name == "posix":
os.system("dpkg-deb --root-owner-group --build dpkg sweecrypt-gtk.deb")

View file

@ -1,2 +0,0 @@
sweecrypt>=1.0.4
PyGObject

View file

@ -3,27 +3,33 @@ gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GdkPixbuf, Gdk from gi.repository import Gtk, GdkPixbuf, Gdk
UI_FILE = os.path.dirname(os.path.realpath(__file__)) + "/sweecrypt-gtk.ui" UI_FILE = os.path.dirname(os.path.realpath(__file__)) + "/sweecrypt-gtk.ui"
class GUI: class GUI:
def __init__(self): def __init__(self):
self.builder = Gtk.Builder() self.builder = Gtk.Builder()
self.builder.add_from_file(UI_FILE) self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self) self.builder.connect_signals(self)
window = self.builder.get_object('window') window = self.builder.get_object('window')
window.show_all() window.show_all()
def on_window_destroy(self, window):Gtk.main_quit() def toggle(self, e:bool):
def toggle(self, checkbox): if e:
checkbox.set_property("label", "Encode" if checkbox.get_property("active") else "Decode") active = self.builder.get_object('encode').get_property("active")
def start_clicked(self, start): self.builder.get_object('decode').set_property("active", not active)
encode = self.builder.get_object('encode').get_property("active") else:
shift = int(self.builder.get_object('shift').get_property("value")) active = self.builder.get_object('decode').get_property("active")
inputted = self.builder.get_object('text').get_property("text") self.builder.get_object('encode').set_property("active", not active)
if encode: def on_window_destroy(self, window):Gtk.main_quit()
self.builder.get_object('text').set_property("text", sc.encrypt(inputted, shift)) def encode_toggle(self, encode):self.toggle(True)
self.builder.get_object('encode').set_property("active", False) def decode_toggle(self, decode):self.toggle(False)
else: def start_clicked(self, start):
self.builder.get_object('text').set_property("text", sc.decrypt(inputted, shift)) encode = self.builder.get_object('encode').get_property("active")
self.builder.get_object('encode').set_property("active", True) inputted = self.builder.get_object('text').get_property("text")
if encode:
self.builder.get_object('text').set_property("text", sc.encrypt(inputted))
self.builder.get_object('encode').set_property("active", False)
else:
self.builder.get_object('text').set_property("text", sc.decrypt(inputted))
self.builder.get_object('decode').set_property("active", False)
def main(): def main():
app = GUI() app = GUI()
Gtk.main() Gtk.main()
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main()) sys.exit(main())

View file

@ -2,11 +2,20 @@
<!-- Generated with glade 3.40.0 --> <!-- Generated with glade 3.40.0 -->
<interface> <interface>
<requires lib="gtk+" version="3.24"/> <requires lib="gtk+" version="3.24"/>
<object class="GtkAdjustment" id="database-shift"> <object class="GtkImage" id="image1">
<property name="lower">-100</property> <property name="visible">True</property>
<property name="upper">100</property> <property name="can-focus">False</property>
<property name="step-increment">1</property> <property name="icon-name">edit-copy</property>
<property name="page-increment">10</property> </object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">document-revert</property>
</object>
<object class="GtkImage" id="start">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">document-properties</property>
</object> </object>
<object class="GtkTextBuffer" id="text"> <object class="GtkTextBuffer" id="text">
<property name="text" translatable="yes">replace this text with anything <property name="text" translatable="yes">replace this text with anything
@ -15,8 +24,6 @@ you want to encode or decode.</property>
<object class="GtkWindow" id="window"> <object class="GtkWindow" id="window">
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="title" translatable="yes">SweeCrypt GTK</property> <property name="title" translatable="yes">SweeCrypt GTK</property>
<property name="default-width">250</property>
<property name="default-height">128</property>
<property name="icon-name">sweecrypt</property> <property name="icon-name">sweecrypt</property>
<signal name="destroy" handler="on_window_destroy" swapped="no"/> <signal name="destroy" handler="on_window_destroy" swapped="no"/>
<child> <child>
@ -25,18 +32,11 @@ you want to encode or decode.</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkScrolledWindow"> <object class="GtkTextView" id="input">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="shadow-type">in</property> <property name="buffer">text</property>
<child> <property name="monospace">True</property>
<object class="GtkTextView" id="input">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="buffer">text</property>
<property name="monospace">True</property>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
@ -45,67 +45,29 @@ you want to encode or decode.</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkBox"> <object class="GtkToggleButton" id="encode">
<property name="label" translatable="yes">Encode</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">True</property>
<child> <property name="receives-default">True</property>
<object class="GtkToggleButton" id="encode"> <property name="image">image1</property>
<property name="label" translatable="yes">Encode</property> <property name="active">True</property>
<property name="visible">True</property> <signal name="toggled" handler="encode_toggle" swapped="no"/>
<property name="can-focus">True</property> </object>
<property name="receives-default">True</property> <packing>
<property name="active">True</property> <property name="expand">False</property>
<signal name="toggled" handler="toggle" swapped="no"/> <property name="fill">True</property>
</object> <property name="position">1</property>
<packing> </packing>
<property name="expand">False</property> </child>
<property name="fill">True</property> <child>
<property name="position">0</property> <object class="GtkToggleButton" id="decode">
</packing> <property name="label" translatable="yes">Decode</property>
</child> <property name="visible">True</property>
<child> <property name="can-focus">True</property>
<object class="GtkLabel"> <property name="receives-default">True</property>
<property name="visible">True</property> <property name="image">image2</property>
<property name="can-focus">False</property> <signal name="toggled" handler="decode_toggle" swapped="no"/>
<property name="label" translatable="yes">Database shift: </property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="star">
<property name="label" translatable="yes">Start</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="start_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="shift">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="caps-lock-warning">False</property>
<property name="primary-icon-tooltip-text" translatable="yes">Database shift</property>
<property name="adjustment">database-shift</property>
<property name="climb-rate">1</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -113,6 +75,21 @@ you want to encode or decode.</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton" id="star">
<property name="label" translatable="yes">Start</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">start</property>
<signal name="clicked" handler="start_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>