update h2inc.glade
This commit is contained in:
12
.idea/h2inc.iml
generated
Normal file
12
.idea/h2inc.iml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
<option name="projectConfiguration" value="Twisted Trial" />
|
||||
<option name="PROJECT_TEST_RUNNER" value="Twisted Trial" />
|
||||
</component>
|
||||
</module>
|
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/h2inc.iml" filepath="$PROJECT_DIR$/.idea/h2inc.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@@ -2,12 +2,41 @@
|
||||
<!-- Generated with glade 3.18.3 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.12"/>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<object class="GtkFileChooserDialog" id="filechooserdialog1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="fcbox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox" id="filechooserdialog-action_area1">
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkApplicationWindow" id="window">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
@@ -17,6 +46,10 @@
|
||||
<object class="GtkFrame" id="sourceframe">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">etched-out</property>
|
||||
<child>
|
||||
@@ -33,6 +66,8 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="hexpand">True</property>
|
||||
@@ -60,14 +95,17 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label" translatable="yes">Source directory...</property>
|
||||
<object class="GtkButton" id="source_button">
|
||||
<property name="label" translatable="yes">Select source directory...</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<signal name="clicked" handler="on_source_button_clicked" after="yes" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">4</property>
|
||||
@@ -81,6 +119,8 @@
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="hexpand">True</property>
|
||||
@@ -111,15 +151,18 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="label" translatable="yes">Destination directory...</property>
|
||||
<object class="GtkButton" id="destination_button">
|
||||
<property name="label" translatable="yes">Select destination directory...</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<signal name="clicked" handler="on_destination_button_clicked" after="yes" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">4</property>
|
||||
@@ -134,6 +177,8 @@
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="xalign">0</property>
|
||||
@@ -154,6 +199,8 @@
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="label" translatable="yes">Select folders</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -169,6 +216,8 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="label_xalign">0</property>
|
||||
@@ -186,6 +235,8 @@
|
||||
<object class="GtkFrame" id="frame2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="label_xalign">0</property>
|
||||
@@ -239,6 +290,8 @@
|
||||
<object class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="label" translatable="yes">Source information</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -267,6 +320,7 @@
|
||||
<object class="GtkFrame" id="frame3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="label_xalign">0</property>
|
||||
@@ -300,6 +354,7 @@
|
||||
<object class="GtkProgressBar" id="progressbar1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
</object>
|
||||
@@ -317,6 +372,8 @@
|
||||
<object class="GtkLabel" id="label8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="label" translatable="yes">Progress</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -334,6 +391,8 @@
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="label" translatable="yes">Translation</property>
|
||||
</object>
|
||||
</child>
|
||||
|
102
Gui test/h2inc_gtk.py
Normal file
102
Gui test/h2inc_gtk.py
Normal file
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env python3.5
|
||||
|
||||
# You are free to use and/or change this code for
|
||||
# your own needs.
|
||||
|
||||
# Original code (c)2018 Jan Lerking
|
||||
# Program to convert C-header (*.h) files to nasm include files (*.inc),
|
||||
# for direct usage in assembly programming using nasm/yasm.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, Gio, GdkPixbuf
|
||||
|
||||
class Handler:
|
||||
|
||||
def on_window_destroy(self,window):
|
||||
window.close()
|
||||
|
||||
def on_dialog_close(self,widget,*event):
|
||||
widget.hide_on_delete()
|
||||
return True
|
||||
|
||||
def on_filechooser_dialog_response(self,widget,response):
|
||||
if response == -6:
|
||||
print("Cancel")
|
||||
elif response == -5:
|
||||
print("File selection: %s" % widget.get_filename())
|
||||
self.on_dialog_close(widget)
|
||||
|
||||
def on_filechooser_dialog_file_activated(self,widget):
|
||||
self.on_filechooser_dialog_response(widget,-5)
|
||||
|
||||
def on_filechooser_dialog_update_preview(self,widget):
|
||||
if widget.get_filename() != None and os.path.isfile(widget.get_filename()):
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(widget.get_filename(),200,200,True)
|
||||
app.obj("preview").set_from_pixbuf(pixbuf)
|
||||
|
||||
def on_file_button_clicked(self,widget):
|
||||
app.obj("filechooser_dialog").show_all()
|
||||
|
||||
def on_source_button_clicked(self,widget):
|
||||
|
||||
dialog = Gtk.FileChooserDialog("Select source 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:
|
||||
print("Folder selection: %s" % dialog.get_filename())
|
||||
elif response == Gtk.ResponseType.CANCEL:
|
||||
print("Cancel")
|
||||
|
||||
dialog.destroy()
|
||||
|
||||
class ExampleApp:
|
||||
|
||||
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)
|
||||
|
||||
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").show_all()
|
||||
|
||||
#add filters to filechooser dialog
|
||||
self.obj("filefilter").set_name("Image files")
|
||||
self.obj("filechooser_dialog").add_filter(self.obj("filefilter"))
|
||||
self.obj("png_filter").set_name("PNG files")
|
||||
self.obj("filechooser_dialog").add_filter(self.obj("png_filter"))
|
||||
self.obj("jpg_filter").set_name("JPG files")
|
||||
self.obj("filechooser_dialog").add_filter(self.obj("jpg_filter"))
|
||||
|
||||
#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)
|
||||
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()
|
||||
|
||||
def run(self, argv):
|
||||
self.app.run(argv)
|
||||
|
||||
app = ExampleApp()
|
||||
app.run(sys.argv)
|
Reference in New Issue
Block a user