./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 \
--leak-resolution=high \
--num-callers=100 \
--suppressions=gtk.suppression \
- ./aweather \
+ .libs/aweather \
2> valgrind.out
/* 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));
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;
}
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);
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)
}
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);
}
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
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;
* \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);
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 */
#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
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);
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);
{
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));
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))) {
AM_CPPFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS)
AM_LDFLAGS = -module $(GLIB_LIBS) $(GTK_LIBS)
-plugindir = $(libdir)/aweather
+plugindir = $(libdir)/gis
plugin_LTLIBRARIES = \
example.la \
* 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);
{
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);
}
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;
}
GObject parent_instance;
/* instance members */
- GisOpenGL *opengl;
GtkToggleButton *button;
+ guint rotate_id;
float rotation;
+ GisOpenGL *opengl;
};
struct _GisPluginExampleClass {
#include <glib.h>
-#include "aweather-gui.h"
#include "radar.h"
//{0xcc,0xff,0xff,0xff},{0xcc,0xff,0xff,0xff}, {0xcc,0xff,0xff,0xff},
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);
}
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));
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);
}
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;
}
GtkWidget *progress_bar;
GtkWidget *progress_label;
SoupSession *soup;
+ guint time_changed_id;
/* Private data for loading radars */
Radar *cur_radar;
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);
}
}