From a098969f3eadcf505fbc621132e9df64082d2868 Mon Sep 17 00:00:00 2001 From: Jan Lerking Date: Tue, 27 Feb 2018 21:19:29 +0100 Subject: [PATCH] Updated h2inc_gtk.py, h2inc.glade --- Gui test/h2inc (copy).xml | 393 --------------------------------- Gui test/h2inc.glade | 2 +- Gui test/h2inc.glade~ | 213 +++++++++++++----- Gui test/h2inc_gtk.py | 41 ++-- Gui test/test.glade~ | 446 -------------------------------------- 5 files changed, 177 insertions(+), 918 deletions(-) delete mode 100644 Gui test/h2inc (copy).xml delete mode 100644 Gui test/test.glade~ diff --git a/Gui test/h2inc (copy).xml b/Gui test/h2inc (copy).xml deleted file mode 100644 index 4702fd7..0000000 --- a/Gui test/h2inc (copy).xml +++ /dev/null @@ -1,393 +0,0 @@ - - - - - - False - normal - select-folder - - - False - vertical - 2 - - - False - end - - - - - - - - - False - False - 0 - - - - - - - - - - False - 5 - 5 - 5 - 5 - - - True - False - - - True - False - 0 - etched-out - - - True - False - 12 - - - True - False - - - True - False - end - 5 - 5 - 5 - True - Source: - right - - - 0 - 0 - 2 - - - - - True - True - 5 - 5 - 5 - 5 - Select source directory! - - - 2 - 0 - 2 - - - - - Source directory... - True - True - True - start - 5 - 5 - 5 - 5 - - - 4 - 0 - 2 - - - - - True - False - False - end - 5 - 5 - 5 - True - Destination: - right - start - 2.2351741811588166e-10 - - - 0 - 1 - 2 - - - - - True - False - True - 5 - 5 - 5 - 5 - Select destination directory! - - - 2 - 1 - 2 - - - - - Destination directory... - True - False - True - True - start - 5 - 5 - 5 - 5 - - - 4 - 1 - 2 - - - - - Create "include" folder if it does not exist. - True - False - True - False - 5 - 5 - 0 - True - - - 0 - 2 - 6 - - - - - - - - - True - False - Select folders - - - - - 0 - 0 - 5 - - - - - True - False - False - 5 - 5 - 0 - etched-out - - - True - False - 12 - - - True - False - - - True - False - 5 - 5 - True - 0 - etched-out - - - True - False - 12 - - - True - False - vertical - - - True - False - start - 5 - 5 - True - Number of folders: 0 - - - False - True - 0 - - - - - True - False - start - 5 - 5 - Number of files: 0 - - - False - True - 1 - - - - - - - - - True - False - Source information - - - - - 0 - 0 - - - - - Translate! - True - True - True - start - 5 - 5 - - - 0 - 1 - - - - - True - False - 5 - 5 - 5 - 0 - etched-out - - - True - False - 12 - - - True - False - vertical - - - True - False - start - 5 - 5 - Total progress: - - - False - True - 0 - - - - - True - False - 5 - 5 - 5 - - - False - True - 1 - - - - - - - - - True - False - Progress - - - - - 0 - 2 - - - - - - - - - True - False - Translation - - - - - 0 - 1 - 5 - - - - - - diff --git a/Gui test/h2inc.glade b/Gui test/h2inc.glade index 128c53f..d6b0cad 100644 --- a/Gui test/h2inc.glade +++ b/Gui test/h2inc.glade @@ -182,8 +182,8 @@ 5 5 0 - True True + 0 diff --git a/Gui test/h2inc.glade~ b/Gui test/h2inc.glade~ index ad6a6e9..65decf7 100644 --- a/Gui test/h2inc.glade~ +++ b/Gui test/h2inc.glade~ @@ -2,26 +2,54 @@ - + + False + dialog + + + False + vertical + 2 + + + False + + + + + + + + + + + + False + False + 0 + + + + + + + + + False - 5 - 5 - 5 - 5 - + True False - 5 - 5 - 5 - 5 - True - True + vertical True False + 5 + 5 + 5 + 5 0 etched-out @@ -34,10 +62,11 @@ True False - + True False end + 5 5 5 5 @@ -52,11 +81,9 @@ - + True True - 5 - 5 5 5 Select source directory! @@ -68,8 +95,8 @@ - - Source directory... + + Select source directory... True True True @@ -78,6 +105,7 @@ 5 5 5 + 4 @@ -86,11 +114,12 @@ - + True False False end + 5 5 5 5 @@ -107,12 +136,10 @@ - + True False True - 5 - 5 5 5 Select destination directory! @@ -124,8 +151,8 @@ - - Destination directory... + + Select destination directory... True False True @@ -135,6 +162,7 @@ 5 5 5 + 4 @@ -143,16 +171,20 @@ - + Create "include" folder if it does not exist. True False True False + 5 + 5 5 5 0 + True True + 0 @@ -168,21 +200,25 @@ True False + 5 + 5 Select folders - 0 - 0 - 5 + False + True + 0 - + True False False + 5 + 5 5 5 0 @@ -201,6 +237,7 @@ True False 5 + 5 5 True 0 @@ -211,19 +248,38 @@ False 12 - + True False vertical - + True False - start - 5 - 5 - True - Number of folders: 0 + + + True + False + 5 + 5 + Number of folders: + + + 0 + 0 + + + + + True + False + 0 + + + 1 + 0 + + False @@ -232,13 +288,33 @@ - + True False - start - 5 - 5 - Number of files: 0 + + + True + False + 5 + 5 + Number of files: + + + 0 + 0 + + + + + True + False + 0 + + + 1 + 0 + + False @@ -254,6 +330,8 @@ True False + 5 + 5 Source information @@ -264,7 +342,7 @@ - + Translate! True True @@ -272,6 +350,7 @@ start 5 5 + 0 @@ -293,37 +372,49 @@ False 12 - + True False - vertical + True - + True False start - 5 - 5 - Total progress: + False + Total progress: - False - True - 0 + 0 + 0 - + + True + False + start + True + 0 of 0 + + + 1 + 0 + + + + True False 5 5 5 + True - False - True - 1 + 0 + 1 + 2 @@ -331,9 +422,11 @@ - + True False + 5 + 5 Progress @@ -351,14 +444,16 @@ True False + 5 + 5 Translation - 0 - 1 - 5 + False + True + 1 diff --git a/Gui test/h2inc_gtk.py b/Gui test/h2inc_gtk.py index c6bf56b..43b5be5 100644 --- a/Gui test/h2inc_gtk.py +++ b/Gui test/h2inc_gtk.py @@ -73,6 +73,7 @@ destdir = '' #num_cores = multiprocessing.cpu_count() fileindex = 0 filecnt = 0 +incinc = False def sourcedir_filecnt(sourcedir): ### Return the number of files, ending with '.h', in sourcedir - including subdirectories ### @@ -159,7 +160,7 @@ class ExampleApp: global destlabel def __init__(self): - + self.filecnt = 0 self.fileindex = 0 self.process = None @@ -169,6 +170,7 @@ class ExampleApp: app = self.app def on_app_activate(self, app): + builder = Gtk.Builder() builder.add_from_file("h2inc.glade") builder.connect_signals(self) @@ -177,13 +179,12 @@ class ExampleApp: self.obj("window").set_application(app) self.obj("window").set_wmclass("h2inc_gtk","h2inc_gtk") self.obj("window").show_all() + self.obj("include_checkbutton").set_active(True) 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() @@ -194,7 +195,6 @@ class ExampleApp: def callbackDisplay(self, obj, fraction, text, index, data=None): self.obj("progress_label").set_text("{} of {}".format(index+1, self.filecnt)) self.obj("progressbar").set_fraction(fraction) - self.obj("progressbar").set_text(text) def callbackFinished(self, obj, data=None): if self.process==None: @@ -204,7 +204,6 @@ class ExampleApp: self.process = None self.obj("progressbar").set_fraction(1.0) - self.obj("progressbar").set_text("done") self.obj("sourceframe").set_sensitive(True) self.obj("translate_button").set_sensitive(True) self.obj("destination_label").set_sensitive(True) @@ -230,7 +229,7 @@ class ExampleApp: def on_source_button_clicked(self,widget): dialog = Gtk.FileChooserDialog("Select source directory!", - app.obj("window"), + self.obj("window"), Gtk.FileChooserAction.SELECT_FOLDER, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_APPLY, Gtk.ResponseType.OK)) @@ -241,15 +240,15 @@ class ExampleApp: self.filecnt = sourcedir_filecnt(dialog.get_filename()) if self.filecnt >0: print(self.filecnt) - 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) - app.obj("numfiles_label").set_text(str(self.filecnt)) - app.obj("progress_label").set_text("{} of {}".format(fileindex, self.filecnt)) + self.obj("source_entry").set_text(dialog.get_filename()) + self.obj("destination_label").set_sensitive(True) + self.obj("destination_entry").set_sensitive(True) + self.obj("destination_button").set_sensitive(True) + self.obj("numfiles_label").set_text(str(self.filecnt)) + self.obj("progress_label").set_text("{} of {}".format(fileindex, self.filecnt)) foldercnt = sourcedir_foldercnt(dialog.get_filename()) if foldercnt >0: - app.obj("numfolders_label").set_text(str(foldercnt)) + self.obj("numfolders_label").set_text(str(foldercnt)) elif response == Gtk.ResponseType.CANCEL: print("Cancel") @@ -259,7 +258,7 @@ class ExampleApp: global destdir dialog = Gtk.FileChooserDialog("Select destination directory!", - app.obj("window"), + self.obj("window"), Gtk.FileChooserAction.SELECT_FOLDER, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_APPLY, Gtk.ResponseType.OK)) @@ -268,9 +267,9 @@ class ExampleApp: 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) - app.obj("translation_frame").set_sensitive(True) + self.obj("destination_entry").set_text(dialog.get_filename()) + self.obj("include_checkbutton").set_sensitive(True) + self.obj("translation_frame").set_sensitive(True) print(srcdir) print(destdir) elif response == Gtk.ResponseType.CANCEL: @@ -278,9 +277,13 @@ class ExampleApp: dialog.destroy() + def on_include_checkbutton_toggled(self, widget): + global incinc + incinc = self.obj("include_checkbutton").get_active() + def on_translate_button_clicked(self, widget, data=None): - app.obj("sourceframe").set_sensitive(False) - app.obj("translate_button").set_sensitive(False) + self.obj("sourceframe").set_sensitive(False) + self.obj("translate_button").set_sensitive(False) if self.process!=None: return diff --git a/Gui test/test.glade~ b/Gui test/test.glade~ deleted file mode 100644 index a48e0df..0000000 --- a/Gui test/test.glade~ +++ /dev/null @@ -1,446 +0,0 @@ - - - - - - False - dialog - select-folder - - - False - vertical - 2 - - - False - end - - - gtk-ok - True - True - True - True - True - - - True - True - 0 - - - - - gtk-cancel - True - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - - - - - button4 - button5 - - - - False - - - True - False - vertical - - - True - False - 5 - 5 - 5 - 0 - etched-out - - - True - False - 12 - - - True - False - - - True - False - end - 5 - 5 - 5 - Source: - start - - - 0 - 0 - - - - - True - False - False - end - 5 - 5 - 5 - Destination: - 0.059999999999999998 - - - 0 - 1 - - - - - True - True - 5 - 5 - - - 1 - 0 - - - - - True - False - True - 5 - 5 - - - 1 - 1 - - - - - Select source directory... - True - True - True - start - 5 - 5 - 5 - 0.52999997138977051 - - - - 2 - 0 - - - - - Select destination directory... - True - False - True - True - start - 5 - 10 - 5 - 5 - - - - 2 - 1 - - - - - checkbutton - True - False - True - False - 0 - 0.47999998927116394 - True - True - - - 0 - 2 - 3 - - - - - - - - - True - False - Select folders - - - - - True - True - 0 - - - - - True - False - False - 5 - 5 - 5 - 0 - etched-out - - - True - False - 12 - - - True - False - vertical - - - True - False - 10 - 5 - 0 - etched-out - - - True - False - 12 - - - True - False - - - True - False - end - 5 - Number of folders: - - - 0 - 0 - - - - - True - False - 0.98999999999999999 - start - 5 - 0 - end - - - 1 - 0 - - - - - True - False - end - 5 - 5 - Number of files: - - - 0 - 1 - - - - - True - False - start - 5 - 5 - 0 - - - 1 - 1 - - - - - - - - - True - False - Source information - - - - - False - True - 0 - - - - - Translate! - True - True - True - start - 5 - 5 - - - False - False - 1 - - - - - True - False - 10 - 5 - 0 - etched-out - - - True - False - 12 - - - True - False - - - True - False - end - 5 - 5 - Total progress: - - - 0 - 0 - - - - - True - False - start - 5 - 5 - True - 0 of 0 - - - 1 - 0 - - - - - True - False - 10 - 5 - - - 0 - 1 - 2 - - - - - - - - - True - False - Progress - - - - - False - True - 2 - - - - - - - - - True - False - Translation! - - - - - True - True - 1 - - - - - -