From: yangxx Date: Wed, 3 Sep 2003 16:38:23 +0000 (+0000) Subject: working version of guiEvents modules X-Git-Tag: v0.12.20~3272 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=37d0eca6ca06648a9330f31d5b632e65da90d646;p=lttv.git working version of guiEvents modules git-svn-id: http://ltt.polymtl.ca/svn@217 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c index d0f75471..65ef18b7 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c @@ -9,14 +9,11 @@ #include "interface.h" #include "support.h" #include - +#include +#include extern systemView * gSysView; -typedef void (*call_Event_Selected_Hook)(void * call_data); -extern call_Event_Selected_Hook selected_hook; -extern view_constructor gConstructor; - mainWindow * get_window_data_struct(GtkWidget * widget); /* test part */ @@ -37,8 +34,8 @@ void insertViewTest(GtkMenuItem *menuitem, gpointer user_data) { guint val = 20; - insertView((GtkWidget*)menuitem, gConstructor); - selected_hook(&val); + insertView((GtkWidget*)menuitem, (view_constructor)user_data); + // selected_hook(&val); } void @@ -164,7 +161,16 @@ void createNewWindow(GtkWidget* widget, gpointer user_data, gboolean clone) mainWindow * newMWindow;/* New main window structure */ //test - GtkWidget * ToolMenuTitle_menu, *insert_view; + int i; + GtkWidget * ToolMenuTitle_menu, *insert_view, *pixmap; + LttvMenus * menu; + LttvToolbars * toolbar; + lttv_menu_closure *menuItem; + lttv_toolbar_closure *toolbarItem; + LttvAttributeValue value; + LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); + view_constructor constructor; + GdkPixbuf *pixbuf; //end mw = lookup_widget (widget, "MWindow"); @@ -201,13 +207,46 @@ void createNewWindow(GtkWidget* widget, gpointer user_data, gboolean clone) // newMWindow->Attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); //test yxx - ToolMenuTitle_menu = lookup_widget(newMWindow->MWindow,"ToolMenuTitle_menu"); - insert_view = gtk_menu_item_new_with_mnemonic ("insert_view"); - gtk_widget_show (insert_view); - gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_view); - g_signal_connect ((gpointer) insert_view, "activate", - G_CALLBACK (insertViewTest), - NULL); + g_assert(lttv_iattribute_find_by_path(attributes, + "viewers/menu", LTTV_POINTER, &value)); + menu = (LttvMenus*)*(value.v_pointer); + + if(menu){ + for(i=0;ilen;i++){ + menuItem = &g_array_index(menu, lttv_menu_closure, i); + constructor = menuItem->con; + ToolMenuTitle_menu = lookup_widget(newMWindow->MWindow,"ToolMenuTitle_menu"); + insert_view = gtk_menu_item_new_with_mnemonic (menuItem->menuText); + gtk_widget_show (insert_view); + gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_view); + g_signal_connect ((gpointer) insert_view, "activate", + G_CALLBACK (insertViewTest), + constructor); + } + } + g_assert(lttv_iattribute_find_by_path(attributes, + "viewers/toolbar", LTTV_POINTER, &value)); + toolbar = (LttvToolbars*)*(value.v_pointer); + + if(toolbar){ + for(i=0;ilen;i++){ + toolbarItem = &g_array_index(toolbar, lttv_toolbar_closure, i); + constructor = toolbarItem->con; + ToolMenuTitle_menu = lookup_widget(newMWindow->MWindow,"MToolbar2"); + pixbuf = gdk_pixbuf_new_from_xpm_data ((const char**)toolbarItem->pixmap); + pixmap = gtk_image_new_from_pixbuf(pixbuf); + insert_view = gtk_toolbar_append_element (GTK_TOOLBAR (ToolMenuTitle_menu), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + "", + toolbarItem->tooltip, NULL, + pixmap, NULL, NULL); + gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (ToolMenuTitle_menu)->children)->data))->label), TRUE); + gtk_widget_show (insert_view); + gtk_container_set_border_width (GTK_CONTAINER (insert_view), 1); + g_signal_connect ((gpointer) insert_view, "clicked",G_CALLBACK (insertViewTest),constructor); + } + } //end g_object_set_data(G_OBJECT(newWindow), "systemView", (gpointer)newSv); diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c index 1aa9c19d..8ab4f5a3 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c @@ -14,7 +14,8 @@ #include #include #include - +#include +#include #include "interface.h" #include "support.h" @@ -24,14 +25,6 @@ /* global variable */ systemView * gSysView; -typedef view_constructor (* constructor)(); -constructor get_constructor = NULL; -typedef void (*call_Event_Selected_Hook)(void * call_data); -call_Event_Selected_Hook selected_hook = NULL; -GModule *gm; -view_constructor gConstructor = NULL; - - static LttvHooks *main_hooks; @@ -53,8 +46,17 @@ typedef struct _WindowCreationData { static gboolean Window_Creation_Hook(void *hook_data, void *call_data) { + int i; + GdkPixbuf *pixbuf; + view_constructor constructor; + LttvMenus * menu; + LttvToolbars * toolbar; + lttv_menu_closure *menuItem; + lttv_toolbar_closure *toolbarItem; + LttvAttributeValue value; + LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); GModule *gm; - GtkWidget * ToolMenuTitle_menu, *insert_view; + GtkWidget * ToolMenuTitle_menu, *insert_view, *pixmap; GtkWidget *window1; mainWindow * mw = g_new(mainWindow, 1); gSysView = g_new(systemView, 1); @@ -89,24 +91,48 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data) // mw->Attributes = lttv_attributes_new(); //test + g_assert(lttv_iattribute_find_by_path(attributes, + "viewers/menu", LTTV_POINTER, &value)); + menu = (LttvMenus*)*(value.v_pointer); + + if(menu){ + for(i=0;ilen;i++){ + menuItem = &g_array_index(menu, lttv_menu_closure, i); + constructor = menuItem->con; + ToolMenuTitle_menu = lookup_widget(mw->MWindow,"ToolMenuTitle_menu"); + insert_view = gtk_menu_item_new_with_mnemonic (menuItem->menuText); + gtk_widget_show (insert_view); + gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_view); + g_signal_connect ((gpointer) insert_view, "activate", + G_CALLBACK (insertViewTest), + constructor); + } + } + + g_assert(lttv_iattribute_find_by_path(attributes, + "viewers/toolbar", LTTV_POINTER, &value)); + toolbar = (LttvToolbars*)*(value.v_pointer); + + if(toolbar){ + for(i=0;ilen;i++){ + toolbarItem = &g_array_index(toolbar, lttv_toolbar_closure, i); + constructor = toolbarItem->con; + ToolMenuTitle_menu = lookup_widget(mw->MWindow,"MToolbar2"); + pixbuf = gdk_pixbuf_new_from_xpm_data ((const char**)toolbarItem->pixmap); + pixmap = gtk_image_new_from_pixbuf(pixbuf); + insert_view = gtk_toolbar_append_element (GTK_TOOLBAR (ToolMenuTitle_menu), + GTK_TOOLBAR_CHILD_BUTTON, + NULL, + "", + toolbarItem->tooltip, NULL, + pixmap, NULL, NULL); + gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (ToolMenuTitle_menu)->children)->data))->label), TRUE); + gtk_widget_show (insert_view); + gtk_container_set_border_width (GTK_CONTAINER (insert_view), 1); + g_signal_connect ((gpointer) insert_view, "clicked",G_CALLBACK (insertViewTest),constructor); + } + } - gm = g_module_open("/home1/yangxx/poly/lttv/modules/libguiEvents.la",0); - printf("Main : the address of gm : %d\n", gm); - if(!g_module_symbol(gm, "get_constructor", (gpointer)&get_constructor)){ - g_error("can not get constructor\n"); - } - if(!g_module_symbol(gm, "call_Event_Selected_Hook", (gpointer)&selected_hook)){ - g_error("can not get selected hook\n"); - } - - gConstructor = get_constructor(); - ToolMenuTitle_menu = lookup_widget(mw->MWindow,"ToolMenuTitle_menu"); - insert_view = gtk_menu_item_new_with_mnemonic ("insert_view"); - gtk_widget_show (insert_view); - gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_view); - g_signal_connect ((gpointer) insert_view, "activate", - G_CALLBACK (insertViewTest), - NULL); //end gSysView->EventDB = NULL; @@ -175,9 +201,8 @@ G_MODULE_EXPORT void destroy() { lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(lttv_global_attributes()), "/hooks/main/before", LTTV_POINTER, &value); - Window_Creation_Data = lttv_hooks_remove(*(value.v_pointer), - Window_Creation_Hook); - + // Window_Creation_Data = lttv_hooks_remove(*(value.v_pointer), Window_Creation_Hook); + g_free(Window_Creation_Data); diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c index de974b48..87e7c269 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c @@ -520,7 +520,7 @@ create_MWindow (void) MToolbar2 = gtk_toolbar_new (); gtk_widget_show (MToolbar2); gtk_box_pack_start (GTK_BOX (MVbox), MToolbar2, FALSE, FALSE, 0); - gtk_toolbar_set_style (GTK_TOOLBAR (MToolbar2), GTK_TOOLBAR_BOTH); + gtk_toolbar_set_style (GTK_TOOLBAR (MToolbar2), GTK_TOOLBAR_ICONS); MNotebook = gtk_notebook_new (); gtk_widget_show (MNotebook);