This commit is contained in:
Swee 2024-09-07 21:09:23 -07:00
parent c194d9a735
commit aabef9c858
6 changed files with 281 additions and 27 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="48"
height="48"
viewBox="0 0 12.7 12.7"
version="1.1"
id="svg1"
inkscape:version="1.4-beta (62f545ba5e, 2024-04-22)"
sodipodi:docname="sweecrypt.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#505050"
inkscape:document-units="mm"
inkscape:zoom="5.5731762"
inkscape:cx="6.5492277"
inkscape:cy="12.560163"
inkscape:window-width="1920"
inkscape:window-height="969"
inkscape:window-x="-8"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#006ee6;fill-opacity:1;stroke:#17ff20;stroke-width:0.246086;stroke-opacity:1"
id="rect1"
width="11.812121"
height="11.812121"
x="0.44393936"
y="0.44393936" />
<text
xml:space="preserve"
style="font-size:9.07594px;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;fill:#00e60b;fill-opacity:1;stroke:none;stroke-width:0.113449;stroke-opacity:1"
x="0.78183079"
y="7.7496824"
id="text1"><tspan
sodipodi:role="line"
id="tspan1"
style="fill:#00e60b;fill-opacity:1;stroke:none;stroke-width:0.113449"
x="0.78183079"
y="7.7496824">S</tspan></text>
<text
xml:space="preserve"
style="font-size:8.57156px;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;fill:#00e60b;fill-opacity:1;stroke:none;stroke-width:0.107145;stroke-opacity:1"
x="6.4419074"
y="10.492256"
id="text2"><tspan
sodipodi:role="line"
id="tspan2"
style="stroke-width:0.107145"
x="6.4419074"
y="10.492256">$</tspan></text>
<path
style="fill:#00e60b;fill-opacity:1;stroke:none;stroke-width:0.264583;stroke-opacity:1"
d="M 5.8868287,2.682305 7.5484334,3.6317935 7.4416158,2.9196771 7.7976741,2.9315458 7.9757032,3.9047715 7.1449009,4.4032529 7.0024776,4.1777494 7.4416158,3.9166399 5.6731938,2.9790203 5.7444053,3.5487133 5.4358215,3.6080564 5.3290042,2.6110935 6.1242007,2.0414004 6.3497042,2.3381155 Z"
id="path2"
sodipodi:nodetypes="ccccccccccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="48"
height="48"
viewBox="0 0 12.7 12.7"
version="1.1"
id="svg1"
inkscape:version="1.4-beta (62f545ba5e, 2024-04-22)"
sodipodi:docname="sweecrypt.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#505050"
inkscape:document-units="mm"
inkscape:zoom="5.5731762"
inkscape:cx="6.5492277"
inkscape:cy="12.560163"
inkscape:window-width="1920"
inkscape:window-height="969"
inkscape:window-x="-8"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#006ee6;fill-opacity:1;stroke:#17ff20;stroke-width:0.246086;stroke-opacity:1"
id="rect1"
width="11.812121"
height="11.812121"
x="0.44393936"
y="0.44393936" />
<text
xml:space="preserve"
style="font-size:9.07594px;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;fill:#00e60b;fill-opacity:1;stroke:none;stroke-width:0.113449;stroke-opacity:1"
x="0.78183079"
y="7.7496824"
id="text1"><tspan
sodipodi:role="line"
id="tspan1"
style="fill:#00e60b;fill-opacity:1;stroke:none;stroke-width:0.113449"
x="0.78183079"
y="7.7496824">S</tspan></text>
<text
xml:space="preserve"
style="font-size:8.57156px;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;fill:#00e60b;fill-opacity:1;stroke:none;stroke-width:0.107145;stroke-opacity:1"
x="6.4419074"
y="10.492256"
id="text2"><tspan
sodipodi:role="line"
id="tspan2"
style="stroke-width:0.107145"
x="6.4419074"
y="10.492256">$</tspan></text>
<path
style="fill:#00e60b;fill-opacity:1;stroke:none;stroke-width:0.264583;stroke-opacity:1"
d="M 5.8868287,2.682305 7.5484334,3.6317935 7.4416158,2.9196771 7.7976741,2.9315458 7.9757032,3.9047715 7.1449009,4.4032529 7.0024776,4.1777494 7.4416158,3.9166399 5.6731938,2.9790203 5.7444053,3.5487133 5.4358215,3.6080564 5.3290042,2.6110935 6.1242007,2.0414004 6.3497042,2.3381155 Z"
id="path2"
sodipodi:nodetypes="ccccccccccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -1,39 +1,36 @@
#!/usr/bin/env python
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
#
# main.py
# Copyright (C) 2024 Swee
#
from gi.repository import Gtk, GdkPixbuf, Gdk
import os, sys
#Comment the first line and uncomment the second before installing
#or making the tarball (alternatively, use project variables)
from sweecrypt import encrypt, decrypt
UI_FILE = os.path.dirname(os.path.realpath(__file__)) + "/sweecrypt-gtk.ui"
#UI_FILE = "/usr/local/share/sweecrypt_gui/ui/sweecrypt_gui.ui"
class GUI:
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self)
window = self.builder.get_object('window')
window.show_all()
def on_window_destroy(self, window):
Gtk.main_quit()
def encode_toggle(self, encode):
active = encode.get_property("active")
print(f"Encode = {active}")
self.builder.get_object('decode').set_property("active", not active)
def decode_toggle(self, decode):
active = decode.get_property("active")
print(f"Decode = {active}")
self.builder.get_object('encode').set_property("active", not active)
def start_clicked(self, start):
print("Start clicked!")
encode = self.builder.get_object('encode').get_property("active")
inputted = self.builder.get_object('text').get_property("text")
if encode:
self.builder.get_object('text').set_property("text", encrypt(inputted))
self.builder.get_object('encode').set_property("active", False)
else:
self.builder.get_object('text').set_property("text", decrypt(inputted))
self.builder.get_object('decode').set_property("active", False)
def main():
app = GUI()
Gtk.main()
if __name__ == "__main__":
sys.exit(main())
sys.exit(main())

View file

@ -17,18 +17,25 @@
<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
you want to encode or decode.</property>
</object>
<object class="GtkWindow" id="window">
<property name="can-focus">False</property>
<property name="title" translatable="yes">SweeCrypt GTK</property>
<property name="icon-name">sweecrypt</property>
<signal name="destroy" handler="on_window_destroy" swapped="no"/>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkTextView">
<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>
<packing>
@ -38,13 +45,14 @@
</packing>
</child>
<child>
<object class="GtkToggleButton">
<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="encode_toggle" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -53,12 +61,13 @@
</packing>
</child>
<child>
<object class="GtkToggleButton">
<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>
@ -67,12 +76,13 @@
</packing>
</child>
<child>
<object class="GtkButton">
<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>

95
sweecrypt-gtk.ui~ Normal file
View file

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<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
you want to encode or decode.</property>
</object>
<object class="GtkWindow" id="window">
<property name="can-focus">False</property>
<property name="icon-name">sweecrypt</property>
<signal name="destroy" handler="on_window_destroy" swapped="no"/>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<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>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<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="encode_toggle" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</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="position">4</property>
</packing>
</child>
</object>
</child>
</object>
</interface>