/*************
* Callbacks *
*************/
-gboolean on_gui_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *self)
+G_MODULE_EXPORT gboolean on_gui_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *self)
{
g_debug("AWeatherGui: on_gui_key_press - key=%x, state=%x",
event->keyval, event->state);
return FALSE;
}
-void on_quit(GtkMenuItem *menu, AWeatherGui *self)
+G_MODULE_EXPORT void on_quit(GtkMenuItem *menu, AWeatherGui *self)
{
gtk_widget_destroy(GTK_WIDGET(self));
}
-void on_zoomin(GtkAction *action, AWeatherGui *self)
+G_MODULE_EXPORT void on_zoomin(GtkAction *action, AWeatherGui *self)
{
gis_viewer_zoom(self->viewer, 3./4);
}
-void on_zoomout(GtkAction *action, AWeatherGui *self)
+G_MODULE_EXPORT void on_zoomout(GtkAction *action, AWeatherGui *self)
{
gis_viewer_zoom(self->viewer, 4./3);
}
-void on_refresh(GtkAction *action, AWeatherGui *self)
+G_MODULE_EXPORT void on_refresh(GtkAction *action, AWeatherGui *self)
{
gis_viewer_refresh(self->viewer);
}
-void on_plugin_toggled(GtkCellRendererToggle *cell, gchar *path_str, AWeatherGui *self)
+G_MODULE_EXPORT void on_plugin_toggled(GtkCellRendererToggle *cell, gchar *path_str, AWeatherGui *self)
{
GtkWidget *tview = aweather_gui_get_widget(self, "prefs_plugins_view");
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tview));
g_free(name);
}
-void on_time_changed(AWeatherGui *self)
+G_MODULE_EXPORT void on_time_changed(AWeatherGui *self)
{
g_debug("AWeatherGui: on_time_changed");
struct tm tm = {};
}
/* Prefs callbacks */
-void on_offline(GtkToggleAction *action, AWeatherGui *self)
+G_MODULE_EXPORT void on_offline(GtkToggleAction *action, AWeatherGui *self)
{
gboolean value = gtk_toggle_action_get_active(action);
g_debug("AWeatherGui: on_offline - offline=%d", value);
gis_viewer_set_offline(self->viewer, value);
}
-void on_initial_site_changed(GtkComboBox *combo, AWeatherGui *self)
+G_MODULE_EXPORT void on_initial_site_changed(GtkComboBox *combo, AWeatherGui *self)
{
gchar *code;
GtkTreeIter iter;
g_free(code);
}
-void on_nexrad_url_changed(GtkEntry *entry, AWeatherGui *self)
+G_MODULE_EXPORT void on_nexrad_url_changed(GtkEntry *entry, AWeatherGui *self)
{
const gchar *text = gtk_entry_get_text(entry);
g_debug("AWeatherGui: on_nexrad_url_changed - url=%s", text);
gis_prefs_set_string(self->prefs, "aweather/nexrad_url", text);
}
-int on_log_level_changed(GtkSpinButton *spinner, AWeatherGui *self)
+G_MODULE_EXPORT int on_log_level_changed(GtkSpinButton *spinner, AWeatherGui *self)
{
gint value = gtk_spin_button_get_value_as_int(spinner);
g_debug("AWeatherGui: on_log_level_changed - %p, level=%d", self, value);
/****************
* GObject code *
****************/
-G_DEFINE_TYPE(AWeatherGui, aweather_gui, GTK_TYPE_WINDOW);
-static void aweather_gui_init(AWeatherGui *self)
+static void aweather_gui_parser_finished(GtkBuildable *_self, GtkBuilder *builder)
{
- g_debug("AWeatherGui: init");
+ g_debug("AWeatherGui: parser finished");
+ AWeatherGui *self = AWEATHER_GUI(_self);
+ self->builder = builder;
/* Simple things */
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->prefs);
- self->viewer = gis_opengl_new(self->plugins, self->prefs);
+ self->viewer = GIS_VIEWER(aweather_gui_get_widget(self, "main_viewer"));
+ gis_viewer_setup(self->viewer, self->plugins, self->prefs);
g_free(config);
g_free(defaults);
- /* Setup window */
- self->builder = gtk_builder_new();
- GError *error = NULL;
- if (!gtk_builder_add_from_file(self->builder, PKGDATADIR "/main.ui", &error))
- g_error("Failed to create gtk builder: %s", error->message);
- gtk_widget_reparent(aweather_gui_get_widget(self, "main_body"), GTK_WIDGET(self));
- GtkWidget *paned = aweather_gui_get_widget(self, "main_paned");
- gtk_widget_destroy(gtk_paned_get_child1(GTK_PANED(paned)));
- gtk_paned_pack1(GTK_PANED(paned), GTK_WIDGET(self->viewer), TRUE, FALSE);
- gtk_widget_show_all(GTK_WIDGET(self));
-
/* Plugins */
GtkTreeIter iter;
self->gtk_plugins = GTK_LIST_STORE(aweather_gui_get_object(self, "plugins"));
G_CALLBACK(gtk_toggle_action_set_active),
aweather_gui_get_object(self, "offline"));
}
+static void aweather_gui_buildable_init(GtkBuildableIface *iface)
+{
+ iface->parser_finished = aweather_gui_parser_finished;
+}
+G_DEFINE_TYPE_WITH_CODE(AWeatherGui, aweather_gui, GTK_TYPE_WINDOW,
+ G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE,
+ aweather_gui_buildable_init));
+static void aweather_gui_init(AWeatherGui *self)
+{
+ g_debug("AWeatherGui: init");
+ /* Do all the real work in parser_finished */
+}
static GObject *aweather_gui_constructor(GType gtype, guint n_properties,
GObjectConstructParam *properties)
{
- g_debug("aweather_gui: constructor");
+ g_debug("AWeatherGui: constructor");
GObjectClass *parent_class = G_OBJECT_CLASS(aweather_gui_parent_class);
return parent_class->constructor(gtype, n_properties, properties);
}
{
g_debug("AWeatherGui: finalize");
G_OBJECT_CLASS(aweather_gui_parent_class)->finalize(_self);
- gtk_main_quit();
}
static void aweather_gui_class_init(AWeatherGuiClass *klass)