Tree @HEAD (Download .tar.gz)
- ..
- gtkextra
- obj
- opengl
- task_project
- .cvsignore
- 3DRings.xpm
- alps.png
- apple-red.png
- application.ui
- background.png
- central.xml
- check-n.xpm
- check-y.xpm
- common.adb
- common.ads
- create_about.adb
- create_about.ads
- create_alignment.adb
- create_alignment.ads
- create_application.adb
- create_application.ads
- create_arrow.adb
- create_arrow.ads
- create_assistant.adb
- create_assistant.ads
- create_box.adb
- create_box.ads
- create_builder.adb
- create_builder.ads
- create_button_box.adb
- create_button_box.ads
- create_buttons.adb
- create_buttons.ads
- create_cairo.adb
- create_cairo.ads
- create_calendar.adb
- create_calendar.ads
- create_canvas.adb
- create_canvas.ads
- create_canvas_view_animate.adb
- create_canvas_view_animate.ads
- create_canvas_view_composite.adb
- create_canvas_view_composite.ads
- create_canvas_view_edit.adb
- create_canvas_view_edit.ads
- create_canvas_view_events.adb
- create_canvas_view_events.ads
- create_canvas_view_items.adb
- create_canvas_view_items.ads
- create_canvas_view_links.adb
- create_canvas_view_links.ads
- create_canvas_view_minimap.adb
- create_canvas_view_minimap.ads
- create_canvas_view_routes.adb
- create_canvas_view_routes.ads
- create_canvas_view_rtrees.adb
- create_canvas_view_rtrees.ads
- create_cell_view.adb
- create_cell_view.ads
- create_check_buttons.adb
- create_check_buttons.ads
- create_clipboard.adb
- create_clipboard.ads
- create_color_chooser.adb
- create_color_chooser.ads
- create_color_selection.adb
- create_color_selection.ads
- create_combo_box.adb
- create_combo_box.ads
- create_css_accordion.adb
- create_css_accordion.ads
- create_css_editor.adb
- create_css_editor.ads
- create_cursors.adb
- create_cursors.ads
- create_dialog.adb
- create_dialog.ads
- create_dnd.adb
- create_dnd.ads
- create_entry.adb
- create_entry.ads
- create_file_chooser.adb
- create_file_chooser.ads
- create_file_selection.adb
- create_file_selection.ads
- create_fixed.adb
- create_fixed.ads
- create_flow_box.adb
- create_flow_box.ads
- create_font_chooser.adb
- create_font_chooser.ads
- create_font_selection.adb
- create_font_selection.ads
- create_frame.adb
- create_frame.ads
- create_gestures.adb
- create_gestures.ads
- create_gtkada_builder.adb
- create_gtkada_builder.ads
- create_gtkada_dialog.adb
- create_gtkada_dialog.ads
- create_icon_view.adb
- create_icon_view.ads
- create_label.adb
- create_label.ads
- create_layout.adb
- create_layout.ads
- create_link_buttons.adb
- create_link_buttons.ads
- create_main_loop.adb
- create_main_loop.ads
- create_mdi.adb
- create_mdi.ads
- create_menu.adb
- create_menu.ads
- create_notebook.adb
- create_notebook.ads
- create_opacity.adb
- create_opacity.ads
- create_paned.adb
- create_paned.ads
- create_pixbuf.adb
- create_pixbuf.ads
- create_print.adb
- create_print.ads
- create_progress.adb
- create_progress.ads
- create_radio_button.adb
- create_radio_button.ads
- create_range.adb
- create_range.ads
- create_reparent.adb
- create_reparent.ads
- create_revealer.adb
- create_revealer.ads
- create_scrolled.adb
- create_scrolled.ads
- create_selection.adb
- create_selection.ads
- create_size_groups.adb
- create_size_groups.ads
- create_sources.adb
- create_sources.ads
- create_spin.adb
- create_spin.ads
- create_spinners.adb
- create_spinners.ads
- create_splittable.adb
- create_splittable.ads
- create_stack.adb
- create_stack.ads
- create_status.adb
- create_status.ads
- create_status_icons.adb
- create_status_icons.ads
- create_task_monitor.adb
- create_task_monitor.ads
- create_test_idle.adb
- create_test_idle.ads
- create_test_timeout.adb
- create_test_timeout.ads
- create_text_view.adb
- create_text_view.ads
- create_toggle_buttons.adb
- create_toggle_buttons.ads
- create_toolbar.adb
- create_toolbar.ads
- create_tooltips.adb
- create_tooltips.ads
- create_tree_filter.adb
- create_tree_filter.ads
- create_tree_view.adb
- create_tree_view.ads
- create_ui_manager.adb
- create_ui_manager.ads
- css_accordion.css
- dancing-penguin.gif
- FilesQueue.xpm
- global_exception_handler.adb
- global_exception_handler.ads
- gnat_debug.adc
- gnome-applets.png
- gnome-calendar.png
- gnome-foot.png
- gnome-gimp.png
- gnome-gmush.png
- gnome-gsame.png
- gnome-textfile.png
- gnu-keys.png
- gtkbuilder_custom_widget.xml
- gtkbuilder_example.xml
- libart_demo.adb
- libart_demo.ads
- lightning.png
- main_windows.adb
- main_windows.ads
- marble.xpm
- menus.ui
- Modeller.xpm
- penguin.lwo
- perspectives.xml
- perspectives_indep.xml
- README
- refresh.svg
- search_and_menu.png
- test.xpm
- test_rtree.adb
- testcairo_drawing.adb
- testcairo_drawing.ads
- testgtk.adb
- testgtk.css
- testgtk.gpr
- tree_minus.xpm
- tree_plus.xpm
create_task_monitor.adb @HEAD — raw · history · blame
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 | ------------------------------------------------------------------------------ -- GtkAda - Ada95 binding for the Gimp Toolkit -- -- -- -- Copyright (C) 2018, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under 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 library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception 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 and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with Ada.Containers; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Glib; use Glib; with Gtk.Box; use Gtk.Box; with Gtk.Button; use Gtk.Button; with Gtk.Label; use Gtk.Label; with Glib.Main; use Glib.Main; with Gtk.Widget; use Gtk.Widget; with Gtk; use Gtk; with Gtk.Progress_Bar; use Gtk.Progress_Bar; with Common; use Common; with Task_Worker; with Gtk.Handlers; package body Create_Task_Monitor is use type Ada.Containers.Count_Type; type GUI_Type is record Label : Gtk_Label; Progress_Bar : Gtk_Progress_Bar; end record; package GUI_Timeout is new Glib.Main.Generic_Sources (GUI_Type); Timeout : G_Source_Id; package GUI_Handler is new Gtk.Handlers.User_Callback (Gtk_Widget_Record, GUI_Type); function Timeout_Test (GUI : GUI_Type) return Boolean is begin -- Pulse the progress bar GUI.Progress_Bar.Pulse; while Task_Worker.Queue.Current_Use > 0 loop -- There is data to display coming from the tasks! declare Data : Task_Worker.Work_Item; begin Task_Worker.Queue.Dequeue (Data); Set_Text (GUI.Label, To_String (Data.Some_Data)); end; end loop; return True; end Timeout_Test; procedure On_Start_Clicked (Widget : access Gtk_Widget_Record'Class; GUI : GUI_Type) is begin -- If there is no timeout registered to monitor the tasks, -- start one now! if Timeout = 0 then Timeout := GUI_Timeout.Timeout_Add ( -- This timeout will refresh every 50 ms 50, -- This is the function to call in the timeout Timeout_Test'Access, -- This is the part of the GUI to refresh GUI); end if; Task_Worker.Run_Task; end On_Start_Clicked; procedure Stop_Timeout (Object : access Gtk_Widget_Record'Class) is pragma Unreferenced (Object); begin if Timeout /= 0 then Remove (Timeout); Timeout := 0; end if; end Stop_Timeout; --------- -- Run -- --------- procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is Button : Gtk_Button; Box : Gtk_Box; GUI : GUI_Type; begin Set_Label (Frame, "Task_Monitor"); Gtk_New_Vbox (Box, Homogeneous => False, Spacing => 0); Add (Frame, Box); -- Create a "start" button Gtk_New (Button, "start"); Button.Set_Can_Default (True); Pack_Start (Box, Button, False, False, 0); -- Add a progress bar, to show that the UI is functioning when -- the tasks are working. Gtk_New (GUI.Progress_Bar); GUI.Progress_Bar.Set_Pulse_Step (0.01); Pack_Start (Box, GUI.Progress_Bar, False, False, 10); -- This is the label that will be refreshed to contain the data -- coming from the tasks. Gtk_New (GUI.Label, "press start to start tasks"); Pack_Start (Box, GUI.Label, False, False, 10); -- Connect the start button GUI_Handler.Connect (Button, "clicked", On_Start_Clicked'Access, User_Data => GUI); -- Cleanup the timeout when the view is destroyed Widget_Handler.Connect (Box, "destroy", Stop_Timeout'Access); Show_All (Frame); end Run; ---------- -- Help -- ---------- function Help return String is begin return "This shows how to use tasking in GtkAda, performing blocking" & " work in a task without blocking the UI."; end Help; end Create_Task_Monitor; |