]> Pileus Git - aweather/commitdiff
bug fixes
authorAndy Spencer <andy753421@gmail.com>
Thu, 6 Aug 2009 03:35:36 +0000 (03:35 +0000)
committerAndy Spencer <andy753421@gmail.com>
Thu, 6 Aug 2009 03:35:36 +0000 (03:35 +0000)
17 files changed:
src/Makefile.am
src/aweather-gui.c
src/gis/Makefile.am
src/gis/gis-data.c
src/gis/gis-data.h
src/gis/gis-opengl.c
src/gis/gis-plugin.c
src/plugins/Makefile.am
src/plugins/example.c
src/plugins/example.h
src/plugins/gis [moved from src/plugins/aweather with 100% similarity]
src/plugins/marching.c [moved from src/marching.c with 100% similarity]
src/plugins/marching.h [moved from src/marching.h with 100% similarity]
src/plugins/radar-colormap.c
src/plugins/radar.c
src/plugins/radar.h
src/plugins/ridge.c

index 18976bc36dac8d84f8eb08932cbe2116f5459888..9b912f511b44c049b9408c4d182ee07d5536a333 100644 (file)
@@ -19,10 +19,10 @@ test: all
        ./aweather -o -d 7 -s KVNX
 
 gdb: all
-       gdb ./aweather
+       gdb .libs/aweather
 
 ddd: all
-       ddd ./aweather
+       ddd .libs/aweather
 
 memcheck:
        G_SLICE=always-malloc                   \
@@ -31,5 +31,5 @@ memcheck:
                 --leak-resolution=high         \
                 --num-callers=100              \
                 --suppressions=gtk.suppression \
-                ./aweather                     \
+                .libs/aweather                 \
        2> valgrind.out
index 2720a00dca83a68947c4c097fff6e804762abf5a..480d026be5f1c6be4223389b54a88de39dda149a 100644 (file)
@@ -55,7 +55,6 @@ static void aweather_gui_init(AWeatherGui *self)
 
        /* GIS things */
        GtkWidget *drawing = aweather_gui_get_widget(self, "drawing");
-       g_message("drawing = %p", drawing);
        self->opengl = gis_opengl_new(self->world, self->view, GTK_DRAWING_AREA(drawing));
        self->opengl->plugins = self->plugins;
        //gtk_widget_show_all(GTK_WIDGET(self));
@@ -425,10 +424,8 @@ static void update_times_gtk(AWeatherGui *self, GList *times)
        GtkTreeIter iter;
        times = g_list_reverse(times);
        for (GList *cur = times; cur; cur = cur->next) {
-               g_message("trying time %s", (gchar*)cur->data);
                if (g_regex_match(regex, cur->data, 0, &info)) {
                        gchar *time = g_match_info_fetch(info, 1);
-                       g_message("adding time %s", (gchar*)cur->data);
                        gtk_list_store_insert(lstore, &iter, 0);
                        gtk_list_store_set(lstore, &iter, 0, time, -1);
                        last_time = time;
@@ -460,6 +457,7 @@ static void update_times_online_cb(char *path, gboolean updated, gpointer _self)
 }
 static void update_times(AWeatherGui *self, GisView *view, char *site)
 {
+       g_debug("AWeatherGui: update_times - site=%s", site);
        if (gis_world_get_offline(self->world)) {
                GList *times = NULL;
                gchar *path = g_build_filename(g_get_user_cache_dir(), PACKAGE, "nexrd2", "raw", site, NULL);
@@ -475,15 +473,15 @@ static void update_times(AWeatherGui *self, GisView *view, char *site)
                update_times_gtk(self, times);
        } else {
                gchar *path = g_strdup_printf("nexrd2/raw/%s/dir.list", site);
-               char *base = gis_prefs_get_string(self->prefs, "general/nexrad_url");
-               cache_file(base, path, AWEATHER_REFRESH, NULL, update_times_online_cb, self);
+               char *base = gis_prefs_get_string(self->prefs, "aweather/nexrad_url");
+               cache_file(base, path, GIS_REFRESH, NULL, update_times_online_cb, self);
                /* update_times_gtk from update_times_online_cb */
        }
 }
 static void on_gis_site_changed(GisView *view, char *site, gpointer _self)
 {
        AWeatherGui *self = AWEATHER_GUI(_self);
-       g_debug("GisPluginRadar: on_site_changed - Loading wsr88d list for %s", site);
+       g_debug("AWeatherGui: on_site_changed - Loading wsr88d list for %s", site);
        update_times(self, view, site);
 }
 static void on_gis_refresh(GisWorld *world, gpointer _self)
@@ -549,5 +547,14 @@ void aweather_gui_attach_plugin(AWeatherGui *self, const gchar *name)
 }
 void aweather_gui_deattach_plugin(AWeatherGui *self, const gchar *name)
 {
+       GtkWidget *config = aweather_gui_get_widget(self, "tabs");
+       guint n_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(config));
+       for (int i = 0; i < n_pages; i++) {
+               GtkWidget *body = gtk_notebook_get_nth_page(GTK_NOTEBOOK(config), i);
+               GtkWidget *tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(config), body);
+               const gchar *tab_name = gtk_label_get_text(GTK_LABEL(tab));
+               if (tab_name && g_str_equal(name, tab_name))
+                       gtk_notebook_remove_page(GTK_NOTEBOOK(config), i);
+       }
        gis_plugins_unload(self->plugins, name);
 }
