add some message box
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 13 Sep 2005 21:14:09 +0000 (21:14 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 13 Sep 2005 21:14:09 +0000 (21:14 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1177 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c
ltt/branches/poly/lttv/modules/gui/detailedevents/events.c
ltt/branches/poly/lttv/modules/gui/filter/filter.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindowtraces.h
ltt/branches/poly/lttv/modules/gui/statistics/statistics.c

index 574538100d4218283874037a504ec43b05a8fa6c..05e3f43e7f88836b24a3d8efc6bc54e46ef42b3a 100644 (file)
@@ -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,
index 13fa73f8d947d88d32a105e29f5bfb57b5859006..17502e89563cd130507c6e50c2df63952a5ad923 100644 (file)
@@ -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,
index 29031c22cf384f94d33a2ca587eef7cefe055ea1..ac2d5b328cff31b690d4b2126df0f4ead3f3d4c7 100644 (file)
@@ -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;
-  
 }
 
 /**
index 409df4245f10fb8fd5281458794e61329dcb77b7..a19cde58bd9bfdaa3cb3867128ae5879b3f0cbc7 100644 (file)
@@ -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;i<nb;i++){
@@ -2633,7 +2645,7 @@ on_load_module_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;i<nb;i++){
@@ -2668,7 +2680,7 @@ on_load_module_activate                (GtkMenuItem     *menuitem,
       gchar *path = module_info[i].name;
       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;i<nb;i++){
@@ -2780,7 +2792,7 @@ on_unload_module_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;i<nb;i++){
@@ -2814,7 +2826,7 @@ on_unload_module_activate              (GtkMenuItem     *menuitem,
       gchar *path = module_info[i].name;
       if(module_info[i].use_count > 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;i<nb;i++){
@@ -2846,13 +2858,17 @@ void
 on_add_library_search_path_activate     (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
+  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
   //GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select library path");
   GtkFileSelection * file_selector = (GtkFileSelection *)gtk_file_selection_new("Select a trace");
   gtk_widget_hide( (file_selector)->file_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);
index fe67fb70cff71b0cbce669c2f1e6d09040b8dee6..9814c3d232c9fe1dd0c5666c2eae509cf4fdbf44 100644 (file)
@@ -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;
 }
 
index 87f186fc6cd39847476d1cc56d74d3ca24dc8ef2..88e7a34586a4c9a2fb3ffa89c3dd2ef74ed70e53 100644 (file)
@@ -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
index 511c6c93a618413e8f480becd987be6bf34f6390..c1df4513c5816753138439679b7f1f08dcbe390c 100644 (file)
@@ -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;
index 8de3ba357694bedbe8db68dd5b6c4028494b14b7..1d21a577fd789a1fea9df963c2b78d713533728b 100644 (file)
@@ -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.
index 4ebda1b6776eae253ffe59e1beb998a0fc810942..87a3e762f74f22fa2736e0eb4efcf86e0fcf451c 100644 (file)
@@ -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,
This page took 0.032669 seconds and 4 git commands to generate.