updated h2inc_gtk.py and h2inc.glade
This commit is contained in:
@@ -252,7 +252,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label6">
|
||||
<object class="GtkLabel" id="numfolders_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
@@ -268,7 +268,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label7">
|
||||
<object class="GtkLabel" id="numfiles_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
@@ -369,7 +369,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label8">
|
||||
<object class="GtkLabel" id="progress_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user