index 97d8a39ec72b1b583a5b6dbbed20a151f743dc9d..786be0073513d76f8f008d5ce51d324cb0ad7c99 100644 (file)
@@ -19,7 +19,7 @@ libgis_la_SOURCES = \
        gis-plugin.c  gis-plugin.h \
        gis-data.c    gis-data.h   \
        gis-marshal.c gis-marshal.h
-libgis_la_CPPFLAGS = -DPLUGINDIR="\"$(libdir)/aweather\"" $(SOUP_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS)
+libgis_la_CPPFLAGS = -DPLUGINDIR="\"$(libdir)/gis\"" $(SOUP_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS)
 libgis_la_LIBADD = $(SOUP_LIBS) $(GLIB_LIBS) $(GTK_LIBS)
 
 MAINTAINERCLEANFILES = Makefile.in
index 7c9f2c9191a1dd942ce558ca539fda125380c700..56c39b4326b7b41fd9e5ba1f5fa1c8c36f3af63c 100644 (file)
@@ -26,8 +26,8 @@ typedef struct {
        gchar *uri;
        gchar *local;
        FILE  *fp;
-       AWeatherCacheDoneCallback  user_done_cb;
-       AWeatherCacheChunkCallback user_chunk_cb;
+       GisDataCacheDoneCallback  user_done_cb;
+       GisDataCacheChunkCallback user_chunk_cb;
        gpointer user_data;
 } cache_file_end_t;
 
