]> Pileus Git - grits/commitdiff
* Fixing some async issue (w/ gthread_init)
authorAndy Spencer <andy753421@gmail.com>
Mon, 25 May 2009 01:48:49 +0000 (01:48 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 25 May 2009 01:48:49 +0000 (01:48 +0000)
* Consistent debug messages
* Debug levels
* Command line arguments
* Making AWeatherGui a subclass of GtkWindow

TODO
configure.ac
data/main.glade
src/aweather-gui.c
src/aweather-gui.h
src/aweather-view.c
src/data.c
src/main.c
src/plugin-example.c
src/plugin-radar.c
src/plugin-ridge.c

diff --git a/TODO b/TODO
index cac456d1ec3d07583c9f3e85504a8a089e73fb6a..613f2bcecc3a339ae3825038a16d7bdf0bb451be 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,7 +2,6 @@ Road plan
 ---------
 0.1 - Working
   * Fix all memory leaks
 ---------
 0.1 - Working
   * Fix all memory leaks
-  * Asynchronous IO and data loading
   * Pre-load textures and polys in OpenGL
 
 0.x - Volume scans
   * Pre-load textures and polys in OpenGL
 
 0.x - Volume scans
index 49ca7614d38060085f943d16d12b6adfa19f399c..a40bc831f3b7c7493535b701e3a5c9112a1bd955 100644 (file)
@@ -9,7 +9,7 @@ PKG_PROG_PKG_CONFIG
 GTK_DOC_CHECK(1.9)
 
 # Check for required packages
 GTK_DOC_CHECK(1.9)
 
 # Check for required packages
-PKG_CHECK_MODULES(GTK,  gtk+-2.0 gtkglext-1.0 gmodule-export-2.0 gobject-2.0)
+PKG_CHECK_MODULES(GTK,  gtk+-2.0 gtkglext-1.0 gmodule-export-2.0 gobject-2.0 gthread-2.0)
 
 # Define odd RSL install location
 #AC_SUBST(RSL_CFLAGS, "-I/usr/local/trmm/GVBOX/include/")
 
 # Define odd RSL install location
 #AC_SUBST(RSL_CFLAGS, "-I/usr/local/trmm/GVBOX/include/")
index 50368fad7148d558623b1d0b4fe2672f62379fcb..eadaba0336cc8603d0b5932f23f665cf975e9dd1 100644 (file)
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Sun May 24 00:31:16 2009 -->
+<!--Generated with glade3 3.4.5 on Mon May 25 01:31:13 2009 -->
 <glade-interface>
   <widget class="GtkWindow" id="window">
     <signal name="key_press_event" handler="on_key_press"/>
     <signal name="delete_event" handler="gtk_main_quit"/>
     <child>
 <glade-interface>
   <widget class="GtkWindow" id="window">
     <signal name="key_press_event" handler="on_key_press"/>
     <signal name="delete_event" handler="gtk_main_quit"/>
     <child>
-      <widget class="GtkVBox" id="vbox1">
+      <widget class="GtkVBox" id="body">
         <property name="visible">True</property>
         <child>
           <widget class="GtkMenuBar" id="menu">
         <property name="visible">True</property>
         <child>
           <widget class="GtkMenuBar" id="menu">
index 4c5bff2df636f2e5de381a6d5de05bb788c7911d..48fc87e24100e34f51dc53a75fe9fc941a7cf1ff 100644 (file)
 /****************
  * GObject code *
  ****************/
 /****************
  * GObject code *
  ****************/
-G_DEFINE_TYPE(AWeatherGui, aweather_gui, G_TYPE_OBJECT);
+G_DEFINE_TYPE(AWeatherGui, aweather_gui, GTK_TYPE_WINDOW);
 static void aweather_gui_init(AWeatherGui *gui)
 {
        gui->plugins = NULL;
 static void aweather_gui_init(AWeatherGui *gui)
 {
        gui->plugins = NULL;
-       //g_message("aweather_gui_init");
+       g_debug("AWeatherGui: init");
 }
 static GObject *aweather_gui_constructor(GType gtype, guint n_properties,
                GObjectConstructParam *properties)
 {
 }
 static GObject *aweather_gui_constructor(GType gtype, guint n_properties,
                GObjectConstructParam *properties)
 {
-       //g_message("aweather_gui_constructor");
+       g_debug("aweather_gui: constructor");
        GObjectClass *parent_class = G_OBJECT_CLASS(aweather_gui_parent_class);
        return  parent_class->constructor(gtype, n_properties, properties);
 }
        GObjectClass *parent_class = G_OBJECT_CLASS(aweather_gui_parent_class);
        return  parent_class->constructor(gtype, n_properties, properties);
 }
-static void aweather_gui_dispose (GObject *gobject)
+static void aweather_gui_dispose(GObject *gobject)
 {
 {
-       //g_message("aweather_gui_dispose");
+       g_debug("AWeatherGui: dispose");
        AWeatherGui *gui = AWEATHER_GUI(gobject);
        g_object_unref(gui->view   );
        g_object_unref(gui->builder);
        AWeatherGui *gui = AWEATHER_GUI(gobject);
        g_object_unref(gui->view   );
        g_object_unref(gui->builder);
-       g_object_unref(gui->window );
-       g_object_unref(gui->tabs   );
-       g_object_unref(gui->drawing);
        G_OBJECT_CLASS(aweather_gui_parent_class)->dispose(gobject);
 }
 static void aweather_gui_finalize(GObject *gobject)
 {
        G_OBJECT_CLASS(aweather_gui_parent_class)->dispose(gobject);
 }
 static void aweather_gui_finalize(GObject *gobject)
 {
-       //g_message("aweather_gui_finalize");
+       g_debug("AWeatherGui: finalize");
        G_OBJECT_CLASS(aweather_gui_parent_class)->finalize(gobject);
 }
 static void aweather_gui_class_init(AWeatherGuiClass *klass)
 {
        G_OBJECT_CLASS(aweather_gui_parent_class)->finalize(gobject);
 }
 static void aweather_gui_class_init(AWeatherGuiClass *klass)
 {
-       //g_message("aweather_gui_class_init");
+       g_debug("AWeatherGui: class_init");
        GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
        gobject_class->constructor  = aweather_gui_constructor;
        gobject_class->dispose      = aweather_gui_dispose;
        GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
        gobject_class->constructor  = aweather_gui_constructor;
        gobject_class->dispose      = aweather_gui_dispose;
@@ -74,7 +71,7 @@ static void aweather_gui_class_init(AWeatherGuiClass *klass)
  *************/
 gboolean on_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *gui)
 {
  *************/
 gboolean on_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *gui)
 {
-       g_message("key_press: key=%x, state=%x", event->keyval, event->state);
+       g_debug("AWeatherGui: on_key_press - key=%x, state=%x", event->keyval, event->state);
        AWeatherView *view = aweather_gui_get_view(gui);
        double x,y,z;
        aweather_view_get_location(view, &x, &y, &z);
        AWeatherView *view = aweather_gui_get_view(gui);
        double x,y,z;
        aweather_view_get_location(view, &x, &y, &z);
@@ -145,9 +142,8 @@ void on_site_changed(GtkComboBox *combo, AWeatherGui *gui)
 
 gboolean on_map(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
 {
 
 gboolean on_map(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
 {
-       g_message("on_map");
+       g_debug("AWeatherGui: on_map");
        AWeatherView *view = aweather_gui_get_view(gui);
        AWeatherView *view = aweather_gui_get_view(gui);
-       aweather_view_set_site(view, "IND");
 
        /* Misc */
        glEnable(GL_BLEND);
 
        /* Misc */
        glEnable(GL_BLEND);
@@ -171,7 +167,7 @@ gboolean on_map(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
 
 gboolean on_configure(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
 {
 
 gboolean on_configure(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
 {
-       //g_message("on_confiure");
+       g_debug("AWeatherGui: on_confiure");
        aweather_gui_gl_begin(gui);
 
        double x, y, z;
        aweather_gui_gl_begin(gui);
 
        double x, y, z;
@@ -199,7 +195,7 @@ gboolean on_configure(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
 
 gboolean on_expose(GtkWidget *da, GdkEventExpose *event, AWeatherGui *gui)
 {
 
 gboolean on_expose(GtkWidget *da, GdkEventExpose *event, AWeatherGui *gui)
 {
-       g_message("aweather:expose - begin");
+       g_debug("AWeatherGui: on_expose - begin");
        aweather_gui_gl_begin(gui);
 
        double x, y, z;
        aweather_gui_gl_begin(gui);
 
        double x, y, z;
@@ -220,7 +216,7 @@ gboolean on_expose(GtkWidget *da, GdkEventExpose *event, AWeatherGui *gui)
 
        aweather_gui_gl_end(gui);
        aweather_gui_gl_flush(gui);
 
        aweather_gui_gl_end(gui);
        aweather_gui_gl_flush(gui);
-       g_message("aweather:expose - end\n");
+       g_debug("AWeatherGui: on_expose - end\n");
        return FALSE;
 }
 
        return FALSE;
 }
 
@@ -250,7 +246,7 @@ void on_location_changed(AWeatherView *view,
 /* TODO: replace the code in these with `gtk_tree_model_find' utility */
 static void update_time_widget(AWeatherView *view, char *time, AWeatherGui *gui)
 {
 /* TODO: replace the code in these with `gtk_tree_model_find' utility */
 static void update_time_widget(AWeatherView *view, char *time, AWeatherGui *gui)
 {
-       g_message("updating time widget");
+       g_debug("AWeatherGui: update_time_widget");
        GtkTreeView  *tview = GTK_TREE_VIEW(aweather_gui_get_widget(gui, "time"));
        GtkTreeModel *model = GTK_TREE_MODEL(gtk_tree_view_get_model(tview));
        for (int i = 0; i < gtk_tree_model_iter_n_children(model, NULL); i++) {
        GtkTreeView  *tview = GTK_TREE_VIEW(aweather_gui_get_widget(gui, "time"));
        GtkTreeModel *model = GTK_TREE_MODEL(gtk_tree_view_get_model(tview));
        for (int i = 0; i < gtk_tree_model_iter_n_children(model, NULL); i++) {
@@ -274,7 +270,7 @@ static void update_time_widget(AWeatherView *view, char *time, AWeatherGui *gui)
 }
 static void update_site_widget(AWeatherView *view, char *site, AWeatherGui *gui)
 {
 }
 static void update_site_widget(AWeatherView *view, char *site, AWeatherGui *gui)
 {
-       g_message("updating site widget to %s", site);
+       g_debug("AWeatherGui: updat_site_widget - site=%s", site);
        GtkComboBox  *combo = GTK_COMBO_BOX(aweather_gui_get_widget(gui, "site"));
        GtkTreeModel *model = GTK_TREE_MODEL(gtk_combo_box_get_model(combo));
        for (int i = 0; i < gtk_tree_model_iter_n_children(model, NULL); i++) {
        GtkComboBox  *combo = GTK_COMBO_BOX(aweather_gui_get_widget(gui, "site"));
        GtkTreeModel *model = GTK_TREE_MODEL(gtk_combo_box_get_model(combo));
        for (int i = 0; i < gtk_tree_model_iter_n_children(model, NULL); i++) {
@@ -380,28 +376,27 @@ static void opengl_setup(AWeatherGui *gui)
  ***********/
 AWeatherGui *aweather_gui_new()
 {
  ***********/
 AWeatherGui *aweather_gui_new()
 {
-       //g_message("aweather_gui_new");
+       g_debug("AWeatherGui: new");
        GError *error = NULL;
 
        GError *error = NULL;
 
-       AWeatherGui *gui = g_object_new(AWEATHER_TYPE_GUI, NULL);
+       AWeatherGui *self = g_object_new(AWEATHER_TYPE_GUI, NULL);
+       self->view    = aweather_view_new();
+       self->builder = gtk_builder_new();
 
 
-       gui->builder = gtk_builder_new();
-       if (!gtk_builder_add_from_file(gui->builder, DATADIR "/aweather/main.xml", &error))
+       if (!gtk_builder_add_from_file(self->builder, DATADIR "/aweather/main.xml", &error))
                g_error("Failed to create gtk builder: %s", error->message);
                g_error("Failed to create gtk builder: %s", error->message);
-       gui->view    = aweather_view_new();
-       gui->window  = GTK_WINDOW      (gtk_builder_get_object(gui->builder, "main"));
-       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, gui);
-
+       gtk_builder_connect_signals(self->builder, self);
+       g_signal_connect(self, "delete-event",    G_CALLBACK(gtk_main_quit), self);
+       g_signal_connect(self, "key-press-event", G_CALLBACK(on_key_press),  self);
+       gtk_widget_reparent(aweather_gui_get_widget(self, "body"), GTK_WIDGET(self));
 
        /* Load components */
 
        /* Load components */
-       aweather_view_set_location(gui->view, 0, 0, -300*1000);
-       g_signal_connect(gui->view, "location-changed", G_CALLBACK(on_location_changed), gui);
-       site_setup(gui);
-       time_setup(gui);
-       opengl_setup(gui);
-       return gui;
+       aweather_view_set_location(self->view, 0, 0, -300*1000);
+       g_signal_connect(self->view, "location-changed", G_CALLBACK(on_location_changed), self);
+       site_setup(self);
+       time_setup(self);
+       opengl_setup(self);
+       return self;
 }
 AWeatherView *aweather_gui_get_view(AWeatherGui *gui)
 {
 }
 AWeatherView *aweather_gui_get_view(AWeatherGui *gui)
 {
@@ -423,12 +418,12 @@ GtkWidget *aweather_gui_get_widget(AWeatherGui *gui, const gchar *name)
 }
 void aweather_gui_register_plugin(AWeatherGui *gui, AWeatherPlugin *plugin)
 {
 }
 void aweather_gui_register_plugin(AWeatherGui *gui, AWeatherPlugin *plugin)
 {
-       g_message("registering plugin");
+       g_debug("AWeatherGui: register_plugin");
        gui->plugins = g_list_append(gui->plugins, plugin);
 }
 void aweather_gui_gl_redraw(AWeatherGui *gui)
 {
        gui->plugins = g_list_append(gui->plugins, plugin);
 }
 void aweather_gui_gl_redraw(AWeatherGui *gui)
 {
-       g_message("redraw");
+       g_debug("AWeatherGui: gl_redraw");
        GtkWidget *drawing = aweather_gui_get_widget(gui, "drawing");
        gtk_widget_queue_draw(drawing);
 }
        GtkWidget *drawing = aweather_gui_get_widget(gui, "drawing");
        gtk_widget_queue_draw(drawing);
 }
index 91e53d24bdabfb629b470682f18a1473ba4700f1..af5e4a8243905906778e74c44fce4653741373a5 100644 (file)
@@ -35,19 +35,16 @@ typedef struct _AWeatherGui      AWeatherGui;
 typedef struct _AWeatherGuiClass AWeatherGuiClass;
 
 struct _AWeatherGui {
 typedef struct _AWeatherGuiClass AWeatherGuiClass;
 
 struct _AWeatherGui {
-       GObject parent_instance;
+       GtkWindow parent_instance;
 
        /* instance members */
        AWeatherView   *view;
        GtkBuilder     *builder;
 
        /* instance members */
        AWeatherView   *view;
        GtkBuilder     *builder;
-       GtkWindow      *window;
-       GtkNotebook    *tabs;
-       GtkDrawingArea *drawing;
        GList          *plugins;
 };
 
 struct _AWeatherGuiClass {
        GList          *plugins;
 };
 
 struct _AWeatherGuiClass {
-       GObjectClass parent_class;
+       GtkWindowClass parent_class;
        
        /* class members */
 };
        
        /* class members */
 };
index 7caaf9b9a3868fddff8039eead3304273e335a1f..627824f0051a91fb8294731f11252439dfb34e4f 100644 (file)
@@ -43,7 +43,7 @@ static guint signals[NUM_SIGNALS];
 
 static void aweather_view_init(AWeatherView *self)
 {
 
 static void aweather_view_init(AWeatherView *self)
 {
-       //g_message("aweather_view_init");
+       g_debug("AWeatherView: init");
        /* Default values */
        self->time = g_strdup("");
        self->site = g_strdup("");
        /* Default values */
        self->time = g_strdup("");
        self->site = g_strdup("");
@@ -52,21 +52,21 @@ static void aweather_view_init(AWeatherView *self)
 static GObject *aweather_view_constructor(GType gtype, guint n_properties,
                GObjectConstructParam *properties)
 {
 static GObject *aweather_view_constructor(GType gtype, guint n_properties,
                GObjectConstructParam *properties)
 {
-       //g_message("aweather_view_constructor");
+       g_debug("AWeatherView: constructor");
        GObjectClass *parent_class = G_OBJECT_CLASS(aweather_view_parent_class);
        return  parent_class->constructor(gtype, n_properties, properties);
 }
 
        GObjectClass *parent_class = G_OBJECT_CLASS(aweather_view_parent_class);
        return  parent_class->constructor(gtype, n_properties, properties);
 }
 
-static void aweather_view_dispose (GObject *gobject)
+static void aweather_view_dispose(GObject *gobject)
 {
 {
-       //g_message("aweather_view_dispose");
+       g_debug("AWeatherView: dispose");
        /* Drop references to other GObjects */
        G_OBJECT_CLASS(aweather_view_parent_class)->dispose(gobject);
 }
 
 static void aweather_view_finalize(GObject *gobject)
 {
        /* Drop references to other GObjects */
        G_OBJECT_CLASS(aweather_view_parent_class)->dispose(gobject);
 }
 
 static void aweather_view_finalize(GObject *gobject)
 {
-       //g_message("aweather_view_finalize");
+       g_debug("AWeatherView: finalize");
        AWeatherView *self = AWEATHER_VIEW(gobject);
        g_free(self->site);
        G_OBJECT_CLASS(aweather_view_parent_class)->finalize(gobject);
        AWeatherView *self = AWEATHER_VIEW(gobject);
        g_free(self->site);
        G_OBJECT_CLASS(aweather_view_parent_class)->finalize(gobject);
@@ -75,7 +75,7 @@ static void aweather_view_finalize(GObject *gobject)
 static void aweather_view_set_property(GObject *object, guint property_id,
                const GValue *value, GParamSpec *pspec)
 {
 static void aweather_view_set_property(GObject *object, guint property_id,
                const GValue *value, GParamSpec *pspec)
 {
-       //g_message("aweather_view_set_property");
+       g_debug("AWeatherView: set_property");
        AWeatherView *self = AWEATHER_VIEW(object);
        switch (property_id) {
        case PROP_TIME:     aweather_view_set_time(self, g_value_get_string(value)); break;
        AWeatherView *self = AWEATHER_VIEW(object);
        switch (property_id) {
        case PROP_TIME:     aweather_view_set_time(self, g_value_get_string(value)); break;
@@ -87,7 +87,7 @@ static void aweather_view_set_property(GObject *object, guint property_id,
 static void aweather_view_get_property(GObject *object, guint property_id,
                GValue *value, GParamSpec *pspec)
 {
 static void aweather_view_get_property(GObject *object, guint property_id,
                GValue *value, GParamSpec *pspec)
 {
-       //g_message("aweather_view_get_property");
+       g_debug("AWeatherView: get_property");
        AWeatherView *self = AWEATHER_VIEW(object);
        switch (property_id) {
        case PROP_TIME:     g_value_set_string(value, aweather_view_get_time(self)); break;
        AWeatherView *self = AWEATHER_VIEW(object);
        switch (property_id) {
        case PROP_TIME:     g_value_set_string(value, aweather_view_get_time(self)); break;
@@ -98,7 +98,7 @@ static void aweather_view_get_property(GObject *object, guint property_id,
 
 static void aweather_view_class_init(AWeatherViewClass *klass)
 {
 
 static void aweather_view_class_init(AWeatherViewClass *klass)
 {
-       //g_message("aweather_view_class_init");
+       g_debug("AWeatherView: class_init");
        GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
        gobject_class->constructor  = aweather_view_constructor;
        gobject_class->dispose      = aweather_view_dispose;
        GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
        gobject_class->constructor  = aweather_view_constructor;
        gobject_class->dispose      = aweather_view_dispose;
@@ -194,14 +194,14 @@ static void _aweather_view_emit_refresh(AWeatherView *view)
  ***********/
 AWeatherView *aweather_view_new()
 {
  ***********/
 AWeatherView *aweather_view_new()
 {
-       //g_message("aweather_view_new");
+       g_debug("AWeatherView: new");
        return g_object_new(AWEATHER_TYPE_VIEW, NULL);
 }
 
 void aweather_view_set_time(AWeatherView *view, const char *time)
 {
        g_assert(AWEATHER_IS_VIEW(view));
        return g_object_new(AWEATHER_TYPE_VIEW, NULL);
 }
 
 void aweather_view_set_time(AWeatherView *view, const char *time)
 {
        g_assert(AWEATHER_IS_VIEW(view));
-       //g_message("aweather_view:set_time: setting time to %s", time);
+       g_debug("AWeatherView: set_time - time=%s", time);
        g_free(view->time);
        view->time = g_strdup(time);
        _aweather_view_emit_time_changed(view);
        g_free(view->time);
        view->time = g_strdup(time);
        _aweather_view_emit_time_changed(view);
@@ -210,14 +210,14 @@ void aweather_view_set_time(AWeatherView *view, const char *time)
 gchar *aweather_view_get_time(AWeatherView *view)
 {
        g_assert(AWEATHER_IS_VIEW(view));
 gchar *aweather_view_get_time(AWeatherView *view)
 {
        g_assert(AWEATHER_IS_VIEW(view));
-       //g_message("aweather_view_get_time");
+       g_debug("AWeatherView: get_time");
        return view->time;
 }
 
 void aweather_view_get_location(AWeatherView *view, gdouble *x, gdouble *y, gdouble *z)
 {
        g_assert(AWEATHER_IS_VIEW(view));
        return view->time;
 }
 
 void aweather_view_get_location(AWeatherView *view, gdouble *x, gdouble *y, gdouble *z)
 {
        g_assert(AWEATHER_IS_VIEW(view));
-       //g_message("aweather_view_get_location");
+       g_debug("AWeatherView: get_location");
        *x = view->location[0];
        *y = view->location[1];
        *z = view->location[2];
        *x = view->location[0];
        *y = view->location[1];
        *z = view->location[2];
@@ -226,7 +226,7 @@ void aweather_view_get_location(AWeatherView *view, gdouble *x, gdouble *y, gdou
 void aweather_view_set_location(AWeatherView *view, gdouble x, gdouble y, gdouble z)
 {
        g_assert(AWEATHER_IS_VIEW(view));
 void aweather_view_set_location(AWeatherView *view, gdouble x, gdouble y, gdouble z)
 {
        g_assert(AWEATHER_IS_VIEW(view));
-       //g_message("aweather_view_set_location");
+       g_debug("AWeatherView: set_location");
        view->location[0] = x;
        view->location[1] = y;
        view->location[2] = z;
        view->location[0] = x;
        view->location[1] = y;
        view->location[2] = z;
@@ -236,7 +236,7 @@ void aweather_view_set_location(AWeatherView *view, gdouble x, gdouble y, gdoubl
 void aweather_view_pan(AWeatherView *view, gdouble x, gdouble y, gdouble z)
 {
        g_assert(AWEATHER_IS_VIEW(view));
 void aweather_view_pan(AWeatherView *view, gdouble x, gdouble y, gdouble z)
 {
        g_assert(AWEATHER_IS_VIEW(view));
-       g_message("aweather_view_pan: %f, %f, %f", x, y, z);
+       g_debug("AWeatherView: pan - x=%.0f, y=%.0f, z=%.0f", x, y, z);
        view->location[0] += x;
        view->location[1] += y;
        view->location[2] += z;
        view->location[0] += x;
        view->location[1] += y;
        view->location[2] += z;
@@ -246,20 +246,21 @@ void aweather_view_pan(AWeatherView *view, gdouble x, gdouble y, gdouble z)
 void aweather_view_zoom(AWeatherView *view, gdouble scale)
 {
        g_assert(AWEATHER_IS_VIEW(view));
 void aweather_view_zoom(AWeatherView *view, gdouble scale)
 {
        g_assert(AWEATHER_IS_VIEW(view));
+       g_debug("AWeatherView: zoom");
        view->location[2] *= scale;
        _aweather_view_emit_location_changed(view);
 }
 
 void aweather_view_refresh(AWeatherView *view)
 {
        view->location[2] *= scale;
        _aweather_view_emit_location_changed(view);
 }
 
 void aweather_view_refresh(AWeatherView *view)
 {
-       g_message("aweather_view_refresh: ..");
+       g_debug("AWeatherView: refresh");
        _aweather_view_emit_refresh(view);
 }
 
 void aweather_view_set_site(AWeatherView *view, const gchar *site)
 {
        g_assert(AWEATHER_IS_VIEW(view));
        _aweather_view_emit_refresh(view);
 }
 
 void aweather_view_set_site(AWeatherView *view, const gchar *site)
 {
        g_assert(AWEATHER_IS_VIEW(view));
-       //g_message("aweather_view_set_site");
+       g_debug("AWeatherView: set_site");
        g_free(view->site);
        view->site = g_strdup(site);
        _aweather_view_emit_site_changed(view);
        g_free(view->site);
        view->site = g_strdup(site);
        _aweather_view_emit_site_changed(view);
@@ -268,7 +269,7 @@ void aweather_view_set_site(AWeatherView *view, const gchar *site)
 gchar *aweather_view_get_site(AWeatherView *view)
 {
        g_assert(AWEATHER_IS_VIEW(view));
 gchar *aweather_view_get_site(AWeatherView *view)
 {
        g_assert(AWEATHER_IS_VIEW(view));
-       //g_message("aweather_view_get_site");
+       g_debug("AWeatherView: get_site");
        return view->site;
 }
 
        return view->site;
 }
 
index 1440fd92ef78b3d0ce7c11156c5dc57f3b39ae07..7a881bd718d4c2cc99cb5881674a6a1d3538e669 100644 (file)
@@ -51,7 +51,7 @@ static void cache_file_cb(GObject *source_object, GAsyncResult *res, gpointer _i
        GError *error = NULL;
        g_file_copy_finish(G_FILE(source_object), res, &error);
        if (error) {
        GError *error = NULL;
        g_file_copy_finish(G_FILE(source_object), res, &error);
        if (error) {
-               g_message("error copying file ([%s]->[%s]): %s",
+               g_warning("error copying file ([%s]->[%s]): %s",
                        url, local, error->message);
                g_error_free(error);
        } else {
                        url, local, error->message);
                g_error_free(error);
        } else {
@@ -68,7 +68,7 @@ static void do_cache(GFile *src, GFile *dst, char *reason,
                AWeatherCacheDoneCallback callback, gpointer user_data)
 {
        char *name = g_file_get_basename(dst);
                AWeatherCacheDoneCallback callback, gpointer user_data)
 {
        char *name = g_file_get_basename(dst);
-       g_message("Caching file %s: %s", name, reason);
+       g_debug("data: do_cache - Caching file %s: %s", name, reason);
        g_free(name);
 
        GFile *parent = g_file_get_parent(dst);
        g_free(name);
 
        GFile *parent = g_file_get_parent(dst);
@@ -82,13 +82,13 @@ static void do_cache(GFile *src, GFile *dst, char *reason,
        info->dst       = dst;
        info->user_data = user_data;
        g_file_copy_async(src, dst,
        info->dst       = dst;
        info->user_data = user_data;
        g_file_copy_async(src, dst,
-               G_FILE_COPY_OVERWRITE, // GFileCopyFlags flags,
-               0,                     // int io_priority,
-               NULL,                  // GCancellable *cancellable,
-               NULL,                  // GFileProgressCallback progress_callback,
-               NULL,                  // gpointer progress_callback_data,
-               cache_file_cb,         // GAsyncReadyCallback callback,
-               info);                 // gpointer user_data
+               G_FILE_COPY_OVERWRITE,   // GFileCopyFlags flags,
+               G_PRIORITY_DEFAULT_IDLE, // int io_priority,
+               NULL,                    // GCancellable *cancellable,
+               NULL,                    // GFileProgressCallback progress_callback,
+               NULL,                    // gpointer progress_callback_data,
+               cache_file_cb,           // GAsyncReadyCallback callback,
+               info);                   // gpointer user_data
        return;
 }
 
        return;
 }
 
index 343b6b9849bd6ed8e7101f9716c89c806c84084a..d1b13b38ec9eb4ba0e3f116e13d457874bb8fd37 100644 (file)
 #include "plugin-ridge.h"
 #include "plugin-example.h"
 
 #include "plugin-ridge.h"
 #include "plugin-example.h"
 
+static gint log_levels = 0;
+
+static void log_func(const gchar *log_domain, GLogLevelFlags log_level,
+              const gchar *message, gpointer udata)
+{
+       if (log_level & log_levels)
+               g_log_default_handler(log_domain, log_level, message, udata);
+}
+
+static gboolean on_map(AWeatherGui *gui, GdkEvent *event, gchar *site)
+{
+       AWeatherView *view = aweather_gui_get_view(gui);
+       aweather_view_set_site(view, site);
+       return FALSE;
+}
+
 /********
  * Main *
  ********/
 int main(int argc, char *argv[])
 {
 /********
  * Main *
  ********/
 int main(int argc, char *argv[])
 {
-       gtk_init(&argc, &argv);
+       /* Arguments */
+       gint     opt_debug = 6;
+       gchar   *opt_site  = "IND";
+       gboolean opt_auto  = FALSE;
+       GOptionEntry entries[] = {
+               //long    short flg type                 location    description                 arg desc
+               {"debug", 'd',  0,  G_OPTION_ARG_INT,    &opt_debug, "Change default log level", "[1-7]"},
+               {"site",  's',  0,  G_OPTION_ARG_STRING, &opt_site,  "Set initial site",         NULL},
+               {"auto",  'a',  0,  G_OPTION_ARG_NONE,   &opt_auto,  "Auto update radar (todo)", NULL},
+               {NULL}
+       };
+
+       /* Init */
+       GError *error = NULL;
+       g_thread_init(NULL);
+       if (!gtk_init_with_args(&argc, &argv, "aweather", entries, NULL, &error)) {
+               g_print("%s\n", error->message);
+               g_error_free(error);
+               return -1;
+       }
        gtk_gl_init(&argc, &argv);
 
        gtk_gl_init(&argc, &argv);
 
+       /* Finish arguments */
+       log_levels = 1 << opt_debug;
+
+       /* Logging */
+       g_log_set_handler(NULL, G_LOG_LEVEL_MASK, log_func, NULL);
+
        /* Set up AWeather */
        AWeatherGui  *gui  = aweather_gui_new();
        /* Set up AWeather */
        AWeatherGui  *gui  = aweather_gui_new();
-       //AWeatherView *view = aweather_gui_get_view(gui);
+       AWeatherView *view = aweather_gui_get_view(gui);
+       g_signal_connect(gui, "map-event", G_CALLBACK(on_map), opt_site);
 
        /* Load plugins */
        aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_example_new(gui)));
        aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_ridge_new(gui)));
        aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_radar_new(gui)));
 
 
        /* Load plugins */
        aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_example_new(gui)));
        aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_ridge_new(gui)));
        aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_radar_new(gui)));
 
-       gtk_widget_show_all(aweather_gui_get_widget(gui, "window"));
+       gtk_widget_show_all(GTK_WIDGET(gui));
        gtk_main();
 
        return 0;
        gtk_main();
 
        return 0;
index 26be63a0c81c571658e9e142b9ba4938d9921b88..40606423319e2888c49f40479bb9f0b2955bc463 100644 (file)
@@ -66,7 +66,7 @@ static gboolean rotate(gpointer _example)
  ***********/
 AWeatherExample *aweather_example_new(AWeatherGui *gui)
 {
  ***********/
 AWeatherExample *aweather_example_new(AWeatherGui *gui)
 {
-       //g_message("aweather_view_new");
+       g_debug("AWeatherExample: new");
        AWeatherExample *example = g_object_new(AWEATHER_TYPE_EXAMPLE, NULL);
        example->gui = gui;
 
        AWeatherExample *example = g_object_new(AWEATHER_TYPE_EXAMPLE, NULL);
        example->gui = gui;
 
@@ -88,7 +88,7 @@ AWeatherExample *aweather_example_new(AWeatherGui *gui)
 static void aweather_example_expose(AWeatherPlugin *_example)
 {
        AWeatherExample *example = AWEATHER_EXAMPLE(_example);
 static void aweather_example_expose(AWeatherPlugin *_example)
 {
        AWeatherExample *example = AWEATHER_EXAMPLE(_example);
-       g_message("aweather_example_expose");
+       g_debug("AWeatherExample: expose");
        glDisable(GL_TEXTURE_2D);
        glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
        glOrtho(-1,1,-1,1,-10,10);
        glDisable(GL_TEXTURE_2D);
        glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
        glOrtho(-1,1,-1,1,-10,10);
index 7858023b829f289648e0e2e297f412dfc0bc9ebd..07161c56af8b762f031b6389db114fd122162fc0 100644 (file)
@@ -152,7 +152,6 @@ static void load_radar_gui(AWeatherRadar *self, Radar *radar)
                        Sweep *sweep = vol->sweep[si];
                        if (sweep == NULL || sweep->h.elev == 0) continue;
                        if (sweep->h.elev != elev) {
                        Sweep *sweep = vol->sweep[si];
                        if (sweep == NULL || sweep->h.elev == 0) continue;
                        if (sweep->h.elev != elev) {
-                               g_message("adding elev");
                                cols++;
                                elev = sweep->h.elev;
 
                                cols++;
                                elev = sweep->h.elev;
 
@@ -200,10 +199,10 @@ static void load_radar(AWeatherRadar *self, gchar *radar_file)
        g_free(dir);
        RSL_read_these_sweeps("all", NULL);
        if (self->cur_radar) {
        g_free(dir);
        RSL_read_these_sweeps("all", NULL);
        if (self->cur_radar) {
-               g_message("Freeing radar");
+               g_debug("AWeatherRadar: load_radar - Freeing old radar");
                RSL_free_radar(self->cur_radar);
        }
                RSL_free_radar(self->cur_radar);
        }
-       g_message("Allocating radar");
+       g_debug("AWeatherRadar: load_radar - Loading new radar");
        Radar *radar = self->cur_radar = RSL_wsr88d_to_radar(radar_file, site);
        if (radar == NULL) {
                g_warning("fail to load radar: path=%s, site=%s", radar_file, site);
        Radar *radar = self->cur_radar = RSL_wsr88d_to_radar(radar_file, site);
        if (radar == NULL) {
                g_warning("fail to load radar: path=%s, site=%s", radar_file, site);
@@ -305,7 +304,7 @@ static void cached_cb(char *path, gboolean updated, gpointer _self)
        decompressed_t *udata = g_malloc(sizeof(decompressed_t));
        udata->self       = self;
        udata->radar_file = decompressed;
        decompressed_t *udata = g_malloc(sizeof(decompressed_t));
        udata->self       = self;
        udata->radar_file = decompressed;
-       g_message("File updated, decompressing..");
+       g_debug("AWeatherRadar: cached_cb - File updated, decompressing..");
        char *argv[] = {"wsr88ddec", path, decompressed, NULL};
        GPid pid;
        GError *error = NULL;
        char *argv[] = {"wsr88ddec", path, decompressed, NULL};
        GPid pid;
        GError *error = NULL;
@@ -341,7 +340,7 @@ static void on_sweep_clicked(GtkRadioButton *button, gpointer _self)
 static void on_time_changed(AWeatherView *view, char *time, gpointer _self)
 {
        AWeatherRadar *self = AWEATHER_RADAR(_self);
 static void on_time_changed(AWeatherView *view, char *time, gpointer _self)
 {
        AWeatherRadar *self = AWEATHER_RADAR(_self);
-       g_message("radar:setting time");
+       g_debug("AWeatherRadar: on_time_changed - setting time");
        // format: http://mesonet.agron.iastate.edu/data/nexrd2/raw/KABR/KABR_20090510_0323
        char *site = aweather_view_get_site(view);
        char *base = "http://mesonet.agron.iastate.edu/data/";
        // format: http://mesonet.agron.iastate.edu/data/nexrd2/raw/KABR/KABR_20090510_0323
        char *site = aweather_view_get_site(view);
        char *base = "http://mesonet.agron.iastate.edu/data/";
@@ -358,7 +357,7 @@ static void on_time_changed(AWeatherView *view, char *time, gpointer _self)
 static void on_site_changed(AWeatherView *view, char *site, gpointer _self)
 {
        AWeatherRadar *self = AWEATHER_RADAR(_self);
 static void on_site_changed(AWeatherView *view, char *site, gpointer _self)
 {
        AWeatherRadar *self = AWEATHER_RADAR(_self);
-       g_message("Loading wsr88d list for %s", site);
+       g_debug("AWeatherRadar: on_site_changed - Loading wsr88d list for %s", site);
        char *time = NULL;
        update_times(self, site, &time);
        aweather_view_set_time(view, time);
        char *time = NULL;
        update_times(self, site, &time);
        aweather_view_set_time(view, time);
@@ -381,7 +380,7 @@ static void on_refresh(AWeatherView *view, gpointer user_data, gpointer _self)
  ***********/
 AWeatherRadar *aweather_radar_new(AWeatherGui *gui)
 {
  ***********/
 AWeatherRadar *aweather_radar_new(AWeatherGui *gui)
 {
-       //g_message("aweather_view_new");
+       g_debug("AWeatherRadar: new");
        AWeatherRadar *self = g_object_new(AWEATHER_TYPE_RADAR, NULL);
        self->gui = gui;
 
        AWeatherRadar *self = g_object_new(AWEATHER_TYPE_RADAR, NULL);
        self->gui = gui;
 
@@ -405,7 +404,7 @@ AWeatherRadar *aweather_radar_new(AWeatherGui *gui)
 static void _aweather_radar_expose(AWeatherPlugin *_self)
 {
        AWeatherRadar *self = AWEATHER_RADAR(_self);
 static void _aweather_radar_expose(AWeatherPlugin *_self)
 {
        AWeatherRadar *self = AWEATHER_RADAR(_self);
-       g_message("radar:expose");
+       g_debug("AWeatherRadar: expose");
        if (self->cur_sweep == NULL)
                return;
        Sweep *sweep = self->cur_sweep;
        if (self->cur_sweep == NULL)
                return;
        Sweep *sweep = self->cur_sweep;
index a9838b9b0c16095fb23ca6c4be92ee2b95459107..646878c834d4d303da5ea5c272bc775ae0fc0490 100644 (file)
@@ -111,7 +111,8 @@ void load_texture(AWeatherRidge *self, layer_t *layer, gchar *filename)
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
        char *base = g_path_get_basename(filename);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
        char *base = g_path_get_basename(filename);
-       g_message("loaded image:  w=%-3d  h=%-3d  fmt=%x  px=(%02x,%02x,%02x,%02x)  img=%s",
+       g_debug("AWeatherRidge: load_texture - "
+               "w=%-3d  h=%-3d  fmt=%x  px=(%02x,%02x,%02x,%02x)  img=%s",
                width, height, format, pixels[0], pixels[1], pixels[2], pixels[3],
                base);
        g_free(base);
                width, height, format, pixels[0], pixels[1], pixels[2], pixels[3],
                base);
        g_free(base);
@@ -144,7 +145,7 @@ void cached_cb(gchar *filename, gboolean updated, gpointer _udata)
  *************/
 static void on_site_changed(AWeatherView *view, gchar *site, AWeatherRidge *self)
 {
  *************/
 static void on_site_changed(AWeatherView *view, gchar *site, AWeatherRidge *self)
 {
-       g_message("site changed to %s", site);
+       g_debug("AWeatherRidge: on_site_changed - site=%s", site);
        for (int i = 0; i < LAYER_COUNT; i++) {
                gchar *base = "http://radar.weather.gov/ridge/";
                gchar *path  = g_strdup_printf(layers[i].fmt, site);
        for (int i = 0; i < LAYER_COUNT; i++) {
                gchar *base = "http://radar.weather.gov/ridge/";
                gchar *path  = g_strdup_printf(layers[i].fmt, site);
@@ -198,7 +199,7 @@ static void aweather_ridge_expose(AWeatherPlugin *_ridge)
 {
        AWeatherRidge *ridge = AWEATHER_RIDGE(_ridge);
 
 {
        AWeatherRidge *ridge = AWEATHER_RIDGE(_ridge);
 
-       g_message("ridge:expose");
+       g_debug("AWeatherRidge: expose");
        glPushMatrix();
        glEnable(GL_TEXTURE_2D);
        glColor4f(1,1,1,1);
        glPushMatrix();
        glEnable(GL_TEXTURE_2D);
        glColor4f(1,1,1,1);