From 93ac601b7487eba4b0733f44117f45fa9dd0baee Mon Sep 17 00:00:00 2001 From: compudj Date: Tue, 13 Sep 2005 21:14:09 +0000 Subject: [PATCH] add some message box git-svn-id: http://ltt.polymtl.ca/svn@1177 04897980-b3bd-0310-b5e0-8ef037075253 --- .../lttv/modules/gui/controlflow/eventhooks.c | 5 +- .../lttv/modules/gui/detailedevents/events.c | 5 +- .../poly/lttv/modules/gui/filter/filter.c | 15 +---- .../gui/lttvwindow/lttvwindow/callbacks.c | 64 ++++++++++++------ .../gui/lttvwindow/lttvwindow/lttvwindow.c | 14 +--- .../gui/lttvwindow/lttvwindow/lttvwindow.h | 13 +--- .../lttvwindow/lttvwindow/lttvwindowtraces.c | 65 ++++++++++++++++++- .../lttvwindow/lttvwindow/lttvwindowtraces.h | 10 +++ .../lttv/modules/gui/statistics/statistics.c | 5 +- 9 files changed, 129 insertions(+), 67 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c index 57453810..05e3f43e 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c @@ -138,9 +138,8 @@ static void request_background_data(ControlFlowData *control_flow_data) * information. Happens when two viewers ask for it before servicing * starts. */ - lttvwindowtraces_background_request_remove(trace, "state"); - lttvwindowtraces_background_request_queue(trace, - "state"); + if(!lttvwindowtraces_background_request_find(trace, "state")) + lttvwindowtraces_background_request_queue(trace, "state"); lttvwindowtraces_background_notify_queue(control_flow_data, trace, ltt_time_infinite, diff --git a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c index 13fa73f8..17502e89 100644 --- a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c +++ b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c @@ -549,9 +549,8 @@ static void request_background_data(EventViewerData *event_viewer_data) * information. Happens when two viewers ask for it before servicing * starts. */ - lttvwindowtraces_background_request_remove(trace, "state"); - lttvwindowtraces_background_request_queue(trace, - "state"); + if(!lttvwindowtraces_background_request_find(trace, "state")) + lttvwindowtraces_background_request_queue(trace, "state"); lttvwindowtraces_background_notify_queue(event_viewer_data, trace, ltt_time_infinite, diff --git a/ltt/branches/poly/lttv/modules/gui/filter/filter.c b/ltt/branches/poly/lttv/modules/gui/filter/filter.c index 29031c22..ac2d5b32 100644 --- a/ltt/branches/poly/lttv/modules/gui/filter/filter.c +++ b/ltt/branches/poly/lttv/modules/gui/filter/filter.c @@ -126,7 +126,6 @@ struct _FilterViewerData { GtkWidget *f_add_button; /**< add expression to current expression (GtkButton) */ - gchar *name; /**< Name of the window in the main window */ }; /** @@ -216,6 +215,9 @@ gui_filter(Tab *tab) fvd->f_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_transient_for(GTK_WINDOW(fvd->f_window), + GTK_WINDOW(main_window_get_widget(tab))); + gtk_window_set_destroy_with_parent(GTK_WINDOW(fvd->f_window), TRUE); /* * Initiating GtkTable layout @@ -434,10 +436,6 @@ gui_filter_destructor(FilterViewerData *fvd) g_filter_list = g_slist_remove(g_filter_list, fvd); - main_window_remove_child_window(tab, fvd->name); - - g_free(fvd->name); - g_free(fvd); } @@ -456,15 +454,8 @@ GtkWidget * h_guifilter(Tab *tab) { FilterViewerData* f = gui_filter(tab) ; - f->name = g_new(gchar, 256); - snprintf(f->name, 256, "guifilter %p", f); - - if(f) - main_window_add_child_window(tab, f, - f->name, (GDestroyNotify)gui_filter_destructor); return NULL; - } /** diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 409df424..a19cde58 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -63,10 +63,13 @@ static char remember_trace_dir[PATH_MAX] = ""; MainWindow * get_window_data_struct(GtkWidget * widget); -char * get_load_module(char ** load_module_name, int nb_module); -char * get_unload_module(char ** loaded_module_name, int nb_module); -char * get_remove_trace(char ** all_trace_name, int nb_trace); -char * get_selection(char ** all_name, int nb, char *title, char * column_title); +char * get_load_module(MainWindow *mw, + char ** load_module_name, int nb_module); +char * get_unload_module(MainWindow *mw, + char ** loaded_module_name, int nb_module); +char * get_remove_trace(MainWindow *mw, char ** all_trace_name, int nb_trace); +char * get_selection(MainWindow *mw, + char ** all_name, int nb, char *title, char * column_title); Tab* create_tab(MainWindow * mw, Tab *copy_tab, GtkNotebook * notebook, char * label); @@ -803,6 +806,9 @@ void open_traceset(GtkWidget * widget, gpointer user_data) gtk_file_selection_hide_fileop_buttons(file_selector); + gtk_window_set_transient_for(GTK_WINDOW(file_selector), + GTK_WINDOW(mw_data->mwindow)); + id = gtk_dialog_run(GTK_DIALOG(file_selector)); switch(id){ case GTK_RESPONSE_ACCEPT: @@ -1701,6 +1707,8 @@ void add_trace(GtkWidget * widget, gpointer user_data) GtkFileSelection * file_selector = (GtkFileSelection *)gtk_file_selection_new("Select a trace"); gtk_widget_hide( (file_selector)->file_list->parent) ; gtk_file_selection_hide_fileop_buttons(file_selector); + gtk_window_set_transient_for(GTK_WINDOW(file_selector), + GTK_WINDOW(mw_data->mwindow)); if(remember_trace_dir[0] != '\0') gtk_file_selection_set_filename(file_selector, remember_trace_dir); @@ -1792,7 +1800,7 @@ void remove_trace(GtkWidget *widget, gpointer user_data) name[i] = g_quark_to_string(ltt_trace_name(trace)); } - remove_trace_name = get_remove_trace(name, nb_trace); + remove_trace_name = get_remove_trace(mw_data, name, nb_trace); if(remove_trace_name){ @@ -2479,7 +2487,8 @@ on_load_library_activate (GtkMenuItem *menuitem, g_ptr_array_add(name, path); } - load_module_path = get_selection((char **)(name->pdata), name->len, + load_module_path = get_selection(mw_data, + (char **)(name->pdata), name->len, "Select a library path", "Library paths"); if(load_module_path != NULL) strncpy(load_module_path_alter, load_module_path, PATH_MAX-1); // -1 for / @@ -2512,6 +2521,9 @@ on_load_library_activate (GtkMenuItem *menuitem, gtk_file_selection_set_filename(file_selector, load_module_path_alter); gtk_file_selection_hide_fileop_buttons(file_selector); + gtk_window_set_transient_for(GTK_WINDOW(file_selector), + GTK_WINDOW(mw_data->mwindow)); + str[0] = '\0'; id = gtk_dialog_run(GTK_DIALOG(file_selector)); switch(id){ @@ -2586,7 +2598,7 @@ on_unload_library_activate (GtkMenuItem *menuitem, gchar *path = lib_info[i].name; g_ptr_array_add(name, path); } - lib_name = get_selection((char **)(name->pdata), name->len, + lib_name = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a library", "Libraries"); if(lib_name != NULL) { for(i=0;ipdata), name->len, + lib_name = get_selection(mw_data,(char **)(name->pdata), name->len, "Select a library", "Libraries"); if(lib_name != NULL) { for(i=0;ipdata), name->len, + module_name = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a module", "Modules"); if(module_name != NULL) { for(i=0;ipdata), name->len, + lib_name = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a library", "Libraries"); if(lib_name != NULL) { for(i=0;i 0) g_ptr_array_add(name, path); } - module_name = get_selection((char **)(name->pdata), name->len, + module_name = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a module", "Modules"); if(module_name != NULL) { for(i=0;ifile_list->parent) ; + + gtk_window_set_transient_for(GTK_WINDOW(file_selector), + GTK_WINDOW(mw_data->mwindow)); + const char * dir; gint id; - MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem); if(remember_plugins_dir[0] != '\0') gtk_file_selection_set_filename(file_selector, remember_plugins_dir); @@ -2895,7 +2911,7 @@ on_remove_library_search_path_activate (GtkMenuItem *menuitem, gchar *path = lttv_library_path_get(i); g_ptr_array_add(name, path); } - lib_path = get_selection((char **)(name->pdata), name->len, + lib_path = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a library path", "Library paths"); g_ptr_array_free(name, TRUE); @@ -3727,9 +3743,10 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, /* Select a trace which will be removed from traceset */ -char * get_remove_trace(char ** all_trace_name, int nb_trace) +char * get_remove_trace(MainWindow *mw_data, + char ** all_trace_name, int nb_trace) { - return get_selection(all_trace_name, nb_trace, + return get_selection(mw_data, all_trace_name, nb_trace, "Select a trace", "Trace pathname"); } @@ -3737,9 +3754,10 @@ char * get_remove_trace(char ** all_trace_name, int nb_trace) /* Select a module which will be loaded */ -char * get_load_module(char ** load_module_name, int nb_module) +char * get_load_module(MainWindow *mw_data, + char ** load_module_name, int nb_module) { - return get_selection(load_module_name, nb_module, + return get_selection(mw_data, load_module_name, nb_module, "Select a module to load", "Module name"); } @@ -3749,9 +3767,10 @@ char * get_load_module(char ** load_module_name, int nb_module) /* Select a module which will be unloaded */ -char * get_unload_module(char ** loaded_module_name, int nb_module) +char * get_unload_module(MainWindow *mw_data, + char ** loaded_module_name, int nb_module) { - return get_selection(loaded_module_name, nb_module, + return get_selection(mw_data, loaded_module_name, nb_module, "Select a module to unload", "Module name"); } @@ -3760,8 +3779,9 @@ char * get_unload_module(char ** loaded_module_name, int nb_module) * select one of them */ -char * get_selection(char ** loaded_module_name, int nb_module, - char *title, char * column_title) +char * get_selection(MainWindow *mw_data, + char ** loaded_module_name, int nb_module, + char *title, char * column_title) { GtkWidget * dialogue; GtkWidget * scroll_win; @@ -3781,6 +3801,8 @@ char * get_selection(char ** loaded_module_name, int nb_module, GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT, NULL); gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200); + gtk_window_set_transient_for(GTK_WINDOW(dialogue), + GTK_WINDOW(mw_data->mwindow)); scroll_win = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show ( scroll_win); diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c index fe67fb70..9814c3d2 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c @@ -1121,19 +1121,9 @@ void events_request_free(EventsRequest *events_request) } -void main_window_add_child_window(Tab *tab, gpointer data, - const gchar *name, GDestroyNotify destroy_fct) -{ - g_object_set_data_full(G_OBJECT(tab->mw->mwindow), - name, - data, - destroy_fct); -} -void main_window_remove_child_window(Tab *tab, - const gchar *name) +GtkWidget *main_window_get_widget(Tab *tab) { - /* Might return NULL if called from the descructor upon main window close */ - g_object_steal_data(G_OBJECT(tab->mw->mwindow), name); + return tab->mw->mwindow; } diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h index 87f186fc..88e7a345 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h @@ -806,17 +806,6 @@ void set_current_time(Tab *tab, const LttTime *current_time); void events_request_free(EventsRequest *events_request); -/* main_window_add_child_window - * - * Add the widget as a data to the main window : it will close a floating window - * with its main window by calling the destroy_fct. - */ - -void main_window_add_child_window(Tab *tab, gpointer data, - const gchar *name, GDestroyNotify descroy_fct); - - -void main_window_remove_child_window(Tab *tab, - const gchar *name); +GtkWidget *main_window_get_widget(Tab *tab); #endif //LTTVWINDOW_H diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c index 511c6c93..c1df4513 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c @@ -45,6 +45,7 @@ typedef struct _BackgroundRequest { where all standard hooks under computation/. i.e. modulename */ LttvTrace *trace; /* trace concerned */ + GtkWidget *dialog; /* Dialog linked with the request, may be NULL */ } BackgroundRequest; typedef struct _BackgroundNotify { @@ -293,6 +294,12 @@ void lttvwindowtraces_remove_trace(LttvTrace *trace) } } +static void destroy_dialog(BackgroundRequest *bg_req) +{ + gtk_widget_destroy(bg_req->dialog); + bg_req->dialog = NULL; +} + /** * Function to request data from a specific trace @@ -349,7 +356,18 @@ void lttvwindowtraces_background_request_queue trace, NULL); /* FIXME : show message in status bar, need context and message id */ - g_info("Background computation started for trace %p", trace); + g_info("Background computation for %s started for trace %p", module_name, + trace); + GtkWidget *dialog = + gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, + "Background computation for %s started for trace %s", + module_name, + g_quark_to_string(ltt_trace_name(lttv_trace(trace)))); + g_signal_connect_swapped (dialog, "response", + G_CALLBACK (destroy_dialog), + bg_req); + bg_req->dialog = dialog; + gtk_widget_show(dialog); } /** @@ -398,6 +416,37 @@ void lttvwindowtraces_background_request_remove } } +/** + * Find a background request in a trace + * + */ + +gboolean lttvwindowtraces_background_request_find + (LttvTrace *trace, gchar *module_name) +{ + LttvAttribute *attribute = lttv_trace_attribute(trace); + LttvAttributeValue value; + GSList *iter = NULL; + GSList **slist; + + g_assert(lttv_iattribute_find(LTTV_IATTRIBUTE(attribute), + LTTV_REQUESTS_QUEUE, + LTTV_POINTER, + &value)); + slist = (GSList**)(value.v_pointer); + + for(iter=*slist;iter!=NULL;) { + BackgroundRequest *bg_req = + (BackgroundRequest *)iter->data; + + if(bg_req->module_name == g_quark_from_string(module_name)) { + return TRUE; + } else { + iter=g_slist_next(iter); + } + } + return FALSE; +} /** * Register a callback to be called when requested data is passed in the next @@ -1245,6 +1294,19 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) LttvHooks *after_request = (LttvHooks*)*(value.v_pointer); if(after_request != NULL) lttv_hooks_call(after_request, tsc); + + if(bg_req->dialog != NULL) + gtk_widget_destroy(bg_req->dialog); + GtkWidget *dialog = + gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, + "Background computation %s finished for trace %s", + g_quark_to_string(bg_req->module_name), + g_quark_to_string(ltt_trace_name(lttv_trace(bg_req->trace)))); + g_signal_connect_swapped (dialog, "response", + G_CALLBACK (gtk_widget_destroy), + dialog); + gtk_widget_show(dialog); + /* - remove request */ remove = TRUE; free_data = TRUE; @@ -1303,6 +1365,7 @@ gboolean lttvwindowtraces_process_pending_requests(LttvTrace *trace) g_debug("Background computation scheduler stopped"); g_info("Background computation finished for trace %p", trace); /* FIXME : remove status bar info, need context id and message id */ + ret_val = FALSE; } else { ret_val = TRUE; diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.h index 8de3ba35..1d21a577 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.h @@ -159,6 +159,16 @@ void lttvwindowtraces_background_request_queue void lttvwindowtraces_background_request_remove (LttvTrace *trace, gchar *module_name); + + +/** + * Find a background request in a trace + * + */ + +gboolean lttvwindowtraces_background_request_find + (LttvTrace *trace, gchar *module_name); + /** * Register a callback to be called when requested data is passed in the next * queued background processing. diff --git a/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c b/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c index 4ebda1b6..87a3e762 100644 --- a/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c +++ b/ltt/branches/poly/lttv/modules/gui/statistics/statistics.c @@ -168,9 +168,8 @@ static void request_background_data(StatisticViewerData *svd) * information. Happens when two viewers ask for it before servicing * starts. */ - lttvwindowtraces_background_request_remove(trace, "stats"); - lttvwindowtraces_background_request_queue(trace, - "stats"); + if(!lttvwindowtraces_background_request_find(trace, "stats")) + lttvwindowtraces_background_request_queue(trace, "stats"); lttvwindowtraces_background_notify_queue(svd, trace, ltt_time_infinite, -- 2.34.1