* Fix all memory leaks
* Pre-load textures and polys in OpenGL
+0.x - Misc
+ * Resume downloads (back to CURL/Soup)
+ * Configuration file
+ * Default site
+ * Keybindings?
+
0.x - Volume scans
* Display iso surfaces of volume scans
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Mon May 25 13:14:23 2009 -->
+<!--Generated with glade3 3.4.5 on Tue May 26 01:20:09 2009 -->
<glade-interface>
<widget class="GtkWindow" id="window">
<child>
<property name="label" translatable="yes">gtk-quit</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
- <signal name="activate" handler="gtk_main_quit"/>
+ <signal name="activate" handler="on_quit"/>
</widget>
</child>
</widget>
G_DEBUG=gc-friendly,resident-modules \
valgrind --leak-check=full \
--leak-resolution=high \
- --num-callers=50 \
+ --num-callers=100 \
--suppressions=gtk.suppression \
./aweather \
2> valgrind.out
{
g_debug("AWeatherGui: dispose");
AWeatherGui *gui = AWEATHER_GUI(gobject);
- g_object_unref(gui->view );
- g_object_unref(gui->builder);
+ if (gui->view) {
+ g_object_unref(gui->view);
+ gui->view = NULL;
+ }
+ if (gui->builder) {
+ /* Reparent to avoid double unrefs */
+ GtkWidget *body = aweather_gui_get_widget(gui, "body");
+ GtkWidget *window = aweather_gui_get_widget(gui, "window");
+ gtk_widget_reparent(body, window);
+ g_object_unref(gui->builder);
+ gui->builder = NULL;
+ }
+ if (gui->plugins) {
+ g_list_foreach(gui->plugins, (GFunc)g_object_unref, NULL);
+ g_list_free(gui->plugins);
+ gui->plugins = NULL;
+ }
+ //for (GList *cur = gui->plugins; cur; cur = cur->next)
+ // g_object_unref(cur->data);
G_OBJECT_CLASS(aweather_gui_parent_class)->dispose(gobject);
}
static void aweather_gui_finalize(GObject *gobject)
{
g_debug("AWeatherGui: finalize");
G_OBJECT_CLASS(aweather_gui_parent_class)->finalize(gobject);
+ gtk_main_quit();
+
}
static void aweather_gui_class_init(AWeatherGuiClass *klass)
{
/*************
* Callbacks *
*************/
+void on_quit(GtkMenuItem *menu, AWeatherGui *gui)
+{
+ gtk_widget_destroy(GTK_WIDGET(gui));
+}
gboolean on_drawing_button_press(GtkWidget *widget, GdkEventButton *event, AWeatherGui *gui)
{
g_debug("AWeatherGui: on_drawing_button_press - Grabbing focus");
}
gboolean on_drawing_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *gui)
{
- g_debug("AWeatherGui: on_drawing_key_press - key=%x, state=%x", event->keyval, event->state);
+ g_debug("AWeatherGui: on_drawing_key_press - key=%x, state=%x",
+ event->keyval, event->state);
AWeatherView *view = aweather_gui_get_view(gui);
double x,y,z;
aweather_view_get_location(view, &x, &y, &z);
- if (event->keyval == GDK_Right) aweather_view_pan(view, z/10, 0, 0);
- else if (event->keyval == GDK_Left) aweather_view_pan(view, -z/10, 0, 0);
- else if (event->keyval == GDK_Up) aweather_view_pan(view, 0, z/10, 0);
- else if (event->keyval == GDK_Down) aweather_view_pan(view, 0, -z/10, 0);
- else if (event->keyval == GDK_minus) aweather_view_zoom(view, 10./9);
- else if (event->keyval == GDK_plus) aweather_view_zoom(view, 9./10);
+ guint kv = event->keyval;
+ if (kv == GDK_Right || kv == GDK_l) aweather_view_pan(view, z/10, 0, 0);
+ else if (kv == GDK_Left || kv == GDK_h) aweather_view_pan(view, -z/10, 0, 0);
+ else if (kv == GDK_Up || kv == GDK_k) aweather_view_pan(view, 0, z/10, 0);
+ else if (kv == GDK_Down || kv == GDK_j) aweather_view_pan(view, 0, -z/10, 0);
+ else if (kv == GDK_minus || kv == GDK_o) aweather_view_zoom(view, 10./9);
+ else if (kv == GDK_plus || kv == GDK_i) aweather_view_zoom(view, 9./10);
return TRUE;
}
gboolean on_gui_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *gui)
{
- g_debug("AWeatherGui: on_gui_key_press - key=%x, state=%x", event->keyval, event->state);
+ g_debug("AWeatherGui: on_gui_key_press - key=%x, state=%x",
+ event->keyval, event->state);
AWeatherView *view = aweather_gui_get_view(gui);
if (event->keyval == GDK_q)
- gtk_main_quit();
+ gtk_widget_destroy(GTK_WIDGET(gui));
else if (event->keyval == GDK_r && event->state & GDK_CONTROL_MASK)
aweather_view_refresh(view);
else if (event->keyval == GDK_Tab || event->keyval == GDK_ISO_Left_Tab) {
void on_about(GtkMenuItem *item, AWeatherGui *gui)
{
+ // TODO: use gtk_widget_hide_on_delete()
GError *error = NULL;
GtkBuilder *builder = gtk_builder_new();
if (!gtk_builder_add_from_file(builder, DATADIR "/aweather/about.xml", &error))
if (!gtk_builder_add_from_file(self->builder, DATADIR "/aweather/main.xml", &error))
g_error("Failed to create gtk builder: %s", error->message);
gtk_builder_connect_signals(self->builder, self);
- g_signal_connect(self, "delete-event", G_CALLBACK(gtk_main_quit), self);
- g_signal_connect(self, "key-press-event", G_CALLBACK(on_gui_key_press), self);
+ g_signal_connect(self, "key-press-event", G_CALLBACK(on_gui_key_press), self);
gtk_widget_reparent(aweather_gui_get_widget(self, "body"), GTK_WIDGET(self));
/* Load components */
}
GtkBuilder *aweather_gui_get_builder(AWeatherGui *gui)
{
+ g_debug("AWeatherGui: get_builder");
g_assert(AWEATHER_IS_GUI(gui));
return gui->builder;
}
GtkWidget *aweather_gui_get_widget(AWeatherGui *gui, const gchar *name)
{
+ g_debug("AWeatherGui: get_widget - name=%s", name);
g_assert(AWEATHER_IS_GUI(gui));
GObject *widget = gtk_builder_get_object(gui->builder, name);
if (!GTK_IS_WIDGET(widget))
/****************
* GObject code *
****************/
-G_DEFINE_TYPE(AWeatherView, aweather_view, G_TYPE_OBJECT);
-
+/* Constants */
enum {
PROP_0,
PROP_TIME,
PROP_SITE,
};
-
enum {
SIG_TIME_CHANGED,
SIG_SITE_CHANGED,
SIG_REFRESH,
NUM_SIGNALS,
};
-
static guint signals[NUM_SIGNALS];
+/* Class/Object init */
+G_DEFINE_TYPE(AWeatherView, aweather_view, G_TYPE_OBJECT);
static void aweather_view_init(AWeatherView *self)
{
g_debug("AWeatherView: init");
self->time = g_strdup("");
self->site = g_strdup("");
}
-
-static GObject *aweather_view_constructor(GType gtype, guint n_properties,
- GObjectConstructParam *properties)
-{
- g_debug("AWeatherView: constructor");
- GObjectClass *parent_class = G_OBJECT_CLASS(aweather_view_parent_class);
- return parent_class->constructor(gtype, n_properties, properties);
-}
-
static void aweather_view_dispose(GObject *gobject)
{
g_debug("AWeatherView: dispose");
/* Drop references to other GObjects */
G_OBJECT_CLASS(aweather_view_parent_class)->dispose(gobject);
}
-
static void aweather_view_finalize(GObject *gobject)
{
g_debug("AWeatherView: finalize");
AWeatherView *self = AWEATHER_VIEW(gobject);
+ g_free(self->time);
g_free(self->site);
G_OBJECT_CLASS(aweather_view_parent_class)->finalize(gobject);
}
-
static void aweather_view_set_property(GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
{
default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
-
static void aweather_view_get_property(GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
{
default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
}
-
static void aweather_view_class_init(AWeatherViewClass *klass)
{
g_debug("AWeatherView: class_init");
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
- gobject_class->constructor = aweather_view_constructor;
gobject_class->dispose = aweather_view_dispose;
gobject_class->finalize = aweather_view_finalize;
gobject_class->get_property = aweather_view_get_property;
g_signal_connect(gui, "map-event", G_CALLBACK(on_map), opt_site);
/* Load plugins */
- aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_example_new(gui)));
- aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_ridge_new(gui)));
- aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_radar_new(gui)));
+ //aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_example_new(gui)));
+ //aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_ridge_new(gui)));
+ //aweather_gui_register_plugin(gui, AWEATHER_PLUGIN(aweather_radar_new(gui)));
gtk_widget_show_all(GTK_WIDGET(gui));
gtk_main();
/****************
* GObject code *
****************/
+/* Plugin init */
static void aweather_example_plugin_init(AWeatherPluginInterface *iface);
static void aweather_example_expose(AWeatherPlugin *_example);
G_DEFINE_TYPE_WITH_CODE(AWeatherExample, aweather_example, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE(AWEATHER_TYPE_PLUGIN,
aweather_example_plugin_init));
-static void aweather_example_class_init(AWeatherExampleClass *klass)
-{
- GObjectClass *object_class = (GObjectClass*)klass;
-}
static void aweather_example_plugin_init(AWeatherPluginInterface *iface)
{
+ g_debug("AWeatherExample: plugin_init");
/* Add methods to the interface */
iface->expose = aweather_example_expose;
}
+/* Class/Object init */
static void aweather_example_init(AWeatherExample *example)
{
+ g_debug("AWeatherExample: init");
/* Set defaults */
example->gui = NULL;
example->button = NULL;
example->rotation = 30.0;
}
+static void aweather_example_dispose(GObject *gobject)
+{
+ g_debug("AWeatherExample: dispose");
+ AWeatherExample *self = AWEATHER_EXAMPLE(gobject);
+ /* Drop references */
+ G_OBJECT_CLASS(aweather_example_parent_class)->dispose(gobject);
+}
+static void aweather_example_finalize(GObject *gobject)
+{
+ g_debug("AWeatherExample: finalize");
+ AWeatherExample *self = AWEATHER_EXAMPLE(gobject);
+ /* Free data */
+ G_OBJECT_CLASS(aweather_example_parent_class)->finalize(gobject);
+
+}
+static void aweather_example_class_init(AWeatherExampleClass *klass)
+{
+ g_debug("AWeatherExample: class_init");
+ GObjectClass *gobject_class = (GObjectClass*)klass;
+ gobject_class->dispose = aweather_example_dispose;
+ gobject_class->finalize = aweather_example_finalize;
+}
/***********
* Helpers *
/****************
* GObject code *
****************/
+/* Plugin init */
static void aweather_radar_plugin_init(AWeatherPluginInterface *iface);
static void _aweather_radar_expose(AWeatherPlugin *_radar);
G_DEFINE_TYPE_WITH_CODE(AWeatherRadar, aweather_radar, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE(AWEATHER_TYPE_PLUGIN,
aweather_radar_plugin_init));
-static void aweather_radar_class_init(AWeatherRadarClass *klass)
-{
- GObjectClass *object_class = (GObjectClass*)klass;
-}
static void aweather_radar_plugin_init(AWeatherPluginInterface *iface)
{
+ g_debug("AWeatherRadar: plugin_init");
/* Add methods to the interface */
iface->expose = _aweather_radar_expose;
}
+/* Class/Object init */
static void aweather_radar_init(AWeatherRadar *radar)
{
+ g_debug("AWeatherRadar: class_init");
/* Set defaults */
radar->gui = NULL;
}
+static void aweather_radar_dispose(GObject *gobject)
+{
+ g_debug("AWeatherRadar: dispose");
+ AWeatherRadar *self = AWEATHER_RADAR(gobject);
+ /* Drop references */
+ G_OBJECT_CLASS(aweather_radar_parent_class)->dispose(gobject);
+}
+static void aweather_radar_finalize(GObject *gobject)
+{
+ g_debug("AWeatherRadar: finalize");
+ AWeatherRadar *self = AWEATHER_RADAR(gobject);
+ /* Free data */
+ G_OBJECT_CLASS(aweather_radar_parent_class)->finalize(gobject);
+
+}
+static void aweather_radar_class_init(AWeatherRadarClass *klass)
+{
+ g_debug("AWeatherRadar: class_init");
+ GObjectClass *gobject_class = (GObjectClass*)klass;
+ gobject_class->dispose = aweather_radar_dispose;
+ gobject_class->finalize = aweather_radar_finalize;
+}
/**************************
* Data loading functions *
/****************
* 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 *