Plugins Menu functions completed
authoryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 10 Oct 2003 14:46:26 +0000 (14:46 +0000)
committeryangxx <yangxx@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 10 Oct 2003 14:46:26 +0000 (14:46 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@295 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/include/lttv/mainWindow.h
ltt/branches/poly/include/lttv/module.h
ltt/branches/poly/lttv/module.c
ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c
ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c

index ac5e98951ef5aaead5bcb0697f98a13f014778a3..c0213e8dfef3c62b49dbdf53b23699dc083ef0ea 100644 (file)
 #include <lttv/common.h>
 #include <lttv/gtkcustom.h>
 
+typedef struct _WindowCreationData {
+       int argc;
+       char ** argv;
+} WindowCreationData;
 
 struct _mainWindow{
   GtkWidget*      MWindow;            /* Main Window */
@@ -37,7 +41,8 @@ struct _mainWindow{
   tab * Tab;
   tab * CurrentTab;
   LttvIAttribute * Attributes;
+
+  WindowCreationData * winCreationData; 
 };
 
 
index 2649902c606d3f88b6bb212015c0472785b9ade1..47f4d16bac8090b31b756a75a796e982ffcfa6b6 100644 (file)
@@ -66,4 +66,5 @@ LttvModule **lttv_module_list(guint *nb);
 LttvModule **lttv_module_info(LttvModule *m, const char **name, 
     guint *ref_count, guint *load_count, guint *nb_dependents);
 
+char * lttv_module_name(LttvModule *m);
 #endif // MODULES_H
index f73e6e935c367e796edb293886ecbf3bc6b3426a..7640f8655be263c6d23edcd5067597b431793128 100644 (file)
@@ -266,6 +266,11 @@ lttv_module_info(LttvModule *m, const char **name,
   return array;
 }
 
+char * 
+lttv_module_name(LttvModule *m)
+{
+  return g_module_name(m->module);
+}
 
 static void
 list_independent(gpointer key, gpointer value, gpointer user_data)
index 5e292993573e8eb5f8e766f0294640e89b084fdb..17050b3f59d95ac2f19e1b3754b4aaaa492d0779 100644 (file)
@@ -24,10 +24,17 @@ extern LttvTracesetContext * gTracesetContext;
 extern GSList * Main_Window_List;
 
 mainWindow * get_window_data_struct(GtkWidget * widget);
+char * get_unload_module(char ** loaded_module_name, int nb_module);
 
 /* test part */
 void insertView(GtkWidget* widget, view_constructor constructor);
 
+enum
+{
+  MODULE_COLUMN,
+  N_COLUMNS
+};
+
 void
 on_textview1_grab_focus                     (GtkTextView     *text_view,
                                          gpointer         user_data)
@@ -593,7 +600,32 @@ void
 on_load_module_activate                (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-  g_printf("Load module\n");
+  char ** dir;
+  gint id;
+  char str[PATH_LENGTH];
+  mainWindow * mwData = get_window_data_struct((GtkWidget*)menuitem);
+  GtkFileSelection * fileSelector = (GtkFileSelection *)gtk_file_selection_new("Select a module");
+  gtk_file_selection_hide_fileop_buttons(fileSelector);
+  
+  str[0] = '\0';
+  id = gtk_dialog_run(GTK_DIALOG(fileSelector));
+  switch(id){
+    case GTK_RESPONSE_ACCEPT:
+    case GTK_RESPONSE_OK:
+      dir = gtk_file_selection_get_selections (fileSelector);
+      sprintf(str,dir[0]);
+      if(mwData->winCreationData)
+       lttv_module_load(str, mwData->winCreationData->argc,mwData->winCreationData->argv);
+      else
+       lttv_module_load(str, 0,NULL);
+      g_strfreev(dir);
+    case GTK_RESPONSE_REJECT:
+    case GTK_RESPONSE_CANCEL:
+    default:
+      gtk_widget_destroy((GtkWidget*)fileSelector);
+      break;
+  }
+  g_printf("Load module: %s\n", str);
 }
 
 
@@ -601,7 +633,31 @@ void
 on_unload_module_activate              (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-  g_printf("Unload module\n");
+  int i;
+  char **name, *unload_module_name;
+  guint nb;
+  LttvModule ** modules, *module;
+  mainWindow * mwData = get_window_data_struct((GtkWidget*)menuitem);
+  
+  modules = lttv_module_list(&nb);
+  name  = g_new(char*, nb);
+  for(i=0;i<nb;i++){
+    module = modules[i];
+    name[i] = lttv_module_name(module);
+  }
+
+  unload_module_name =get_unload_module(name,nb);
+  
+  if(unload_module_name){
+    for(i=0;i<nb;i++){
+      if(strcmp(unload_module_name, name[i]) == 0){
+       lttv_module_unload(modules[i]);
+       break;
+      }
+    }    
+  }
+
+  g_free(name);
 }
 
 
@@ -613,7 +669,6 @@ on_add_module_search_path_activate     (GtkMenuItem     *menuitem,
   char * dir;
   gint id;
 
-  gchar  str[PATH_LENGTH];
   mainWindow * mwData = get_window_data_struct((GtkWidget*)menuitem);
 
   id = gtk_dialog_run(GTK_DIALOG(fileSelector));
@@ -815,3 +870,71 @@ on_MNotebook_switch_page               (GtkNotebook     *notebook,
   mw->CurrentTab = Tab;
 }
 
+char * get_unload_module(char ** loaded_module_name, int nb_module)
+{
+  GtkWidget         * dialogue;
+  GtkWidget         * scroll_win;
+  GtkWidget         * tree;
+  GtkListStore      * store;
+  GtkTreeViewColumn * column;
+  GtkCellRenderer   * renderer;
+  GtkTreeSelection  * select;
+  GtkTreeIter         iter;
+  gint                id, i;
+  char              * unload_module_name = NULL;
+
+  dialogue = gtk_dialog_new_with_buttons("Select an unload module",
+                                        NULL,
+                                        GTK_DIALOG_MODAL,
+                                        GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
+                                        GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
+                                        NULL); 
+  gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200);
+
+  scroll_win = gtk_scrolled_window_new (NULL, NULL);
+  gtk_widget_show ( scroll_win);
+  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), 
+                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+  store = gtk_list_store_new (N_COLUMNS,G_TYPE_STRING);
+  tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL (store));
+  gtk_widget_show ( tree);
+  g_object_unref (G_OBJECT (store));
+               
+  renderer = gtk_cell_renderer_text_new ();
+  column   = gtk_tree_view_column_new_with_attributes ("MODULE NAME",
+                                                    renderer,
+                                                    "text", MODULE_COLUMN,
+                                                    NULL);
+  gtk_tree_view_column_set_alignment (column, 0.5);
+  gtk_tree_view_column_set_fixed_width (column, 150);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+
+  select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
+  gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
+
+  gtk_container_add (GTK_CONTAINER (scroll_win), tree);  
+
+  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), scroll_win,TRUE, TRUE,0);
+
+  for(i=0;i<nb_module;i++){
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, MODULE_COLUMN,loaded_module_name[i],-1);
+  }
+
+  id = gtk_dialog_run(GTK_DIALOG(dialogue));
+  switch(id){
+    case GTK_RESPONSE_ACCEPT:
+    case GTK_RESPONSE_OK:
+      if (gtk_tree_selection_get_selected (select, (GtkTreeModel**)&store, &iter)){
+         gtk_tree_model_get ((GtkTreeModel*)store, &iter, MODULE_COLUMN, &unload_module_name, -1);
+      }
+    case GTK_RESPONSE_REJECT:
+    case GTK_RESPONSE_CANCEL:
+    default:
+      gtk_widget_destroy(dialogue);
+      break;
+  }
+
+  return unload_module_name;
+}
index 4e55042deb80ae30168ed662542b402bcc19e25f..a2d74a317d1f7bf1c2941c28c941beaa3d769334 100644 (file)
@@ -65,11 +65,6 @@ void lttv_trace_option(void *hook_data)
  * This function initializes the GUI.
  */
 
-typedef struct _WindowCreationData {
-       int argc;
-       char ** argv;
-} WindowCreationData;
-
 static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
 {
   int i;
@@ -86,7 +81,9 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
   GtkWidget *window1;
   mainWindow * mw = g_new(mainWindow, 1);
   gSysView = g_new(systemView, 1);
-  WindowCreationData *Window_Creation_Data = (WindowCreationData*)call_data;
+  WindowCreationData *Window_Creation_Data = (WindowCreationData*)hook_data;
+
+  mw->winCreationData = Window_Creation_Data;
 
   /* Add the object's information to the module's array */
   Main_Window_List = g_slist_append(Main_Window_List, mw);
This page took 0.034134 seconds and 4 git commands to generate.