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
Version: 1.2
Version: 1.0
Section: utils
Priority: optional
Architecture: all

View file

@ -1,6 +1,8 @@
#!/usr/bin/python3
import os
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")
open("dpkg/opt/sweecrypt-gtk.ui",'w').write(open("sweecrypt-gtk.ui").read())
file[3] = 'UI_FILE = "/opt/sweecrypt-gtk.ui"'
@ -8,4 +10,5 @@ file.insert(0, "#!/usr/bin/env python3")
file = "\n".join(file)
open("dpkg/usr/bin/sweecrypt-gtk",'w').write(file)
os.system("chmod 1777 dpkg/usr/bin/sweecrypt-gtk")
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

@ -9,19 +9,25 @@ class GUI:
self.builder.connect_signals(self)
window = self.builder.get_object('window')
window.show_all()
def toggle(self, e:bool):
if e:
active = self.builder.get_object('encode').get_property("active")
self.builder.get_object('decode').set_property("active", not active)
else:
active = self.builder.get_object('decode').get_property("active")
self.builder.get_object('encode').set_property("active", not active)
def on_window_destroy(self, window):Gtk.main_quit()
def toggle(self, checkbox):
checkbox.set_property("label", "Encode" if checkbox.get_property("active") else "Decode")
def encode_toggle(self, encode):self.toggle(True)
def decode_toggle(self, decode):self.toggle(False)
def start_clicked(self, start):
encode = self.builder.get_object('encode').get_property("active")
shift = int(self.builder.get_object('shift').get_property("value"))
inputted = self.builder.get_object('text').get_property("text")
if encode:
self.builder.get_object('text').set_property("text", sc.encrypt(inputted, shift))
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, shift))
self.builder.get_object('encode').set_property("active", True)
self.builder.get_object('text').set_property("text", sc.decrypt(inputted))
self.builder.get_object('decode').set_property("active", False)
def main():
app = GUI()
Gtk.main()

View file

@ -2,11 +2,20 @@
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkAdjustment" id="database-shift">
<property name="lower">-100</property>
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">edit-copy</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 class="GtkTextBuffer" id="text">
<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">
<property name="can-focus">False</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>
<signal name="destroy" handler="on_window_destroy" swapped="no"/>
<child>
@ -24,11 +31,6 @@ you want to encode or decode.</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="input">
<property name="visible">True</property>
@ -36,38 +38,21 @@ you want to encode or decode.</property>
<property name="buffer">text</property>
<property name="monospace">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkToggleButton" id="encode">
<property name="label" translatable="yes">Encode</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image1</property>
<property name="active">True</property>
<signal name="toggled" handler="toggle" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Database shift: </property>
<signal name="toggled" handler="encode_toggle" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -75,42 +60,34 @@ you want to encode or decode.</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="decode">
<property name="label" translatable="yes">Decode</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image2</property>
<signal name="toggled" handler="decode_toggle" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</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>
<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="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>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">4</property>
</packing>
</child>
</object>