Skip to content
This repository
branch: gtk3
Fetching contributors…

Cannot retrieve contributors at this time

file 315 lines (259 sloc) 10.12 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
! 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 <http://www.gnu.org/licenses/>.
!
! Contributed by James Tappin
! Last modification: 11-21-2011

! --------------------------------------------------------
! gtk-hl-combobox.f90
! Generated: Tue Oct 29 17:12:20 2013 GMT
! Please do not edit this file directly,
! Edit gtk-hl-combobox-tmpl.f90, and use ./mk_gtk_hl.pl to regenerate.
! Generated for GTK+ version: 3.10.0.
! Generated for GLIB version: 2.38.0.
! --------------------------------------------------------


!*
! ComboBox
module gtk_hl_combobox
  ! This interface implements the GtkComboBoxText widget for making a chooser.
  ! While this has more limited capabilities than the full GtkComboBox, it
  ! is adequate for the vast majority of uses.
  !/

  use gtk_sup
  use iso_c_binding
  ! Autogenerated use's
  use gtk, only: gtk_combo_box_get_active, gtk_combo_box_new,&
       & gtk_combo_box_set_active, &
       & gtk_widget_set_sensitive, gtk_widget_set_tooltip_text,&
!!$GTK< 2.24! & gtk_combo_box_get_active_text, &
!!$GTK< 2.24! & gtk_combo_box_new_with_entry, &
!!$GTK< 2.24! & gtk_combo_box_new_text, gtk_combo_box_entry_new_text, &
!!$GTK< 2.24! & gtk_combo_box_append_text,&
!!$GTK< 2.24! & gtk_combo_box_insert_text,&
!!$GTK< 2.24! & gtk_combo_box_prepend_text,&
!!$GTK< 2.24! & gtk_combo_box_remove_text,&
       & gtk_combo_box_text_get_active_text, gtk_combo_box_text_new,&
       & gtk_combo_box_text_new_with_entry, &
       & gtk_combo_box_text_remove, &
       & gtk_combo_box_text_append_text,&
       & gtk_combo_box_text_insert_text,&
       & gtk_combo_box_text_prepend_text,&
       & gtk_combo_box_text_remove_all, &
       & gtk_combo_box_get_model, gtk_tree_model_iter_n_children, &
       & TRUE, FALSE, g_signal_connect

  implicit none

interface hl_gtk_combo_box_delete
     module procedure hl_gtk_combo_box_delete_single
     module procedure hl_gtk_combo_box_delete_multi
     module procedure hl_gtk_combo_box_delete_all
  end interface hl_gtk_combo_box_delete

contains
  !+
  function hl_gtk_combo_box_new(has_entry, changed, data, initial_choices, &
       & sensitive, tooltip, active) result(cbox)

    type(c_ptr) :: cbox
    integer(kind=c_int), intent(in), optional :: has_entry
    type(c_funptr), optional :: changed
    type(c_ptr), intent(in), optional :: data
character(len=*), dimension(:), intent(in), optional :: initial_choices
    integer(kind=c_int), intent(in), optional :: sensitive
    character(kind=c_char), dimension(*), optional, intent(in) :: tooltip
    integer(kind=c_int), optional, intent(in) :: active

    ! Creator for the combobox.
    !
    ! HAS_ENTRY: boolean: optional: Set to TRUE to add an entry field.
    ! CHANGED: c_funptr: optional: Callback routine for the "changed" signal.
    ! DATA: c_ptr: optional: User data for the changed callback.
    ! INITIAL_CHOICES: string(): optional: Initial list of choices.
    ! SENSITIVE: boolean: optional: Set to FALSE to make the widget start in an
    ! insensitive state.
    ! TOOLTIP: string: optional: A tooltip to display when the pointer is
    ! held over the widget.
    ! ACTIVE: c_int: optional: The initial active selection.
    !-

    integer(kind=c_int) :: ientry
    integer(kind=c_int) :: i

    if (present(has_entry)) then
ientry = has_entry
    else
ientry = FALSE
    end if

if (ientry == TRUE) then
!GTK3
       cbox = gtk_combo_box_text_new_with_entry()
!GTK2
!!$GTK< 2.24! cbox = gtk_combo_box_entry_new_text()
    else
!GTK3
       cbox = gtk_combo_box_text_new()
!GTK2
!!$GTK< 2.24! cbox = gtk_combo_box_new_text()
    end if

