don't show pref panel if not available
authorJulien Desfossez <julien.desfossez@efficios.com>
Thu, 19 Apr 2012 21:30:23 +0000 (17:30 -0400)
committerJulien Desfossez <julien.desfossez@efficios.com>
Thu, 19 Apr 2012 21:30:23 +0000 (17:30 -0400)
Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com>
src/cursesdisplay.c

index 2c6ee4e0243f21702c93fa69c995d63acaead16e..9821fb40677930e4681aaabd8368735868687633 100644 (file)
@@ -743,9 +743,13 @@ void update_current_view()
        sem_post(&update_display_sem);
 }
 
-void setup_pref_panel()
+void update_perf_panel(int line_selected, int toggle_view, int toggle_sort)
 {
+       int i;
+       struct perfcounter *perf;
+       GList *perflist;
        int size;
+
        if (!data)
                return;
        if (pref_panel_window) {
@@ -753,20 +757,11 @@ void setup_pref_panel()
                delwin(pref_panel_window);
        }
        size = g_hash_table_size(global_perf_liszt);
+
        pref_panel_window = create_window(size + 2, 30, 10, 10);
        pref_panel = new_panel(pref_panel_window);
        pref_panel_visible = 0;
        hide_panel(pref_panel);
-}
-
-void update_perf_panel(int line_selected, int toggle_view, int toggle_sort)
-{
-       int i;
-       struct perfcounter *perf;
-       GList *perflist;
-
-       if (!data)
-               return;
 
        werase(pref_panel_window);
        box(pref_panel_window, 0 , 0);
@@ -817,25 +812,33 @@ void update_perf_panel(int line_selected, int toggle_view, int toggle_sort)
        doupdate();
 }
 
-void update_preference_panel(int line_selected, int toggle_view, int toggle_sort)
+int update_preference_panel(int line_selected, int toggle_view, int toggle_sort)
 {
+       int ret = 0;
+
        switch(current_view) {
                case perf:
                        update_perf_panel(line_selected, toggle_view, toggle_sort);
                        break;
                default:
+                       ret = -1;
                        break;
        }
+
+       return ret;
 }
 
 void toggle_pref_panel(void)
 {
+       int ret;
+
        if (pref_panel_visible) {
                hide_panel(pref_panel);
                pref_panel_visible = 0;
        } else {
-               setup_pref_panel();
-               update_preference_panel(perf_line_selected, 0, 0);
+               ret = update_preference_panel(perf_line_selected, 0, 0);
+               if (ret < 0)
+                       return;
                show_panel(pref_panel);
                pref_panel_visible = 1;
        }
@@ -1037,7 +1040,6 @@ void init_ncurses()
        print_log("Starting display");
 
        main_panel = new_panel(center);
-       setup_pref_panel();
 
        current_view = cpu;
 
This page took 0.032326 seconds and 4 git commands to generate.