Coder Social home page Coder Social logo

vmagnin / gtk-fortran Goto Github PK

View Code? Open in Web Editor NEW
247.0 30.0 45.0 18.86 MB

A GTK / Fortran binding. The documentation is in the Wiki tab.

License: GNU General Public License v3.0

CMake 0.89% Fortran 95.36% Python 2.74% Perl 0.57% Shell 0.39% Roff 0.06%
fortran gui gtk cross-platform graphical-user-interface graphics gtk4 fortran-package-manager gtk-fortran bindings

gtk-fortran's Introduction

gtk-fortran

This branch is for GTK 4

The gtk-fortran project aims to offer scientists programming in Fortran a cross-platform library to build Graphical User Interfaces (GUI). Gtk-fortran is a partial GTK / Fortran binding 100% written in Fortran, thanks to the C / Fortran interoperability features introduced in the Fortran 2003 standard.

To install gtk-fortran, you can follow the quick instructions in the INSTALL file or the more detailed instructions on the wiki documentation.

Full documentation (wiki tab): https://github.com/vmagnin/gtk-fortran/wiki

Please post bugs on GitHub: https://github.com/vmagnin/gtk-fortran/issues

Files in this directory

  • README.md: the present file.
  • CHANGELOG.md: list of the releases with main changes.
  • CITATION.cff: file used by the GitHub interface (button "Cite this repository").
  • CMakeLists.txt: main CMake instructions to build the project.
  • codemeta.json: metadata about the project.
  • fpm.toml: Fortran Package Manager manifest.
  • INSTALL: quick installation instructions (see the Wiki for more details).
  • LICENSE: text of the GNU GPL v3 license.
  • LICENSE_EXCEPTION: text of the GCC Runtime Library Exception version 3.1.
  • README-high-level: about the High Level part of the gtk-fortran library.
  • VERSIONS: a CSV file with the gtk-fortran, GTK, GLib and distribution versions.

Citing gtk-fortran

Please acknowledge the use of gtk-fortran by citing the following publication:

Vincent MAGNIN, James TAPPIN, Jens HUNGER, Jerry DE LISLE, "gtk-fortran: a GTK+ binding to build Graphical User Interfaces in Fortran", Journal of Open Source Software, 4(34), 1109, 12th January 2019, https://doi.org/10.21105/joss.01109

gtk-fortran's People

Contributors

awvwgk avatar bonanza avatar florianober avatar jtappin avatar mehdichinoune avatar vmagnin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gtk-fortran's Issues

GPL3 license

While you're free to use the GPL license for these bindings, could I suggest you use the LGPL instead? Most of the libraries you are binding are using the more permissive LGPL. This would allow the use of your bindings in all types of software that can use Gtk+.

GtkExtra installation problem

"GtkExtra is a useful set of widgets for creating GUI's for the Xwindows system using GTK+." It would be interesting to use it with gtk-fortran but I did not succeed compiling its 2.1.2 version under Ubuntu 10.10 (see the error message below when I use "make"). Note that "a developer release of gtkextra-3 has been made available in the project download area (26 Feb 2011)."

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I -I.. -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -g -O2 -Wall -MT gtkitementry.lo -MD -MP -MF .deps/gtkitementry.Tpo -c gtkitementry.c  -fPIC -DPIC -o .libs/gtkitementry.o
gtkitementry.c:134: error: static declaration of ‘gtk_entry_reset_im_context’ follows non-static declaration
/usr/include/gtk-2.0/gtk/gtkentry.h:311: note: previous declaration of ‘gtk_entry_reset_im_context’ was here
make[2]: *** [gtkitementry.lo] Erreur 1
make[2]: quittant le répertoire « /home/vmagnin/Bureau/gtk+extra-2.1.2/gtkextra »
make[1]: *** [all-recursive] Erreur 1
make[1]: quittant le répertoire « /home/vmagnin/Bureau/gtk+extra-2.1.2 »
make: *** [all] Erreur 2

Setting Enum integer constants

Hi,

In order to be able to use another f03 compiler two changes to the cfwrapper script were necessary. The boz constants were not accepted as scalar-int-constant-expr in the enumerator definition and assignment.

Instead of converting to a bit pattern the same C like bit shifting can be used:

        def set_bit_field(match):
          """ Returns the Fortran bitfield from a C enum flag"""
          b = int(match.group(1))
          field = "1"
          s = "ISHFTC(1,"+str(b)+")"
          return s

And for the hex constants simply insert the INT intrinsic function:

        # Is it in hexadecimal ?
        parameters[0] = re.sub("0x([0-9A-Fa-f]+)", "INT(z'\\1')", parameters[0])

Now a major f03 compiler accepts the statements in gtk.f90/gtkenums-auto.f90. For example:

enum, bind(c) !GModuleFlags
enumerator :: G_MODULE_BIND_LAZY = ISHFTC(1,0)
enumerator :: G_MODULE_BIND_LOCAL = ISHFTC(1,1)
enumerator :: G_MODULE_BIND_MASK = INT(z'03')
end enum

Regards!
Henk

GtkFileSelector vs. GtkFileChooserDialog

Some essential requirement for almost every useful GUI application is a file selector widget.
GtkFileSelector seems to be already implemented in gtk-fortran. However, after some trials to get a fortran string as return value from the result of gtk_file_selection_get_filename() I must admit that I haven't got a clue how to do that. Maybe you can provide some example?
I think, it will be better to use GtkFileChooserDialog (which is not implemented in the current version of gtk-fortran?) instead of the deprecated GtkFileSelector.

Graphics status

Since several of us appear to be looking at different aspects of Gtk-Gdk-Cairo graphics, I've started this issue as a place to note ideas and progress.

Toward GIR ?

Currently, we use regular expressions to parse the C header files of the libraries (see cfwrapper.py and extract_events.pl). GIR files could be an alternative. This is opened to discussion.

I have begun playing with the ElementTree module in python to parse the GIR files that can be found in /usr/share/gir-1.0/ :

Atk-1.0.gir        GdkPixbuf-2.0.gir  Gtk-3.0.gir         PangoXft-1.0.gir
Epiphany-2.29.gir  GdkX11-2.0.gir     Pango-1.0.gir       Unity-3.0.gir
Gdk-2.0.gir        GdkX11-3.0.gir     PangoCairo-1.0.gir
Gdk-3.0.gir        Gtk-2.0.gir        PangoFT2-1.0.gir

