*
*/
-#include <lttvwindow/common.h>
#include <ltt/ltt.h>
#include <lttv/lttv.h>
+#include <lttv/state.h>
+#include <lttv/stats.h>
+#include <lttv/tracecontext.h>
+#include <lttvwindow/common.h>
#include <lttvwindow/mainwindow.h>
#include <lttvwindow/viewer.h>
-#include <lttv/tracecontext.h>
#include <lttvwindow/toolbar.h>
#include <lttvwindow/menu.h>
-#include <lttv/state.h>
-#include <lttv/stats.h>
+#include <lttvwindow/callbacks.h> // for execute_time_requests
/**
tmp = (LttvHooks*)*(value.v_pointer);
if(tmp == NULL) return 1;
+
lttv_hooks_call(tmp,traceset);
-
+
return 0;
}
lttv_hooks_call(tmp, NULL);
}
+void set_time_window_adjustment(MainWindow * main_win, const TimeWindow* new_time_window)
+{
+ gtk_multi_vpaned_set_adjust(main_win->current_tab->multi_vpaned, new_time_window, FALSE);
+}
-/**
- * Function to show each viewer in the current tab.
- * It will be called by main window after it called process_traceset
- * @param main_win the main window the viewer belongs to.
- */
-
-void show_viewer(MainWindow *main_win)
+void set_time_window(MainWindow * main_win, const TimeWindow *time_window)
{
LttvAttributeValue value;
LttvHooks * tmp;
+
+ TimeWindowNotifyData time_window_notify_data;
+ TimeWindow old_time_window = main_win->current_tab->time_window;
+ time_window_notify_data.old_time_window = &old_time_window;
+ main_win->current_tab->time_window = *time_window;
+ time_window_notify_data.new_time_window =
+ &(main_win->current_tab->time_window);
+
g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
- "hooks/showviewer", LTTV_POINTER, &value));
+ "hooks/updatetimewindow", LTTV_POINTER, &value));
tmp = (LttvHooks*)*(value.v_pointer);
if(tmp == NULL) return;
- lttv_hooks_call(tmp, NULL);
+ lttv_hooks_call(tmp, &time_window_notify_data);
+
+
+}
+
+void add_toolbar_constructor(MainWindow *mw, LttvToolbarClosure *toolbar_c)
+{
+ LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes);
+ LttvAttributeValue value;
+ LttvToolbars * instance_toolbar;
+ lttvwindow_viewer_constructor constructor;
+ GtkWidget * tool_menu_title_menu, *new_widget, *pixmap;
+ GdkPixbuf *pixbuf;
+
+ g_assert(lttv_iattribute_find_by_path(attributes,
+ "viewers/toolbar", LTTV_POINTER, &value));
+ if(*(value.v_pointer) == NULL)
+ (LttvToolbars*)*(value.v_pointer) = lttv_toolbars_new();
+ instance_toolbar = (LttvToolbars*)*(value.v_pointer);
+
+ constructor = toolbar_c->con;
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
+ pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c->pixmap);
+ pixmap = gtk_image_new_from_pixbuf(pixbuf);
+ new_widget =
+ gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu),
+ GTK_TOOLBAR_CHILD_BUTTON,
+ NULL,
+ "",
+ toolbar_item->tooltip, NULL,
+ pixmap, NULL, NULL);
+ gtk_label_set_use_underline(
+ GTK_LABEL (((GtkToolbarChild*) (
+ g_list_last (GTK_TOOLBAR
+ (tool_menu_title_menu)->children)->data))->label),
+ TRUE);
+ gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1);
+ g_signal_connect ((gpointer) new_widget,
+ "clicked",
+ G_CALLBACK (insert_viewer_wrap),
+ constructor);
+ gtk_widget_show (new_widget);
+
+ lttv_toolbars_add(instance_toolbar, toolbar_item_i->con,
+ toolbar_item_i->tooltip,
+ toolbar_item_i->pixmap,
+ new_widget);
+
+}
+
+void add_menu_constructor(MainWindow *mw, LttvMenuClosure *menu_c)
+{
+ LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes);
+ LttvAttributeValue value;
+ LttvToolbars * instance_menu;
+ lttvwindow_viewer_constructor constructor;
+ GtkWidget * tool_menu_title_menu, *new_widget;
+
+ g_assert(lttv_iattribute_find_by_path(attributes,
+ "viewers/menu", LTTV_POINTER, &value));
+ if(*(value.v_pointer) == NULL)
+ (LttvMenus*)*(value.v_pointer) = lttv_menus_new();
+ instance_menu = (LttvMenus*)*(value.v_pointer);
+
+
+ constructor = menu_item->con;
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
+ new_widget =
+ gtk_menu_item_new_with_mnemonic (menu_c->menuText);
+ gtk_container_add (GTK_CONTAINER (tool_menu_title_menu),
+ new_widget);
+ g_signal_connect ((gpointer) new_widget, "activate",
+ G_CALLBACK (insert_viewer_wrap),
+ constructor);
+ gtk_widget_show (new_widget);
+ lttv_menus_add(instance_menu, menu_c->con,
+ menu_c->menu_path,
+ menu_c->menu_text,
+ new_widget);
+}
+
+void remove_toolbar_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
+{
+ LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes);
+ LttvAttributeValue value;
+ LttvToolbars * instance_toolbar;
+ lttvwindow_viewer_constructor constructor;
+ GtkWidget * tool_menu_title_menu, *widget;
+
+ g_assert(lttv_iattribute_find_by_path(attributes,
+ "viewers/toolbar", LTTV_POINTER, &value));
+ if(*(value.v_pointer) == NULL)
+ (LttvToolbars*)*(value.v_pointer) = lttv_toolbars_new();
+ instance_toolbar = (LttvToolbars*)*(value.v_pointer);
+
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
+ widget = lttv_menus_remove(instance_toolbar, viewer_constructor);
+ gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu),
+ widget);
}
+void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
+{
+ LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes);
+ LttvAttributeValue value;
+ LttvMenus * instance_menu;
+ lttvwindow_viewer_constructor constructor;
+ GtkWidget * tool_menu_title_menu, *widget;
+ LttvMenuClosure *menu_item_i;
+
+ g_assert(lttv_iattribute_find_by_path(attributes,
+ "viewers/menu", LTTV_POINTER, &value));
+ if(*(value.v_pointer) == NULL)
+ (LttvMenus*)*(value.v_pointer) = lttv_menus_new();
+ instance_menu = (LttvMenus*)*(value.v_pointer);
+
+ widget = lttv_menus_remove(instance_menu, viewer_constructor);
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
+ gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), widget);
+}
/**
* API parts
*/
+
/**
* Function to register a view constructor so that main window can generate
- * a toolbar item for the viewer in order to generate a new instance easily.
- * It will be called by init function of the module.
- * @param ButtonPixmap image shown on the toolbar item.
+ * a menu item and a toolbar item for the viewer in order to generate a new
+ * instance easily. A menu entry and toolbar item will be added to each main
+ * window.
+ *
+ * It should be called by init function of the module.
+ *
+ * @param menu_path path of the menu item.
+ * @param menu_text text of the menu item.
+ * @param pixmap Image shown on the toolbar item.
* @param tooltip tooltip of the toolbar item.
* @param view_constructor constructor of the viewer.
*/
-void lttvwindow_register_toolbar(char ** pixmap, char *tooltip, lttvwindow_viewer_constructor view_constructor)
+void lttvwindow_register_constructor
+ (char * menu_path,
+ char * menu_text,
+ char ** pixmap,
+ char * tooltip,
+ lttvwindow_viewer_constructor view_constructor)
{
LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
LttvToolbars * toolbar;
+ LttvMenus * menu;
+ LttvToolbarClosure toolbar_c;
+ LttvMenuClosure menu_c;
LttvAttributeValue value;
- g_assert(lttv_iattribute_find_by_path(attributes_global,
- "viewers/toolbar", LTTV_POINTER, &value));
- toolbar = (LttvToolbars*)*(value.v_pointer);
+ if(pixmap != NULL) {
+ g_assert(lttv_iattribute_find_by_path(attributes_global,
+ "viewers/toolbar", LTTV_POINTER, &value));
+ toolbar = (LttvToolbars*)*(value.v_pointer);
+
+ if(toolbar == NULL) {
+ toolbar = lttv_toolbars_new();
+ *(value.v_pointer) = toolbar;
+ }
+ toolbar_c = lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap);
+
+ g_slist_foreach(g_main_window_list,
+ (gpointer)add_toolbar_constructor,
+ &toolbar_c);
+ }
- if(toolbar == NULL){
- toolbar = lttv_toolbars_new();
- *(value.v_pointer) = toolbar;
+ if(menu_path != NULL) {
+ g_assert(lttv_iattribute_find_by_path(attributes_global,
+ "viewers/menu", LTTV_POINTER, &value));
+ menu = (LttvMenus*)*(value.v_pointer);
+
+ if(menu == NULL) {
+ menu = lttv_menus_new();
+ *(value.v_pointer) = menu;
+ }
+ menu_c = lttv_menus_add(menu, view_constructor, menu_path, menu_text);
+
+ g_slist_foreach(g_main_window_list,
+ (gpointer)add_menu_constructor,
+ &menu_c);
}
- lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap);
}
/**
* Function to unregister the viewer's constructor, release the space
- * occupied by pixmap, tooltip and constructor of the viewer.
+ * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
+ * viewer.
+ *
* It will be called when a module is unloaded.
- * @param view_constructor constructor of the viewer which is used as
- * a reference to find out where the pixmap and tooltip are.
+ *
+ * @param view_constructor constructor of the viewer.
*/
-void lttvwindow_unregister_toolbar(lttvwindow_viewer_constructor view_constructor)
+
+void lttvwindow_unregister_constructor
+ (lttvwindow_viewer_constructor view_constructor)
{
LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
LttvToolbars * toolbar;
+ LttvMenus * menu;
LttvAttributeValue value;
g_assert(lttv_iattribute_find_by_path(attributes_global,
"viewers/toolbar", LTTV_POINTER, &value));
toolbar = (LttvToolbars*)*(value.v_pointer);
- main_window_remove_toolbar_item(view_constructor);
-
- lttv_toolbars_remove(toolbar, view_constructor);
-}
-
-
-/**
- * Function to register a view constructor so that main window can generate
- * a menu item for the viewer in order to generate a new instance easily.
- * It will be called by init function of the module.
- * @param menu_path path of the menu item.
- * @param menu_text text of the menu item.
- * @param view_constructor constructor of the viewer.
- */
-
-void lttvwindow_register_menu(char *menu_path, char *menu_text, lttvwindow_viewer_constructor view_constructor)
-{
- LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
- LttvMenus * menu;
- LttvAttributeValue value;
+ if(toolbar != NULL) {
+ g_slist_foreach(g_main_window_list,
+ (gpointer)remove_toolbar_constructor,
+ view_constructor);
+ lttv_toolbars_remove(toolbar, view_constructor);
+ }
g_assert(lttv_iattribute_find_by_path(attributes_global,
"viewers/menu", LTTV_POINTER, &value));
menu = (LttvMenus*)*(value.v_pointer);
- if(menu == NULL){
- menu = lttv_menus_new();
- *(value.v_pointer) = menu;
+ if(menu != NULL) {
+ g_slist_foreach(g_main_window_list,
+ (gpointer)remove_menu_constructor,
+ view_constructor);
+ lttv_menus_remove(menu, view_constructor);
}
- lttv_menus_add(menu, view_constructor, menu_path, menu_text);
}
-/**
- * Function to unregister the viewer's constructor, release the space
- * occupied by menu_path, menu_text and constructor of the viewer.
- * It will be called when a module is unloaded.
- * @param view_constructor constructor of the viewer which is used as
- * a reference to find out where the menu_path and menu_text are.
- */
-
-void lttvwindow_unregister_menu(lttvwindow_viewer_constructor view_constructor)
-{
- LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
- LttvMenus * menu;
- LttvAttributeValue value;
-
- g_assert(lttv_iattribute_find_by_path(attributes_global,
- "viewers/menu", LTTV_POINTER, &value));
- menu = (LttvMenus*)*(value.v_pointer);
-
- main_window_remove_menu_item(view_constructor);
-
- lttv_menus_remove(menu, view_constructor);
-}
/**
* Function to register a hook function for a viewer to set/update its
* @param main_win the main window the viewer belongs to.
*/
-void lttvwindow_unregister_filter_notify(LttvHook hook, gpointer hook_data,
- MainWindow * main_win)
+void lttvwindow_unregister_filter_notify(MainWindow * main_win,
+ LttvHook hook,
+ gpointer hook_data)
{
LttvAttributeValue value;
LttvHooks * tmp;
lttv_hooks_remove_data(tmp, hook, hook_data);
}
-
/**
* Function to register a hook function for a viewer to set/update its
* current time.
* @param main_win the main window the viewer belongs to.
*/
-void lttvwindow_register_show(MainWindow *main_win,
+void lttvwindow_register_show_notify(MainWindow *main_win,
LttvHook hook, gpointer hook_data)
{
LttvAttributeValue value;
* @param main_win the main window the viewer belongs to.
*/
-void lttvwindow_unregister_show(MainWindow * main_win,
+void lttvwindow_unregister_show_notify(MainWindow * main_win,
LttvHook hook, gpointer hook_data)
{
LttvAttributeValue value;
* @param info the message which will be shown in the status bar.
*/
-void lttvwindow_report_status(MainWindow *main_win, char *info)
+void lttvwindow_report_status(MainWindow *main_win, const char *info)
{
//FIXME
g_warning("update_status not implemented in viewer.c");
*/
void lttvwindow_report_time_window(MainWindow *main_win,
- TimeWindow *time_window)
+ const TimeWindow *time_window)
{
- LttvAttributeValue value;
- LttvHooks * tmp;
-
- TimeWindowNotifyData time_window_notify_data;
- TimeWindow old_time_window = main_win->current_tab->time_window;
- time_window_notify_data.old_time_window = &old_time_window;
- main_win->current_tab->time_window = *time_window;
- time_window_notify_data.new_time_window =
- &(main_win->current_tab->time_window);
-
- gtk_multi_vpaned_set_scroll_value(main_win->current_tab->multi_vpaned,
- ltt_time_to_double(time_window->start_time)
- * NANOSECONDS_PER_SECOND );
- g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
- "hooks/updatetimewindow", LTTV_POINTER, &value));
- tmp = (LttvHooks*)*(value.v_pointer);
- if(tmp == NULL) return;
- lttv_hooks_call(tmp, &time_window_notify_data);
+ set_time_window(main_win, time_window);
+ set_time_window_adjustment(main_win, time_window);
}
+
/**
* Function to set the current time/event of the current tab.
* It will be called by a viewer's signal handle associated with
* @param time a pointer where time is stored.
*/
-void lttvwindow_report_current_time(MainWindow *main_win, LttTime *time)
+void lttvwindow_report_current_time(MainWindow *main_win,
+ const LttTime *time)
{
LttvAttributeValue value;
LttvHooks * tmp;
tmp = (LttvHooks*)*(value.v_pointer);
if(tmp == NULL)return;
- lttv_hooks_call(tmp, time);
+ lttv_hooks_call(tmp, &main_win->current_tab->current_time);
}
/**
* It will be called by a viewer's signal handle associated with
* the grab_focus signal
* @param main_win the main window the viewer belongs to.
- * @param paned a pointer to a pane where the viewer is contained.
+ * @param top_widget the top widget containing all the other widgets of the
+ * viewer.
*/
-void lttvwindow_report_focus(MainWindow *main_win, gpointer paned)
+void lttvwindow_report_focus(MainWindow *main_win, GtkWidget *top_widget)
{
- gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned,paned);
+ gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned,
+ gtk_widget_get_parent(top_widget));
}
-
/**
- * Function to get the current time interval of the current traceset.
- * It will be called by a viewer's hook function to update the
- * time interval of the viewer and also be called by the constructor
- * of the viewer.
+ * Function to request data in a specific time interval to the main window.
+ * The main window will use this time interval and the others present
+ * to get the data from the process trace.
* @param main_win the main window the viewer belongs to.
- * @param time_interval a pointer where time interval will be stored.
+ * @param paned a pointer to a pane where the viewer is contained.
*/
-const TimeInterval *lttvwindow_get_time_span(MainWindow *main_win)
+void lttvwindow_time_interval_request(MainWindow *main_win,
+ TimeWindow time_requested, guint num_events,
+ LttvHook after_process_traceset,
+ gpointer after_process_traceset_data)
{
- //time_window->start_time = main_win->current_tab->time_window.start_time;
- //time_window->time_width = main_win->current_tab->time_window.time_width;
- return (LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
- traceset_context)->Time_Span);
-}
+ TimeRequest time_request;
+ time_request.time_window = time_requested;
+ time_request.num_events = num_events;
+ time_request.after_hook = after_process_traceset;
+ time_request.after_hook_data = after_process_traceset_data;
+ g_array_append_val(main_win->current_tab->time_requests, time_request);
+
+ if(!main_win->current_tab->time_request_pending)
+ {
+ /* Redraw has +20 priority. We want a prio higher than that, so +19 */
+ g_idle_add_full((G_PRIORITY_HIGH_IDLE + 19),
+ (GSourceFunc)execute_time_requests,
+ main_win,
+ NULL);
+ main_win->current_tab->time_request_pending = TRUE;
+ }
+}
/**
* Function to get the current time interval shown on the current tab.
}
-/**
- * Function to get the traceset from the current tab.
- * It will be called by the constructor of the viewer and also be
- * called by a hook funtion of the viewer to update its traceset.
- * @param main_win the main window the viewer belongs to.
- * @param traceset a pointer to a traceset.
- */
-const LttvTraceset *lttvwindow_get_traceset(MainWindow *main_win)
-{
- return main_win->current_tab->traceset_info->traceset;
-}
-
/**
* Function to get the filter of the current tab.
* It will be called by the constructor of the viewer and also be