------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2023, Frank Singhoff, Alain Plantec, Jerome Legrand, -- Hai Nam Tran, Stephane Rubini -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in README.md -- -- This program 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 2 of the License, or -- (at your option) any later version. -- -- This program 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. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 3657 $ -- $Date: 2020-12-13 13:25:49 +0100 (dim., 13 déc. 2020) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Text_IO; use Ada.Text_IO; with Gtk.Text_Iter; use Gtk.Text_Iter; package body graphical_editor.generic_package_widget is function get_value_buffer_string (buffer : gtk_text_buffer) return Unbounded_String is start_iterator, end_iterator : gtk_text_iter; begin Get_Start_Iter (buffer, start_iterator); Get_End_Iter (buffer, end_iterator); return To_Unbounded_String (Gtk.Text_Buffer.Get_Text (buffer, start_iterator, end_iterator)); end get_value_buffer_string; function get_value_buffer_integer (buffer : gtk_text_buffer) return Integer is start_iterator, end_iterator : gtk_text_iter; a_string : Unbounded_String; begin Get_Start_Iter (buffer, start_iterator); Get_End_Iter (buffer, end_iterator); a_string := suppress_space (Gtk.Text_Buffer.Get_Text (buffer, start_iterator, end_iterator)); if a_string = empty_string then return 0; else return Integer'Value (To_String (a_string)); end if; end get_value_buffer_integer; function get_value_buffer_double (buffer : gtk_text_buffer) return Double is start_iterator, end_iterator : gtk_text_iter; begin Get_Start_Iter (buffer, start_iterator); Get_End_Iter (buffer, end_iterator); return Double'Value (Gtk.Text_Buffer.Get_Text (buffer, start_iterator, end_iterator)); end get_value_buffer_double; function get_number_elements (treemodel : gtk_tree_model) return Integer is number : Integer := 0; tree_iter : gtk_tree_iter; begin tree_iter := Get_Iter_First (treemodel); while tree_iter /= Null_Iter loop number := number + 1; Next (treemodel, tree_iter); end loop; return number; end get_number_elements; function get_int_combo (combo : gtk_combo_box_text; value : Unbounded_String) return Integer is i : Integer := 0; treemodel : gtk_tree_model; tree_iter : gtk_tree_iter; comp : Unbounded_String; begin treemodel := Get_Model (combo); tree_iter := Get_Iter_First (treemodel); comp := To_Unbounded_String (Get_String (treemodel, tree_iter, gint (0))); while comp /= value and tree_iter /= Null_Iter loop Next (treemodel, tree_iter); comp := To_Unbounded_String (Get_String (treemodel, tree_iter, gint (0))); i := i + 1; end loop; if comp = value then return i; else return -1; end if; end get_int_combo; end graphical_editor.generic_package_widget;