From 36b3c068721ec15aae394e65e5fc50ac4ec26358 Mon Sep 17 00:00:00 2001 From: yangxx Date: Fri, 10 Oct 2003 14:46:26 +0000 Subject: [PATCH] Plugins Menu functions completed git-svn-id: http://ltt.polymtl.ca/svn@295 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/include/lttv/mainWindow.h | 7 +- ltt/branches/poly/include/lttv/module.h | 1 + ltt/branches/poly/lttv/module.c | 5 + .../lttv/modules/gui/mainWin/src/callbacks.c | 129 +++++++++++++++++- .../modules/gui/mainWin/src/init_module.c | 9 +- 5 files changed, 141 insertions(+), 10 deletions(-) diff --git a/ltt/branches/poly/include/lttv/mainWindow.h b/ltt/branches/poly/include/lttv/mainWindow.h index ac5e9895..c0213e8d 100644 --- a/ltt/branches/poly/include/lttv/mainWindow.h +++ b/ltt/branches/poly/include/lttv/mainWindow.h @@ -11,6 +11,10 @@ #include #include +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; }; diff --git a/ltt/branches/poly/include/lttv/module.h b/ltt/branches/poly/include/lttv/module.h index 2649902c..47f4d16b 100644 --- a/ltt/branches/poly/include/lttv/module.h +++ b/ltt/branches/poly/include/lttv/module.h @@ -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 diff --git a/ltt/branches/poly/lttv/module.c b/ltt/branches/poly/lttv/module.c index f73e6e93..7640f865 100644 --- a/ltt/branches/poly/lttv/module.c +++ b/ltt/branches/poly/lttv/module.c @@ -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) 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 5e292993..17050b3f 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/callbacks.c @@ -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;iCurrentTab = 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;iwinCreationData = Window_Creation_Data; /* Add the object's information to the module's array */ Main_Window_List = g_slist_append(Main_Window_List, mw); -- 2.34.1