diff --git a/src/Makefile.am b/src/Makefile.am index 91dcdc2..0fcff41 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,11 +12,12 @@ BUILT_SOURCES = \ $(NULL) astrognome_source_files = \ - ag-app.c \ - ag-window.c \ - ag-chart.c \ - ag-settings.c \ - astrognome.c \ + ag-app.c \ + ag-window.c \ + ag-chart.c \ + ag-settings.c \ + ag-preferences.c \ + astrognome.c \ $(NULL) EXTRA_DIST = \ diff --git a/src/ag-app.c b/src/ag-app.c index e050c5b..6347c8f 100644 --- a/src/ag-app.c +++ b/src/ag-app.c @@ -2,6 +2,7 @@ #include "ag-app.h" #include "ag-window.h" #include "ag-chart.h" +#include "ag-preferences.h" #include "config.h" #include "astrognome.h" @@ -65,7 +66,7 @@ new_window_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) static void preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) { - //ag_preferences_show_dialog(); + ag_preferences_show_dialog(); } static void diff --git a/src/ag-preferences.c b/src/ag-preferences.c new file mode 100644 index 0000000..7a80a77 --- /dev/null +++ b/src/ag-preferences.c @@ -0,0 +1,43 @@ +#include +#include + +#include "ag-settings.h" + +typedef struct { + GtkWidget *dialog; + AgSettings *settings; +} AgPreferences; + +static AgPreferences *prefs; + +static void +ag_preferences_init(void) +{ + GApplication *app; + + if (prefs) { + return; + } + + if ((app = g_application_get_default()) == NULL) { + g_warning("Cannot launch preferences: No default application found"); + + return; + } + + prefs = g_new0(AgPreferences, 1); + prefs->settings = ag_settings_get(); +} + +void +ag_preferences_show_dialog(void) +{ + ag_preferences_init(); + + if (prefs->dialog != NULL) { + gtk_window_present(GTK_WINDOW(prefs->dialog)); + + return; + } +} + diff --git a/src/ag-preferences.h b/src/ag-preferences.h new file mode 100644 index 0000000..adfd3ab --- /dev/null +++ b/src/ag-preferences.h @@ -0,0 +1,13 @@ +#ifndef __AG_PREFERENCES_H__ +#define __AG_PREFERENCES_H__ + +#include + +G_BEGIN_DECLS + +void ag_preferences_show_dialog(void); + +G_END_DECLS + +#endif /* __AG_PREFERENCES_H__ */ +