1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 /*! \defgroup guiEvents libguiControlFlow: The GUI ControlFlow display plugin */
24 /*! \file guiControlFlow.c
25 * \brief Graphical plugin for showing control flow of a trace.
27 * This plugin adds a Control Flow Viewer functionnality to Linux TraceToolkit
28 * GUI when this plugin is loaded. The init and destroy functions add the
29 * viewer's insertion menu item and toolbar icon by calling gtkTraceSet's
30 * API functions. Then, when a viewer's object is created, the constructor
31 * creates ans register through API functions what is needed to interact
32 * with the TraceSet window.
34 * This plugin uses the gdk library to draw the events and gtk to interact
37 * Author : Mathieu Desnoyers, June 2003
42 #include <lttv/lttv.h>
43 #include <lttv/module.h>
44 #include <lttv/gtktraceset.h>
47 #include "eventhooks.h"
49 #include "../icons/hGuiControlFlowInsert.xpm"
51 static LttvModule
*Main_Win_Module
;
54 /** Array containing instanced objects. Used when module is unloaded */
55 GSList
*g_control_flow_data_list
= NULL
;
60 /*****************************************************************************
61 * Functions for module loading/unloading *
62 *****************************************************************************/
64 * plugin's init function
66 * This function initializes the Control Flow Viewer functionnality through the
69 G_MODULE_EXPORT
void init(LttvModule
*self
, int argc
, char *argv
[]) {
71 Main_Win_Module
= lttv_module_require(self
, "mainwin", argc
, argv
);
73 if(Main_Win_Module
== NULL
)
75 g_critical("Can't load Control Flow Viewer : missing mainwin\n");
79 g_info("GUI ControlFlow Viewer init()");
81 /* Register the toolbar insert button */
82 toolbar_item_reg(hGuiControlFlowInsert_xpm
, "Insert Control Flow Viewer",
85 /* Register the menu item insert entry */
86 menu_item_reg("/", "Insert Control Flow Viewer", h_guicontrolflow
);
90 void destroy_walk(gpointer data
, gpointer user_data
)
92 g_info("Walk destroy GUI Control Flow Viewer");
93 guicontrolflow_destructor_full((ControlFlowData
*)data
);
99 * plugin's destroy function
101 * This function releases the memory reserved by the module and unregisters
102 * everything that has been registered in the gtkTraceSet API.
104 G_MODULE_EXPORT
void destroy() {
105 g_info("GUI Control Flow Viewer destroy()");
108 g_slist_foreach(g_control_flow_data_list
, destroy_walk
, NULL
);
110 g_slist_free(g_control_flow_data_list
);
112 /* Unregister the toolbar insert button */
113 toolbar_item_unreg(h_guicontrolflow
);
115 /* Unregister the menu item insert entry */
116 menu_item_unreg(h_guicontrolflow
);