Converting GTK 1.2 glade XML file to something glade can now read - gtk3

In old project I wrote circa 2000 I have a glade file that I would like to convert to something glade can now read, and I will use in PyGtk. I have scoured SO for similar questions and see things for the code changes, but I am just interested right now in converting the glade file.
When I run gtk-builder-convert I get Python traceback:
Traceback (most recent call last):
File "/usr/bin/gtk-builder-convert", line 799, in <module>
sys.exit(main(sys.argv))
File "/usr/bin/gtk-builder-convert", line 787, in main
conv.parse_file(input_filename)
File "/usr/bin/gtk-builder-convert", line 162, in parse_file
self._parse()
File "/usr/bin/gtk-builder-convert", line 234, in _parse
assert glade_iface, ("Badly formed XML, there is "
AssertionError: Badly formed XML, there is no <glade-interface> tag.
which is indeed true. The file starts:
<?xml version="1.0"?>
<GTK-Interface>
Suggestions?

If your XML file starts with GTK-Interface then it means it you were using GTK+ 1.2.
It's very unlikely you can mechanically transform such an old Glade file into something that can be used with modern API — even if you constrain yourself to the legacy 2.0 version of the GTK+ API. Your UI description will contain deprecated properties, signals, and classes — and there is no direct, 1:1 mapping for those.
The last time the XML format for the UI definition was changed was 2007, with the introduction of GtkBuilder, but the format was heavily based on the Glade XML for GTK+ 2.0, to the point that a simple mechanical script like gtk-builder-convert could transform the older format into the new one. Your XML predates even that.

Thanks to the information from ebassi, what I wound up doing is running libglade-convert to get this to gtk 2.0 and then gtk-builder-convert to go the rest of the way. Of course there were lots of errors and it is imperfect, but its a start.

It worked on Linux for me using Gtk3+ and Glade3+ installed from conda by following steps.
Open your Gtk1+ older glade XML file designed in Glade1+ user interface in Glade3+ user interface.
Click on Save button in Glade3+ user interface.
Open terminal to conda activate gtk-builder-convert infile outfile.
Good Luck!

Related

Is there a way to use Microsoft Word Save as -> html from command line or python?

I am trying to automate an existing process that uses html files produced from docx for post-treatment.
I know Word is producing a lot of garbage while converting to html, and I have already tested Mammoth https://github.com/mwilliamson/mammoth.js/, but the process using the html file as input is designed to support the html format from Word and I cannot touch that process.
My question is: is there a way to call the Save As -> html in Word from command line or eventually in Python? Something similar to what exists in OpenOffice with:
soffice --convert-to html:HTML
I know also about win32com, but this package exists only in Pythong for Windows, not for Mac, or eventually on other platforms as Linux.

Can VSCode display a binary file if there is an executable that will convert it to an equivalent text file?

I sometimes use VSCode for a Delphi 7 project because I like VSCode's git functionality and for a few other reasons (superior string search, diff, etc).
Delphi 7 is a pain, and to get it to consistently compile I need to convert the dfm files to their binary version (all 2300 of them). This of course makes them unviewable in the diff viewer, or to just open the file?
Is there a setting where if I open that file, it will first pass it through the convert.exe (that's its actual name) util so that it can be viewed as a text? I understand that this might be read-only, which would be sufficient to my needs (though if on save it could just pass it back through, that'd be great too).
I'm having trouble figuring out what exactly to to search for on Google (the keywords seem too generic), but I can imagine some generalized functionality that would work for other environments beyond just Delphi/pascal.

OmegaT: How to import already translated files?

My team has been using Notepad for translation purposes so far. Recently, we decided to use one of the CAT tools available on the Internet - OmegaT.
We've got source and manually translated files, and only values were ever touched.
Is it possible to import both to the same project, so that source phrases stay source, and our phrases become their translated counterparts?
Note: I don't know if it matters, but files are formatted as INI (key=value).
What you need is an alignment. It takes source and target files and creates a translation memory.
In your specific case (INI files), you can use OmegaT to do an automatic alignment with a command line:
http://omegat.sourceforge.net/manual-standard/en/chapter.installing.and.running.html#omegat.command.arguments
Sample command line:
java -jar OmegaT.jar "C:\OmegaTProject" --mode=console-align --alignDir="C:\OmegaTProject\align"
For more general purposes, and with a GUI, there's a prototype version of OmegaT with an aligner:
https://omegat.ci.cloudbees.com/job/omegat-prototype/26/
See the OmegaT development mailing list for information about this.
Didier
With currently Beta version of 4.* releases (currently 4.1.5), you can use nice visual aligner - https://www.proz.com/forum/omegat_support/306343-new_interactive_aligner_in_omegat.html

How to load a matlab file (.mat) in windows if it was originally saved in UNIX

I'm trying to open a .mat file in the windows environment but it is failing. It was created in a Unix environment. Also note that this file was first put in a .tar file first, ftp via binary method. The file opens in Unix and I don't think it was corrupted in any way.
The *.mat file format is platform agnostic. The OS does not matter.
There are a number of variants of the *.mat file which have been used, and older versions cannot always read formats saved with newer versions. You can save to an older version using flags available in the save command. These formats have been updated as the Matlab feature set has demanded a more flexible file format, and as other technologies have advanced, most notably HDF5 in the recent version.
Finally, the save command supports an ASCII formatted option. I suspect this is your current problem, based on your comment regarding the error message received.
To address your current problem:
First, check to see if the file is an ASCII file. The easiest way is to simply open it in notepat, wordpad, or even the matlab editor. If the file is text, then this becomes a file parsing problem, and the appropriate use of fscanf shoudl fix the problem.
If the file is actually a binary *.mat file then you probably have a Matlab version incompatability. Yuo can either go back to the source unix environment and save to an older version (eg save .... -v7) or update the Matlab version of the reading computer.

WCAT report.xsl invalid

WCAT from Microsoft is as simple as it promises to be. Running it on Windows 7 x64 is not that straight forward though. The included script file breaks and the XML transformation for the output summary also uses MS-only features.
You can still look at a formatted version of the log.xml using Internet Explorer 9, hitting F12 for the developer features and enable Browser Mode:"Compatibility View". This will allow the xsl transformation, which will not work anywhere else, as other browser complain about some invalid functions and syntax.
If you have Visual Studio installed, you can also use it to apply the XSLT.
In Visual Studio 2012:
Ensure that the XML file that WCAT created (log.xml) and the XSLT file (report.xsl) are in the same directory.
Open the XML file.
In VS2012, click on the XML menu > Start XSLT Debugging (or Start XSLT Without Debugging).
Wait a few seconds for the result html file to be generated.
As an aside...
Remember that the1 WCAT 6.3 report.xsl file has some bugs/typos in it.
The report.xsl causes the the following errors when you transform with it:
Variable 'i' has not been declared (line: 52, column: 13)
The variable or parameter 'rowId' is either not defined or it is out of scope. (line: 1182, column: 37)
The variable or par
You can fix this manually (reference):
Cut the code on lines 1151-1157 and paste it on line 1146.
On line 51 add: var i=0;
Solution for WCAT 6.4.0:
Cut the code on lines 1259-1265 and paste it on line 1293
On line 53 add: var i=0
Valid report.xsl:
https://www.dropbox.com/s/avyuyc6bxzt5k6x/report.xsl?dl=0
I had the same issue, after which i went through the xsl file and fixed the code.
Unfortunatelly IE was still not displaying it correctly, however in Inspect Element the DOM seems to appear fine. So you need to save that into a HTML file and it should look fine after that.
I use WCAT frequently and found that opening the log.xml file in IETester is reliable as you can select the IE8 rendering engine to consistently view the formatted report. No need to edit the xsl or find another viewer after IE upgrades.
i have opened result.xsl in studio, start debugging, defined the 'result'.xml as input and start debugging.
you will get 3 errors. all simple to fix.
1) add a 'var' before the i in a loop
2) remove the $ in the two other error lines
works after that change