working version of guiEvents modules
authoryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 3 Sep 2003 16:38:23 +0000 (16:38 +0000)
committeryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 3 Sep 2003 16:38:23 +0000 (16:38 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@217 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c
ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c
ltt/branches/poly/lttv/modules/gui/mainWin/src/interface.c

index d0f75471665ef8e152d400cd428e97b99c9fd1fd..65ef18b7bee81a932a1a868d193489c0a6c3c4e6 100644 (file)
@@ -9,14 +9,11 @@
 #include "interface.h"
 #include "support.h"
 #include <lttv/mainWindow.h>
-
+#include <lttv/menu.h>
+#include <lttv/toolbar.h>
 
 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;i<menu->len;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;i<toolbar->len;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);    
index 1aa9c19df9784aa6348a8abfc3944e80b9c668e0..8ab4f5a30f56bae05ec00314188bbd7f16e8ccbf 100644 (file)
@@ -14,7 +14,8 @@
 #include <lttv/hook.h>
 #include <lttv/option.h>
 #include <lttv/module.h>
-
+#include <lttv/menu.h>
+#include <lttv/toolbar.h>
 
 #include "interface.h"
 #include "support.h"
 /* 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;i<menu->len;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;i<toolbar->len;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);
 
 
index de974b4812043743682fef362706fcbe54bba63f..87e7c269cae19235ff5146f8a82cef35eae0d25b 100644 (file)
@@ -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);
This page took 0.028448 seconds and 4 git commands to generate.