basic trace control : in progress
[lttv.git] / ltt / branches / poly / lttv / modules / gui / tracecontrol / tracecontrol.c
CommitLineData
e7c8534e 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2005 Mathieu Desnoyers
3 *
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;
7 *
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.
12 *
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,
16 * MA 02111-1307, USA.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include <config.h>
21#endif
22
23#include <glib.h>
24#include <string.h>
25#include <gtk/gtk.h>
26#include <gdk/gdk.h>
27#include <gdk/gdkkeysyms.h>
28
29#include <lttv/lttv.h>
30#include <lttv/module.h>
31#include <lttv/hook.h>
32#include <lttv/filter.h>
33
34#include <lttvwindow/lttvwindow.h>
35#include <lttvwindow/lttvwindowtraces.h>
36
37#include "hTraceControlInsert.xpm"
38
39
40GSList *g_control_list = NULL ;
41
42/*! \file lttv/modules/gui/tracecontrol/tracecontrol.c
43 * \brief Graphic trace start/stop control interface.
44 *
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.
47 *
48 */
49
50typedef struct _ControlData ControlData;
51
52/*
53 * Prototypes
54 */
55GtkWidget *guicontrol_get_widget(ControlData *tcd);
56ControlData *gui_control(Tab *tab);
57void gui_control_destructor(ControlData *tcd);
58GtkWidget* h_guicontrol(Tab *tab);
59void control_destroy_walk(gpointer data, gpointer user_data);
60
61/*
62 * Callback functions
63 */
64
65
66/**
67 * @struct _ControlData
68 *
69 * @brief Main structure of gui filter
70 * Main struct for the filter gui module
71 */
72struct _ControlData {
73 Tab *tab; /**< current tab of module */
74
75 GtkWidget *f_window; /**< filter window */
76
77 GtkWidget *f_main_box; /**< main container */
78
79};
80
81/**
82 * @fn GtkWidget* guicontrol_get_widget(ControlData*)
83 *
84 * This function returns the current main widget
85 * used by this module
86 * @param tcd the module struct
87 * @return The main widget
88 */
89GtkWidget*
90guicontrol_get_widget(ControlData *tcd)
91{
92 return tcd->f_window;
93}
94
95/**
96 * @fn ControlData* gui_control(Tab*)
97 *
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.
101 */
102ControlData*
103gui_control(Tab *tab)
104{
105 g_debug("filter::gui_control()");
106
107 unsigned i;
108 GtkCellRenderer *renderer;
109 GtkTreeViewColumn *column;
110
111 ControlData* tcd = g_new(ControlData,1);
112
113 tcd->tab = tab;
114
115 tcd->f_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
116 gtk_window_set_title(GTK_WINDOW(tcd->f_window), "LTTng Trace Control");
117 /*
118 * Initiating GtkTable layout
119 * starts with 2 rows and 5 columns and
120 * expands when expressions added
121 */
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);
125
126 gtk_container_add(GTK_CONTAINER(tcd->f_window), GTK_WIDGET(tcd->f_main_box));
127
128 /*
129 * First half of the filter window
130 * - textual entry of filter expression
131 * - processing button
132 */
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");
137
138 gtk_widget_show (username_entry);
139
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);
142
143
144 /*
145 * show main container
146 */
147 gtk_widget_show(tcd->f_main_box);
148 gtk_widget_show(tcd->f_window);
149
150
151 g_object_set_data_full(
152 G_OBJECT(guifilter_get_widget(tcd)),
153 "filter_viewer_data",
154 tcd,
155 (GDestroyNotify)gui_control_destructor);
156
157 g_control_list = g_slist_append(
158 g_control_list,
159 tcd);
160
161 return tcd;
162}
163
164
165/**
166 * @fn void gui_control_destructor(ControlData*)
167 *
168 * Destructor for the filter gui module
169 * @param tcd The module structure
170 */
171void
172gui_control_destructor(ControlData *tcd)
173{
174 Tab *tab = tcd->tab;
175
176 /* May already been done by GTK window closing */
177 if(GTK_IS_WIDGET(guifilter_get_widget(tcd))){
178 g_info("widget still exists");
179 }
180// if(tab != NULL) {
181// lttvwindow_unregister_traceset_notify(tcd->tab,
182// filter_traceset_changed,
183// filter_viewer_data);
184// }
185 lttvwindowtraces_background_notify_remove(tcd);
186
187 g_control_list = g_slist_remove(g_control_list, tcd);
188
189 g_free(tcd);
190}
191
192
193/**
194 * @fn GtkWidget* h_guicontrol(Tab*)
195 *
196 * Control Module's constructor hook
197 *
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.
202 */
203GtkWidget *
204h_guicontrol(Tab *tab)
205{
206 ControlData* f = gui_control(tab) ;
207
208 return NULL;
209}
210
211/**
212 * @fn static void init()
213 *
214 * This function initializes the Filter Viewer functionnality through the
215 * gtkTraceSet API.
216 */
217static void init() {
218
219 lttvwindow_register_constructor("guicontrol",
220 "/",
221 "Insert Tracing Control Module",
222 hTraceControlInsert_xpm,
223 "Insert Tracing Control Module",
224 h_guicontrol);
225}
226
227/**
228 * @fn void control_destroy_walk(gpointer,gpointer)
229 *
230 * Initiate the destruction of the current gui module
231 * on the GTK Interface
232 */
233void
234control_destroy_walk(gpointer data, gpointer user_data)
235{
236 ControlData *tcd = (ControlData*)data;
237
238 g_debug("traceontrol.c : control_destroy_walk, %p", tcd);
239
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));
243}
244
245/**
246 * @fn static void destroy()
247 * @brief plugin's destroy function
248 *
249 * This function releases the memory reserved by the module and unregisters
250 * everything that has been registered in the gtkTraceSet API.
251 */
252static void destroy() {
253
254 g_slist_foreach(g_control_list, control_destroy_walk, NULL );
255
256 lttvwindow_unregister_constructor(h_guicontrol);
257
258}
259
260
261LTTV_MODULE("guitracecontrol", "Trace Control Window", \
262 "Graphical module that let user control kernel tracing", \
263 init, destroy, "lttvwindow")
264
This page took 0.031271 seconds and 4 git commands to generate.