diff --git a/.idea/h2inc.iml b/.idea/h2inc.iml new file mode 100644 index 0000000..1de84ce --- /dev/null +++ b/.idea/h2inc.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7ba73c2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0cc5137 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Gui test/h2inc.glade b/Gui test/h2inc.glade index d8e6c2b..b1f9dbe 100644 --- a/Gui test/h2inc.glade +++ b/Gui test/h2inc.glade @@ -2,12 +2,41 @@ - + + False + dialog + + + False + vertical + 2 + + + False + + + + + + + + + + + + False + False + 0 + + + + + + + + + False - 5 - 5 - 5 - 5 True @@ -17,6 +46,10 @@ True False + 5 + 5 + 5 + 5 0 etched-out @@ -33,6 +66,8 @@ True False end + 5 + 5 5 5 True @@ -60,14 +95,17 @@ - - Source directory... + + Select source directory... True True True start + 5 + 5 5 5 + 4 @@ -81,6 +119,8 @@ False False end + 5 + 5 5 5 True @@ -111,15 +151,18 @@ - - Destination directory... + + Select destination directory... True False True True start + 5 + 5 5 5 + 4 @@ -134,6 +177,8 @@ False True False + 5 + 5 5 5 0 @@ -154,6 +199,8 @@ True False + 5 + 5 Select folders @@ -169,6 +216,8 @@ True False False + 5 + 5 5 5 0 @@ -186,6 +235,8 @@ True False + 5 + 5 5 True 0 @@ -239,6 +290,8 @@ True False + 5 + 5 Source information @@ -267,6 +320,7 @@ True False + 5 5 5 0 @@ -300,6 +354,7 @@ True False + 5 5 5 @@ -317,6 +372,8 @@ True False + 5 + 5 Progress @@ -334,6 +391,8 @@ True False + 5 + 5 Translation diff --git a/Gui test/h2inc_gtk.py b/Gui test/h2inc_gtk.py new file mode 100644 index 0000000..290b100 --- /dev/null +++ b/Gui test/h2inc_gtk.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3.5 + +# You are free to use and/or change this code for +# your own needs. + +# Original code (c)2018 Jan Lerking +# Program to convert C-header (*.h) files to nasm include files (*.inc), +# for direct usage in assembly programming using nasm/yasm. + +import os +import sys +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk, Gio, GdkPixbuf + +class Handler: + + def on_window_destroy(self,window): + window.close() + + def on_dialog_close(self,widget,*event): + widget.hide_on_delete() + return True + + def on_filechooser_dialog_response(self,widget,response): + if response == -6: + print("Cancel") + elif response == -5: + print("File selection: %s" % widget.get_filename()) + self.on_dialog_close(widget) + + def on_filechooser_dialog_file_activated(self,widget): + self.on_filechooser_dialog_response(widget,-5) + + def on_filechooser_dialog_update_preview(self,widget): + if widget.get_filename() != None and os.path.isfile(widget.get_filename()): + pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(widget.get_filename(),200,200,True) + app.obj("preview").set_from_pixbuf(pixbuf) + + def on_file_button_clicked(self,widget): + app.obj("filechooser_dialog").show_all() + + def on_source_button_clicked(self,widget): + + dialog = Gtk.FileChooserDialog("Select source directory!", + app.obj("window"), + Gtk.FileChooserAction.SELECT_FOLDER, + (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + Gtk.STOCK_APPLY, Gtk.ResponseType.OK)) + dialog.set_default_size(600, 300) + + response = dialog.run() + if response == Gtk.ResponseType.OK: + print("Folder selection: %s" % dialog.get_filename()) + elif response == Gtk.ResponseType.CANCEL: + print("Cancel") + + dialog.destroy() + +class ExampleApp: + + def __init__(self): + + self.app = Gtk.Application.new("org.h2inc", Gio.ApplicationFlags(0)) + self.app.connect("activate", self.on_app_activate) + self.app.connect("shutdown", self.on_app_shutdown) + + def on_app_activate(self, app): + builder = Gtk.Builder() + #builder.add_from_file("16_filechooser.glade") + builder.add_from_file("h2inc.glade") + builder.connect_signals(Handler()) + + self.obj = builder.get_object + self.obj("window").set_application(app) + self.obj("window").set_wmclass("Filechooser example","Filechooser example") + self.obj("window").show_all() + + #add filters to filechooser dialog + self.obj("filefilter").set_name("Image files") + self.obj("filechooser_dialog").add_filter(self.obj("filefilter")) + self.obj("png_filter").set_name("PNG files") + self.obj("filechooser_dialog").add_filter(self.obj("png_filter")) + self.obj("jpg_filter").set_name("JPG files") + self.obj("filechooser_dialog").add_filter(self.obj("jpg_filter")) + + #add buttons to headerbar of Glade generated dialog + button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL) + button.set_property("can-default",True) + self.obj("filechooser_dialog").add_action_widget(button, Gtk.ResponseType.CANCEL) + button = Gtk.Button.new_from_stock(Gtk.STOCK_APPLY) + button.set_property("can-default",True) + self.obj("filechooser_dialog").add_action_widget(button, Gtk.ResponseType.OK) + + def on_app_shutdown(self, app): + self.app.quit() + + def run(self, argv): + self.app.run(argv) + +app = ExampleApp() +app.run(sys.argv)