From 8313b4c2a6a59a45a998d416d2d36b1fe72c0b72 Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Sat, 21 Sep 2013 21:54:35 +0200 Subject: [PATCH] Added skeleton for the preferences code --- src/Makefile.am | 11 ++++++----- src/ag-app.c | 3 ++- src/ag-preferences.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/ag-preferences.h | 13 +++++++++++++ 4 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 src/ag-preferences.c create mode 100644 src/ag-preferences.h 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 d7299f2..926b7a1 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__ */ +