From 561f58527175d5546f8269760e2691459293d4ac Mon Sep 17 00:00:00 2001 From: yangxx Date: Mon, 25 Aug 2003 19:12:30 +0000 Subject: [PATCH] main window api files git-svn-id: http://ltt.polymtl.ca/svn@186 04897980-b3bd-0310-b5e0-8ef037075253 --- .../poly/lttv/modules/gui/API/Makefile.am | 16 + .../poly/lttv/modules/gui/API/common.h | 14 + .../poly/lttv/modules/gui/API/gtkTraceSet.c | 638 ++++++++++++++++++ ltt/branches/poly/lttv/modules/gui/API/menu.c | 49 ++ ltt/branches/poly/lttv/modules/gui/API/menu.h | 29 + .../poly/lttv/modules/gui/API/toolbar.c | 48 ++ .../poly/lttv/modules/gui/API/toolbar.h | 28 + 7 files changed, 822 insertions(+) create mode 100644 ltt/branches/poly/lttv/modules/gui/API/Makefile.am create mode 100644 ltt/branches/poly/lttv/modules/gui/API/common.h create mode 100644 ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c create mode 100644 ltt/branches/poly/lttv/modules/gui/API/menu.c create mode 100644 ltt/branches/poly/lttv/modules/gui/API/menu.h create mode 100644 ltt/branches/poly/lttv/modules/gui/API/toolbar.c create mode 100644 ltt/branches/poly/lttv/modules/gui/API/toolbar.h diff --git a/ltt/branches/poly/lttv/modules/gui/API/Makefile.am b/ltt/branches/poly/lttv/modules/gui/API/Makefile.am new file mode 100644 index 00000000..099b98d1 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/API/Makefile.am @@ -0,0 +1,16 @@ +# +# Makefile for LTT New generation user interface : plugins. +# +# Created by Mathieu Desnoyers on May 6, 2003 +# + +libdir = ${lttlibdir} + +AM_CFLAGS = $(GLIB_CFLAGS) +AM_CFLAGS += $(GTK_CFLAGS) +LIBS += $(GLIB_LIBS) +LIBS += $(GTK_LIBS) + +lib_LTLIBRARIES = libmainwindowapi.la +libmainwindowapi_la_SOURCES = toolbar.c menu.c gtkTraceSet.c +EXTRA_DIST = diff --git a/ltt/branches/poly/lttv/modules/gui/API/common.h b/ltt/branches/poly/lttv/modules/gui/API/common.h new file mode 100644 index 00000000..0d17e13a --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/API/common.h @@ -0,0 +1,14 @@ +#ifndef COMMON_H +#define COMMON_H + +#include +#include +#include + +/* constructor of the viewer */ +typedef GtkWidget * (*lttv_constructor)(void * main_window); + + + + +#endif // COMMON_H diff --git a/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c b/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c new file mode 100644 index 00000000..019a96b8 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/API/gtkTraceSet.c @@ -0,0 +1,638 @@ +/*! \file gtkTraceSet.h + * \brief API used by the graphical viewers to interact with their top window. + * + * Main window (gui module) is the place to contain and display viewers. + * Viewers (lttv plugins) interacte with main window through this API and + * events sent by gtk. + * This header file should be included in each graphic module. + * This library is used by graphical modules to interact with the + * tracesetWindow. + * + */ + +#include "common.h" +#include +#include +#include +#include +#include +#include "toolbar.h" +#include "menu.h" + +/** + * Internal function parts + */ + +/** + * Function to remove toolbar from the GUI + * @param view_constructor constructor of the viewer. + */ + +void RemoveToolbar(void *view_constructor) +{ + g_printf("Toolbar for the viewer will be removed\n"); +} + +/** + * Function to remove menu entry from the GUI + * @param view_constructor constructor of the viewer. + */ + +void RemoveMenu(void *view_constructor) +{ + g_printf("Menu entry for the viewer will be removed\n"); +} + + +/** + * Function to set/update traceset for the viewers + * @param main_win main window + * @param traceset traceset of the main window. + */ + +void SetTraceset(mainWindow * main_win, gpointer traceset) +{ + LttvHooks * tmp; + LttvAttributeValue value; + + g_assert(lttv_iattribute_find_by_path(main_win->Attributes, + "hooks/updatetraceset", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL)return; + lttv_hooks_call(tmp,traceset); +} + + +/** + * Function to set/update filter for the viewers + * @param main_win main window + * @param filter filter of the main window. + */ + +void SetFilter(mainWindow * main_win, gpointer filter) +{ + LttvHooks * tmp; + LttvAttributeValue value; + + g_assert(lttv_iattribute_find_by_path(main_win->Attributes, + "hooks/updatefilter", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + + if(tmp == NULL)return; + lttv_hooks_call(tmp,filter); +} + + + +/** + * 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. + * @param tooltip tooltip of the toolbar item. + * @param view_constructor constructor of the viewer. + */ + +void ToolbarItemReg(GdkPixmap * pixmap, char *tooltip, void *view_constructor) +{ + LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); + LttvToolbars * toolbar; + LttvAttributeValue value; + + 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; + } + 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. + * 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. + */ + +void ToolbarItemUnreg(void *view_constructor) +{ + LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); + LttvToolbars * toolbar; + LttvAttributeValue value; + + g_assert(lttv_iattribute_find_by_path(attributes_global, + "viewers/toolbar", LTTV_POINTER, &value)); + toolbar = (LttvToolbars*)*(value.v_pointer); + + if(lttv_toolbars_remove(toolbar, view_constructor)) + RemoveToolbar(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 MenuItemReg(char *menu_path, char *menu_text, void *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); + + if(menu == NULL){ + menu = lttv_menus_new(); + *(value.v_pointer) = menu; + } + 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 MenuItemUnreg(void *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); + + if(lttv_menus_remove(menu, view_constructor)) + RemoveMenu(view_constructor); +} + + +/** + * Update the status bar whenever something changed in the viewer. + * @param main_win the main window the viewer belongs to. + * @param info the message which will be shown in the status bar. + */ + +void UpdateStatus(mainWindow *main_win, char *info) +{ +} + + +/** + * Function to get the current time interval of the current tab. + * 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. + * @param main_win the main window the viewer belongs to. + * @param time_interval a pointer where time interval will be stored. + */ + +void GetTimeInterval(mainWindow *main_win, TimeInterval *time_interval) +{ + time_interval->startTime = main_win->CurrentTab->startTime; + time_interval->endTime = main_win->CurrentTab->endTime; +} + + +/** + * Function to set the time interval of the current tab. + * It will be called by a viewer's signal handle associated with + * the move_slider signal + * @param main_win the main window the viewer belongs to. + * @param time_interval a pointer where time interval is stored. + */ + +void SetTimeInterval(mainWindow *main_win, TimeInterval *time_interval) +{ + LttvAttributeValue value; + LttvHooks * tmp; + main_win->CurrentTab->startTime = time_interval->startTime; + main_win->CurrentTab->endTime = time_interval->endTime; + g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, + "hooks/updatetimeinterval", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL)return; + lttv_hooks_call(tmp, time_interval); +} + + +/** + * Function to get the current time/event of the current tab. + * It will be called by a viewer's hook function to update the + * current time/event of the viewer. + * @param main_win the main window the viewer belongs to. + * @param time a pointer where time will be stored. + */ + +void GetCurrentTime(mainWindow *main_win, LttTime *time) +{ + time = &main_win->CurrentTab->currentTime; +} + + +/** + * Function to set the current time/event of the current tab. + * It will be called by a viewer's signal handle associated with + * the button-release-event signal + * @param main_win the main window the viewer belongs to. + * @param time a pointer where time is stored. + */ + +void SetCurrentTime(mainWindow *main_win, LttTime *time) +{ + LttvAttributeValue value; + LttvHooks * tmp; + main_win->CurrentTab->currentTime = *time; + g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, + "hooks/updatecurrenttime", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + + if(tmp == NULL)return; + lttv_hooks_call(tmp, time); +} + + +/** + * 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. + */ +/* +void GetTraceset(mainWindow *main_win, Traceset *traceset) +{ +} +*/ + +/** + * Function to get the filter of 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 filter. + * @param main_win, the main window the viewer belongs to. + * @param filter, a pointer to a filter. + */ +/* +void GetFilter(mainWindow *main_win, Filter *filter) +{ +} +*/ + +/** + * Function to register a hook function for a viewer to set/update its + * time interval. + * It will be called by the constructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void RegUpdateTimeInterval(LttvHook hook, gpointer hook_data, + mainWindow * main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, + "hooks/updatetimeinterval", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL){ + tmp = lttv_hooks_new(); + *(value.v_pointer) = tmp; + } + lttv_hooks_add(tmp, hook,hook_data); +} + + +/** + * Function to unregister a viewer's hook function which is used to + * set/update the time interval of the viewer. + * It will be called by the destructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void UnregUpdateTimeInterval(LttvHook hook, gpointer hook_data, + mainWindow * main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, + "hooks/updatetimeinterval", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL) return; + lttv_hooks_remove_data(tmp, hook, hook_data); +} + + +/** + * Function to register a hook function for a viewer to set/update its + * traceset. + * It will be called by the constructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void RegUpdateTraceset(LttvHook hook, gpointer hook_data, + mainWindow * main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->Attributes, + "hooks/updatetraceset", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL){ + tmp = lttv_hooks_new(); + *(value.v_pointer) = tmp; + } + lttv_hooks_add(tmp, hook, hook_data); +} + + +/** + * Function to unregister a viewer's hook function which is used to + * set/update the traceset of the viewer. + * It will be called by the destructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void UnregUpdateTraceset(LttvHook hook, gpointer hook_data, + mainWindow * main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->Attributes, + "hooks/updatetraceset", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL) return; + lttv_hooks_remove_data(tmp, hook, hook_data); +} + + +/** + * Function to register a hook function for a viewer to set/update its + * filter. + * It will be called by the constructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void RegUpdateFilter(LttvHook hook, gpointer hook_data, + mainWindow *main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->Attributes, + "hooks/updatefilter", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL){ + tmp = lttv_hooks_new(); + *(value.v_pointer) = tmp; + } + lttv_hooks_add(tmp, hook, hook_data); +} + + +/** + * Function to unregister a viewer's hook function which is used to + * set/update the filter of the viewer. + * It will be called by the destructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void UnregUpdateFilter(LttvHook hook, gpointer hook_data, + mainWindow * main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->Attributes, + "hooks/updatefilter", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL) return; + lttv_hooks_remove_data(tmp, hook, hook_data); +} + + +/** + * Function to register a hook function for a viewer to set/update its + * current time. + * It will be called by the constructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void RegUpdateCurrentTime(LttvHook hook, gpointer hook_data, + mainWindow *main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, + "hooks/updatecurrenttime", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL){ + tmp = lttv_hooks_new(); + *(value.v_pointer) = tmp; + } + lttv_hooks_add(tmp, hook, hook_data); +} + + +/** + * Function to unregister a viewer's hook function which is used to + * set/update the current time of the viewer. + * It will be called by the destructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void UnregUpdateCurrentTime(LttvHook hook, gpointer hook_data, + mainWindow * main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, + "hooks/updatecurrenttime", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL) return; + lttv_hooks_remove_data(tmp, hook, hook_data); +} + + +/** + * Function to set the focused pane (viewer). + * 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. + */ + +void SetFocusedPane(mainWindow *main_win, gpointer paned) +{ + gtk_custom_set_focus((GtkWidget*)main_win->CurrentTab->custom,paned); +} + + +/** + * Function to register a hook function for a viewer to set/update the + * dividor of the hpane. + * It will be called by the constructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void RegUpdateDividor(LttvHook hook, gpointer hook_data, + mainWindow *main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, + "hooks/hpanedividor", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL){ + tmp = lttv_hooks_new(); + *(value.v_pointer) = tmp; + } + lttv_hooks_add(tmp, hook, hook_data); +} + + +/** + * Function to unregister a viewer's hook function which is used to + * set/update hpane's dividor of the viewer. + * It will be called by the destructor of the viewer. + * @param hook hook function of the viewer. + * @param hook_data hook data associated with the hook function. + * @param main_win the main window the viewer belongs to. + */ + +void UnregUpdateDividor(LttvHook hook, gpointer hook_data, + mainWindow *main_win) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, + "hooks/hpanedividor", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL) return; + lttv_hooks_remove_data(tmp, hook, hook_data); +} + + +/** + * Function to set the position of the hpane's dividor (viewer). + * It will be called by a viewer's signal handle associated with + * the motion_notify_event event/signal + * @param main_win the main window the viewer belongs to. + * @param position position of the hpane's dividor. + */ + +void SetHPaneDividor(mainWindow *main_win, gint position) +{ + LttvAttributeValue value; + LttvHooks * tmp; + g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, + "hooks/hpanedividor", LTTV_POINTER, &value)); + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL) return; + lttv_hooks_call(tmp, &position); +} + + +/** + * Function to process traceset. It will call lttv_process_trace, + * each view will call this api to get events. + * @param main_win the main window the viewer belongs to. + * @param start the start time of the first event to be processed. + * @param end the end time of the last event to be processed. + */ + +void processTraceset(mainWindow *main_win, LttTime start, LttTime end) +{ + lttv_process_trace(start, end, main_win->traceset, main_win->traceset_context); +} + +/** + * Function to add hooks into the context of a traceset, + * before reading events from traceset, viewer will call this api to + * register hooks + * @param main_win the main window the viewer belongs to. + * @param LttvHooks hooks to be registered. + */ + +void contextAddHooks(mainWindow *main_win , + LttvHooks *before_traceset, + LttvHooks *after_traceset, + LttvHooks *check_trace, + LttvHooks *before_trace, + LttvHooks *after_trace, + LttvHooks *check_tracefile, + LttvHooks *before_tracefile, + LttvHooks *after_tracefile, + LttvHooks *check_event, + LttvHooks *before_event, + LttvHooks *after_event) +{ + LttvTracesetContext * tsc = main_win->traceset_context; + lttv_traceset_context_add_hooks(tsc,before_traceset,after_traceset, + check_trace,before_trace,after_trace, + check_tracefile,before_tracefile,after_tracefile, + check_event,before_event, after_event); +} + + +/** + * Function to remove hooks from the context of a traceset, + * before reading events from traceset, viewer will call this api to + * unregister hooks + * @param main_win the main window the viewer belongs to. + * @param LttvHooks hooks to be registered. + */ + +void contextRemoveHooks(mainWindow *main_win , + LttvHooks *before_traceset, + LttvHooks *after_traceset, + LttvHooks *check_trace, + LttvHooks *before_trace, + LttvHooks *after_trace, + LttvHooks *check_tracefile, + LttvHooks *before_tracefile, + LttvHooks *after_tracefile, + LttvHooks *check_event, + LttvHooks *before_event, + LttvHooks *after_event) +{ + LttvTracesetContext * tsc = main_win->traceset_context; + lttv_traceset_context_remove_hooks(tsc,before_traceset,after_traceset, + check_trace,before_trace,after_trace, + check_tracefile,before_tracefile,after_tracefile, + check_event,before_event, after_event); +} diff --git a/ltt/branches/poly/lttv/modules/gui/API/menu.c b/ltt/branches/poly/lttv/modules/gui/API/menu.c new file mode 100644 index 00000000..e4e0ed8e --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/API/menu.c @@ -0,0 +1,49 @@ +//#include +#include "menu.h" + + +inline LttvMenus *lttv_menus_new() { + return g_array_new(FALSE, FALSE, sizeof(lttv_menu_closure)); +} + +/* MD: delete elements of the array also, but don't free pointed addresses + * (functions). + */ +inline void lttv_menus_destroy(LttvMenus *h) { + g_array_free(h, TRUE); +} + +inline void lttv_menus_add(LttvMenus *h, lttv_constructor f, char* menuPath, char* menuText) +{ + lttv_menu_closure c; + + /* if h is null, do nothing, or popup a warning message */ + if(h == NULL)return; + + c.con = f; + c.menuPath = menuPath; + c.menuText = menuText; + g_array_append_val(h,c); +} + +gboolean lttv_menus_remove(LttvMenus *h, lttv_constructor f) +{ + lttv_menu_closure * tmp; + gint i; + for(i=0;ilen;i++){ + tmp = & g_array_index(h, lttv_menu_closure, i); + if(tmp->con == f)break; + } + if(ilen){ + g_array_remove_index(h, i); + return TRUE; + }else return FALSE; + +} + +unsigned lttv_menus_number(LttvMenus *h) +{ + return h->len; +} + + diff --git a/ltt/branches/poly/lttv/modules/gui/API/menu.h b/ltt/branches/poly/lttv/modules/gui/API/menu.h new file mode 100644 index 00000000..7dbe44f0 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/API/menu.h @@ -0,0 +1,29 @@ +#ifndef MENU_H +#define MENU_H + +#include "common.h" + +/* constructor of the viewer */ +//typedef GtkWidget* (*lttv_constructor)(void * main_window); + + +typedef GArray LttvMenus; + +typedef struct _lttv_menu_closure { + lttv_constructor con; + char * menuPath; + char * menuText; +} lttv_menu_closure; + + +LttvMenus *lttv_menus_new(); + +void lttv_menus_destroy(LttvMenus *h); + +void lttv_menus_add(LttvMenus *h, lttv_constructor f, char* menuPath, char * menuText); + +gboolean lttv_menus_remove(LttvMenus *h, lttv_constructor f); + +unsigned lttv_menus_number(LttvMenus *h); + +#endif // MENU_H diff --git a/ltt/branches/poly/lttv/modules/gui/API/toolbar.c b/ltt/branches/poly/lttv/modules/gui/API/toolbar.c new file mode 100644 index 00000000..263e5c04 --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/API/toolbar.c @@ -0,0 +1,48 @@ +//#include +#include "toolbar.h" + + +inline LttvToolbars *lttv_toolbars_new() { + return g_array_new(FALSE, FALSE, sizeof(lttv_toolbar_closure)); +} + +/* MD: delete elements of the array also, but don't free pointed addresses + * (functions). + */ +inline void lttv_toolbars_destroy(LttvToolbars *h) { + g_array_free(h, TRUE); +} + +inline void lttv_toolbars_add(LttvToolbars *h, lttv_constructor f, char* tooltip, GdkPixmap * pixmap) +{ + lttv_toolbar_closure c; + + /* if h is null, do nothing, or popup a warning message */ + if(h == NULL)return; + + c.con = f; + c.tooltip = tooltip; + c.pixmap = pixmap; + g_array_append_val(h,c); +} + +gboolean lttv_toolbars_remove(LttvToolbars *h, lttv_constructor f) +{ + lttv_toolbar_closure * tmp; + gint i; + for(i=0;ilen;i++){ + tmp = & g_array_index(h, lttv_toolbar_closure, i); + if(tmp->con == f)break; + } + if(ilen){ + g_array_remove_index(h, i); + return TRUE; + }else return FALSE; +} + +unsigned lttv_toolbars_number(LttvToolbars *h) +{ + return h->len; +} + + diff --git a/ltt/branches/poly/lttv/modules/gui/API/toolbar.h b/ltt/branches/poly/lttv/modules/gui/API/toolbar.h new file mode 100644 index 00000000..0e39107f --- /dev/null +++ b/ltt/branches/poly/lttv/modules/gui/API/toolbar.h @@ -0,0 +1,28 @@ +#ifndef TOOLBAR_H +#define TOOLBAR_H + +#include "common.h" + +/* constructor of the viewer */ +//typedef GtkWidget* (*lttv_constructor)(void * main_window); + + +typedef GArray LttvToolbars; + +typedef struct _lttv_toolbar_closure { + lttv_constructor con; + char * tooltip; + GdkPixmap * pixmap; +} lttv_toolbar_closure; + +LttvToolbars *lttv_toolbars_new(); + +void lttv_toolbars_destroy(LttvToolbars *h); + +void lttv_toolbars_add(LttvToolbars *h, lttv_constructor f, char* tooltip, GdkPixmap * pixmap); + +gboolean lttv_toolbars_remove(LttvToolbars *h, lttv_constructor f); + +unsigned lttv_toolbars_number(LttvToolbars *h); + +#endif // TOOLBAR_H -- 2.34.1