Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* src/gtk-hl.f90: Minor bug fix (status in hl_gtk_entry_get_text)

*  src/gtk-sup.f90: Add utility routines to convert F<->C logicals.
  • Loading branch information...
commit 52ec09a6a5accaaf5b2476391e6cf6226058ec53 1 parent 7a47b39
@jtappin jtappin authored
Showing with 80 additions and 12 deletions.
  1. +11 −7 src/gtk-hl.f90
  2. +69 −5 src/gtk-sup.f90
View
18 src/gtk-hl.f90
@@ -339,6 +339,7 @@ module gtk_hl
!*
! Containers
! The high-level interface provides convenience interfaces for:
+ !
! * Window, the gtk top-level window.
! * Box, Horizontal and vertical boxes to pack widgets. This was added because the
! gtk_box_pack_start_defaults procedure is removed from GTK3.x
@@ -1137,6 +1138,7 @@ subroutine hl_gtk_entry_get_text(entry, text, status)
ntext = gtk_entry_get_text_length(entry)
if (ntext == 0) then
text=''
+ if (present(status)) status = 0
return
end if
ctext = gtk_entry_get_text(entry)
@@ -4583,7 +4585,9 @@ function hl_gtk_progress_bar_new(vertical, reversed, step) result(bar)
! Intializer for a progress bar
!
- ! ORIENTATION: integer: optional: The orientation of the bar.
+ ! VERTICAL: boolean: optional: Set to TRUE to make a vertical bar
+ ! REVERSED: boolean: optional: Set to TRUE to make a reversed
+ ! R->L or T->B bar).
! STEP: double: optional: The fractional step to advance when
! pulsing the bar
!-
@@ -4639,7 +4643,7 @@ subroutine hl_gtk_progress_bar_set_f(bar, val, string, text)
! TEXT: string: optional: Text to put in the bar, (overrides STRING)
!
! This routine is normally accessed via the generic interface
- ! hl_gtk_progress_bar
+ ! hl_gtk_progress_bar_set
!-
character(len=50) :: sval
@@ -4689,7 +4693,7 @@ subroutine hl_gtk_progress_bar_set_ii(bar, val, maxv, string, text)
! TEXT: string: optional: Text to put in the bar, (overrides STRING)
!
! This routine is normally accessed via the generic interface
- ! hl_gtk_progress_bar
+ ! hl_gtk_progress_bar_set
!-
real(kind=c_double) :: frac
@@ -5583,7 +5587,7 @@ subroutine hl_gtk_slider_set_range(slider, lower, upper)
! LOWER: c_double: optional: The new lower bound
! UPPER: c_double: optional: The new uppper bound
!
- ! Note: This routine is not a generic interface as
+ ! **Note** This routine is not a generic interface as
! overloading requires that the interface be distinguishable by its
! required arguments, and it seems less annoying to have to convert to
! doubles or use a separate call than to specify an unchanged bound.
@@ -5623,7 +5627,7 @@ subroutine hl_gtk_slider_set_range_int(slider, lower, upper)
! LOWER: c_int: optional: The new lower bound
! UPPER: c_int: optional: The new uppper bound
!
- ! Note: This routine is not a generic interface as
+ ! **Note** This routine is not a generic interface as
! overloading requires that the interface be distinguishable by its
! required arguments, and it seems less annoying to use a separate
! call than to specify an unchanged bound.
@@ -5838,7 +5842,7 @@ subroutine hl_gtk_spin_button_set_range(spin_button, lower, upper)
! LOWER: c_double: optional: The new lower bound
! UPPER: c_double: optional: The new uppper bound
!
- ! Note: This routine is not a generic interface as
+ ! **Note** This routine is not a generic interface as
! overloading requires that the interface be distinguishable by its
! required arguments, and it seems less annoying to have to convert to
! doubles or use a separate call than to specify an unchanged bound.
@@ -5879,7 +5883,7 @@ subroutine hl_gtk_spin_button_set_range_int(spin_button, lower, upper)
! LOWER: c_int: optional: The new lower bound
! UPPER: c_int: optional: The new uppper bound
!
- ! Note: This routine is not a generic interface as
+ ! **Note** This routine is not a generic interface as
! overloading requires that the interface be distinguishable by its
! required arguments, and it seems less annoying to use a separate
! call than to specify an unchanged bound.
View
74 src/gtk-sup.f90
@@ -23,7 +23,7 @@
! If not, see <http://www.gnu.org/licenses/>.
!
! Contributed by James Tappin
-! Last modification: 04-17-2011
+! Last modification: 08-13-2011
!*
! Supplementary material
@@ -45,7 +45,7 @@ module gtk_sup
! Various GTK_STOCK strings.
use iso_c_binding
- use gtk, only: NULL, CNULL
+ use gtk, only: NULL, CNULL, TRUE, FALSE
use g, only: alloca, g_type_fundamental
implicit none
@@ -363,6 +363,12 @@ module gtk_sup
module procedure convert_c_string_array_cptr
end interface convert_c_string
+ ! Interfaces for logical conversion
+ interface f_c_logical
+ module procedure f_c_logical4
+ module procedure f_c_logical1
+ end interface f_c_logical
+
contains
! These 2 clear_ routines are only needed of you need to re-initialize
! the types. The definitions include the intial setting to zero or NULL.
@@ -571,6 +577,10 @@ end subroutine convert_c_string_array_cptr
!+
subroutine convert_f_string(f_string, textptr, length)
+ character(len=*), intent(in), dimension(:) :: f_string
+ character(kind=c_char), dimension(:), intent(out), allocatable :: textptr
+ integer(kind=c_int), intent(out), optional :: length
+
! Convert a fortran string array into a null-terminated, LF_separated
! c-string
!
@@ -578,9 +588,6 @@ subroutine convert_f_string(f_string, textptr, length)
! TEXTPR: string: required: A C tyoe string, (allocatable).
! LENGTH: c_int: optional: The lenght of the generated c string.
!-
- character(len=*), intent(in), dimension(:) :: f_string
- character(kind=c_char), dimension(:), intent(out), allocatable :: textptr
- integer(kind=c_int), intent(out), optional :: length
integer :: lcstr, i, j, ii
@@ -606,4 +613,61 @@ subroutine convert_f_string(f_string, textptr, length)
ii = ii+1
end do
end subroutine convert_f_string
+
+ !+
+ function c_f_logical(cbool)
+ logical :: c_f_logical
+ integer(kind=c_int), intent(in) :: cbool
+
+ ! Convert a gboolean to a Fortran logical
+ !
+ ! CBOOL: boolean: required: The Gboolean to convert.
+ !-
+
+ if (cbool == FALSE) then
+ c_f_logical = .false.
+ else
+ c_f_logical = .true.
+ end if
+
+ end function c_f_logical
+
+ !+
+ function f_c_logical4(flog)
+ integer(kind=c_int) :: f_c_logical4
+ logical, intent(in) :: flog
+
+ ! Convert a Fortran default logical to a gboolean
+ !
+ ! FLOG: logical: required: The fortran logical to convert.
+ !
+ ! Usually accessed via the generic f_c_logical interface
+ !-
+
+ if (flog) then
+ f_c_logical4 = TRUE
+ else
+ f_c_logical4 = FALSE
+ end if
+ end function f_c_logical4
+
+ !+
+ function f_c_logical1(flog)
+ integer(kind=c_int) :: f_c_logical1
+ logical(kind=1), intent(in) :: flog
+
+ ! Convert a Fortran 1-byte logical to a gboolean
+ !
+ ! FLOG: logical*1: required: The fortran logical to convert.
+ !
+ ! Usually accessed via the generic f_c_logical interface
+ !-
+
+ if (flog) then
+ f_c_logical1 = TRUE
+ else
+ f_c_logical1 = FALSE
+ end if
+ end function f_c_logical1
+
end module gtk_sup
Please sign in to comment.
Something went wrong with that request. Please try again.