1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2005 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,
27 #include <gdk/gdkkeysyms.h>
29 #include <lttv/lttv.h>
30 #include <lttv/module.h>
31 #include <lttv/hook.h>
32 #include <lttv/filter.h>
34 #include <lttvwindow/lttvwindow.h>
35 #include <lttvwindow/lttvwindowtraces.h>
37 #include "hTraceControlInsert.xpm"
40 GSList
*g_control_list
= NULL
;
42 /*! \file lttv/modules/gui/tracecontrol/tracecontrol.c
43 * \brief Graphic trace start/stop control interface.
45 * This plugin interacts with lttctl to start/stop tracing. It needs to take the
46 * root password to be able to interact with lttctl.
50 typedef struct _ControlData ControlData
;
55 GtkWidget
*guicontrol_get_widget(ControlData
*tcd
);
56 ControlData
*gui_control(Tab
*tab
);
57 void gui_control_destructor(ControlData
*tcd
);
58 GtkWidget
* h_guicontrol(Tab
*tab
);
59 void control_destroy_walk(gpointer data
, gpointer user_data
);
67 * @struct _ControlData
69 * @brief Main structure of gui filter
70 * Main struct for the filter gui module
73 Tab
*tab
; /**< current tab of module */
75 GtkWidget
*f_window
; /**< filter window */
77 GtkWidget
*f_main_box
; /**< main container */
82 * @fn GtkWidget* guicontrol_get_widget(ControlData*)
84 * This function returns the current main widget
86 * @param tcd the module struct
87 * @return The main widget
90 guicontrol_get_widget(ControlData
*tcd
)
96 * @fn ControlData* gui_control(Tab*)
98 * Constructor is used to create ControlData data structure.
99 * @param tab The tab structure used by the widget
100 * @return The Filter viewer data created.
103 gui_control(Tab
*tab
)
105 g_debug("filter::gui_control()");
108 GtkCellRenderer
*renderer
;
109 GtkTreeViewColumn
*column
;
111 ControlData
* tcd
= g_new(ControlData
,1);
115 tcd
->f_window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
116 gtk_window_set_title(GTK_WINDOW(tcd
->f_window
), "LTTng Trace Control");
118 * Initiating GtkTable layout
119 * starts with 2 rows and 5 columns and
120 * expands when expressions added
122 tcd
->f_main_box
= gtk_table_new(13,2,FALSE
);
123 gtk_table_set_row_spacings(GTK_TABLE(tcd
->f_main_box
),5);
124 gtk_table_set_col_spacings(GTK_TABLE(tcd
->f_main_box
),5);
126 gtk_container_add(GTK_CONTAINER(tcd
->f_window
), GTK_WIDGET(tcd
->f_main_box
));
129 * First half of the filter window
130 * - textual entry of filter expression
131 * - processing button
133 GtkWidget
*username_label
= gtk_label_new("Username:");
134 gtk_widget_show (username_label
);
135 GtkWidget
*username_entry
= gtk_entry_new();
136 gtk_entry_set_text(GTK_ENTRY(username_entry
),"root");
138 gtk_widget_show (username_entry
);
140 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),username_label
,0,6,0,1,GTK_FILL
,GTK_FILL
,0,0);
141 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),username_entry
,6,7,0,1,GTK_FILL
,GTK_FILL
,0,0);
145 * show main container
147 gtk_widget_show(tcd
->f_main_box
);
148 gtk_widget_show(tcd
->f_window
);
151 g_object_set_data_full(
152 G_OBJECT(guifilter_get_widget(tcd
)),
153 "filter_viewer_data",
155 (GDestroyNotify
)gui_control_destructor
);
157 g_control_list
= g_slist_append(
166 * @fn void gui_control_destructor(ControlData*)
168 * Destructor for the filter gui module
169 * @param tcd The module structure
172 gui_control_destructor(ControlData
*tcd
)
176 /* May already been done by GTK window closing */
177 if(GTK_IS_WIDGET(guifilter_get_widget(tcd
))){
178 g_info("widget still exists");
181 // lttvwindow_unregister_traceset_notify(tcd->tab,
182 // filter_traceset_changed,
183 // filter_viewer_data);
185 lttvwindowtraces_background_notify_remove(tcd
);
187 g_control_list
= g_slist_remove(g_control_list
, tcd
);
194 * @fn GtkWidget* h_guicontrol(Tab*)
196 * Control Module's constructor hook
198 * This constructor is given as a parameter to the menuitem and toolbar button
199 * registration. It creates the list.
200 * @param tab A pointer to the parent window.
201 * @return The widget created.
204 h_guicontrol(Tab
*tab
)
206 ControlData
* f
= gui_control(tab
) ;
212 * @fn static void init()
214 * This function initializes the Filter Viewer functionnality through the
219 lttvwindow_register_constructor("guicontrol",
221 "Insert Tracing Control Module",
222 hTraceControlInsert_xpm
,
223 "Insert Tracing Control Module",
228 * @fn void control_destroy_walk(gpointer,gpointer)
230 * Initiate the destruction of the current gui module
231 * on the GTK Interface
234 control_destroy_walk(gpointer data
, gpointer user_data
)
236 ControlData
*tcd
= (ControlData
*)data
;
238 g_debug("traceontrol.c : control_destroy_walk, %p", tcd
);
240 /* May already have been done by GTK window closing */
241 if(GTK_IS_WIDGET(guicontrol_get_widget(tcd
)))
242 gtk_widget_destroy(guicontrol_get_widget(tcd
));
246 * @fn static void destroy()
247 * @brief plugin's destroy function
249 * This function releases the memory reserved by the module and unregisters
250 * everything that has been registered in the gtkTraceSet API.
252 static void destroy() {
254 g_slist_foreach(g_control_list
, control_destroy_walk
, NULL
);
256 lttvwindow_unregister_constructor(h_guicontrol
);
261 LTTV_MODULE("guitracecontrol", "Trace Control Window", \
262 "Graphical module that let user control kernel tracing", \
263 init
, destroy
, "lttvwindow")
This page took 0.035354 seconds and 4 git commands to generate.