]> Pileus Git - aweather/blobdiff - src/aweather-gui.c
Update for GisData -> GisHttp
[aweather] / src / aweather-gui.c
index bd2adb1b6be6efe65649177b2f932033c318117b..2e05fc46f048dc31639089edf3f9cf1f44eb88be 100644 (file)
@@ -20,7 +20,7 @@
 #include <gdk/gdkkeysyms.h>
 #include <math.h>
 
-#include <gis/gis.h>
+#include <gis.h>
 
 #include "aweather-gui.h"
 #include "aweather-location.h"
@@ -84,7 +84,6 @@ void on_plugin_toggled(GtkCellRendererToggle *cell, gchar *path_str, AWeatherGui
                aweather_gui_attach_plugin(self, name);
        else
                aweather_gui_deattach_plugin(self, name);
-       gis_prefs_set_boolean_v(self->prefs, name, "enabled", state);
        g_free(name);
 }
 
@@ -178,7 +177,6 @@ void on_offline(GtkToggleAction *action, AWeatherGui *self)
 {
        gboolean value = gtk_toggle_action_get_active(action);
        g_debug("AWeatherGui: on_offline - offline=%d", value);
-       gis_prefs_set_boolean(self->prefs, "gis/offline", value);
        gis_viewer_set_offline(self->viewer, value);
 }
 
@@ -239,6 +237,7 @@ static void prefs_setup(AWeatherGui *self)
                        "Plugin",  rend1, "text",   0, NULL);
        GtkTreeViewColumn *col2  = gtk_tree_view_column_new_with_attributes(
                        "Enabled", rend2, "active", 1, NULL);
+       g_object_set(rend2, "xalign", 0, NULL);
        gtk_tree_view_append_column(tview, col1);
        gtk_tree_view_append_column(tview, col2);
        g_signal_connect(rend2, "toggled", G_CALLBACK(on_plugin_toggled), self);
@@ -342,7 +341,7 @@ static void update_times(AWeatherGui *self, GisViewer *viewer, char *site)
        if (gis_viewer_get_offline(self->viewer)) {
                GList *times = NULL;
                gchar *path = g_build_filename(g_get_user_cache_dir(),
-                               "libgis", "nexrd2", "raw", site, NULL);
+                               "libgis", "nexrad", "level2", site, NULL);
                GDir *dir = g_dir_open(path, 0, NULL);
                if (dir) {
                        const gchar *name;
@@ -354,9 +353,13 @@ static void update_times(AWeatherGui *self, GisViewer *viewer, char *site)
                g_free(path);
                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, "aweather/nexrad_url", NULL);
-               cache_file(base, path, GIS_REFRESH, NULL, update_times_online_cb, self);
+               GisHttp *http = gis_http_new("/nexrad/level2/");
+               gchar *base  = gis_prefs_get_string(self->prefs, "aweather/nexrad_url", NULL);
+               gchar *local = g_strdup_printf("%s/dir.list", site);
+               gchar *uri   = g_strconcat(base, "/", local, NULL);
+               gchar *path  = gis_http_fetch(http, uri, local, GIS_REFRESH, NULL, NULL);
+               update_times_online_cb(path, TRUE, self);
+               gis_http_free(http);
                /* update_times_gtk from update_times_online_cb */
        }
 }
@@ -437,7 +440,7 @@ GObject *aweather_gui_get_object(AWeatherGui *self, const gchar *name)
 }
 void aweather_gui_attach_plugin(AWeatherGui *self, const gchar *name)
 {
-       GisPlugin *plugin = gis_plugins_load(self->plugins, name,
+       GisPlugin *plugin = gis_plugins_enable(self->plugins, name,
                        self->viewer, self->prefs);
        GtkWidget *body = gis_plugin_get_config(plugin);
        if (body) {
@@ -462,7 +465,7 @@ void aweather_gui_deattach_plugin(AWeatherGui *self, const gchar *name)
                if (tab_name && g_str_equal(name, tab_name))
                        gtk_notebook_remove_page(GTK_NOTEBOOK(config), i);
        }
-       gis_plugins_unload(self->plugins, name);
+       gis_plugins_disable(self->plugins, name);
        gtk_widget_queue_draw(GTK_WIDGET(self->viewer));
 }
 
@@ -479,8 +482,8 @@ static void aweather_gui_init(AWeatherGui *self)
        gchar *config   = g_build_filename(g_get_user_config_dir(), PACKAGE, "config.ini", NULL);
        gchar *defaults = g_build_filename(PKGDATADIR, "defaults.ini", NULL);
        self->prefs   = gis_prefs_new(config, defaults);
-       self->plugins = gis_plugins_new(PLUGINSDIR);
-       self->viewer  = gis_opengl_new(self->plugins);
+       self->plugins = gis_plugins_new(PLUGINSDIR, self->prefs);
+       self->viewer  = gis_opengl_new(self->plugins, self->prefs);
        g_free(config);
        g_free(defaults);
 
@@ -501,7 +504,7 @@ static void aweather_gui_init(AWeatherGui *self)
        for (GList *cur = gis_plugins_available(self->plugins); cur; cur = cur->next) {
                gchar *name = cur->data;
                GError *error = NULL;
-               gboolean enabled = gis_prefs_get_boolean_v(self->prefs, cur->data, "enabled", &error);
+               gboolean enabled = gis_prefs_get_boolean_v(self->prefs, "plugins", cur->data, &error);
                if (error && error->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND)
                        enabled = TRUE;
                gtk_list_store_append(self->gtk_plugins, &iter);