Updated h2inc_gtk.py, h2inc.glade
This commit is contained in:
+22
-19
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user