X-Git-Url: http://pileus.org/git/?p=grits;a=blobdiff_plain;f=src%2Fplugin-ridge.c;h=75927d93ed8f72253f2858370cb4b761cc225757;hp=646878c834d4d303da5ea5c272bc775ae0fc0490;hb=1ac2b7c2d9465293d168c33555a43862320b5c04;hpb=40b17f742041c317915326c6f5ea6d92397c7363 diff --git a/src/plugin-ridge.c b/src/plugin-ridge.c index 646878c..75927d9 100644 --- a/src/plugin-ridge.c +++ b/src/plugin-ridge.c @@ -29,25 +29,47 @@ /**************** * GObject code * ****************/ +/* Plugin init */ static void aweather_ridge_plugin_init(AWeatherPluginInterface *iface); static void aweather_ridge_expose(AWeatherPlugin *_ridge); G_DEFINE_TYPE_WITH_CODE(AWeatherRidge, aweather_ridge, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(AWEATHER_TYPE_PLUGIN, aweather_ridge_plugin_init)); -static void aweather_ridge_class_init(AWeatherRidgeClass *klass) -{ - GObjectClass *object_class = (GObjectClass*)klass; -} static void aweather_ridge_plugin_init(AWeatherPluginInterface *iface) { + g_debug("AWeatherRidge: plugin_init"); /* Add methods to the interface */ iface->expose = aweather_ridge_expose; } +/* Class/Object init */ static void aweather_ridge_init(AWeatherRidge *ridge) { + g_debug("AWeatherRidge: init"); /* Set defaults */ ridge->gui = NULL; } +static void aweather_ridge_dispose(GObject *gobject) +{ + g_debug("AWeatherRidge: dispose"); + AWeatherRidge *self = AWEATHER_RIDGE(gobject); + /* Drop references */ + G_OBJECT_CLASS(aweather_ridge_parent_class)->dispose(gobject); +} +static void aweather_ridge_finalize(GObject *gobject) +{ + g_debug("AWeatherRidge: finalize"); + AWeatherRidge *self = AWEATHER_RIDGE(gobject); + /* Free data */ + G_OBJECT_CLASS(aweather_ridge_parent_class)->finalize(gobject); + +} +static void aweather_ridge_class_init(AWeatherRidgeClass *klass) +{ + g_debug("AWeatherRidge: class_init"); + GObjectClass *gobject_class = (GObjectClass*)klass; + gobject_class->dispose = aweather_ridge_dispose; + gobject_class->finalize = aweather_ridge_finalize; +} /********************* * Overlay constants * @@ -91,9 +113,12 @@ void load_texture(AWeatherRidge *self, layer_t *layer, gchar *filename) aweather_gui_gl_begin(self->gui); /* Load image */ - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, NULL); - if (!pixbuf) + GError *error = NULL; + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, &error); + if (!pixbuf || error) { g_warning("Failed to load texture: %s", filename); + return; + } guchar *pixels = gdk_pixbuf_get_pixels(pixbuf); int width = gdk_pixbuf_get_width(pixbuf); int height = gdk_pixbuf_get_height(pixbuf); @@ -148,11 +173,12 @@ static void on_site_changed(AWeatherView *view, gchar *site, AWeatherRidge *self 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); + gchar *path = g_strdup_printf(layers[i].fmt, site+1); cached_t *udata = g_malloc(sizeof(cached_t)); udata->self = self; udata->layer = &layers[i]; - cache_file(base, path, AWEATHER_NEVER, cached_cb, udata); + cache_file(base, path, AWEATHER_ONCE, NULL, cached_cb, udata); + //cache_file(base, path, AWEATHER_UPDATE, cached_cb, udata); g_free(path); } }