~martijnbraam/thumbdrives

58f44d4fc628a449d221ff38a3d64a8df7db380c — Martijn Braam 2 years ago 9500cf5
Cleanup
2 files changed, 10 insertions(+), 5 deletions(-)

M src/pk-thumbdrive-action.sh
M src/window.py
M src/pk-thumbdrive-action.sh => src/pk-thumbdrive-action.sh +5 -2
@@ 53,6 53,8 @@ disable_existing_gadgets () {

create_gadget () {
	local backing="$1"
	local devtype="$2"

	mkdir $GADGET
	echo "0x1209" > $GADGET/idVendor # Generic
	echo "0x4202" > $GADGET/idProduct # Random id


@@ 79,6 81,7 @@ create_gadget () {

	# Link mass storage gadget to backing file
	echo $backing > $LUN/file
	echo $devtype > $LUN/cdrom

	# Mass storage hardware name
	echo "Thumbdrives" > $LUN/inquiry_string


@@ 96,7 99,7 @@ then

	[ -d $GADGET ] && remove_gadget $GADGET
	disable_existing_gadgets
	create_gadget "$BACKING_FILE"
	create_gadget "$BACKING_FILE" "0"
fi

if [ "$ACTION" = "mount-iso" ]


@@ 104,7 107,7 @@ then

	[ -d $GADGET ] && remove_gadget $GADGET
	disable_existing_gadgets
	create_gadget "$BACKING_FILE"
	create_gadget "$BACKING_FILE" "1"
fi

if [ "$ACTION" = "umount" ]

M src/window.py => src/window.py +5 -3
@@ 60,6 60,8 @@ class ThumbdrivesWindow(Gtk.ApplicationWindow):
        for iso in datadir.glob('*.iso'):
            self.add_iso(iso)

        self.update_mounted()

        self.thumbdrive_list.show_all()
        self.iso_list.show_all()



@@ 83,14 85,14 @@ class ThumbdrivesWindow(Gtk.ApplicationWindow):
        box.filename = str(path)
        self.iso_list.insert(box, -1)

    def update_mounted():
    def update_mounted(self):
        filename = vdisk.get_mounted()
        if filename is None:
            self.headerbar.set_subtitle("No drive mounted")
        else:
            self.headerbar.set_subtitle(filename)
            self.headerbar.set_subtitle("Loaded " + os.path.basename(filename))

    @Gtk.Template.Callback
    @Gtk.Template.Callback()
    def on_image_row_activated(self, listbox, row):
        box = row.get_child()
        filename = box.filename