These GIR files are XML files that describe the functions, structures, constants, etc. that are in these libraries (see http://live.gnome.org/GObjectIntrospection).

For other libraries like GLib, you may generate the GIR file using the .typelib file in /usr/gir/girepository-1.0 (you need the gobject-introspection package):

g-ir-generate /usr/lib/girepository-1.0/GLib-2.0.typelib > glib.xml

But in that case, there is no "c:identifier" attribute in the tag (how to identify a pointer ?)

Advantages:

  • parsing XML is easier than using regular expressions which must take into account many exceptions and peculiarities.
  • The binding would be more complete (to what extent ?).

Drawbacks:

  • GIR format is not well documented.
  • Cairo is not (yet ?) supported. So cfwrapper.py would still be necessary at least for it. Probably also for others like GLib (see the "c:identifier" problem above).
  • We would lose the C prototypes in comments and also in gtk-fortran-index.csv
  • A new effort.

The question is: is it worth while ? Or would it be more adequate to improve cfwrapper.py ?

See also http://mkestner.blogspot.com/2011/02/signs-of-life.html on the gtk-sharp binding. After installing the gobject-introspection package under Ubuntu, we have the python file /usr/lib/gobject-introspection/giscanner/girparser.py which we could perhaps use to parse the gir files.

**gchar and similar arguments

In the interfaces generated by cfwrapper.py arrays of strings (c type **gchar) are incorrectly interpreted as arrays of characters:

character(kind=c_char), dimension(*)

instead of arrays of pointers:

type(c_ptr), dimension(*)

If this change is made then a null-terminated array of strings can be passed (e.g.

    character(kind=c_char), dimension(:), allocatable, target :: au1
    type(c_ptr), dimension(2) :: authors

    call convert_f_string((/ "James Tappin" /), au1)
    authors(1) = c_loc(au1)
    authors(2) = NULL

    call gtk_about_dialog_set_authors(adialog, authors)

)

Vincent, can you update the code?

Implementing a Pause functionality

In the latest julia_pixbuf.f90 (master branch), I have implemented a Pause function with a toggle button in order to pause during a long computation. It works but the application crashes if you try to quit the program during the pause. Have you an idea for a better implementation ?

internal compiler error: Segmentation fault

I am getting this strange issue during make in opensuse 11.4 :

make
[ 1%] Building Fortran object src/CMakeFiles/gtk-fortran_shared.dir/gtk.f90.o
/home/zmi007/Download/linux/gtk-fortran/src/gtk.f90: In function ‘g_signal_connect’:
/home/zmi007/Download/linux/gtk-fortran/src/gtk.f90:70:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See http://bugs.opensuse.org/ for instructions.
make[3]: *** [src/CMakeFiles/gtk-fortran_shared.dir/gtk.f90.o] Error 1
make[2]: *** [src/CMakeFiles/gtk-fortran_shared.dir/gtk.f90.o.provides] Error 2
make[1]: *** [src/CMakeFiles/gtk-fortran_shared.dir/all] Error 2
make: *** [all] Error 2

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.5/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.5 --enable-linux-futex --without-system-libunwind --enable-gold --with-plugin-ld=/usr/bin/gold --with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux

Thread model: posix
gcc version 4.5.1 20101208 [gcc-4_5-branch revision 167585](SUSE Linux)

INFO
if I replace FNULL and NULL in handler_id = g_signal_connect_data (..., FNULL) calls with their values, it does compile.

Mac OS X lion 10.7.4 problems

Message received from A. Graziosi:

The following occurs on Mac OS X lion 10.7.4, Xcode 4.4.1, MacPorts + its packages (gcc47, gtk2 etc.), and gtk-fortran jerryd-gtk-fortran-fcfa718.

  1. Using src/test.sh to build example gives this warning:

    ...
    ../examples/hl_list1.f90
    ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in anon from gtk-hl-tree.o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie
    ...

the attached patch seems to fix the warning but perhaps there is a better way

Still building the examples there is this error:

...
../examples/hl_list_renderers.f90:36.6:

use gdk_pixbuf_hl
1
Fatal Error: Can't open module file 'gdk_pixbuf_hl.mod' for reading at (1): No such file or directory

I think you know how to fix it

I have tried to build a library file, .a, with some changes to src/test.sh:

...
echo ">>> Removing old files..."
rm -rf *.o
rm -rf *.a
rm -rf *.mod
rm -rf *.out

gtkversion="pkg-config --cflags --libs gtk+-2.0"

gtk_hl_obj="gtk-hl-misc.o gtk-hl-accelerator.o gtk-hl-button.o gtk-hl-combobox.o gtk-hl-container.o gtk-hl-entry.o gtk-hl-menu.o gtk-hl-progress.o gtk-hl-spin-slider.o gtk-hl-tree.o gtk-hl-chooser.o gtk-hl-dialog.o"

echo ">>> Compiling gtk libraries..."

gtk3 only: "unix-print-auto.f90"

for file in "gdk-auto.f90" "glib-auto.f90" "gtk.f90" "atk-auto.f90" "cairo-auto.f90" "gdk-pixbuf-auto.f90" "pango-auto.f90" "gtk-sup.f90" "gtk-hl-misc.f90" "gtk-hl-accelerator.f90" "gtk-hl-button.f90" "gtk-hl-combobox.f90" "gtk-hl-container.f90" "gtk-hl-entry.f90" "gtk-hl-menu.f90" "gtk-hl-progress.f90" "gtk-hl-spin-slider.f90" "gtk-hl-tree.f90" "gtk-hl-chooser.f90" "gtk-hl-dialog.f90" "gtk-hl.f90" "gdkevents-auto2.f90" "gtk-draw-hl.f90" ; do
"${GFC}" -c $file $gtkversion
done

echo ">>> Building the library..."
ar rcs libGtkFortran.a gtk.o gtk-sup.o gtk-hl.o ${gtk_hl_obj} gtk-draw-hl.o
...

("ar ru" gives the same...) but I got this warning:

/opt/local/bin/ranlib: file libGtkFortran.a(gtk/hl.o) has no symbol

it looks harmless, indeed using libGtkFortran.a seems to work but avoid that warning would be better!

--- test.sh~    2012-08-13 18:43:52.000000000 +0200
+++ test.sh 2012-08-19 12:52:58.000000000 +0200
@@ -16,6 +16,20 @@
 rm ../examples/*.mod
 rm ../examples/*.out

+osname="`uname -s`"
+
+case "${osname}" in
+    "Darwin")
+   linkerflags="-Wl,-no_pie"
+   ;;
+    # "Linux")
+    #  linkerflags="???"   
+    #  ;;
+    * )
+   linkerflags=""
+   ;;
+esac
+
 gtkversion="`pkg-config --cflags --libs gtk+-2.0`"

 gtk_hl_obj="gtk-hl-misc.o gtk-hl-accelerator.o gtk-hl-button.o gtk-hl-combobox.o gtk-hl-container.o gtk-hl-entry.o gtk-hl-menu.o gtk-hl-progress.o gtk-hl-spin-slider.o gtk-hl-tree.o  gtk-hl-chooser.o gtk-hl-dialog.o"
@@ -29,9 +43,9 @@
 echo ">>> Compiling examples..."
 for i in ../examples/*.f90 ; do 
   echo $i
-  "${GFC}" gtk.o gtk-sup.o gtk-hl.o ${gtk_hl_obj} gtk-draw-hl.o $i $gtkversion -o $i.out
+  "${GFC}" "${linkerflags}" gtk.o gtk-sup.o gtk-hl.o ${gtk_hl_obj} gtk-draw-hl.o $i $gtkversion -o $i.out
 done
-"${GFC}" gtk.o ../examples/gtkbuilder2.f90 -o ../examples/gtkbuilder2.f90.out $gtkversion `pkg-config --cflags --libs gmodule-2.0`
+"${GFC}" "${linkerflags}" gtk.o ../examples/gtkbuilder2.f90 -o ../examples/gtkbuilder2.f90.out $gtkversion `pkg-config --cflags --libs gmodule-2.0`

 echo ">>> Running the examples..."
 cd ../examples/

tests.f90 fails with g95 (Cannot allocate memory)

tests.f90 fails with g95 version 0.93 Jun 16 2010 (not gfortran): it runs during severals tens of seconds then finally print the following error:
_MEMORY-ERROR_: [4767]: GSlice: failed to allocate 248 bytes (alignment: 256): Cannot allocate memory
Aborted

Is it a problem in tests.f90 or a g95 bug ? (the development of g95 seems to be stopped or frozen).

Thoughts on code structure and other issues.

Here are few thoughts and ideas.

  1. I'd like to break up the high level interface into a number of submodules (containers, buttons etc.) -- there would still be a global high-level module to include all of them. The main reason for this is just that the source file is too long for convenient maintenance.
  2. I would also like to commit the template files and converter code that I use to keep the gtk2 and gtk3 versions in sync.
  3. I think it would be fairly trivial to modify the cmake stuff so that the GTK2 & GTK3 versions can be installed in parallel. Basically this would involve calling the libraries libgtk-fortran2.* and libgtk-fortran3.* and moving the modules to $(INSTALL)/include/gtk-fortran2/ and $(INSTALL)/include/gtk-fortran3/, and making corresponding changes to the pgkconfig files.

If nobody has any objections to these I'll try to get them done over the upcoming long weekend in the US.

gtk-fortran with Pathscale EKOPath 4

The EKOPath 4 compiler suite is now released as open source (http://www.pathscale.com/ekopath4-open-source-announcement) and can be downloaded from github (https://github.com/path64/compiler).

I tried to compile gtk-fortran with the pathf95 Fortran compiler, which resulted in a cascade of errors. The first one produces the following message:

GTK_SCROLLABLE_SET_HADJUSTMENT
  Pgm_Unit                  Not_Referenced            IDX             = 21815   
  AT_ACCESS_SET   = F       AT_ACTUAL_ARG   = F       AT_PROTECTED    = F       
  AT_ARG_TO_KIND  = F       AT_ATTR_LINK    = 0       AT_CIF_DONE     = F       
  AT_CIF_IN_USAGE_= F       AT_CIF_SYMBOL_ID= 0       AT_CIF_USE_IN_BN= F       
  AT_COMPILER_GEND= F       AT_DCL_ERR      = F       AT_DEF_COLUMN   = 12      
  AT_DEF_LINE     = 25880   AT_DEF_IN_CHILD = F       AT_DEFINED      = F       
  AT_ELEMENTAL_INT= F       AT_HOST_ASSOCIAT= F       AT_IGNORE_ATTR_L= F       
  AT_IS_DARG      = F       AT_IS_INTRIN    = F       AT_LOCKED_IN    = F       
  AT_MODULE_IDX   = 0       AT_MODULE_OBJECT= F       AT_NAME_LEN     = 30      
  AT_NAMELIST_OBJ = F       AT_NOT_VISIBLE  = F       AT_ORIG_MODULE_I= 0       
  AT_ORIG_NAME_LEN= 0       AT_ORIG_NAME_IDX= 0
  AT_OPTIONAL     = F       AT_PRIVATE      = Public  AT_REF_IN_CHILD = F       
  AT_SEMANTICS_DON= T       AT_TYPED        = F       AT_USE_ASSOCIATE= F       
  Subroutine                Extern_Proc               ATP_ALIGN       = F       
  ATP_ALL_INTENT_I= F       ATP_ALT_ENTRY   = F       ATP_ARGCHCK_CALL= F       
  ATP_ARGCHCK_ENTR= F       ATP_DCL_EXTERNAL= F       ATP_DUPLICATE_IN= 0       
  AT_BIND_ATTR    = T       ATP_PP_ABSTRACT = F       ATP_PP_PROTO    = T      
  ATP_ELEMENTAL   = F       ATP_ENTRY_LABEL_= 0       ATP_EXPL_ITRFC  = T       
  ATP_EXT_NAME_IDX= 80294   ATP_EXT_NAME_LEN= 30      gtk_scrollable_set_hadjustment
  ATP_EXTERNAL_INT= F       ATP_EXTRA_DARG  = F       ATP_FIRST_IDX   = 12302   
  ATP_FIRST_SH_IDX= 0       ATP_GLOBAL_ATTR_= 19188  
  ATP_HAS_ALT_RET = F       ATP_HAS_OVER_IND= F       ATP_HAS_TASK_DIR= F       
  ATP_IN_INTERFACE= T       ATP_IN_UNNAMED_I= T       ATP_INLINE_ALWAY= F       
  ATP_INLINE_NEVER= F       ATP_MAY_INLINE  = F       ATP_NAME_IN_STON= F       
  ATP_NO_ENTRY_LIS= 0       ATP_NON_ANSI_INT= F       ATP_NOSIDE_EFFEC= F       
  ATP_NUM_DARGS   = 2       ATP_OPTIONAL_DIR= F       ATP_PARENT_IDX  = 469     
  ATP_PURE        = F       ATP_RECURSIVE   = F      
  ATP_RSLT_IDX    = 0       ATP_SAVE_ALL    = F       ATP_SCP_ALIVE   = F       
  ATP_SCP_IDX     = 1       ATP_SGI_RTN_INL = F       ATP_SGI_RTN_NOIN= F       
  ATP_SGI_GLB_INL = F       ATP_SGI_GLB_NOIN= F       ATP_SGI_LOC_INL = F       
  ATP_SGI_LOC_NOIN= F       ATP_STACK_DIR   = F       ATP_SYMMETRIC   = F       
  ATP_TASK_SHARED = F       ATP_USES_EREGS  = F       ATP_VFUNCTION   = F       


  Dummy Arguments for GTK_SCROLLABLE_SET_HADJUSTMENT:

  SCROLLABLE                                                      IDX = 12302   
  SN_COLUMN_NUM   = 43      SN_LINE_NUM     = 25880   SN_NAME_LEN     = 10      
  SN_NAME_IDX     = 80290   SN_ATTR_IDX     = 21816   SN_SIBLING_LINK = 0       
  ATD_ARRAY_IDX   = 0       ATD_POINTER     = F       ATD_TYPE_IDX    = 2848    
  ATD_PE_ARRAY_IDX= 0       

  HADJUSTMENT                                                     IDX = 12303   
  SN_COLUMN_NUM   = 55      SN_LINE_NUM     = 25880   SN_NAME_LEN     = 11      
  SN_NAME_IDX     = 80292   SN_ATTR_IDX     = 21817   SN_SIBLING_LINK = 0       
  ATD_ARRAY_IDX   = 0       ATD_POINTER     = F       ATD_TYPE_IDX    = 2848    
  ATD_PE_ARRAY_IDX= 0       


pathf95-42 pathf95: INTERNAL GTK_INIT, File = gtk.f90, Line = 95, Column = 7 
  Attribute entry 21815 has a variant problem with field ATD_PP_ATP.
Signal: Aborted in Front End Parse/Semantic phase.
Error: Signal Aborted in phase Front End Parse/Semantic -- processing aborted

g95, "Remaining memory"

With g95 (not gfortran), I systematically obtain that kind of message when quitting a program:
Remaining memory: 30 bytes at 0907a2e0 allocated at line 88 of gtk.f90

Line 88 is:
allocate(carg(0:strlen))

We should deallocate it somewhere.

Alias of C_NULL_PTR to "NULL" clashes with Fortran intrinsic

While I was cleaning up some code, I updated some of its pointer definitions to intialize the pointers using the intrinsic null() function.

e.g.
real, dimension(:), pointer :: ptr = null()

to ensure a valid result for any call to associated().

Unfortunately by providing the convenience alias of NULL for C_NULL_PTR, we have made the intrinsic Fortran function inaccessible in any module that USEs the gtk fortran modules.

Not sure what's the best to do with the conflict. I know I've used the NULL constant extensively in my code.

Trouble compiling hl tests on windows

Hello,

I am having trouble compiling the hl test problems on a windows 32 bit machine. I'm using gfortran version 4.7 and i took the gtk libraries from the windows bundle I downloaded (gtk+-bundle_2.24.8-20111122_win32).

I was able to successfully compile the non hl tests (although originally didn't get this to work for two reasons. First I had to copy the cairo-auto.o to cairo.o and then I had to compile the hl source files before the first compilation line in the test script due to a dependency of one of the files to gtk_hl_container.mod. After that they compiled fine and all run successfully but gtkbuilder2 (runs but cannot fine signal handlers, which I think is addressed somewhere here and I can fix) and cairo-tests which segfaults (which has been noted before I believe))

For the hl tests, when compiling, I get for the first compilation (others similarly):

D:\opt\Cygwin\home\mtw125\gtkfortran_test\test1\newHLtest>gfortran gtk.o gtk-sup.o gtk-hl.o hl_choosers.f90 -o hl_choosers.exe -L. -llibglib-2.0-0 -llibgtk-win32-2.0-0 -llibgdk-win32-2.0-0 -llibgobject-2.0-0 -llibgdk_pixbuf-2.0-0 -llibcairo-2
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x36a): undefined reference to ___gtk_hl_chooser_MOD_hl_gtk_file_chooser_show' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x55c): undefined reference to___gtk_hl_entry_MOD_hl_gtk_text_view_get_text'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x820): undefined reference to ___gtk_hl_entry_MOD_hl_gtk_text_view_get_text' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0xb09): undefined reference to___gtk_hl_entry_MOD_hl_gtk_text_view_delete'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x1022): undefined reference to ___gtk_hl_entry_MOD_hl_gtk_text_view_insert' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x148b): undefined reference to___gtk_hl_chooser_MOD_hl_gtk_file_chooser_show'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x158d): undefined reference to ___gtk_hl_entry_MOD_hl_gtk_text_view_delete' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x1aa6): undefined reference to___gtk_hl_entry_MOD_hl_gtk_text_view_insert'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x1eeb): undefined reference to ___gtk_hl_dialog_MOD_hl_gtk_message_dialog_show' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x2194): undefined reference to___gtk_hl_container_MOD_hl_gtk_window_new'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x21b5): undefined reference to ___gtk_hl_container_MOD_hl_gtk_box_new' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x21e8): undefined reference to___gtk_hl_container_MOD_hl_gtk_box_new'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x2223): undefined reference to ___gtk_hl_container_MOD_hl_gtk_box_pack' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x228f): undefined reference to___gtk_hl_button_MOD_hl_gtk_button_new'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x22cd): undefined reference to ___gtk_hl_container_MOD_hl_gtk_box_pack' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x23de): undefined reference to___gtk_hl_chooser_MOD_hl_gtk_file_chooser_button_new'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x241c): undefined reference to ___gtk_hl_container_MOD_hl_gtk_box_pack' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x2488): undefined reference to___gtk_hl_button_MOD_hl_gtk_button_new'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x24c3): undefined reference to ___gtk_hl_container_MOD_hl_gtk_box_pack' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x252f): undefined reference to___gtk_hl_button_MOD_hl_gtk_button_new'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x256a): undefined reference to ___gtk_hl_container_MOD_hl_gtk_box_pack' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x2626): undefined reference to___gtk_hl_entry_MOD_hl_gtk_text_view_new'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x2660): undefined reference to ___gtk_hl_container_MOD_hl_gtk_box_pack' /tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x26cc): undefined reference to___gtk_hl_button_MOD_hl_gtk_button_new'
/tmp/cc1wsEfv.o:hl_choosers.f90:(.text+0x2707): undefined reference to `___gtk_hl_container_MOD_hl_gtk_box_pack'

Note the "three" underscores. Is that supposed to be or is it not finding them due to an extra underscore. If so I tried some compiler flags to change this but it changes everything. If this is the problem can it be done with a compiler directive, and if so, how? Not I'm only one of those lowly scientific programmers :).

Accelerating compilation by breaking up gtk-auto.f90 into modules

Please see the test2 branch: I have broken up gtk-auto.f90 into numerous module files, one for each GTK+ .h file. The user must now add use statements as he would add #include statements in C.
The only example I have so far modified is menu.f90: the compilation time is now 4 seconds instead of 101 seconds on my netbook.
First you compile all modules, once for all:
cd ../modules
gfortran -c *.f90 pkg-config --cflags --libs gtk+-2.0
cd ../src
gfortran -c gtk.f90 pkg-config --cflags --libs gtk+-2.0
Then you compile your program:
gfortran -I../modules/ gtk.o ../examples/menu.f90 pkg-config --cflags --libs gtk+-2.0
Note that pango_break module was renamed pango__break (two underscores) because one of its subroutine has the same name.
Let me know if you agree with this new branch.
Vincent

New GTK 3.0 branch

I created a new GTK+ 3.0.8 branch (8393 functions). The objective of this branch is to adapt all examples to the new GTK.
Some examples work, some don't because of deprecated functions (gtk-hl.f90, notebooks.f90, bazaar.f90...) or signals.
Some problems had already been reported here:
https://github.com/jerryd/gtk-fortran/wiki/Gtk3

Concerning gtk-hl, be carreful: I modified test.sh to compile the other examples.

gtk-hl-tree: Support for other CellRenderers

It will be nice to have support for other CellRenderers than GtkCellRendererText in gtk-hl-tree - e.g. toggles and combos can be very useful in treeviews. Maybe this can be realized with an additional optional argument in hl_gtk_tree_new. However, then also the data handling for the callback routines have to be adapted.

Setlocale causes real number read error after calling gtk_init

with the current gtk-fortran revisions I get some strange behaviour with reading real numbers: after calling gtk_init all decimal places are set to zero.
Here is some short example, maybe you can test it on your systems:

program realtest

  use gtk, only: gtk_init

implicit none

  character(len=20)::line
  real::r
  
  line='100.3456'
  read(line,fmt=*)r
  print*,r

  call gtk_init ()

  read(line,fmt=*)r
  print*,r

end program realtest

The result on my system:

   100.34560    
   100.00000   

Any ideas?

Gtkextra installation problem

Hello,

I had this issue while typing the 'make' command:

[renzo@localhost gtk+extra-2.1.2]$ make
make all-recursive
make[1] : on entre dans le répertoire « /home/renzo/Fortran/gtk+extra-2.1.2 »
Making all in gtkextra
make[2] : on entre dans le répertoire « /home/renzo/Fortran/gtk+extra-2.1.2/gtkextra »
Makefile:1031: *** séparateur manquant (vouliez-vous dire TAB au lieu des 8 espaces ?). Arrêt.
make[2] : on quitte le répertoire « /home/renzo/Fortran/gtk+extra-2.1.2/gtkextra »
make[1]: *** [all-recursive] Erreur 1
make[1] : on quitte le répertoire « /home/renzo/Fortran/gtk+extra-2.1.2 »
make: *** [all] Erreur 2

Would someone knnow how i could solve this issue...

Thanks a lot,

Renzo

GtkDatabox

I tried to use cfwrapper.py with the gtkdatabox 0.9.1.1 header files.
Unfortunately, this produces a lot of errors, mainly "Unknown data type".
However, I'm not familiar enough with Python to do some adaptations in the cfwrapper script.

/usr/include/gtkdatabox/gtkdatabox_markers.h
Unknown data type:    typedef struct _GtkDataboxMarkers GtkDataboxMarkers
  typedef struct _GtkDataboxMarkers GtkDataboxMarkers;

/usr/include/gtkdatabox/gtkdatabox_markers.h
Function name not found
  typedef struct _GtkDataboxMarkers GtkDataboxMarkers;

/usr/include/gtkdatabox/gtkdatabox_markers.h
Unknown data type:    typedef struct _GtkDataboxMarkersClass GtkDataboxMarkersClass
 typedef struct _GtkDataboxMarkersClass GtkDataboxMarkersClass;

/usr/include/gtkdatabox/gtkdatabox_markers.h
Function name not found
 typedef struct _GtkDataboxMarkersClass GtkDataboxMarkersClass;

/usr/include/gtkdatabox/gtkdatabox_markers.h
Unknown data type:    typedef struct _GtkDataboxMarkersPrivate GtkDataboxMarkersPrivate
  typedef struct _GtkDataboxMarkersPrivate GtkDataboxMarkersPrivate;

/usr/include/gtkdatabox/gtkdatabox_markers.h
Function name not found
  typedef struct _GtkDataboxMarkersPrivate GtkDataboxMarkersPrivate;

/usr/include/gtkdatabox/gtkdatabox_markers.h
Unknown data type:    typedef enum   struct _GtkDataboxMarkersClass   GType gtk_databox_markers_get_type 
  typedef enum   struct _GtkDataboxMarkersClass   GType gtk_databox_markers_get_type (void);

/usr/include/gtkdatabox/gtkdatabox_markers.h
Unknown data type:    GtkDataboxMarkersType type
 GtkDataboxGraph *gtk_databox_markers_new (guint len, gfloat * X, gfloat * Y, GdkColor * color, guint size, GtkDataboxMarkersType type);

/usr/include/gtkdatabox/gtkdatabox_markers.h
Unknown data type:    GtkDataboxMarkersPosition position
void gtk_databox_markers_set_position (GtkDataboxMarkers * markers, guint index, GtkDataboxMarkersPosition position);

/usr/include/gtkdatabox/gtkdatabox_markers.h
Unknown data type:    GtkDataboxMarkersTextPosition label_position
 void gtk_databox_markers_set_label (GtkDataboxMarkers * markers, guint index, GtkDataboxMarkersTextPosition label_position, gchar * text, gboolean boxed);

/usr/include/gtkdatabox/gtkdatabox_markers.h
Unknown data type:    gboolean boxed
 void gtk_databox_markers_set_label (GtkDataboxMarkers * markers, guint index, GtkDataboxMarkersTextPosition label_position, gchar * text, gboolean boxed);

/usr/include/gtkdatabox/gtkdatabox_bars.h
Unknown data type:    typedef struct _GtkDataboxBars GtkDataboxBars
  typedef struct _GtkDataboxBars GtkDataboxBars;

/usr/include/gtkdatabox/gtkdatabox_bars.h
Function name not found
  typedef struct _GtkDataboxBars GtkDataboxBars;

/usr/include/gtkdatabox/gtkdatabox_bars.h
Unknown data type:    typedef struct _GtkDataboxBarsClass GtkDataboxBarsClass
 typedef struct _GtkDataboxBarsClass GtkDataboxBarsClass;

/usr/include/gtkdatabox/gtkdatabox_bars.h
Function name not found
 typedef struct _GtkDataboxBarsClass GtkDataboxBarsClass;

/usr/include/gtkdatabox/gtkdatabox_bars.h
Unknown data type:    typedef struct _GtkDataboxBarsPrivate GtkDataboxBarsPrivate
  typedef struct _GtkDataboxBarsPrivate GtkDataboxBarsPrivate;

/usr/include/gtkdatabox/gtkdatabox_bars.h
Function name not found
  typedef struct _GtkDataboxBarsPrivate GtkDataboxBarsPrivate;

/usr/include/gtkdatabox/gtkdatabox_bars.h
Unknown data type:    struct _GtkDataboxBars   struct _GtkDataboxBarsClass   GType gtk_databox_bars_get_type 
 struct _GtkDataboxBars   struct _GtkDataboxBarsClass   GType gtk_databox_bars_get_type (void);

/usr/include/gtkdatabox/gtkdatabox_ruler.h
Unknown data type:    typedef struct _GtkDataboxRulerPrivate GtkDataboxRulerPrivate
  typedef struct _GtkDataboxRulerPrivate GtkDataboxRulerPrivate;

/usr/include/gtkdatabox/gtkdatabox_ruler.h
Function name not found
  typedef struct _GtkDataboxRulerPrivate GtkDataboxRulerPrivate;

/usr/include/gtkdatabox/gtkdatabox_ruler.h
Unknown data type:    GtkOrientation orientation
GtkWidget *gtk_databox_ruler_new (GtkOrientation orientation);

/usr/include/gtkdatabox/gtkdatabox_ruler.h
Unknown data type:    gdouble lower
 void gtk_databox_ruler_set_range (GtkDataboxRuler * ruler, gdouble lower, gdouble upper, gdouble position);

/usr/include/gtkdatabox/gtkdatabox_ruler.h
Unknown data type:    gdouble upper
 void gtk_databox_ruler_set_range (GtkDataboxRuler * ruler, gdouble lower, gdouble upper, gdouble position);

/usr/include/gtkdatabox/gtkdatabox_ruler.h
Unknown data type:    gdouble position
 void gtk_databox_ruler_set_range (GtkDataboxRuler * ruler, gdouble lower, gdouble upper, gdouble position);

/usr/include/gtkdatabox/gtkdatabox_ruler.h
Unknown data type:    GtkOrientation orientation
 void gtk_databox_ruler_set_orientation (GtkDataboxRuler * ruler, GtkOrientation orientation);

/usr/include/gtkdatabox/gtkdatabox_ruler.h
Unknown data type:    GtkOrientation gtk_databox_ruler_get_orientation 
 GtkOrientation gtk_databox_ruler_get_orientation (GtkDataboxRuler * ruler);

/usr/include/gtkdatabox/gtkdatabox_points.h
Unknown data type:    typedef struct _GtkDataboxPoints GtkDataboxPoints
  typedef struct _GtkDataboxPoints GtkDataboxPoints;

/usr/include/gtkdatabox/gtkdatabox_points.h
Function name not found
  typedef struct _GtkDataboxPoints GtkDataboxPoints;

/usr/include/gtkdatabox/gtkdatabox_points.h
Unknown data type:    typedef struct _GtkDataboxPointsClass GtkDataboxPointsClass
 typedef struct _GtkDataboxPointsClass GtkDataboxPointsClass;

/usr/include/gtkdatabox/gtkdatabox_points.h
Function name not found
 typedef struct _GtkDataboxPointsClass GtkDataboxPointsClass;

/usr/include/gtkdatabox/gtkdatabox_points.h
Unknown data type:    typedef struct _GtkDataboxPointsPrivate GtkDataboxPointsPrivate
  typedef struct _GtkDataboxPointsPrivate GtkDataboxPointsPrivate;

/usr/include/gtkdatabox/gtkdatabox_points.h
Function name not found
  typedef struct _GtkDataboxPointsPrivate GtkDataboxPointsPrivate;

/usr/include/gtkdatabox/gtkdatabox_points.h
Unknown data type:    struct _GtkDataboxPoints   struct _GtkDataboxPointsClass   GType gtk_databox_points_get_type 
 struct _GtkDataboxPoints   struct _GtkDataboxPointsClass   GType gtk_databox_points_get_type (void);

/usr/include/gtkdatabox/gtkdatabox_points.h
Unknown data type:    gint size
 GtkDataboxGraph *gtk_databox_points_new (guint len, gfloat * X, gfloat * Y, GdkColor * color, gint size);

/usr/include/gtkdatabox/gtkdatabox_graph.h
Unknown data type:    typedef struct _GtkDataboxGraphClass GtkDataboxGraphClass
  typedef struct _GtkDataboxGraphClass GtkDataboxGraphClass;

/usr/include/gtkdatabox/gtkdatabox_graph.h
Function name not found
  typedef struct _GtkDataboxGraphClass GtkDataboxGraphClass;

/usr/include/gtkdatabox/gtkdatabox_graph.h
Unknown data type:    typedef struct _GtkDataboxGraphPrivate GtkDataboxGraphPrivate
  typedef struct _GtkDataboxGraphPrivate GtkDataboxGraphPrivate;

/usr/include/gtkdatabox/gtkdatabox_graph.h
Function name not found
  typedef struct _GtkDataboxGraphPrivate GtkDataboxGraphPrivate;

/usr/include/gtkdatabox/gtkdatabox_graph.h
Unknown data type:    struct _GtkDataboxGraph   struct _GtkDataboxGraphClass   GType gtk_databox_graph_get_type 
  struct _GtkDataboxGraph   struct _GtkDataboxGraphClass   GType gtk_databox_graph_get_type (void);

/usr/include/gtkdatabox/gtkdatabox_graph.h
Unknown data type:    gboolean hide
 void gtk_databox_graph_set_hide (GtkDataboxGraph * graph, gboolean hide);

/usr/include/gtkdatabox/gtkdatabox_graph.h
Unknown data type:    gboolean gtk_databox_graph_get_hide 
gboolean gtk_databox_graph_get_hide (GtkDataboxGraph * graph);

/usr/include/gtkdatabox/gtkdatabox_graph.h
Unknown data type:    gint size
 void gtk_databox_graph_set_size (GtkDataboxGraph * graph, gint size);

/usr/include/gtkdatabox/gtkdatabox_graph.h
Unknown data type:    gint gtk_databox_graph_get_size 
gint gtk_databox_graph_get_size (GtkDataboxGraph * graph);

/usr/include/gtkdatabox/gtkdatabox_graph.h
Unknown data type:    gint gtk_databox_graph_calculate_extrema 
 gint gtk_databox_graph_calculate_extrema (GtkDataboxGraph * graph, gfloat * min_x, gfloat * max_x, gfloat * min_y, gfloat * max_y);

/usr/include/gtkdatabox/gtkdatabox_marshal.h
No function to implement in this file


/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    typedef struct _GtkDataboxGrid GtkDataboxGrid
  typedef struct _GtkDataboxGrid GtkDataboxGrid;

/usr/include/gtkdatabox/gtkdatabox_grid.h
Function name not found
  typedef struct _GtkDataboxGrid GtkDataboxGrid;

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    typedef struct _GtkDataboxGridClass GtkDataboxGridClass
 typedef struct _GtkDataboxGridClass GtkDataboxGridClass;

/usr/include/gtkdatabox/gtkdatabox_grid.h
Function name not found
 typedef struct _GtkDataboxGridClass GtkDataboxGridClass;

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    typedef struct _GtkDataboxGridPrivate GtkDataboxGridPrivate
  typedef struct _GtkDataboxGridPrivate GtkDataboxGridPrivate;

/usr/include/gtkdatabox/gtkdatabox_grid.h
Function name not found
  typedef struct _GtkDataboxGridPrivate GtkDataboxGridPrivate;

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    struct _GtkDataboxGrid   struct _GtkDataboxGridClass   GType gtk_databox_grid_get_type 
 struct _GtkDataboxGrid   struct _GtkDataboxGridClass   GType gtk_databox_grid_get_type (void);

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    gint hlines
 GtkDataboxGraph *gtk_databox_grid_new (gint hlines, gint vlines, GdkColor * color, guint size);

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    gint vlines
 GtkDataboxGraph *gtk_databox_grid_new (gint hlines, gint vlines, GdkColor * color, guint size);

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    gint hlines
GtkDataboxGraph *gtk_databox_grid_array_new (gint hlines, gint vlines, gfloat *hline_vals, gfloat *vline_vals, GdkColor * color, guint size);

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    gint vlines
GtkDataboxGraph *gtk_databox_grid_array_new (gint hlines, gint vlines, gfloat *hline_vals, gfloat *vline_vals, GdkColor * color, guint size);

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    gint hlines
 void gtk_databox_grid_set_hlines (GtkDataboxGrid * grid, gint hlines);

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    gint gtk_databox_grid_get_hlines 
gint gtk_databox_grid_get_hlines (GtkDataboxGrid * grid);

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    gint vlines
 void gtk_databox_grid_set_vlines (GtkDataboxGrid * grid, gint vlines);

/usr/include/gtkdatabox/gtkdatabox_grid.h
Unknown data type:    gint gtk_databox_grid_get_vlines 
gint gtk_databox_grid_get_vlines (GtkDataboxGrid * grid);

/usr/include/gtkdatabox/gtkdatabox_xyc_graph.h
Unknown data type:    typedef struct _GtkDataboxXYCGraph GtkDataboxXYCGraph
  typedef struct _GtkDataboxXYCGraph GtkDataboxXYCGraph;

/usr/include/gtkdatabox/gtkdatabox_xyc_graph.h
Function name not found
  typedef struct _GtkDataboxXYCGraph GtkDataboxXYCGraph;

/usr/include/gtkdatabox/gtkdatabox_xyc_graph.h
Unknown data type:    typedef struct _GtkDataboxXYCGraphClass GtkDataboxXYCGraphClass
 typedef struct _GtkDataboxXYCGraphClass GtkDataboxXYCGraphClass;

/usr/include/gtkdatabox/gtkdatabox_xyc_graph.h
Function name not found
 typedef struct _GtkDataboxXYCGraphClass GtkDataboxXYCGraphClass;

/usr/include/gtkdatabox/gtkdatabox_xyc_graph.h
Unknown data type:    typedef struct _GtkDataboxXYCGraphPrivate GtkDataboxXYCGraphPrivate
  typedef struct _GtkDataboxXYCGraphPrivate GtkDataboxXYCGraphPrivate;

/usr/include/gtkdatabox/gtkdatabox_xyc_graph.h
Function name not found
  typedef struct _GtkDataboxXYCGraphPrivate GtkDataboxXYCGraphPrivate;

/usr/include/gtkdatabox/gtkdatabox_xyc_graph.h
Unknown data type:    struct _GtkDataboxXYCGraph   struct _GtkDataboxXYCGraphClass   GType gtk_databox_xyc_graph_get_type 
 struct _GtkDataboxXYCGraph   struct _GtkDataboxXYCGraphClass   GType gtk_databox_xyc_graph_get_type (void);

/usr/include/gtkdatabox/gtkdatabox_cross_simple.h
Unknown data type:    typedef struct _GtkDataboxCrossSimple GtkDataboxCrossSimple
  typedef struct _GtkDataboxCrossSimple GtkDataboxCrossSimple;

/usr/include/gtkdatabox/gtkdatabox_cross_simple.h
Function name not found
  typedef struct _GtkDataboxCrossSimple GtkDataboxCrossSimple;

/usr/include/gtkdatabox/gtkdatabox_cross_simple.h
Unknown data type:    typedef struct _GtkDataboxCrossSimpleClass GtkDataboxCrossSimpleClass
 typedef struct _GtkDataboxCrossSimpleClass GtkDataboxCrossSimpleClass;

/usr/include/gtkdatabox/gtkdatabox_cross_simple.h
Function name not found
 typedef struct _GtkDataboxCrossSimpleClass GtkDataboxCrossSimpleClass;

/usr/include/gtkdatabox/gtkdatabox_cross_simple.h
Unknown data type:    typedef struct _GtkDataboxCrossSimplePrivate GtkDataboxCrossSimplePrivate
  typedef struct _GtkDataboxCrossSimplePrivate GtkDataboxCrossSimplePrivate;

/usr/include/gtkdatabox/gtkdatabox_cross_simple.h
Function name not found
  typedef struct _GtkDataboxCrossSimplePrivate GtkDataboxCrossSimplePrivate;

/usr/include/gtkdatabox/gtkdatabox_cross_simple.h
Unknown data type:    struct _GtkDataboxCrossSimple   struct _GtkDataboxCrossSimpleClass   GType gtk_databox_cross_simple_get_type 
 struct _GtkDataboxCrossSimple   struct _GtkDataboxCrossSimpleClass   GType gtk_databox_cross_simple_get_type (void);

/usr/include/gtkdatabox/gtkdatabox_lines.h
Unknown data type:    typedef struct _GtkDataboxLines GtkDataboxLines
  typedef struct _GtkDataboxLines GtkDataboxLines;

/usr/include/gtkdatabox/gtkdatabox_lines.h
Function name not found
  typedef struct _GtkDataboxLines GtkDataboxLines;

/usr/include/gtkdatabox/gtkdatabox_lines.h
Unknown data type:    typedef struct _GtkDataboxLinesClass GtkDataboxLinesClass
 typedef struct _GtkDataboxLinesClass GtkDataboxLinesClass;

/usr/include/gtkdatabox/gtkdatabox_lines.h
Function name not found
 typedef struct _GtkDataboxLinesClass GtkDataboxLinesClass;

/usr/include/gtkdatabox/gtkdatabox_lines.h
Unknown data type:    typedef struct _GtkDataboxLinesPrivate GtkDataboxLinesPrivate
  typedef struct _GtkDataboxLinesPrivate GtkDataboxLinesPrivate;

/usr/include/gtkdatabox/gtkdatabox_lines.h
Function name not found
  typedef struct _GtkDataboxLinesPrivate GtkDataboxLinesPrivate;

/usr/include/gtkdatabox/gtkdatabox_lines.h
Unknown data type:    struct _GtkDataboxLines   struct _GtkDataboxLinesClass   GType gtk_databox_lines_get_type 
 struct _GtkDataboxLines   struct _GtkDataboxLinesClass   GType gtk_databox_lines_get_type (void);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    typedef struct _GtkDataboxClass GtkDataboxClass
  typedef struct _GtkDataboxClass GtkDataboxClass;

/usr/include/gtkdatabox/gtkdatabox.h
Function name not found
  typedef struct _GtkDataboxClass GtkDataboxClass;

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    typedef struct _GtkDataboxPrivate GtkDataboxPrivate
  typedef struct _GtkDataboxPrivate GtkDataboxPrivate;

/usr/include/gtkdatabox/gtkdatabox.h
Function name not found
  typedef struct _GtkDataboxPrivate GtkDataboxPrivate;

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    typedef struct    struct _GtkDatabox   struct _GtkDataboxClass   GType gtk_databox_get_type 
 typedef struct    struct _GtkDatabox   struct _GtkDataboxClass   GType gtk_databox_get_type (void);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gint gtk_databox_graph_add 
 gint gtk_databox_graph_add (GtkDatabox * box, GtkDataboxGraph * graph);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gint gtk_databox_graph_remove 
gint gtk_databox_graph_remove (GtkDatabox * box, GtkDataboxGraph * graph);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gint gtk_databox_graph_remove_all 
gint gtk_databox_graph_remove_all (GtkDatabox * box);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gint gtk_databox_auto_rescale 
 gint gtk_databox_auto_rescale (GtkDatabox * box, gfloat border);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat border
 gint gtk_databox_auto_rescale (GtkDatabox * box, gfloat border);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gint gtk_databox_calculate_extrema 
gint gtk_databox_calculate_extrema (GtkDatabox * box, gfloat * min_x, gfloat * max_x, gfloat * min_y, gfloat * max_y);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat left
 void gtk_databox_set_total_limits (GtkDatabox * box, gfloat left, gfloat right, gfloat top, gfloat bottom);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat right
 void gtk_databox_set_total_limits (GtkDatabox * box, gfloat left, gfloat right, gfloat top, gfloat bottom);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat top
 void gtk_databox_set_total_limits (GtkDatabox * box, gfloat left, gfloat right, gfloat top, gfloat bottom);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat bottom
 void gtk_databox_set_total_limits (GtkDatabox * box, gfloat left, gfloat right, gfloat top, gfloat bottom);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat left
void gtk_databox_set_visible_limits (GtkDatabox * box, gfloat left, gfloat right, gfloat top, gfloat bottom);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat right
void gtk_databox_set_visible_limits (GtkDatabox * box, gfloat left, gfloat right, gfloat top, gfloat bottom);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat top
void gtk_databox_set_visible_limits (GtkDatabox * box, gfloat left, gfloat right, gfloat top, gfloat bottom);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat bottom
void gtk_databox_set_visible_limits (GtkDatabox * box, gfloat left, gfloat right, gfloat top, gfloat bottom);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gboolean enable
 void gtk_databox_set_enable_selection (GtkDatabox * box, gboolean enable);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gboolean enable
void gtk_databox_set_enable_zoom (GtkDatabox * box, gboolean enable);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gboolean gtk_databox_get_enable_selection 
 gboolean gtk_databox_get_enable_selection (GtkDatabox * box);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gboolean gtk_databox_get_enable_zoom 
gboolean gtk_databox_get_enable_zoom (GtkDatabox * box);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat value
 gint16 gtk_databox_value_to_pixel_x (GtkDatabox * box, gfloat value);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat value
gint16 gtk_databox_value_to_pixel_y (GtkDatabox * box, gfloat value);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat gtk_databox_pixel_to_value_x 
gfloat gtk_databox_pixel_to_value_x (GtkDatabox * box, gint16 pixel);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gfloat gtk_databox_pixel_to_value_y 
gfloat gtk_databox_pixel_to_value_y (GtkDatabox * box, gint16 pixel);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gboolean scrollbar_x
 void gtk_databox_create_box_with_scrollbars_and_rulers (GtkWidget ** p_box, GtkWidget ** p_table, gboolean scrollbar_x, gboolean scrollbar_y, gboolean ruler_x, gboolean ruler_y);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gboolean scrollbar_y
 void gtk_databox_create_box_with_scrollbars_and_rulers (GtkWidget ** p_box, GtkWidget ** p_table, gboolean scrollbar_x, gboolean scrollbar_y, gboolean ruler_x, gboolean ruler_y);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gboolean ruler_x
 void gtk_databox_create_box_with_scrollbars_and_rulers (GtkWidget ** p_box, GtkWidget ** p_table, gboolean scrollbar_x, gboolean scrollbar_y, gboolean ruler_x, gboolean ruler_y);

/usr/include/gtkdatabox/gtkdatabox.h
Unknown data type:    gboolean ruler_y
 void gtk_databox_create_box_with_scrollbars_and_rulers (GtkWidget ** p_box, GtkWidget ** p_table, gboolean scrollbar_x, gboolean scrollbar_y, gboolean ruler_x, gboolean ruler_y);

/usr/include/gtkdatabox/gtkdatabox_typedefs.h
Unknown data type:    typedef struct _GtkDatabox GtkDatabox
   typedef struct _GtkDatabox GtkDatabox;

/usr/include/gtkdatabox/gtkdatabox_typedefs.h
Function name not found
   typedef struct _GtkDatabox GtkDatabox;

/usr/include/gtkdatabox/gtkdatabox_typedefs.h
Unknown data type:     


/usr/include/gtkdatabox/gtkdatabox_typedefs.h
Function name not found

64 bits

I just installed a 64 bits Ubuntu 11.04 on an AMD64 machine. I then installed the 64 bits gfortran 4.6 using the following instructions : http://gcc.gnu.org/wiki/GFortranBinaries64Linux
I put it in my home directory: ~/gcc-4.6/
I added in my .bashrc:

if [ -z "$LD_LIBRARY_PATH" ]; then
LD_LIBRARY_PATH="~/gcc-4.6/lib64"
else
LD_LIBRARY_PATH="~/gcc-4.6/lib64:$LD_LIBRARY_PATH"
fi
export LD_LIBRARY_PATH

export PATH="~/gcc-4.6/bin:$PATH"

When I launch ./test.sh everything compiles. But when I try to run an example, I just obtain that message:

../examples/menu.f90.out: error while loading shared libraries: libquadmath.so.0: cannot open shared object file: No such file or directory

Any idea ?

Build error in hl_cairo example

Using the cmake build system I get this error message (in all branches):

/examples/hl_cairo1.f90:182.23:

    my_cairo_context = hl_gtk_drawing_area_cairo_new(widget)
                       1
Error: Function 'hl_gtk_drawing_area_cairo_new' at (1) has no IMPLICIT type

Simple Menu Example

I wrote a small example with a simple menu based on GtkUIManager:

! Copyright (C) 2011
! Free Software Foundation, Inc.

! This file is part of the gtk-fortran gtk+ Fortran Interface library.

! This is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 3, or (at your option)
! any later version.

! This software is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! GNU General Public License for more details.

! Under Section 7 of GPL version 3, you are granted additional
! permissions described in the GCC Runtime Library Exception, version
! 3.1, as published by the Free Software Foundation.

! You should have received a copy of the GNU General Public License along with
! this program; see the files COPYING3 and COPYING.RUNTIME respectively.
! If not, see .
!
! gfortran -g gtk.f90 simplemenu.f90 `pkg-config --cflags --libs gtk+-2.0`
! Contributed by Jens Hunger

module handlers
  use gtk
  implicit none
  
  logical :: run_status = TRUE
  logical(c_bool) :: boolresult
  logical :: boolevent
  
  type(c_ptr) :: my_pixbuf
  character(c_char), dimension(:), pointer :: pixel
  integer :: nch, rowstride, width, height
  
contains
  ! User defined event handlers go here

! destroy all
  subroutine destroy (widget, gdata) bind(c)
    use iso_c_binding, only: c_ptr
    type(c_ptr), value :: widget, gdata
    print *, "my destroy"
    call gtk_main_quit ()
  end subroutine destroy

! delete event
  function delete_event (widget, event, gdata) result(ret)  bind(c)
    use iso_c_binding, only: c_ptr, c_int, c_bool
    logical(c_bool)    :: ret
    type(c_ptr), value :: widget, event, gdata
    print *, "my delete_event"
    ret = FALSE
  end function delete_event
  
! open file
  function file_open (widget, event, gdata ) result(ret)  bind(c)
    use iso_c_binding, only: c_ptr, c_int, c_bool
    logical(c_bool)    :: ret
    type(c_ptr), value :: widget, event, gdata
    print *, "File open"
    ret = .false.
  end function file_open

! save file
  function file_save (widget, event, gdata ) result(ret)  bind(c)
    use iso_c_binding, only: c_ptr, c_int, c_bool
    logical(c_bool)    :: ret
    type(c_ptr), value :: widget, event, gdata
    print *, "File save"
    ret = .false.
  end function file_save

! close file
  function file_close (widget, event, gdata ) result(ret)  bind(c)
    use iso_c_binding, only: c_ptr, c_int, c_bool
    logical(c_bool)    :: ret
    type(c_ptr), value :: widget, event, gdata
    print *, "File close"
    ret = .false.
  end function file_close

! cut
  function cut (widget, event, gdata ) result(ret)  bind(c)
    use iso_c_binding, only: c_ptr, c_int, c_bool
    logical(c_bool)    :: ret
    type(c_ptr), value :: widget, event, gdata
    print *, "Cut"
    ret = .false.
  end function cut

! copy
  function copy (widget, event, gdata ) result(ret)  bind(c)
    use iso_c_binding, only: c_ptr, c_int, c_bool
    logical(c_bool)    :: ret
    type(c_ptr), value :: widget, event, gdata
    print *, "Copy"
    ret = .false.
  end function copy

! paste
  function paste (widget, event, gdata ) result(ret)  bind(c)
    use iso_c_binding, only: c_ptr, c_int, c_bool
    logical(c_bool)    :: ret
    type(c_ptr), value :: widget, event, gdata
    print *, "Paste"
    ret = .false.
  end function paste
  
! help
  function help (widget, event, gdata ) result(ret)  bind(c)
    use iso_c_binding, only: c_ptr, c_int, c_bool
    logical(c_bool)    :: ret
    type(c_ptr), value :: widget, event, gdata
    print *, "Help"
    ret = .false.
  end function help

  subroutine convert_c_string(textptr, f_string)
    use iso_c_binding, only: c_char
    implicit none
    character(c_char), dimension(:), pointer, intent(in) :: textptr
    character(len=*), intent(out) :: f_string
    integer :: i
          
    f_string=""
    i=1
    do while(textptr(i) .NE. char(0))
      f_string(i:i)=textptr(i)
      i=i+1
    end do
  end subroutine convert_c_string
  
end module handlers

program simplemenu

    use iso_c_binding
  use gtk
  use handlers

    implicit none

    type ui_action
        character(kind=c_char,len=30)::name
        character(kind=c_char,len=30)::label
        character(kind=c_char,len=30)::tooltip
        character(kind=c_char,len=30)::stock_id
        type(c_funptr)   ::c_handler
    end type ui_action
    
  type(c_ptr) :: mainwindow
  type(c_ptr) :: box
  type(c_ptr) :: menu_bar
  type(c_ptr) :: action_group,menu_manager,error
  character(c_char), dimension(:), pointer :: textptr
  character(len=512) :: error_string
  integer :: ui,i
  ! Menu action data
  type(ui_action),dimension(11)::action = (/&
    ui_action("FileMenuAction"//CNULL, "_File"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("OpenAction"//CNULL, "_Open"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("SaveAction"//CNULL, "_Save"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("CloseAction"//CNULL, "_Close"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("QuitAction"//CNULL, "_Quit"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("EditMenuAction"//CNULL, "_Edit"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("CutAction"//CNULL, "_Cut"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("CopyAction"//CNULL, "_Copy"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("PasteAction"//CNULL, "_Paste"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("HelpMenuAction"//CNULL, "_Help"//CNULL, CNULL, CNULL, c_null_funptr),&
    ui_action("HelpAction"//CNULL, "_Help"//CNULL, CNULL, CNULL, c_null_funptr)&
    /)
  
  ! this is necessary because gfortran gives error:
  ! Function 'c_funloc' in initialization expression at must be an intrinsic function
  !action(1)%c_handler=c_funloc(destroy)
  action(2)%c_handler=c_funloc(file_open)
  action(3)%c_handler=c_funloc(file_save)
  action(4)%c_handler=c_funloc(file_close)
  action(5)%c_handler=c_funloc(destroy)
  !action(6)%c_handler=c_funloc(destroy)
  action(7)%c_handler=c_funloc(cut)
  action(8)%c_handler=c_funloc(copy)
  action(9)%c_handler=c_funloc(paste)
  !action(10)%c_handler=c_funloc(destroy)
  action(11)%c_handler=c_funloc(help)
  
    ! GTK initialisation            
  call gtk_init ()
  
  ! Properties of the main window :
  width = 700
  height = 700
  mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL)
  call gtk_window_set_title(mainwindow, "Simple Menu Example"//CNULL)
  call gtk_window_set_default_size(mainwindow, 500, 500)
  
  ! Connect signals to the main window
  call g_signal_connect (mainwindow, "delete-event"//CNULL, c_funloc(delete_event))
  call g_signal_connect (mainwindow, "destroy"//CNULL, c_funloc(destroy))

  ! Fill action group with actions and connect signals
  action_group = gtk_action_group_new("Menu");
  do i=1,size(action)
      call gtk_action_group_add_action(action_group, gtk_action_new(action(i)%name,&
        action(i)%label,action(i)%tooltip,action(i)%stock_id))
      call g_signal_connect (gtk_action_group_get_action(action_group,action(i)%name),&
        "activate"//CNULL, action(i)%c_handler)
  enddo
  
  ! Insert action group into ui manager
  menu_manager = gtk_ui_manager_new ()
  call gtk_ui_manager_insert_action_group (menu_manager, action_group, 0)
  error = NULL
  ui = gtk_ui_manager_add_ui_from_file (menu_manager, "menu.xml"//CNULL, error)
            
  ! Handle error
  if (c_associated(error)) then
                call C_F_POINTER(error, textptr, (/512/))
                call convert_c_string(textptr, error_string)
                print *,"building menus failed: ", error_string
  endif
  
  ! Container for menu
  box = gtk_vbox_new (FALSE,0)
  call gtk_container_add (mainwindow, box)
  call gtk_box_pack_start (box, gtk_ui_manager_get_widget (menu_manager, "/MainMenu"//CNULL), FALSE, FALSE, 0)

  ! Show all
  call gtk_widget_show_all (mainwindow)
  
  ! Main loop
    call gtk_main ()

end program simplemenu

Here is the corresponding menu.xml with the XML representation of the menu:

















Use of G95 compiler

The examples gtkhello2, cairo-basics, mandelbrot and mandelbrot_pixbuf work with G95 compiler (g95 gtk.f90 .f90 -o pkg-config --cflags --libs gtk+-2.0), version 0.93, configured with ../configure --enable-languages=c --disable-multilib, thread model: posix, gcc version 4.1.2, Linux 2.6.32-22-generic #36-Ubuntu SMP x86_64 GNU/Linux.

hl-plplot: Resize plot on window resize

I tried to implement a plot via plplot which resizes by resizing the toplevel window container (see code below). So far it works in principle, but the parts of the plot which are not within the initial size of the drawing area are not visualized. Furthermore it is not possible to shrink the window below the initial size this way. Any ideas?

! gfortran hl_plplot_resize.f90 -o hlplplotr `pkg-config --cflags --libs gtk-2-fortran plplotd-f95`

module common
  use iso_c_binding
  use gtk, only: gtk_button_new, gtk_container_add, gtk_drawing_area&
       &_new, gtk_events_pending, gtk_main, gtk_main_iteration, gtk_main_iteration_do,&
       & gtk_widget_show, gtk_widget_show_all, gtk_window_new, gtk_init
  use g, only: g_object_get_data, g_usleep
  use gdk_pixbuf, only: gdk_pixbuf_get_height, gdk_pixbuf_get_pixels, gdk_pixbuf_&
       &get_width

  use gtk_draw_hl

  use plplot_extra

  integer(kind=c_int) :: height, width
  type(c_ptr) :: window, drawing, scroll_w, base, qbut

end module common

module plplot_code
  use plplot, PI => PL_PI
  use iso_c_binding
  use common 

  implicit none
  
  real(plflt) :: xscale, yscale, xoff, yoff

contains
  subroutine x01f95(area)

    type(c_ptr), intent(in) :: area

    type(c_ptr) :: cc

    character(len=80) :: version
    character(len=20) :: geometry
    integer :: digmax

    ! Define colour map 0 to match the "GRAFFER" colour table in
    ! place of the PLPLOT default.
    integer, parameter, dimension(16) :: rval = (/255, 0, 255, &
         & 0, 0, 0, 255, 255, 255, 127, 0, 0, 127, 255, 85, 170/),&
         & gval = (/ 255, 0, 0, 255, 0, 255, 0, 255, 127, 255, 255, 127,&
         & 0, 0, 85, 170/), &
         & bval = (/ 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 127, 255, 255,&
         & 127, 85, 170/)

    !  Process command-line arguments
    call plparseopts(PL_PARSE_FULL)

    ! Get a cairo context from the drawing area.

    cc = hl_gtk_drawing_area_cairo_new(area)

    !  Initialize plplot
    call plscmap0(rval, gval, bval)
    call plsdev("extcairo")

    ! By default the "extcairo" driver does not reset the background
    ! This is equivalent to the command line option "-drvopt set_background=1"
    call plsetopt("drvopt", "set_background=1")  

    ! The "extcairo" device doesn't read the size from the context.
    write(geometry, "(I0,'x',I0)") width, height
    call plsetopt("geometry",  geometry)
    call plstar(1,1)

    ! Tell the "extcairo" driver where the context is located.
    call pl_cmd(PLESC_DEVINIT, cc)

    !  Set up the data
    xscale = 6._plflt
    yscale = 1._plflt
    xoff = 0._plflt
    yoff = 0._plflt

    !  Do a plot
    call plot1()

    !  Don't forget to call PLEND to finish off!

    call plend()
    call hl_gtk_drawing_area_cairo_destroy(cc)

  end subroutine x01f95

  !======================================================================
  subroutine plot1()

    real(plflt), dimension(1:60) :: x, y
    real(plflt), dimension(1:6)  :: xs, ys
    real(plflt) :: xmin, xmax, ymin, ymax 
    integer :: i

    do i = 1, 60
       x(i) = xoff + xscale * dble(i)/60.0_plflt
       y(i) = yoff + yscale * x(i)**2
    enddo

    xmin = x(1)
    xmax = x(60)
    ymin = y(1)
    ymax = y(60)

    do i = 1, 6
       xs(i) = x((i-1)*10+4)
       ys(i) = y((i-1)*10+4)
    enddo

    !   Set up the viewport and window using PLENV. The range in X is
    !   0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are
    !   scaled separately (just = 0), and we just draw a labelled
    !   box (axis = 0).

    call plcol0(1)
    call plenv( xmin, xmax, ymin, ymax, 0, 0 )
    call plcol0(2)
    call pllab( '(x)', '(y)', '#frPLplot Example 1 - y=x#u2' )

    !   Plot the data points

    call plcol0(4)
    call plpoin( xs, ys, 9 )

    !   Draw the line through the data

    call plcol0(3)
    call plline( x, y )

  end subroutine plot1

end module plplot_code

module cl_handlers

  use common

  use gtk, only: gtk_widget_get_allocation
  use gtk_hl
  use gtk_draw_hl
  
  use plplot_code

  use iso_c_binding

  implicit none

  type, bind(c) :: gtkallocation
     integer(kind=c_int) :: x,y,width,height
  end type gtkallocation

  integer(kind=c_int) :: run_status = TRUE

contains
  function delete_cb (widget, event, gdata) result(ret)  bind(c)

    integer(c_int)    :: ret
    type(c_ptr), value :: widget, event, gdata

    run_status = FALSE
    ret = FALSE
  end function delete_cb

  subroutine quit_cb(widget, gdata) bind(c)
    type(c_ptr), value :: widget, gdata

    run_status = FALSE
  end subroutine quit_cb

  subroutine pending_events ()
    integer(kind=c_int) :: boolresult
    do while(IAND(gtk_events_pending(), run_status) /= FALSE)
       boolresult = gtk_main_iteration_do(FALSE) ! False for non-blocking
    end do
  end subroutine pending_events

  function resize (widget, gdata) result(ret) bind(c)
    use iso_c_binding, only: c_ptr, c_int
    integer(c_int)     :: ret
    type(c_ptr), value :: widget, gdata
    type(gtkallocation), target:: alloc
!
    call gtk_widget_get_allocation(drawing,c_loc(alloc))
    print*,"resize",alloc%width,alloc%height
    width=alloc%width
    height=alloc%height
    call x01f95(drawing)
    ret = FALSE
  end function resize

end module cl_handlers

program cairo_plplot_resize

  use cl_handlers

  implicit none

  height = 500
  width = 500

  call gtk_init()

  window = hl_gtk_window_new("PLplot gtk-fortran (extcairo) - resize"//c_null_char, &
       & delete_event = c_funloc(delete_cb),resizable=true)
  call g_signal_connect(window, "check-resize"//C_NULL_CHAR, c_funloc(resize))
  base = hl_gtk_box_new()
  call gtk_container_add(window, base)

  drawing = hl_gtk_drawing_area_new(size=(/width, height/), &
       & has_alpha = FALSE)
  call hl_gtk_box_pack(base, drawing)

  qbut = hl_gtk_button_new("Quit"//c_null_char, clicked=c_funloc(quit_cb))
  call hl_gtk_box_pack(base, qbut, expand=FALSE)

  call gtk_widget_show_all (window)

  call x01f95(drawing)

  do
     call pending_events()
     if (run_status == FALSE) exit
     call g_usleep(10000_c_long) ! So we don't burn CPU cycles
  end do
  print *, "All done"
end program cairo_plplot_resize

GtkBuilder-Fortran code sketcher

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.

c_char kind

Hello all,
in my copy of the repository, I found that there is the c_char kind attribute used without kind=. I think it is a bug and it can't compile on Sun Studio because of that. I believe the compiler interprets it correctly as len= attribute. I don't know, why it works on gcc.

Forgive me if I am wrong, i can't pull right now. Regards,

Vladimir

High-level interface status & questions

Higher-level Fortran <-> GTK+ interfaces.

Why?

One of the biggest disincentives to writing GUI interfaces for most programmers (particularly those whose main job is to get the science out of the end of the program) is the very low-level nature of the standard API of the main toolkits, which means that many calls are needed to do even very simple tasks. Experience with IDL (Interactive Data Language) shows that the construction of widget interfaces need not be as complex as it generally is with the C and C++ toolkits.

Because of this (and partially inspired by the Pilib project--http://pilib.beta-centauri.de/index.php/Main_Page) I felt that it would be useful to add higher-level interfaces to the GtkFortran project.

How

The f_gtk_ routines are mainly widget creation bundles. They make use of Fortran95's optional arguments to allow the setting of event-handlers, user data, sizes and the like within a single call, but without forcing the user to set things he/she does not need.

For more complex widgets such as radio button groups and clickable lists, routines are also provided for setting and reading selections etc.

The f_gtk_ routines can be freely mixed with the normal gtk_ interface from GtkFortran. In particular, other than top-level windows, bundling of containers has not been attempted, since the variety of types available means that the interface would likely become more and not less complex.

As far as possible the feel of the interfaces has been retained from the standard gtk_ routines, even though in principle it would have been possible to remove most of the C-isms from the API (e.g. the c_loc() and c_funloc() wrappers) as I felt that would be confusing. The one exception to this rule is likely to be for multi-line text items where arrays of character strings needs to be passed and there is no easy way to do this other than passing Fortran strings and converting them individually.

What

This is still incomplete, but currently implemented are:

  • Window: A top-level window with size and close handling
  • Buttons: A normal button, a checkbox button and radio button menus.
  • Entry: A 1-line text entry box
  • List: A single-column list with indexing, based on the GtkTreeView family. N.B. This does not work correctly with g95, owing to problems with the handling of GValue types.

Written but not yet tested:

  • Menu: Menus with submenus. An item-at-a-time interface.
  • Progress bar: Including settings for m-of-n and automatically adding text.

Still to do:

  • Multiline text boxes.
  • Message windows (important as GtkMessageDialog has only varargs-based creators, will need to make one from a plain GtkDialog).
  • Multicolumn lists.
  • Sliders and Spinboxes.
  • ComboBoxes.
  • Drawing areas?

and probably many more.

There is probably not a lot of point in adding wrappers to very simple widgets that typically only have a single call to create them and a single call to add or modify data (e.g. Labels or Status bars). Likewise I don't see much scope for simplifying the interfaces to the various container widgets (possibly notebooks might be an exception here).

An example

The example below is a snippet from the code to test radio buttons to give an example of the feel of the interface.
group=NULL

do i=1,6
   write(label,"('Choice #',i0)") i-1
   rbut(i) = f_gtk_radio_button(group, trim(label)//cnull, &
        & toggled=c_funloc(rb_toggle), data=c_loc(isel(i)))
   call gtk_box_pack_start_defaults(box, rbut(i))
end do

! Set a selection (3)
call f_gtk_radio_set_select(group, 3)

Questions

There are a number of questions to which we need to agree an answer before the module is committed.

  1. Name of the module and source file. Right now it's called fgtk_h_widgets and fgtk_h_widgets.f90.
  2. Naming conventions for the routines. Currently they are called f_gtk_..., and creators have a bare name e.g. f_gtk_button where perhaps f_gtk_button_new might be considered more correct.
  3. Or even if it is appropriate as part of the main distrubution

RPNcalc -- a useful GtkFortran application

For a while now I've been working on and off on a RPN scientific calculator application (based on an earlier one using an extended PiLib). I've now got it to a usable state. So I've created a new repository for it, since it's intended to be built from an installed GtkFortran.

The repository is at: https://github.com/jtappin/RPNcalc

By using the gtk_hl interface it is possible to make this app in well under 2000 lines of actual code (in fact it was the main driver of the initial choices of widgets included in gtk_hl).

extract_events stumbles over an empty line

Hi,

The extract_events script stumbles on Ubuntu 12.04 over an empty line in
/usr/include/gtk-3.0/gdk/gdkevents.h:

  ...
   *
   * Generated during DND operations.
   */
  struct _GdkEventDND {
    GdkEventType type;
    GdkWindow *window;
    gint8 send_event;
    GdkDragContext *context;

    guint32 time;
    gshort x_root, y_root;
  };
  ...

Modified extract_events.pl to skip a blank line:

  ...
  if ( $sflag ) {  # We are defining a structure
    if ($_ eq "{") { # Skip the starting delimiter 
    next LINE;
    }
    if ($_ eq "") { # Skip blank line
    next LINE;
    }
    if ($_ eq $sepattern) { # Ending delimiter close out the definition
    $sflag = 0;
    ...

Regards!
Henk

Build System

I don't know what others think, but I feel we a now at a stage where we should think about a proper build system for GtkFortran.

I have been running the examples by making a static library from the src directory and then using a script like:

#!/bin/bash

gfortdir=/usr/local/gfortran
time ${gfortdir}/bin/gfortran -g ${1}.f90 -L${gfortdir}/lib64 -L../src \
    -Xlinker -R${gfortdir}/lib64 -I../src \
    -o $1 `pkg-config --cflags --libs gtk+-2.0` -lfgtk

to build the examples.

I think the main candidates would be autotools or cmake, I've not used either though cmake looks easier and is probably more convenient for something which needs to port to Windows & MacOS/

Thoughts...

Linking on Windows

I am having trouble getting my first GTK/Fortran program
to link.

Great project! I am hoping to put links to it on fortran.com
(when I get it to work :-) and include it with our Fortran Tools.

Here is what I have. All the Fortran
programs compile OK. I am using gfortran 4.7 on Windows 7 (64).
I am using bash because of the `tic stuff in the command, but
would like to be able to use it without bash, if possible.

I get the same "invalid argumentr" when trying to compile the
examples running "test.sh".

Help would be appreciated.

Thanks.

walt dot brainerd
gmail dot com

C:\walt\FortranToolsCB\Src\GTK\Test>bash

Walt@HP_Laptop /cygdrive/c/walt/FortranToolsCB/Src/GTK/Test
$ XXX=pkg-config --cflags --libs gtk+-2.0

Walt@HP_Laptop /cygdrive/c/walt/FortranToolsCB/Src/GTK/Test
$ echo $XXX
-mms-bitfields -IC:/walt/FortranToolsCB/Src/GTK/include/gtk-2.0
-IC:/walt/FortranToolsCB/Src/GTK/lib/gtk-2.0/include -IC
:/walt/FortranToolsCB/Src/GTK/include/atk-1.0
-IC:/walt/FortranToolsCB/Src/GTK/include/cairo
-IC:/walt/FortranToolsCB/Sr
c/GTK/include/gdk-pixbuf-2.0
-IC:/walt/FortranToolsCB/Src/GTK/include/pango-1.0
-IC:/walt/FortranToolsCB/Src/GTK/include
/glib-2.0 -IC:/walt/FortranToolsCB/Src/GTK/lib/glib-2.0/include
-IC:/walt/FortranToolsCB/Src/GTK/include -IC:/walt/Fortr
anToolsCB/Src/GTK/include/freetype2
-IC:/walt/FortranToolsCB/Src/GTK/include/libpng14
-LC:/walt/FortranToolsCB/Src/GTK/l
ib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0
-lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpang
o-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl

Walt@HP_Laptop /cygdrive/c/walt/FortranToolsCB/Src/GTK/Test
$ gfortran *.o $XXX
: Invalid argumentr:

Walt@HP_Laptop /cygdrive/c/walt/FortranToolsCB/Src/GTK/Test
$

Some thoughts

I've just started playing with gtk-fortran (mainly on Pardus Linux).

One thing I'm currently trying to do is to convert a rpn-calculator program that I wrote with an extended version of pilib (I was planning to try to make an updated pilib, but my C wasn't up to some of the changes needed). I'll try to keep folks updated on progress there.

One thing which I am doing as part of that is to make some higher-level calls, which I think could be useful for acceptance of gtk-fortran[*]. For example the button routine has an optional argument CLICKED which if present will attach the "clicked" signal handler. It might be possible to use this to hide some of the messier parts of the C-bindings by this means as well, though I think it would still have to be exposed in the event handlers.

Has anybody had any thoughts about the usability of the "data" argument to the signal_connect routines? I see that there is a manual work around on g_signal_connect which removes it. The only way I could think of doing it was by giving a fixed type and then using that ugly FORTRAN-66ism EQUIVALENCE to allow arbitrary data types to be passed.

[*] I'm guessing that the typical programmer who would want gtk-fortran would be most likely to have done GUI development in IDL.

GTK+ 2.24.6 & 3.2.0 update (Ubuntu 11.10)

I have upgraded to Ubuntu 11.10 (gtk 2.24.6, gtk 3.2.0, gfortran 4.6.1, python 2.7.2). And so, I have just updated gtk-fortran with gtk 2.24.6 & gtk 3.2.0. We have gained respectively 169 & 251 new interfaces.

gtk 2.24.6
=== Statistics ===
nb_files scanned = 554
nb_generated_interfaces = 8972
nb_type_errors = 196
nb_errors (others) = 314
nb_lines treated = 24267
nb_variadic functions = 85

gtk 3.2.0
=== Statistics ===
nb_files scanned = 569
nb_generated_interfaces = 8717
nb_type_errors = 186
nb_errors (others) = 260
nb_lines treated = 22509
nb_variadic functions = 86

usemodules.py

There are a number of issues with usemodules.py that really need to be addressed, and I'm not sufficiently conversant with python to do it.

  1. It picks out substrings of routine names rather than full names. While this isn't a major problem with gtk routines that are substrings of others (e.g. gtk_combo_box_new, gtk_combo_box_new_with_model and gtk_combo_box_new_with_model_and_entry), it can be an issue with cases like hl_gtk_table_new which if scanned against a version of gtk-fortran using gtk 3.2 or less will add gtk_table_new to the symbol list, thus requiring modification of the source to build against gtk 3.4 or above. In perl regexps I think a match might be along the lines of m/[^a-zA-Z0-9_]([a-zA-Z0-9_]+)[^a-zA-Z0-9_]/ to find strings to compare (i.e. a string of letters, numbers and underscores delimited by characters not in that set).
  2. It requires write access to the source tree. One possible solution to this within the context of an installed gtk-fortran might be:
    • Install usemodules.py under a suitable name in ${PREFIX}/bin (e.g. gtk-3-fortran-modscan and gtk-2-fortran-modscan)
    • Install gtk-fortran-index.csv in ${PREFIX}/share/gtk-fortran, again with a suitable way to distinguish gtk2 and gtk 3 versions.
    • Have a way to find the path to the index file (the simplest would be to use sed at build time to change a token (as I currently do for the pkg-config file).
  3. It would be nice if it could scan individual files as well as whole directories and had an output filename derived from the input file or directory.

GTK+ 2.24.10 & 3.4.2 cause problems to cfwrapper.py

Please do not use cfwrapper.py if you have upgraded to GTK+ 2.24.10 or GTK+ 3.4.2 (available in Ubuntu 12.04). The automatically generated files lack some functions interfaces and gtk-fortran can not be compiled anymore. I need to have a look to the GTK+ files in order to understand what has changed...

Documentation license

Do all contributors to the wiki documentation agree to put it under a free license ?
Do you thing we should we use the GNU Free Documentation License or a Creative Commons license ?

Interesting issue with gtk_tree_view & associated widgets

I've been trying to make a clickable list (following some of the examples in Pilib). And I have come across what looks to be a fairly fundamental problem.
Pilib creates its columns using (layout calls excised for clarity):
types = malloc(sizeof(GType) * 2);
types[0] = G_TYPE_INT;
types[1] = G_TYPE_STRING;

model = (GtkTreeModel*) gtk_list_store_newv(2, types);
*widget = gtk_tree_view_new_with_model(model);
renderer = gtk_cell_renderer_text_new ();
renderer->visible = FALSE;

column = gtk_tree_view_column_new_with_attributes("#", renderer, 
                          "text", 0, NULL);
.
.
.

Now the obvious problem here is that "gtk_tree_view_column_new_with_attributes" is a varargs routine. However a little perusal of the manual suggests that the following sequence should replace the call:
column = gtk_tree_view_column_new()
call gtk_tree_view_column_set_title(column, "#"//cnull)
call gtk_tree_view_column_add_attribute(column, renderer, &
& "text"//CNULL, 0)

However, this gives an assertion error:
(list1:2243): Gtk-CRITICAL **: gtk_tree_view_column_cell_layout_add_attribute: assertion `info != NULL' failed

Likewise the calls to set a row:
gtk_list_store_set(store,&iter, 0, nrow, -1);
gtk_list_store_set(store,&iter, 1, val->str, -1);
Should be replaceable with:
call gtk_list_store_set_value(store, c_loc(iter), 0, c_loc(nrow))
call gtk_list_store_set_value(store, c_loc(iter), 1, c_loc(text))

In this case on the 64-bit system the first call gives a segfault while on the 32-bit system the first gives an assertion error and the second a segfault.
(list1:2243): Gtk-CRITICAL **: IA__gtk_list_store_set_value: assertion `G_IS_VALUE (value)' failed

I don't think the problem is with the Fortran interface as I've been able to reproduce the
64-bit system errors with a modified Pilib code that makes the same call substitutions.
This is mainly a heads-up in case anyone else is messing in this region of the library as so far I've not had any response to my queries on the gtk-apps-devel list.

gtkbuilder and Mac OS X

Paul F. built gtk-fortran on a MacBook Pro with a Core2Duo running the latest MacOSX 10.6.7
(Darwin 10.7.0 on x86_64), gtk 2.24.4 quartz version as well as gfortran 4.6 using macports. You can see some screenshots on the wiki.

The only problems are that gtkbuilder did not launch properly (he killed it after 5 minutes), and issued two
messages:

(gtkbuilder.f90.out:1578): Gtk-CRITICAL **: gtk_builder_add_from_file: assertion
`error == NULL || *error == NULL' failed
(gtkbuilder.f90.out:1578): Gtk-CRITICAL **: gtk_widget_show: assertion
`GTK_IS_WIDGET (widget)' failed

Same for gtkbuilder2:

(gtkbuilder2.f90.out:1601): Gtk-CRITICAL **: gtk_builder_add_from_file:
assertion `error == NULL || *error == NULL' failed
(gtkbuilder2.f90.out:1601): Gtk-CRITICAL **: gtk_widget_show: assertion
`GTK_IS_WIDGET (widget)' failed

They were launched from the examples/ directory.
Any idea ?

void * functions in cairo

Another type issue:

In cairo, generic pointers are void * rather than gpointer (since cairo doesn't depend on glib). This confuses cfwrapper.py which turns functions returning a generic pointer (e.g. cairo_get_user_data into subroutines instead of functions returning a c_ptr. I tried to find where to fix it but my python isn't up to the job.

Required software for compiling this library

Hi,

What are the pre-requisite SW needed for building gtk-fortran ? When I try this

gfortran `pkg-config --cflags --libs gtk+-2.0`  ./gtkhello2.f90

I get the following error:

Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
./gtkhello2.f90:28.9:

use gtk
       1
Fatal Error: Can't open module file 'gtk.mod' for reading at (1): No such file or directory

I'm using Ubuntu 10.10 (Maverick). I tried to install "libgtk-2.0-dev" but it seems to pull along a whole lot of baggage (~ 46 packages to be installed for libgtk-2.0-dev to work !). The non-dev version is already installed. I'm not willing to waste > 100 MB space just to compile 2 *.f90 files. So, I was wondering if there is a simpler / easier way.

CMake Build System

I have created a CMake build system for gtk-fortran, and successfully used in on the Debian (wheezy) system to build the examples. CMake provides many features that could be useful to the project. I can be contacted at the following address:
horne \dot kyle \at gmail \dot com

Problem with gtkbuilder2: "Could not find signal handler"

There seems to be a problem with gtkbuilder2 on PC BSD 9.0 with both gtk2 and gtk3 (-old branches in each case as glib is at 2.28). Since it occurs with Gtk+2 as well as 3, I don't think it's an issue of the version for which the interface files were generated, and the versions do match in gtk2.

(gtkbuilder2:2931): Gtk-WARNING **: Could not find signal handler 'destroy'

(gtkbuilder2:2931): Gtk-WARNING **: Could not find signal handler 'delete_event'

(gtkbuilder2:2931): Gtk-WARNING **: Could not find signal handler 'destroy'

(gtkbuilder2:2931): Gtk-WARNING **: Could not find signal handler 'button2clicked'

(gtkbuilder2:2931): Gtk-WARNING **: Could not find signal handler 'hello'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.