f0d936c0 |
1 | /*! \defgroup guiEvents libguiControlFlow: The GUI ControlFlow display plugin */ |
2 | /*\@{*/ |
3 | |
4 | /*! \file guiControlFlow.c |
5 | * \brief Graphical plugin for showing control flow of a trace. |
6 | * |
7 | * This plugin adds a Control Flow Viewer functionnality to Linux TraceToolkit |
8 | * GUI when this plugin is loaded. The init and destroy functions add the |
9 | * viewer's insertion menu item and toolbar icon by calling gtkTraceSet's |
10 | * API functions. Then, when a viewer's object is created, the constructor |
11 | * creates ans register through API functions what is needed to interact |
12 | * with the TraceSet window. |
13 | * |
14 | * This plugin uses the gdk library to draw the events and gtk to interact |
15 | * with the user. |
16 | * |
17 | * Author : Mathieu Desnoyers, June 2003 |
18 | */ |
19 | |
558aa013 |
20 | #include <glib.h> |
f0d936c0 |
21 | #include <gmodule.h> |
22 | #include <lttv/module.h> |
1ab818de |
23 | #include <lttv/gtkTraceSet.h> |
558aa013 |
24 | |
1ab818de |
25 | #include "CFV.h" |
26 | #include "Event_Hooks.h" |
558aa013 |
27 | |
1ab818de |
28 | #include "../icons/hGuiControlFlowInsert.xpm" |
558aa013 |
29 | |
ae4e77e0 |
30 | static LttvModule *Main_Win_Module; |
558aa013 |
31 | |
32 | |
33 | /** Array containing instanced objects. Used when module is unloaded */ |
1ab818de |
34 | GSList *gControl_Flow_Data_List = NULL ; |
558aa013 |
35 | |
36 | |
f0d936c0 |
37 | |
f0d936c0 |
38 | |
39 | /***************************************************************************** |
40 | * Functions for module loading/unloading * |
41 | *****************************************************************************/ |
42 | /** |
43 | * plugin's init function |
44 | * |
45 | * This function initializes the Control Flow Viewer functionnality through the |
46 | * gtkTraceSet API. |
47 | */ |
558aa013 |
48 | G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { |
49 | |
50 | Main_Win_Module = lttv_module_require(self, "mainwin", argc, argv); |
51 | |
52 | if(Main_Win_Module == NULL) |
53 | { |
54 | g_critical("Can't load Control Flow Viewer : missing mainwin\n"); |
55 | return; |
56 | } |
57 | |
f0d936c0 |
58 | g_critical("GUI ControlFlow Viewer init()"); |
59 | |
60 | /* Register the toolbar insert button */ |
1ab818de |
61 | ToolbarItemReg(hGuiControlFlowInsert_xpm, "Insert Control Flow Viewer", |
62 | hGuiControlFlow); |
f0d936c0 |
63 | |
64 | /* Register the menu item insert entry */ |
1ab818de |
65 | MenuItemReg("/", "Insert Control Flow Viewer", hGuiControlFlow); |
f0d936c0 |
66 | |
67 | } |
68 | |
69 | void destroy_walk(gpointer data, gpointer user_data) |
70 | { |
78417791 |
71 | GuiControlFlow_Destructor_Full((ControlFlowData*)data); |
1ab818de |
72 | g_critical("Walk destroy GUI Control Flow Viewer"); |
f0d936c0 |
73 | } |
74 | |
75 | |
76 | |
77 | /** |
78 | * plugin's destroy function |
79 | * |
80 | * This function releases the memory reserved by the module and unregisters |
81 | * everything that has been registered in the gtkTraceSet API. |
82 | */ |
83 | G_MODULE_EXPORT void destroy() { |
84 | g_critical("GUI Control Flow Viewer destroy()"); |
85 | int i; |
86 | |
1ab818de |
87 | ControlFlowData *Control_Flow_Data; |
f0d936c0 |
88 | |
1ab818de |
89 | g_slist_foreach(gControl_Flow_Data_List, destroy_walk, NULL ); |
f0d936c0 |
90 | |
91 | /* Unregister the toolbar insert button */ |
1ab818de |
92 | ToolbarItemUnreg(hGuiControlFlow); |
f0d936c0 |
93 | |
94 | /* Unregister the menu item insert entry */ |
1ab818de |
95 | MenuItemUnreg(hGuiControlFlow); |
558aa013 |
96 | |
558aa013 |
97 | } |