Updated h2inc_gtk.py
This commit is contained in:
@@ -86,7 +86,6 @@
|
||||
<property name="can_focus">True</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="text" translatable="yes">/usr/include</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
@@ -142,7 +141,6 @@
|
||||
<property name="can_focus">True</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="text" translatable="yes">~/include</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
|
@@ -73,8 +73,10 @@ destdir = ''
|
||||
#num_cores = multiprocessing.cpu_count()
|
||||
fileindex = 0
|
||||
filecnt = 0
|
||||
incinc = False
|
||||
incinc = ''
|
||||
defdir = False
|
||||
defsrc = 'usr/include'
|
||||
defdest = '~'
|
||||
|
||||
def sourcedir_filecnt(sourcedir):
|
||||
### Return the number of files, ending with '.h', in sourcedir - including subdirectories ###
|
||||
@@ -181,7 +183,9 @@ class ExampleApp:
|
||||
self.obj("window").set_wmclass("h2inc_gtk","h2inc_gtk")
|
||||
self.obj("window").show_all()
|
||||
self.obj("default_dir_checkbutton").set_active(False)
|
||||
self.obj("default_dir_checkbutton").emit("toggled")
|
||||
self.obj("include_checkbutton").set_active(True)
|
||||
self.obj("include_checkbutton").emit("toggled")
|
||||
|
||||
button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
|
||||
button.set_property("can-default",True)
|
||||
@@ -236,6 +240,7 @@ class ExampleApp:
|
||||
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_APPLY, Gtk.ResponseType.OK))
|
||||
dialog.set_default_size(600, 300)
|
||||
Gtk.FileChooser.set_filename(dialog, srcdir)
|
||||
|
||||
response = dialog.run()
|
||||
if response == Gtk.ResponseType.OK:
|
||||
@@ -258,6 +263,7 @@ class ExampleApp:
|
||||
|
||||
def on_destination_button_clicked(self,widget):
|
||||
global destdir
|
||||
global incinc
|
||||
|
||||
dialog = Gtk.FileChooserDialog("Select destination directory!",
|
||||
self.obj("window"),
|
||||
@@ -273,6 +279,9 @@ class ExampleApp:
|
||||
self.obj("include_checkbutton").set_sensitive(True)
|
||||
self.obj("translation_frame").set_sensitive(True)
|
||||
print(srcdir)
|
||||
if self.obj("include_checkbutton").get_active() == True:
|
||||
incinc = '/include'
|
||||
destdir = destdir+incinc
|
||||
print(destdir)
|
||||
elif response == Gtk.ResponseType.CANCEL:
|
||||
print("Cancel")
|
||||
@@ -280,12 +289,39 @@ class ExampleApp:
|
||||
dialog.destroy()
|
||||
|
||||
def on_include_checkbutton_toggled(self, widget):
|
||||
global destdir
|
||||
global incinc
|
||||
incinc = self.obj("include_checkbutton").get_active()
|
||||
if self.obj("include_checkbutton").get_active() == True:
|
||||
incinc = '/include'
|
||||
destdir = destdir+incinc
|
||||
if self.obj("include_checkbutton").get_active() == False:
|
||||
incinc = ''
|
||||
destdir = destdir.replace('/include', '')
|
||||
self.obj("destination_entry").set_text(destdir)
|
||||
print(destdir)
|
||||
|
||||
def on_default_dir_checkbutton_toggled(self, widget):
|
||||
global defdir
|
||||
global srcdir
|
||||
global destdir
|
||||
global incinc
|
||||
defdir = self.obj("default_dir_checkbutton").get_active()
|
||||
if defdir == True:
|
||||
srcdir = defsrc
|
||||
self.obj("source_entry").set_text(srcdir)
|
||||
destdir = defdest+incinc
|
||||
self.obj("destination_entry").set_text(destdir)
|
||||
self.obj("include_checkbutton").set_sensitive(True)
|
||||
self.obj("source_label").set_sensitive(False)
|
||||
self.obj("source_entry").set_sensitive(False)
|
||||
self.obj("source_button").set_sensitive(False)
|
||||
self.obj("translation_frame").set_sensitive(True)
|
||||
filecnt = sourcedir_filecnt(defsrc)
|
||||
if filecnt >0:
|
||||
print(filecnt)
|
||||
foldercnt = sourcedir_foldercnt(defsrc)
|
||||
if foldercnt >0:
|
||||
self.obj("numfolders_label").set_text(str(foldercnt))
|
||||
|
||||
def on_translate_button_clicked(self, widget, data=None):
|
||||
self.obj("sourceframe").set_sensitive(False)
|
||||
|
Reference in New Issue
Block a user