diff --git a/Gui test/h2inc.glade b/Gui test/h2inc.glade
index 920ffb5..8db104c 100644
--- a/Gui test/h2inc.glade
+++ b/Gui test/h2inc.glade
@@ -252,7 +252,7 @@
False
vertical
-
-
+
True
False
start
@@ -369,7 +369,7 @@
-
+
True
False
5
diff --git a/Gui test/h2inc_gtk.py b/Gui test/h2inc_gtk.py
index c2eb4d2..262a0cb 100644
--- a/Gui test/h2inc_gtk.py
+++ b/Gui test/h2inc_gtk.py
@@ -24,7 +24,6 @@ sourcedir = ''
destdir = ''
num_cores = mp.cpu_count()
-
def sourcedir_filecnt(sourcedir):
### Return the number of files, ending with '.h', in sourcedir - including subdirectories ###
cnt = 0
@@ -158,15 +157,29 @@ class Handler:
cnt = sourcedir_filecnt(dialog.get_filename())
if cnt >0:
print(cnt)
- builder = Gtk.Builder()
- builder.add_from_file("h2inc.glade")
- obj = builder.get_object
- obj("destination_label").set_sensitive(True)
- obj("destination_entry").set_sensitive(True)
- obj("destination_button").set_sensitive(True)
- obj("include_checkbutton").set_sensitive(True)
- while Gtk.events_pending():
- Gtk.main_iteration()
+ app.obj("source_entry").set_text(dialog.get_filename())
+ app.obj("destination_label").set_sensitive(True)
+ app.obj("destination_entry").set_sensitive(True)
+ app.obj("destination_button").set_sensitive(True)
+ elif response == Gtk.ResponseType.CANCEL:
+ print("Cancel")
+
+ dialog.destroy()
+
+ def on_destination_button_clicked(self,widget):
+
+ dialog = Gtk.FileChooserDialog("Select destination 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:
+ destdir = dialog.get_filename()
+ app.obj("destination_entry").set_text(dialog.get_filename())
+ app.obj("include_checkbutton").set_sensitive(True)
elif response == Gtk.ResponseType.CANCEL:
print("Cancel")
@@ -174,24 +187,26 @@ class Handler:
class ExampleApp:
+ global app
+ global destlabel
+
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)
+ app = self.app
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").set_wmclass("h2inc_gtk","h2inc_gtk")
self.obj("window").show_all()
- #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)