Added skeleton for the preferences code

This commit is contained in:
Gergely Polonkai 2013-09-21 21:54:35 +02:00
parent d5011879f9
commit 8313b4c2a6
4 changed files with 64 additions and 6 deletions

View File

@ -16,6 +16,7 @@ astrognome_source_files = \
ag-window.c \ ag-window.c \
ag-chart.c \ ag-chart.c \
ag-settings.c \ ag-settings.c \
ag-preferences.c \
astrognome.c \ astrognome.c \
$(NULL) $(NULL)

View File

@ -2,6 +2,7 @@
#include "ag-app.h" #include "ag-app.h"
#include "ag-window.h" #include "ag-window.h"
#include "ag-chart.h" #include "ag-chart.h"
#include "ag-preferences.h"
#include "config.h" #include "config.h"
#include "astrognome.h" #include "astrognome.h"
@ -65,7 +66,7 @@ new_window_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
static void static void
preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{ {
//ag_preferences_show_dialog(); ag_preferences_show_dialog();
} }
static void static void

43
src/ag-preferences.c Normal file
View File

@ -0,0 +1,43 @@
#include <glib.h>
#include <gtk/gtk.h>
#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;
}
}

13
src/ag-preferences.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef __AG_PREFERENCES_H__
#define __AG_PREFERENCES_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
void ag_preferences_show_dialog(void);
G_END_DECLS
#endif /* __AG_PREFERENCES_H__ */