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,
26 #include <lttv/lttv.h>
27 #include <lttvwindow/lttvwindow.h>
28 #include <lttvwindow/lttvwindowtraces.h>
29 #include <lttvwindow/support.h>
32 #include "xenoltt_drawing.h"
33 #include "xenoltt_threadlist.h"
34 #include "xenoltt_eventhooks.h"
35 #include "lttv_plugin_xfv.h"
37 extern GSList
*g_xenoltt_data_list
;
39 static gboolean
header_size_allocate(GtkWidget
*widget
,GtkAllocation
*allocation
,gpointer user_data
){
40 XenoLtt_Drawing_t
*drawing
= (XenoLtt_Drawing_t
*)user_data
;
42 gtk_widget_set_size_request(drawing
->ruler
, -1, allocation
->height
);
43 gtk_container_check_resize(GTK_CONTAINER(drawing
->ruler_hbox
));
47 gboolean
xfv_scroll_event(GtkWidget
*widget
, GdkEventScroll
*event
,gpointer data
){
48 XenoLTTData
*xenoltt_data
= (XenoLTTData
*)data
;
49 unsigned int cell_height
= get_cell_height(GTK_TREE_VIEW(xenoltt_data
->thread_list
->thread_list_widget
));
52 switch(event
->direction
) {
55 new = gtk_adjustment_get_value(xenoltt_data
->v_adjust
) - cell_height
;
60 new = gtk_adjustment_get_value(xenoltt_data
->v_adjust
) + cell_height
;
66 if(new >= xenoltt_data
->v_adjust
->lower
&&
67 new <= xenoltt_data
->v_adjust
->upper
68 - xenoltt_data
->v_adjust
->page_size
)
69 gtk_adjustment_set_value(xenoltt_data
->v_adjust
, new);
74 /* Toolbar callbacks */
75 static void property_button(GtkToolButton
*toolbutton
, gpointer user_data
)
77 XenoLTTData
*xenoltt_data
= (XenoLTTData
*)user_data
;
79 g_printf("CFV Property button clicked\n");
83 /* Toolbar callbacks */
84 static void filter_button (GtkToolButton
*toolbutton
,
87 LttvPluginXFV
*plugin_xfv
= (LttvPluginXFV
*)user_data
;
88 LttvAttribute
*attribute
;
89 LttvAttributeValue value
;
91 g_printf("Filter button clicked\n");
93 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
94 LTTV_IATTRIBUTE(lttv_global_attributes()),
95 LTTV_VIEWER_CONSTRUCTORS
));
98 ret
= lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
99 "guifilter", LTTV_POINTER
, &value
);
101 lttvwindow_viewer_constructor constructor
=
102 (lttvwindow_viewer_constructor
)*(value
.v_pointer
);
103 if(constructor
) constructor(&plugin_xfv
->parent
);
104 else g_warning("Filter module not loaded.");
106 //FIXME : viewer returned.
111 /*****************************************************************************
112 * XenoLTT Viewer class implementation *
113 *****************************************************************************/
115 * XenoLTT Viewer's constructor
117 * This constructor is given as a parameter to the menuitem and toolbar button
118 * registration. It creates the drawing widget.
119 * @param ParentWindow A pointer to the parent window.
120 * @return The widget created.
122 XenoLTTData
*guixenoltt(LttvPluginTab
*ptab
){
123 Tab
*tab
= ptab
->tab
;
124 GtkWidget
*tmp_toolbar_icon
;
125 GtkWidget
*thread_list_widget
, *drawing_widget
, *drawing_area
;
126 LttvPluginXFV
*plugin_xfv
= g_object_new(LTTV_TYPE_PLUGIN_XFV
, NULL
);
127 XenoLTTData
* xenoltt_data
= plugin_xfv
->xfd
;
128 xenoltt_data
->ptab
= ptab
;
129 xenoltt_data
->tab
= ptab
->tab
;
131 xenoltt_data
->v_adjust
= GTK_ADJUSTMENT(gtk_adjustment_new( 0.0, /* Value */
136 0.0)); /* page size */
138 /* Create the drawing */
139 xenoltt_data
->drawing
= xenoltt_drawing_construct(xenoltt_data
);
141 drawing_widget
= drawing_get_widget(xenoltt_data
->drawing
);
143 drawing_area
= drawing_get_drawing_area(xenoltt_data
->drawing
);
145 xenoltt_data
->number_of_thread
= 0;
146 xenoltt_data
->background_info_waiting
= 0;
148 /* Create the Thread list */
149 xenoltt_data
->thread_list
= threadlist_construct();
151 thread_list_widget
= threadlist_get_widget(xenoltt_data
->thread_list
);
153 gtk_tree_view_set_vadjustment(GTK_TREE_VIEW(thread_list_widget
),GTK_ADJUSTMENT(xenoltt_data
->v_adjust
));
155 g_signal_connect (G_OBJECT(thread_list_widget
),
157 G_CALLBACK (xfv_scroll_event
),
158 (gpointer
)xenoltt_data
);
159 g_signal_connect (G_OBJECT(drawing_area
),
161 G_CALLBACK (xfv_scroll_event
),
162 (gpointer
)xenoltt_data
);
164 g_signal_connect (G_OBJECT(xenoltt_data
->thread_list
->button
),
166 G_CALLBACK(header_size_allocate
),
167 (gpointer
)xenoltt_data
->drawing
);
169 xenoltt_data
->hbox
= gtk_hbox_new(FALSE
, 1);
170 xenoltt_data
->toolbar
= gtk_toolbar_new();
171 gtk_toolbar_set_orientation(GTK_TOOLBAR(xenoltt_data
->toolbar
),
172 GTK_ORIENTATION_VERTICAL
);
174 tmp_toolbar_icon
= create_pixmap (main_window_get_widget(tab
),
175 "guifilter16x16.png");
176 gtk_widget_show(tmp_toolbar_icon
);
177 xenoltt_data
->button_filter
= gtk_tool_button_new(tmp_toolbar_icon
,
179 g_signal_connect (G_OBJECT(xenoltt_data
->button_filter
),
181 G_CALLBACK (filter_button
),
182 (gpointer
)plugin_xfv
);
183 gtk_toolbar_insert(GTK_TOOLBAR(xenoltt_data
->toolbar
),
184 xenoltt_data
->button_filter
,
187 tmp_toolbar_icon
= create_pixmap (main_window_get_widget(tab
),
189 gtk_widget_show(tmp_toolbar_icon
);
190 xenoltt_data
->button_prop
= gtk_tool_button_new(tmp_toolbar_icon
,
192 g_signal_connect (G_OBJECT(xenoltt_data
->button_prop
),
194 G_CALLBACK (property_button
),
195 (gpointer
)xenoltt_data
);
196 gtk_toolbar_insert(GTK_TOOLBAR(xenoltt_data
->toolbar
),xenoltt_data
->button_prop
,1);
198 gtk_toolbar_set_style(GTK_TOOLBAR(xenoltt_data
->toolbar
),GTK_TOOLBAR_ICONS
);
200 gtk_box_pack_start(GTK_BOX(xenoltt_data
->hbox
), xenoltt_data
->toolbar
,FALSE
, FALSE
, 0);
202 xenoltt_data
->h_paned
= gtk_hpaned_new();
203 xenoltt_data
->box
= gtk_event_box_new();
204 gtk_box_pack_end(GTK_BOX(xenoltt_data
->hbox
), xenoltt_data
->box
,TRUE
, TRUE
, 0);
205 xenoltt_data
->top_widget
= xenoltt_data
->hbox
;
206 plugin_xfv
->parent
.top_widget
= xenoltt_data
->top_widget
;
207 gtk_container_add(GTK_CONTAINER(xenoltt_data
->box
),xenoltt_data
->h_paned
);
209 gtk_paned_pack1(GTK_PANED(xenoltt_data
->h_paned
),thread_list_widget
, FALSE
, TRUE
);
210 gtk_paned_pack2(GTK_PANED(xenoltt_data
->h_paned
),drawing_widget
, TRUE
, TRUE
);
212 gtk_container_set_border_width(GTK_CONTAINER(xenoltt_data
->box
), 1);
215 gtk_widget_show(drawing_widget
);
216 gtk_widget_show(thread_list_widget
);
217 gtk_widget_show(xenoltt_data
->h_paned
);
218 gtk_widget_show(xenoltt_data
->box
);
219 // gtk_widget_show(xenoltt_data->toolbar);
220 // gtk_widget_show(GTK_WIDGET(xenoltt_data->button_prop));
221 // gtk_widget_show(GTK_WIDGET(xenoltt_data->button_filter));
222 gtk_widget_show(xenoltt_data
->hbox
);
224 g_object_set_data_full(
225 G_OBJECT(xenoltt_data
->top_widget
),
228 (GDestroyNotify
)guixenoltt_destructor
);
231 G_OBJECT(drawing_area
),
235 g_xenoltt_data_list
= g_slist_append(g_xenoltt_data_list
,plugin_xfv
);
238 xenoltt_data
->filter
= NULL
;
240 //WARNING : The widget must be
241 //inserted in the main window before the drawing area
242 //can be configured (and this must happend bedore sending
248 /* Destroys widget also */
249 void guixenoltt_destructor_full(gpointer data
){
250 LttvPluginXFV
*plugin_xfv
= (LttvPluginXFV
*)data
;
251 g_info("XFV.c : guixenoltt_destructor_full, %p", plugin_xfv
);
252 /* May already have been done by GTK window closing */
253 if(GTK_IS_WIDGET(guixenoltt_get_widget(plugin_xfv
->xfd
)))
254 gtk_widget_destroy(guixenoltt_get_widget(plugin_xfv
->xfd
));
257 /* When this destructor is called, the widgets are already disconnected */
258 void guixenoltt_destructor(gpointer data
){
259 LttvPluginXFV
*plugin_xfv
= (LttvPluginXFV
*)data
;
260 Tab
*tab
= plugin_xfv
->xfd
->tab
;
261 XenoLTTData
*xenoltt_data
= plugin_xfv
->xfd
;
263 g_info("CFV.c : guixenoltt_destructor, %p", plugin_xfv
);
264 g_info("%p, %p, %p", update_time_window_hook
, plugin_xfv
, tab
);
265 if(GTK_IS_WIDGET(guixenoltt_get_widget(plugin_xfv
->xfd
)))
266 g_info("widget still exists");
268 lttv_filter_destroy(plugin_xfv
->xfd
->filter
);
269 /* Thread List is removed with it's widget */
271 /* Delete reading hooks */
272 lttvwindow_unregister_traceset_notify(tab
,traceset_notify
,xenoltt_data
);
274 lttvwindow_unregister_time_window_notify(tab
,update_time_window_hook
,xenoltt_data
);
276 lttvwindow_unregister_current_time_notify(tab
,update_current_time_hook
,xenoltt_data
);
278 lttvwindow_unregister_redraw_notify(tab
, redraw_notify
, xenoltt_data
);
279 lttvwindow_unregister_continue_notify(tab
,continue_notify
,xenoltt_data
);
281 lttvwindow_events_request_remove_all(xenoltt_data
->tab
,xenoltt_data
);
284 lttvwindowtraces_background_notify_remove(xenoltt_data
);
285 g_xenoltt_data_list
= g_slist_remove(g_xenoltt_data_list
, xenoltt_data
);
287 g_info("XFV.c : guixenoltt_destructor end, %p", xenoltt_data
);
288 g_object_unref(plugin_xfv
);