with Gtk.Menu_Item; use Gtk.Menu_Item; with Gtk; use Gtk; with Gtk.Main; use Gtk.Main; with Glib.Error; use Glib.Error; with Gtk.Widget; use Gtk.Widget; with Gtk.Dialog; use Gtk.Dialog; with Gtk.About_Dialog; use Gtk.About_Dialog; with Gtk.Label; use Gtk.Label; with Ada.Text_IO; with Gtkada.Builder; use Gtkada.Builder; with Glib; use Glib; with Glib.Object; use Glib.Object; with Task_Set; use Task_Set; use Task_Set.Generic_Task_Set; with Tasks; use Tasks; with graphical_editor.user_message; use graphical_editor.user_message; with Gtk.Combo_Box; use Gtk.Combo_Box; with Gtk.Tree_Model; use Gtk.Tree_Model; with Gtk.Text_Iter; use Gtk.Text_Iter; with Gtk.List_Store; use Gtk.List_Store; with Framework_Config; use Framework_Config; with Translate; use Translate; with Processors; use Processors; with Processors.extended; use Processors.extended; with Processor_Set; use Processor_Set; with address_spaces; use address_spaces; with Address_Space_Set; use Address_Space_Set; with Resources; use Resources; with Resource_Set; use Resource_Set; use Resource_Set.Generic_Resource_Set; with Gtk.Tree_View; use Gtk.Tree_View; with Ada.Text_IO; use Ada.Text_IO; package body graphical_editor.resources is function get_compatible_protocol(myprotocol: Resources_Type) return unbounded_string is protocol_string: Unbounded_String; begin if myprotocol = No_Protocol then protocol_string:= to_Unbounded_String("No Protocol"); end if; if myprotocol = Priority_Ceiling_Protocol then protocol_string:= to_Unbounded_String("Priority Ceiling Protocol"); end if; if myprotocol = Priority_Inheritance_Protocol then protocol_string:= to_Unbounded_String("Priority Inheritance Protocol"); end if; if myprotocol = Immediate_Priority_Ceiling_Protocol then protocol_string:= to_Unbounded_String("Immediate Priority Ceiling Protocol"); end if; return protocol_string; end get_compatible_protocol; procedure Show_Resource_Widget is Builder : Gtkada_Builder; Error : Glib.Error.GError; tree_iter: Gtk_Tree_Iter; liststore: GObject; A_Resource : Generic_Resource_Ptr; My_Iterator : Resources_Iterator; A_Task : Generic_Task_Ptr; My_Task_Iterator : Tasks_Iterator; my_combo1: GObject; A_Cpu : Generic_Processor_Ptr; My_Cpu_Iterator : Processors_Iterator; my_combo_cpu: GObject; A_Adr : Address_Space_Ptr; My_Adr_Iterator : Address_Spaces_Iterator; my_combo_adr: GObject; begin Gtk.Main.Init; Gtk_New (Builder); Error := Add_From_File (Builder, to_string(Glade_path) & "resource.glade"); if Error /= null then Ada.Text_IO.Put_Line ("Error : " & Get_Message (Error)); Error_Free (Error); return; end if; -- add values in task combo ... my_combo1 := Get_Object(Builder, "combobox4"); reset_iterator (sys.Tasks, My_Task_Iterator); if not is_empty (sys.Tasks) then loop current_element (sys.Tasks, A_Task, My_Task_Iterator); Append_Text (Gtk_Combo_Box(my_combo1), To_String(A_Task.name)); exit when is_last_element (sys.Tasks, My_Task_Iterator); next_element (sys.Tasks, My_Task_Iterator); end loop; else Show_Message_Box (Lb_Define_Tasks_Before (Current_Language)); end if; -- add values in cpu combo ... my_combo_cpu := Get_Object(Builder, "combobox3"); reset_iterator (sys.Processors, My_Cpu_Iterator); if not is_empty (sys.Processors) then loop current_element (sys.Processors, A_Cpu, My_Cpu_Iterator); Append_Text (Gtk_Combo_Box(my_combo_cpu), To_String(A_Cpu.name)); exit when is_last_element (sys.Processors, My_Cpu_Iterator); next_element (sys.Processors, My_Cpu_Iterator); end loop; else Show_Message_Box (Lb_Define_Processors_Before (Current_Language)); end if; -- add values in address combo ... my_combo_adr := Get_Object(Builder, "combobox2"); reset_iterator (sys.Address_Spaces, My_Adr_Iterator); if not is_empty (sys.Address_Spaces) then loop current_element (sys.Address_Spaces, A_Adr, My_Adr_Iterator); Append_Text (Gtk_Combo_Box(my_combo_adr), To_String(A_Adr.name)); exit when is_last_element (sys.Address_Spaces, My_Adr_Iterator); next_element (sys.Address_Spaces, My_Adr_Iterator); end loop; else Show_Message_Box (Lb_Define_Address_Spaces_Before (Current_Language)); end if; -- list in treeview list of resources liststore:= Get_Object(Builder, "liststore6"); reset_iterator (sys.Resources, My_Iterator); if not is_empty (sys.Resources) then loop current_element (sys.Resources, A_Resource, My_Iterator); Append(Gtk_List_Store(liststore), tree_iter); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 0, To_String (A_Resource.name)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 1, Gint(A_Resource.state)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 2, Gint(A_Resource.size)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 3, To_String (A_Resource.address_space_name)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 4, To_String (A_Resource.cpu_name)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 5, Gint(A_Resource.address)); --put_line(Resources_Type'image(A_Resource.protocol)); Gtk.List_Store.Set(Gtk_List_Store(liststore), tree_iter, 6, To_String(get_compatible_protocol(A_Resource.protocol))); exit when is_last_element (sys.Resources, My_Iterator); next_element (sys.Resources, My_Iterator); end loop; end if; Do_Connect (Builder); Gtk.Widget.Show_All (Get_Widget (Builder, "window1")); Gtk.Main.Main; Unref (Builder); end Show_Resource_Widget; end graphical_editor.resources;