tabular radar tab
authorAndy Spencer <andy753421@gmail.com>
Sun, 17 May 2009 02:28:54 +0000 (02:28 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 17 May 2009 02:28:54 +0000 (02:28 +0000)
HACKING
src/aweather-gui.c
src/plugin-radar.c

diff --git a/HACKING b/HACKING
index 25a2add..94e5c6c 100644 (file)
--- a/HACKING
+++ b/HACKING
@@ -5,7 +5,6 @@ Road plan
   * Asynchronous IO and data loading
   * Pre-load textures and polys in OpenGL
   * GObject integration (plugin object/interface)
-  * `Refresh button' (pull new level 2 data)
 
 0.x - Volume scans
   * Display iso surfaces of volume scans
index 555a9c2..081b877 100644 (file)
 /*************
  * callbacks *
  *************/
-gboolean on_window_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
+gboolean on_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *gui)
 {
+       g_message("key_press: key=%x, state=%x", event->keyval, event->state);
+       AWeatherView *view = aweather_gui_get_view(gui);
        if (event->keyval == GDK_q)
                gtk_main_quit();
+       else if (event->keyval == GDK_r && event->state & GDK_CONTROL_MASK)
+               aweather_view_refresh(view);
+       else if (event->keyval == GDK_plus)
+               aweather_view_zoomin(view);
+       else if (event->keyval == GDK_minus)
+               aweather_view_zoomout(view);
+       else if (event->keyval == GDK_Tab || event->keyval == GDK_ISO_Left_Tab) {
+               GtkNotebook *tabs = GTK_NOTEBOOK(aweather_gui_get_widget(gui, "tabs"));
+               gint num_tabs = gtk_notebook_get_n_pages(tabs);
+               gint cur_tab  = gtk_notebook_get_current_page(tabs);
+               if (event->state & GDK_SHIFT_MASK)
+                       gtk_notebook_set_current_page(tabs, (cur_tab-1)%num_tabs);
+               else 
+                       gtk_notebook_set_current_page(tabs, (cur_tab+1)%num_tabs);
+       }
        return TRUE;
 }
 
@@ -80,9 +97,9 @@ void on_time_changed(GtkTreeView *view, GtkTreePath *path,
        g_free(time);
 }
 
-static gboolean on_map(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
+gboolean on_map(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
 {
-       //g_message("map:map");
+       g_message("on_map");
        AWeatherView *view = aweather_gui_get_view(gui);
        aweather_view_set_location(view, "IND");
 
@@ -106,8 +123,9 @@ static gboolean on_map(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui
        return FALSE;
 }
 
-static gboolean on_configure(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
+gboolean on_configure(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
 {
+       //g_message("on_confiure");
        aweather_gui_gl_begin(gui);
 
        double width  = da->allocation.width;
@@ -134,12 +152,13 @@ static gboolean on_configure(GtkWidget *da, GdkEventConfigure *event, AWeatherGu
        return FALSE;
 }
 
-static gboolean on_expose_begin(GtkWidget *da, GdkEventExpose *event, AWeatherGui *gui)
+gboolean on_expose_begin(GtkWidget *da, GdkEventExpose *event, AWeatherGui *gui)
 {
+       g_message("aweather:espose_begin");
        aweather_gui_gl_begin(gui);
        return FALSE;
 }
-static gboolean on_expose_end(GtkWidget *da, GdkEventExpose *event, AWeatherGui *gui)
+gboolean on_expose_end(GtkWidget *da, GdkEventExpose *event, AWeatherGui *gui)
 {
        g_message("aweather:espose_end\n");
        aweather_gui_gl_end(gui);
@@ -235,7 +254,6 @@ static void site_setup(AWeatherGui *gui)
        g_object_unref(renderer);
        g_object_unref(store);
 
-       g_signal_connect(combo, "changed", G_CALLBACK(on_site_changed),  gui);
        AWeatherView *aview = aweather_gui_get_view(gui);
        g_signal_connect(aview, "location-changed", G_CALLBACK(update_location_widget), gui);
 }
@@ -251,7 +269,6 @@ static void time_setup(AWeatherGui *gui)
                                        "Time", rend, "text", 0, NULL);
        gtk_tree_view_append_column(tview, col);
 
-       g_signal_connect(tview, "row-activated", G_CALLBACK(on_time_changed), gui);
        AWeatherView *aview = aweather_gui_get_view(gui);
        g_signal_connect(aview, "time-changed", G_CALLBACK(update_time_widget), gui);
 }
@@ -276,16 +293,6 @@ static void opengl_setup(AWeatherGui *gui)
        g_signal_connect_after(drawing, "expose-event",    G_CALLBACK(on_expose_end),   gui);
 }
 
-static void toolbar_setup(AWeatherGui *gui)
-{
-       GtkWidget *refresh = aweather_gui_get_widget(gui, "refresh_button");
-       GtkWidget *zoomin  = aweather_gui_get_widget(gui, "zoomin_button");
-       GtkWidget *zoomout = aweather_gui_get_widget(gui, "zoomout_button");
-       g_signal_connect(refresh, "clicked", G_CALLBACK(on_refresh), gui);
-       g_signal_connect(zoomin,  "clicked", G_CALLBACK(on_zoomin ), gui);
-       g_signal_connect(zoomout, "clicked", G_CALLBACK(on_zoomout), gui);
-}
-
 
 /****************
  * GObject code *
@@ -348,10 +355,9 @@ AWeatherGui *aweather_gui_new()
        gui->window  = GTK_WINDOW      (gtk_builder_get_object(gui->builder, "window"));
        gui->tabs    = GTK_NOTEBOOK    (gtk_builder_get_object(gui->builder, "tabs")); 
        gui->drawing = GTK_DRAWING_AREA(gtk_builder_get_object(gui->builder, "drawing"));
-       gtk_builder_connect_signals(gui->builder, NULL);
+       gtk_builder_connect_signals(gui->builder, gui);
 
        /* Load components */
-       toolbar_setup(gui);
        site_setup(gui);
        time_setup(gui);
        opengl_setup(gui);
index 4d75c73..cce0c3e 100644 (file)
@@ -115,32 +115,52 @@ static void load_radar_gui(Radar *radar)
        if (child)
                gtk_widget_destroy(child);
 
-       GtkWidget *hbox = gtk_hbox_new(TRUE, 0);
-       GtkWidget *button = NULL;
-       int vi = 0, si = 0;
-       for (vi = 0; vi < radar->h.nvolumes; vi++) {
+       /* Get table size */
+
+       guint rows = 1, cols = 1, cur_cols;
+       gchar row_label_str[64], col_label_str[64], button_str[64];
+       GtkWidget *row_label, *col_label, *button = NULL;
+       GtkWidget *table = gtk_table_new(rows, cols, FALSE);
+       for (guint vi = 0; vi < radar->h.nvolumes; vi++) {
                Volume *vol = radar->v[vi];
                if (vol == NULL) continue;
-               GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
-               for (si = 0; si < vol->h.nsweeps; si++) {
+               rows++; cols = 1;
+
+               /* Row label */
+               g_snprintf(row_label_str, 64, "<b>%s:</b>", vol->h.type_str);
+               row_label = gtk_label_new(row_label_str);
+               gtk_label_set_use_markup(GTK_LABEL(row_label), TRUE);
+               gtk_misc_set_alignment(GTK_MISC(row_label), 1, 0.5);
+               gtk_table_attach(GTK_TABLE(table), row_label, 0,1, rows-1,rows, GTK_FILL,GTK_FILL, 5,0);
+
+               for (guint si = 0; si < vol->h.nsweeps; si++) {
                        Sweep *sweep = vol->sweep[si];
-                       if (sweep == NULL) continue;
-                       char *label = g_strdup_printf("Tilt: %.2f (%s)",
-                                       sweep->h.elev, vol->h.type_str);
-                       button = gtk_radio_button_new_with_label_from_widget(
-                                       GTK_RADIO_BUTTON(button), label);
+                       if (sweep == NULL || sweep->h.elev == 0) continue;
+                       cols++;
+
+                       /* Column label */
+                       g_object_get(table, "n-columns", &cur_cols, NULL);
+                       if (cols >  cur_cols) {
+                               g_snprintf(col_label_str, 64, "<b>%.2f°</b>", sweep->h.elev);
+                               col_label = gtk_label_new(col_label_str);
+                               gtk_label_set_use_markup(GTK_LABEL(col_label), TRUE);
+                               gtk_widget_set_size_request(col_label, 40, -1);
+                               gtk_table_attach(GTK_TABLE(table), col_label, cols-1,cols, 0,1, GTK_FILL,GTK_FILL, 0,0);
+                       }
+
+                       /* Button */
+                       //g_snprintf(button_str, 64, "%c: %.2f", vol->h.type_str[0], sweep->h.elev);
+                       //button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(button), button_str);
+                       button = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(button));
+                       gtk_widget_set_size_request(button, -1, 22);
                        g_object_set(button, "draw-indicator", FALSE, NULL);
-                       g_signal_connect_swapped(button, "clicked",
-                                       G_CALLBACK(load_color_table), vol->h.type_str);
-                       g_signal_connect_swapped(button, "clicked",
-                                       G_CALLBACK(load_sweep), sweep);
-                       gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, TRUE, 0);
-                       g_free(label);
+                       g_signal_connect_swapped(button, "clicked", G_CALLBACK(load_color_table), vol->h.type_str);
+                       g_signal_connect_swapped(button, "clicked", G_CALLBACK(load_sweep), sweep);
+                       gtk_table_attach(GTK_TABLE(table), button, cols-1,cols, rows-1,rows, GTK_FILL,GTK_FILL, 0,0);
                }
-               gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
        }
-       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(config_body), hbox);
-       gtk_widget_show_all(hbox);
+       gtk_container_add(GTK_CONTAINER(config_body), table);
+       gtk_widget_show_all(table);
 }
 
 /* Load a radar from a file */
@@ -388,13 +408,10 @@ gboolean radar_init(AWeatherGui *_gui)
        AWeatherView *view    = aweather_gui_get_view(gui);
 
        /* Add configuration tab */
-       config_body = gtk_scrolled_window_new(NULL, NULL);
-       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(config_body),
-                       gtk_label_new("No radar loaded"));
-       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(config_body),
-                       GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-       gtk_notebook_prepend_page(GTK_NOTEBOOK(config),
-                       config_body, gtk_label_new("Radar"));
+       config_body = gtk_alignment_new(0, 0, 1, 1);
+       gtk_container_set_border_width(GTK_CONTAINER(config_body), 5);
+       gtk_container_add(GTK_CONTAINER(config_body), gtk_label_new("No radar loaded"));
+       gtk_notebook_prepend_page(GTK_NOTEBOOK(config), config_body, gtk_label_new("Radar"));
 
        /* Set up OpenGL Stuff */
        g_signal_connect(drawing, "expose-event",     G_CALLBACK(on_expose),           NULL);