vmagnin / gtk-fortran

A GTK / Fortran binding. The documentation is in the Wiki tab.
GNU General Public License v3.0
252 stars 43 forks source link

GtkBuilder-Fortran code sketcher #13

Closed bonanza closed 11 years ago

bonanza commented 13 years ago

I started to write an GtkBuilder example which uses a XML file created by Glade to construct the GUI (will be commited in the next days). However, I found an interesting sketcher application, which creates Freebasic raw code from a Glade XML file (http://www.freebasic.net/forum/viewtopic.php?t=14856), where only the code in the handler functions have to be added by the programmer. Should be not very difficult to do the same thing with Fortran (programmed in Fortran or Python?). Maybe this is another interesting way to allow more rapid application development with gtk-fortran.

vmagnin commented 13 years ago

See also https://launchpad.net/gladex/

"Gladex is a Python application which takes a .glade file written in the Glade User Interface Builder and generates code in Perl, Python, or Ruby. The generated code uses libglade to draw a GUI and is not raw pygtk code. Support for additional languages can be added through the plugin API."

bonanza commented 13 years ago

I think, using Gladex is not a good idea since it is using libglade, which is deprecated (http://mail.gnome.org/archives/devel-announce-list/2009-May/msg00003.html). Furthermore, Gladex seems not to support further expansion or reviews of the GUI-XML-file like GTK+tobac2, which is imho an important point for larger projects.

bonanza commented 13 years ago

I pushed a draft version of a sketcher to the gtk3 branch. However, I think this will not work with windows since the system commands mkdir and cp are used in the current version. I think, this stuff can be replaced by platform independent calls to functions of the flibs collection (http://flibs.sourceforge.net/m_vfile.html). Any other ideas?

vmagnin commented 13 years ago

Perhaps you may find some solutions in the GLib:

http://developer.gnome.org/glib/unstable/glib-File-Utilities.html#g-mkdir-with-parents http://developer.gnome.org/glib/unstable/glib-File-Utilities.html#g-mkdir (only the first seems to be in gtk-fortran)

I found no "cp"-like function.

vmagnin commented 13 years ago

Nice piece of code ! I tried it under Ubuntu 11.04 - 32 bits with the example.glade file: the only little problem is that it did not succeed copying example.glade in the example directory. Perhaps because there is a space in one of the directory name in my working dir path.

jtappin commented 13 years ago

One issue I did notice was that if I try to open a second file, there is a runtime error at line 244 because connections is already allocated.

bonanza commented 13 years ago

I fixed the allocation issue and pushed a new version without system calls to the gtk3 branch. However, I tried to use the glib function g_file_get_contents to implement system independent file copy (Indeed there is no one-call-routine for file copy in glib). Unfortunately, I got this not to work (I obtained strange characters in "contents") and the current version is now using standard fortran file access routines. Did anyone ever tried the g_file_get_contents function?

bonanza commented 13 years ago

I tried also to reproduce the copy error using a directory with a blank in the name. On my system this works well, at least with the current version.

vmagnin commented 13 years ago

Hi Jens, the copy error has disappeared... It now works fine.

jtappin commented 13 years ago

Hi Jens, In the newest version, there are a number of places in gtkf-sketcher.glade where the line:

<property name="ubuntu_local">True</property>

occurs. However since this is not portable, on Debian Sid it generates a warning:

Gtk-WARNING **: Unknown property: GtkMenuBar.ubuntu-local

(or similar depending on the widget), I'd suggest removing it or finding a system-independent equivalent.

P.S. I've added a target for default.options to CMakeLists.txt so that it works properly with the cmake build.

vmagnin commented 13 years ago

Same warnings under Fedora 15 (gtk3 branch).

bonanza commented 13 years ago

I just deleted the respective lines in gtkf-sketcher.glade, since this seems to be some Ubuntu bug (http://lists.ximian.com/pipermail/glade-users/2011-March/005235.html).

vmagnin commented 13 years ago

OK, the warnings have disappeared. I found another problem: when "Create file for each handler function" is selected, I obtain this error for each handler function:

handler_delete_event.f90:3.8:

print*,"handler function: delete_event
        1
Error: Unterminated character constant beginning at (1)

No problem when there is no handler files.

bonanza commented 13 years ago

I resolved that - the reason was a too long line in gtkf-sketcher.f90.

bonanza commented 13 years ago

I committed a new version with some more options.