@@ -111,12 +111,20 @@ static SoupSession *do_cache(cache_file_end_t *info, gboolean truncate, gchar *r
  * \param  path  Path to the Ridge file, starting after /ridge/
  * \return The local path to the cached image
  */
-SoupSession *cache_file(char *base, char *path, AWeatherCacheType update,
-               AWeatherCacheChunkCallback user_chunk_cb,
-               AWeatherCacheDoneCallback user_done_cb,
+SoupSession *cache_file(char *base, char *path, GisDataCacheType update,
+               GisDataCacheChunkCallback user_chunk_cb,
+               GisDataCacheDoneCallback user_done_cb,
                gpointer user_data)
 {
-
+       g_debug("GisData: cache_file - base=%s, path=%s", base, path);
+       if (base == NULL) {
+               g_warning("GisData: cache_file - base is null");
+               return NULL;
+       }
+       if (path == NULL) {
+               g_warning("GisData: cache_file - base is null");
+               return NULL;
+       }
        cache_file_end_t *info = g_malloc0(sizeof(cache_file_end_t));
        info->uri           = g_strconcat(base, path, NULL);
        info->local         = g_build_filename(g_get_user_cache_dir(), PACKAGE, path, NULL);
@@ -125,13 +133,13 @@ SoupSession *cache_file(char *base, char *path, AWeatherCacheType update,
        info->user_done_cb  = user_done_cb;
        info->user_data     = user_data;
 
-       if (update == AWEATHER_REFRESH)
+       if (update == GIS_REFRESH)
                return do_cache(info, TRUE, "cache forced");
 
-       if (update == AWEATHER_UPDATE)
+       if (update == GIS_UPDATE)
                return do_cache(info, FALSE, "attempting updating");
 
-       if (update == AWEATHER_ONCE && !g_file_test(info->local, G_FILE_TEST_EXISTS))
+       if (update == GIS_ONCE && !g_file_test(info->local, G_FILE_TEST_EXISTS))
                return do_cache(info, TRUE, "local does not exist");
 
        /* No nead to cache, run the callback now and clean up */
index f08f9365c335125abfa773eb29df70a1217cfbe4..5fe9067dbb9dc6be509e40a55ef197f995fbcae0 100644 (file)
 #include <libsoup/soup.h>
 
 typedef enum {
-       AWEATHER_ONCE,    // Cache the file if it does not exist
-       AWEATHER_UPDATE,  // Append additional data to cached copy (resume)
-       AWEATHER_REFRESH, // Delete existing file and cache a new copy
-} AWeatherCacheType;
+       GIS_ONCE,    // Cache the file if it does not exist
+       GIS_UPDATE,  // Append additional data to cached copy (resume)
+       GIS_REFRESH, // Delete existing file and cache a new copy
+} GisDataCacheType;
 
-typedef void (*AWeatherCacheDoneCallback)(gchar *file, gboolean updated,
+typedef void (*GisDataCacheDoneCallback)(gchar *file, gboolean updated,
                gpointer user_data);
 
-typedef void (*AWeatherCacheChunkCallback)(gchar *file, goffset cur,
+typedef void (*GisDataCacheChunkCallback)(gchar *file, goffset cur,
                goffset total, gpointer user_data);
 
-SoupSession *cache_file(char *base, char *path, AWeatherCacheType update,
-               AWeatherCacheChunkCallback user_chunk_cb,
-               AWeatherCacheDoneCallback user_done_cb,
+SoupSession *cache_file(char *base, char *path, GisDataCacheType update,
+               GisDataCacheChunkCallback user_chunk_cb,
+               GisDataCacheDoneCallback user_done_cb,
                gpointer user_data);
 
 #endif
index acf12eb0238dc9058399ba586408840159f63f50..bdcaf404bf0c59da1ce6a96cb154c1dc3d757fc7 100644 (file)
@@ -137,8 +137,8 @@ gboolean on_configure(GtkWidget *drawing, GdkEventConfigure *event, GisOpenGL *s
        gis_view_get_location(self->view, &x, &y, &z);
 
        /* Window is at 500 m from camera */
-       double width  = drawing->allocation.width;
-       double height = drawing->allocation.height;
+       double width  = GTK_WIDGET(self->drawing)->allocation.width;
+       double height = GTK_WIDGET(self->drawing)->allocation.height;
 
        glViewport(0, 0, width, height);
 
@@ -198,7 +198,6 @@ GisOpenGL *gis_opengl_new(GisWorld *world, GisView *view, GtkDrawingArea *drawin
        self->world   = world;
        self->view    = view;
        self->drawing = drawing;
-       g_message("drawing = %p", drawing);
        g_object_ref(world);
        g_object_ref(view);
        g_object_ref(drawing);
@@ -235,7 +234,6 @@ void gis_opengl_begin(GisOpenGL *self)
 {
        g_assert(GIS_IS_OPENGL(self));
 
-       g_message("drawing = %p", self->drawing);
        GdkGLContext   *glcontext  = gtk_widget_get_gl_context(GTK_WIDGET(self->drawing));
        GdkGLDrawable  *gldrawable = gtk_widget_get_gl_drawable(GTK_WIDGET(self->drawing));
 
index e15c53c2b42fc3add42abb60db38c25c82de095f..6888b484d8dba073cd1cb2fd8577cab6843ccf44 100644 (file)
@@ -82,6 +82,8 @@ void gis_plugins_free(GisPlugins *self)
 GList *gis_plugins_available()
 {
        GDir *dir = g_dir_open(PLUGINDIR, 0, NULL);
+       if (dir == NULL)
+               return NULL;
        GList *list = NULL;
        const gchar *name;
        while ((name = g_dir_read_name(dir))) {
index 7a0c4be29e1c1993f72ca9d9cf2afc096ccb36db..d831149ebe2df37f39703aef9fa93ba5e18b5bcd 100644 (file)
@@ -2,7 +2,7 @@ AM_CFLAGS   = -Wall -Werror -Wno-unused --std=gnu99  -I../
 AM_CPPFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS)
 AM_LDFLAGS  = -module $(GLIB_LIBS) $(GTK_LIBS)
 
-plugindir = $(libdir)/aweather
+plugindir = $(libdir)/gis
 
 plugin_LTLIBRARIES = \
        example.la \
index 3930fb5915a8cd285700f1d961840cd5ae79f6c9..01ef9cad5f11a9647723eae9d8bc382041492b97 100644 (file)
@@ -28,6 +28,7 @@
  * GObject code *
  ****************/
 /* Plugin init */
+static gboolean rotate(gpointer _self);
 static void gis_plugin_example_plugin_init(GisPluginInterface *iface);
 static void gis_plugin_example_expose(GisPlugin *_self);
 static GtkWidget *gis_plugin_example_get_config(GisPlugin *_self);
@@ -46,14 +47,16 @@ static void gis_plugin_example_init(GisPluginExample *self)
 {
        g_debug("GisPluginExample: init");
        /* Set defaults */
-       self->opengl   = NULL;
-       self->button   = NULL;
-       self->rotation = 30.0;
+       self->button    = GTK_TOGGLE_BUTTON(gtk_toggle_button_new_with_label("Rotate"));
+       self->rotate_id = g_timeout_add(1000/60, rotate, self);
+       self->rotation  = 30.0;
+       self->opengl    = NULL;
 }
 static void gis_plugin_example_dispose(GObject *gobject)
 {
        g_debug("GisPluginExample: dispose");
        GisPluginExample *self = GIS_PLUGIN_EXAMPLE(gobject);
+       g_source_remove(self->rotate_id);
        /* Drop references */
        G_OBJECT_CLASS(gis_plugin_example_parent_class)->dispose(gobject);
 }
@@ -94,10 +97,6 @@ GisPluginExample *gis_plugin_example_new(GisWorld *world, GisView *view, GisOpen
        g_debug("GisPluginExample: new");
        GisPluginExample *self = g_object_new(GIS_TYPE_PLUGIN_EXAMPLE, NULL);
        self->opengl = opengl;
-       self->button = GTK_TOGGLE_BUTTON(gtk_toggle_button_new_with_label("Rotate"));
-
-       /* Set up OpenGL Stuff */
-       g_timeout_add(1000/60, rotate, self);
 
        return self;
 }
index e9a2eddf6e409dcb3432eb963c778e1d91cd18f1..039d3bb19a2eca872c60005c29489553efd36fe1 100644 (file)
@@ -34,9 +34,10 @@ struct _GisPluginExample {
        GObject parent_instance;
 
        /* instance members */
-       GisOpenGL       *opengl;
        GtkToggleButton *button;
+       guint            rotate_id;
        float            rotation;
+       GisOpenGL       *opengl;
 };
 
 struct _GisPluginExampleClass {
similarity index 100%
rename from src/plugins/aweather
rename to src/plugins/gis
similarity index 100%
rename from src/marching.c
rename to src/plugins/marching.c
similarity index 100%
rename from src/marching.h
rename to src/plugins/marching.h
index 24f601557157a47e831b6b7a8d516bb7b3501788..03b2f32816ae1ff58f509d438f80f534995f3078 100644 (file)
@@ -1,5 +1,4 @@
 #include <glib.h>
-#include "aweather-gui.h"
 #include "radar.h"
 
          //{0xcc,0xff,0xff,0xff},{0xcc,0xff,0xff,0xff}, {0xcc,0xff,0xff,0xff},
index 107ccf2d297f127ad9ffb6dbc1762b240253e2f2..c91215100c70ab15f2ec40217e3caa5ebc3c6896 100644 (file)
@@ -47,18 +47,23 @@ static void gis_plugin_radar_plugin_init(GisPluginInterface *iface)
        iface->get_config = gis_plugin_radar_get_config;
 }
 /* Class/Object init */
-static void gis_plugin_radar_init(GisPluginRadar *radar)
+static void gis_plugin_radar_init(GisPluginRadar *self)
 {
        g_debug("GisPluginRadar: class_init");
        /* Set defaults */
-       radar->soup          = NULL;
-       radar->cur_triangles = NULL;
-       radar->cur_num_triangles = 0;
+       self->soup          = NULL;
+       self->cur_triangles = NULL;
+       self->cur_num_triangles = 0;
+
+       self->config_body = gtk_alignment_new(0, 0, 1, 1);
+       gtk_container_set_border_width(GTK_CONTAINER(self->config_body), 5);
+       gtk_container_add(GTK_CONTAINER(self->config_body), gtk_label_new("No radar loaded"));
 }
 static void gis_plugin_radar_dispose(GObject *gobject)
 {
        g_debug("GisPluginRadar: dispose");
        GisPluginRadar *self = GIS_PLUGIN_RADAR(gobject);
+       g_signal_handler_disconnect(self->view, self->time_changed_id);
        /* Drop references */
        G_OBJECT_CLASS(gis_plugin_radar_parent_class)->dispose(gobject);
 }
@@ -389,8 +394,8 @@ static void cache_chunk_cb(char *path, goffset cur, goffset total, gpointer _sel
        GisPluginRadar *self = GIS_PLUGIN_RADAR(_self);
        double percent = (double)cur/total;
 
-       g_message("GisPluginRadar: cache_chunk_cb - %lld/%lld = %.2f%%",
-                       cur, total, percent*100);
+       //g_message("GisPluginRadar: cache_chunk_cb - %lld/%lld = %.2f%%",
+       //              cur, total, percent*100);
 
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(self->progress_bar), MIN(percent, 1.0));
 
@@ -480,12 +485,12 @@ static void on_time_changed(GisView *view, const char *time, gpointer _self)
                soup_session_abort(self->soup);
                self->soup = NULL;
        }
-       gchar *base = gis_prefs_get_string(self->prefs, "general/nexrad_url");
+       gchar *base = gis_prefs_get_string(self->prefs, "aweather/nexrad_url");
        if (gis_world_get_offline(self->world)) 
-               self->soup = cache_file(base, path, AWEATHER_ONCE,
+               self->soup = cache_file(base, path, GIS_ONCE,
                                cache_chunk_cb, cache_done_cb, self);
        else 
-               self->soup = cache_file(base, path, AWEATHER_UPDATE,
+               self->soup = cache_file(base, path, GIS_UPDATE,
                                cache_chunk_cb, cache_done_cb, self);
        g_free(path);
 }
@@ -502,14 +507,8 @@ GisPluginRadar *gis_plugin_radar_new(GisWorld *world, GisView *view, GisOpenGL *
        self->view   = view;
        self->opengl = opengl;
        self->prefs  = prefs;
-
-       self->config_body = gtk_alignment_new(0, 0, 1, 1);
-       gtk_container_set_border_width(GTK_CONTAINER(self->config_body), 5);
-       gtk_container_add(GTK_CONTAINER(self->config_body), gtk_label_new("No radar loaded"));
-
-       /* Set up OpenGL Stuff */
-       g_signal_connect(view,  "time-changed", G_CALLBACK(on_time_changed), self);
-
+       self->time_changed_id = g_signal_connect(view, "time-changed",
+                       G_CALLBACK(on_time_changed), self);
        return self;
 }
 
index 95367b47c3c12f804155b2b47ac9a21f1e983868..c4b74beab4c85b469a68638788b07f118fa4ad13 100644 (file)
@@ -55,6 +55,7 @@ struct _GisPluginRadar {
        GtkWidget   *progress_bar;
        GtkWidget   *progress_label;
        SoupSession *soup;
+       guint        time_changed_id;
 
        /* Private data for loading radars */
        Radar       *cur_radar;
index 2250a6991a1484ab543fb7d3b2eb8fcb7a97ad15..a25bd59b1a94368037754f27e1b4d44d3df9727c 100644 (file)
@@ -179,8 +179,7 @@ static void on_site_changed(GisView *view, gchar *site, GisPluginRidge *self)
                cached_t *udata = g_malloc(sizeof(cached_t));
                udata->self  = self;
                udata->layer = &layers[i];
-               cache_file(base, path, AWEATHER_ONCE, NULL, cached_cb, udata);
-               //cache_file(base, path, AWEATHER_UPDATE, cached_cb, udata);
+               cache_file(base, path, GIS_ONCE, NULL, cached_cb, udata);
                g_free(path);
        }
 }