if (present(initial_choices)) then
do i=1,size(initial_choices)
!GTK3
          call gtk_combo_box_text_append_text(cbox, &
               & trim(initial_choices(i))//C_NULL_CHAR)
!GTK2
!!$GTK< 2.24! call gtk_combo_box_append_text(cbox, &
!!$GTK< 2.24! & trim(initial_choices(i))//C_NULL_CHAR)
       end do
end if

if (present(active)) call gtk_combo_box_set_active(cbox, active)

    if (present(changed)) then
if (present(data)) then
call g_signal_connect(cbox, "changed"//C_NULL_CHAR, changed, data)
       else
call g_signal_connect(cbox, "changed"//C_NULL_CHAR, changed)
       end if
end if

if (present(sensitive)) call gtk_widget_set_sensitive(cbox, sensitive)
    if (present(tooltip)) call gtk_widget_set_tooltip_text(cbox, tooltip)
  end function hl_gtk_combo_box_new

  !+
  subroutine hl_gtk_combo_box_add_text(cbox, text, index, at_start)

    type(c_ptr), intent(in) :: cbox
    character(kind=c_char), dimension(*), optional :: text
    integer(kind=c_int), intent(in), optional :: index
integer(kind=c_int), intent(in), optional :: at_start

    ! Add a new choice to a combo box.
    !
    ! CBOX: c_ptr: required: The combo box to modify.
    ! TEXT: string: required: The text to add.
    ! INDEX: c_int: optional: The location at which to add the text.
    ! AT_START: boolean: optional: If set to TRUE and INDEX is not given
    ! then add the text at the start of the list.
    !
    ! If neither INDEX nor AT_START is present the text is appended.
    !-

    integer(kind=c_int) :: prepend

    if (present(index)) then
!GTK3
       call gtk_combo_box_text_insert_text(cbox, index, text)
!GTK2
!!$GTK< 2.24! call gtk_combo_box_insert_text(cbox, index, text)
    else
if (present(at_start)) then
prepend = at_start
       else
prepend = FALSE
       end if
if (prepend == TRUE) then
!GTK3
          call gtk_combo_box_text_prepend_text(cbox, text)
!GTK2
!!$GTK< 2.24! call gtk_combo_box_prepend_text(cbox, text)
       else
!GTK3
          call gtk_combo_box_text_append_text(cbox, text)
!GTK2
!!$GTK< 2.24! call gtk_combo_box_append_text(cbox, text)
       end if
end if
end subroutine hl_gtk_combo_box_add_text

  !+
  subroutine hl_gtk_combo_box_delete_single(cbox, index)

    type(c_ptr), intent(in) :: cbox
    integer(kind=c_int), intent(in) :: index

    ! Delete a line from a combo box
    !
    ! CBOX: c_ptr: required: The combo box to update
    ! INDEX: c_int: required: The index of the choce to remove
    !
    ! Usually called via the generic hl_gtk_combo_box_delete interface.
    !-

!GTK3
    call gtk_combo_box_text_remove(cbox, index)
!GTK2
!!$GTK< 2.24! call gtk_combo_box_remove_text(cbox, index)

  end subroutine hl_gtk_combo_box_delete_single

  !+
  subroutine hl_gtk_combo_box_delete_multi(cbox, index)

    type(c_ptr), intent(in) :: cbox
    integer(kind=c_int), dimension(:), intent(in) :: index

    ! Delete lines from a combo box
    !
    ! CBOX: c_ptr: required: The combo box to update
    ! INDEX: c_int(): required: The index of the choce to remove
    !
    ! Usually called via the generic hl_gtk_combo_box_delete interface.
    !-

    integer(kind=c_int) :: i

    do i = size(index),1,-1
!GTK3
       call gtk_combo_box_text_remove(cbox, index(i))
!GTK2
!!$GTK< 2.24! call gtk_combo_box_remove_text(cbox, index(i))
    end do
end subroutine hl_gtk_combo_box_delete_multi

  !+
  subroutine hl_gtk_combo_box_delete_all(cbox)

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

    ! Delete all lines from a combo box
    !
    ! CBOX: c_ptr: required: The combo box to update
    !
    ! Usually called via the generic hl_gtk_combo_box_delete interface.
    !-

!!$GTK<3.0! integer(kind=c_int) :: n, i

!GTK3
    call gtk_combo_box_text_remove_all(cbox)
!GTK2
! Note that by using the hl delete we avoid 3-level conditional compilation.
!!$GTK<3.0! n = hl_gtk_combo_box_n_entries(cbox)
!!$GTK<3.0! do i = 1, n
!!$GTK<3.0! call hl_gtk_combo_box_delete(cbox, 0_c_int)
!!$GTK<3.0! end do

  end subroutine hl_gtk_combo_box_delete_all
  !+
  function hl_gtk_combo_box_get_active(cbox, text, ftext) result(index)

    integer(kind=c_int) :: index
type(c_ptr), intent(in) :: cbox
    type(c_ptr), intent(out), optional :: text
    character(len=*), intent(out), optional :: ftext

    ! Get the selection from a combo box
    !
    ! CBOX: c_ptr: required: The combo box to query.
    ! TEXT: c_ptr: optional: C pointer to the text.
    ! FTEXT: fstring: optional: The string as a Fortran string.
    !-

    type(c_ptr), target :: ctext

    index = gtk_combo_box_get_active(cbox)

    if (present(text) .or. present(ftext)) then

!GTK3
      ctext = gtk_combo_box_text_get_active_text(cbox)
!GTK2
!!$GTK< 2.24! ctext = gtk_combo_box_get_active_text(cbox)

       ! This is a bit ugly
       if (present(ftext)) &
            & call convert_c_string(ctext, ftext)

       if (present(text)) text=ctext
    end if
end function hl_gtk_combo_box_get_active

  !+
  function hl_gtk_combo_box_n_entries(cbox) result(count)
    integer(kind=c_int) :: count
type(c_ptr), intent(in) :: cbox

    ! Find the number of entries in a combo box.
    !
    ! CBOX: c_ptr: required: The combo box to query.
    !-

    type(c_ptr) :: model

    model = gtk_combo_box_get_model(cbox)
    count = gtk_tree_model_iter_n_children (model, C_NULL_PTR)

  end function hl_gtk_combo_box_n_entries
    
end module gtk_hl_combobox
Something went wrong with that request. Please try again.