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"
38 #include "TraceControlStart.xpm"
39 #include "TraceControlPause.xpm"
40 #include "TraceControlStop.xpm"
43 GSList
*g_control_list
= NULL
;
45 /*! \file lttv/modules/gui/tracecontrol/tracecontrol.c
46 * \brief Graphic trace start/stop control interface.
48 * This plugin interacts with lttctl to start/stop tracing. It needs to take the
49 * root password to be able to interact with lttctl.
53 typedef struct _ControlData ControlData
;
58 GtkWidget
*guicontrol_get_widget(ControlData
*tcd
);
59 ControlData
*gui_control(Tab
*tab
);
60 void gui_control_destructor(ControlData
*tcd
);
61 GtkWidget
* h_guicontrol(Tab
*tab
);
62 void control_destroy_walk(gpointer data
, gpointer user_data
);
70 * @struct _ControlData
72 * @brief Main structure of gui filter
73 * Main struct for the filter gui module
76 Tab
*tab
; /**< current tab of module */
78 GtkWidget
*f_window
; /**< filter window */
80 GtkWidget
*f_main_box
; /**< main container */
85 * @fn GtkWidget* guicontrol_get_widget(ControlData*)
87 * This function returns the current main widget
89 * @param tcd the module struct
90 * @return The main widget
93 guicontrol_get_widget(ControlData
*tcd
)
99 * @fn ControlData* gui_control(Tab*)
101 * Constructor is used to create ControlData data structure.
102 * @param tab The tab structure used by the widget
103 * @return The Filter viewer data created.
106 gui_control(Tab
*tab
)
108 g_debug("filter::gui_control()");
111 GtkCellRenderer
*renderer
;
112 GtkTreeViewColumn
*column
;
114 ControlData
* tcd
= g_new(ControlData
,1);
118 tcd
->f_window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
119 gtk_window_set_title(GTK_WINDOW(tcd
->f_window
), "LTTng Trace Control");
121 * Initiating GtkTable layout
122 * starts with 2 rows and 5 columns and
123 * expands when expressions added
125 tcd
->f_main_box
= gtk_table_new(14,7,FALSE
);
126 gtk_table_set_row_spacings(GTK_TABLE(tcd
->f_main_box
),5);
127 gtk_table_set_col_spacings(GTK_TABLE(tcd
->f_main_box
),5);
129 gtk_container_add(GTK_CONTAINER(tcd
->f_window
), GTK_WIDGET(tcd
->f_main_box
));
132 * start/pause/stop buttons
136 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStart_xpm
);
137 image
= gtk_image_new_from_pixbuf(pixbuf
);
138 GtkWidget
*start_button
= gtk_button_new_with_label("start");
139 gtk_button_set_image(GTK_BUTTON(start_button
), image
);
140 gtk_button_set_alignment(GTK_BUTTON(start_button
), 0.0, 0.0);
141 gtk_widget_show (start_button
);
142 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),start_button
,6,7,0,1,GTK_FILL
,GTK_FILL
,2,2);
144 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char **)TraceControlPause_xpm
);
145 image
= gtk_image_new_from_pixbuf(pixbuf
);
146 GtkWidget
*pause_button
= gtk_button_new_with_label("pause");
147 gtk_button_set_image(GTK_BUTTON(pause_button
), image
);
148 gtk_button_set_alignment(GTK_BUTTON(pause_button
), 0.0, 0.0);
149 gtk_widget_show (pause_button
);
150 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),pause_button
,6,7,1,2,GTK_FILL
,GTK_FILL
,2,2);
152 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStop_xpm
);
153 image
= gtk_image_new_from_pixbuf(pixbuf
);
154 GtkWidget
*stop_button
= gtk_button_new_with_label("stop");
155 gtk_button_set_image(GTK_BUTTON(stop_button
), image
);
156 gtk_button_set_alignment(GTK_BUTTON(stop_button
), 0.0, 0.0);
157 gtk_widget_show (stop_button
);
158 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),stop_button
,6,7,2,3,GTK_FILL
,GTK_FILL
,2,2);
161 * First half of the filter window
162 * - textual entry of filter expression
163 * - processing button
165 GtkWidget
*username_label
= gtk_label_new("Username:");
166 gtk_widget_show (username_label
);
167 GtkWidget
*username_entry
= gtk_entry_new();
168 gtk_entry_set_text(GTK_ENTRY(username_entry
),"root");
169 gtk_widget_show (username_entry
);
170 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),username_label
,0,2,0,1,GTK_FILL
,GTK_FILL
,2,2);
171 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),username_entry
,2,6,0,1,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
175 GtkWidget
*password_label
= gtk_label_new("Password:");
176 gtk_widget_show (password_label
);
177 GtkWidget
*password_entry
= gtk_entry_new();
178 gtk_entry_set_visibility(GTK_ENTRY(password_entry
), FALSE
);
179 gtk_widget_show (password_entry
);
180 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),password_label
,0,2,1,2,GTK_FILL
,GTK_FILL
,2,2);
181 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),password_entry
,2,6,1,2,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
184 GtkWidget
*channel_dir_label
= gtk_label_new("Channel directory:");
185 gtk_widget_show (channel_dir_label
);
186 GtkWidget
*channel_dir_entry
= gtk_entry_new();
187 gtk_entry_set_text(GTK_ENTRY(channel_dir_entry
),"/mnt/relayfs/ltt");
188 gtk_widget_show (channel_dir_entry
);
189 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),channel_dir_label
,0,2,2,3,GTK_FILL
,GTK_FILL
,2,2);
190 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),channel_dir_entry
,2,6,2,3,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
192 GtkWidget
*trace_dir_label
= gtk_label_new("Trace directory:");
193 gtk_widget_show (trace_dir_label
);
194 GtkWidget
*trace_dir_entry
= gtk_entry_new();
195 gtk_entry_set_text(GTK_ENTRY(trace_dir_entry
),"/tmp/trace1");
196 gtk_widget_show (trace_dir_entry
);
197 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),trace_dir_label
,0,2,3,4,GTK_FILL
,GTK_FILL
,2,2);
198 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),trace_dir_entry
,2,6,3,4,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
200 GtkWidget
*trace_name_label
= gtk_label_new("Trace name:");
201 gtk_widget_show (trace_name_label
);
202 GtkWidget
*trace_name_entry
= gtk_entry_new();
203 gtk_entry_set_text(GTK_ENTRY(trace_name_entry
),"trace");
204 gtk_widget_show (trace_name_entry
);
205 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),trace_name_label
,0,2,4,5,GTK_FILL
,GTK_FILL
,2,2);
206 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),trace_name_entry
,2,6,4,5,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
208 GtkWidget
*trace_mode_label
= gtk_label_new("Trace mode ");
209 gtk_widget_show (trace_mode_label
);
210 GtkWidget
*trace_mode_combo
= gtk_combo_box_new_text();
211 gtk_combo_box_append_text(GTK_COMBO_BOX(trace_mode_combo
),
213 gtk_combo_box_append_text(GTK_COMBO_BOX(trace_mode_combo
),
215 gtk_combo_box_set_active(GTK_COMBO_BOX(trace_mode_combo
), 0);
216 gtk_widget_show (trace_mode_combo
);
217 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),trace_mode_label
,0,2,5,6,GTK_FILL
,GTK_FILL
,2,2);
218 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),trace_mode_combo
,2,6,5,6,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
220 GtkWidget
*start_daemon_label
= gtk_label_new("Start daemon ");
221 gtk_widget_show (start_daemon_label
);
222 GtkWidget
*start_daemon_check
= gtk_check_button_new();
223 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(start_daemon_check
), TRUE
);
224 gtk_widget_show (start_daemon_check
);
225 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),start_daemon_label
,0,2,6,7,GTK_FILL
,GTK_FILL
,2,2);
226 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),start_daemon_check
,2,6,6,7,GTK_FILL
,GTK_FILL
,0,0);
228 GtkWidget
*optional_label
= gtk_label_new("Optional fields ");
229 gtk_widget_show (optional_label
);
230 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),optional_label
,0,6,7,8,GTK_FILL
,GTK_FILL
,2,2);
232 GtkWidget
*subbuf_size_label
= gtk_label_new("Subbuffer size:");
233 gtk_widget_show (subbuf_size_label
);
234 GtkWidget
*subbuf_size_entry
= gtk_entry_new();
235 gtk_widget_show (subbuf_size_entry
);
236 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),subbuf_size_label
,0,2,8,9,GTK_FILL
,GTK_FILL
,2,2);
237 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),subbuf_size_entry
,2,6,8,9,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
239 GtkWidget
*subbuf_num_label
= gtk_label_new("Number of subbuffers:");
240 gtk_widget_show (subbuf_num_label
);
241 GtkWidget
*subbuf_num_entry
= gtk_entry_new();
242 gtk_widget_show (subbuf_num_entry
);
243 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),subbuf_num_label
,0,2,9,10,GTK_FILL
,GTK_FILL
,2,2);
244 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),subbuf_num_entry
,2,6,9,10,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
246 GtkWidget
*lttctl_path_label
= gtk_label_new("path to lttctl:");
247 gtk_widget_show (lttctl_path_label
);
248 GtkWidget
*lttctl_path_entry
= gtk_entry_new();
249 gtk_widget_show (lttctl_path_entry
);
250 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),lttctl_path_label
,0,2,10,11,GTK_FILL
,GTK_FILL
,2,2);
251 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),lttctl_path_entry
,2,6,10,11,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
254 GtkWidget
*lttd_path_label
= gtk_label_new("path to lttd:");
255 gtk_widget_show (lttd_path_label
);
256 GtkWidget
*lttd_path_entry
= gtk_entry_new();
257 gtk_widget_show (lttd_path_entry
);
258 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),lttd_path_label
,0,2,11,12,GTK_FILL
,GTK_FILL
,2,2);
259 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),lttd_path_entry
,2,6,11,12,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
262 GtkWidget
*fac_path_label
= gtk_label_new("path to facilities:");
263 gtk_widget_show (fac_path_label
);
264 GtkWidget
*fac_path_entry
= gtk_entry_new();
265 gtk_entry_set_text(GTK_ENTRY(fac_path_entry
),"/usr/share/LinuxTraceToolkitViewer/facilities");
266 gtk_widget_set_size_request(fac_path_entry
, 250, -1);
267 gtk_widget_show (fac_path_entry
);
268 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),fac_path_label
,0,2,12,13,GTK_FILL
,GTK_FILL
,2,2);
269 gtk_table_attach( GTK_TABLE(tcd
->f_main_box
),fac_path_entry
,2,6,12,13,GTK_FILL
|GTK_EXPAND
|GTK_SHRINK
,GTK_FILL
,0,0);
273 * show main container
275 gtk_widget_show(tcd
->f_main_box
);
276 gtk_widget_show(tcd
->f_window
);
279 g_object_set_data_full(
280 G_OBJECT(guifilter_get_widget(tcd
)),
281 "filter_viewer_data",
283 (GDestroyNotify
)gui_control_destructor
);
285 g_control_list
= g_slist_append(
294 * @fn void gui_control_destructor(ControlData*)
296 * Destructor for the filter gui module
297 * @param tcd The module structure
300 gui_control_destructor(ControlData
*tcd
)
304 /* May already been done by GTK window closing */
305 if(GTK_IS_WIDGET(guifilter_get_widget(tcd
))){
306 g_info("widget still exists");
309 // lttvwindow_unregister_traceset_notify(tcd->tab,
310 // filter_traceset_changed,
311 // filter_viewer_data);
313 lttvwindowtraces_background_notify_remove(tcd
);
315 g_control_list
= g_slist_remove(g_control_list
, tcd
);
322 * @fn GtkWidget* h_guicontrol(Tab*)
324 * Control Module's constructor hook
326 * This constructor is given as a parameter to the menuitem and toolbar button
327 * registration. It creates the list.
328 * @param tab A pointer to the parent window.
329 * @return The widget created.
332 h_guicontrol(Tab
*tab
)
334 ControlData
* f
= gui_control(tab
) ;
340 * @fn static void init()
342 * This function initializes the Filter Viewer functionnality through the
347 lttvwindow_register_constructor("guicontrol",
349 "Insert Tracing Control Module",
350 hTraceControlInsert_xpm
,
351 "Insert Tracing Control Module",
356 * @fn void control_destroy_walk(gpointer,gpointer)
358 * Initiate the destruction of the current gui module
359 * on the GTK Interface
362 control_destroy_walk(gpointer data
, gpointer user_data
)
364 ControlData
*tcd
= (ControlData
*)data
;
366 g_debug("traceontrol.c : control_destroy_walk, %p", tcd
);
368 /* May already have been done by GTK window closing */
369 if(GTK_IS_WIDGET(guicontrol_get_widget(tcd
)))
370 gtk_widget_destroy(guicontrol_get_widget(tcd
));
374 * @fn static void destroy()
375 * @brief plugin's destroy function
377 * This function releases the memory reserved by the module and unregisters
378 * everything that has been registered in the gtkTraceSet API.
380 static void destroy() {
382 g_slist_foreach(g_control_list
, control_destroy_walk
, NULL
);
384 lttvwindow_unregister_constructor(h_guicontrol
);
389 LTTV_MODULE("guitracecontrol", "Trace Control Window", \
390 "Graphical module that let user control kernel tracing", \
391 init
, destroy
, "lttvwindow")
This page took 0.048665 seconds and 5 git commands to generate.