From 84a4dd59a9a7412d51bb2a29fbef4c76e1f4875f Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Sun, 5 Nov 2017 17:20:16 +0000 Subject: [PATCH] frontend: Start skeleton for a proper GObject derived LsiSettingsWindow We can't properly track state within a big ugly main() function, so let's start breaking it up into a proper object. Signed-off-by: Ikey Doherty --- src/frontend/main-window.c | 81 ++++++++++++++++++++++++++++++++++++++ src/frontend/main-window.h | 49 +++++++++++++++++++++++ src/frontend/meson.build | 1 + 3 files changed, 131 insertions(+) create mode 100644 src/frontend/main-window.c create mode 100644 src/frontend/main-window.h diff --git a/src/frontend/main-window.c b/src/frontend/main-window.c new file mode 100644 index 0000000..0f8851e --- /dev/null +++ b/src/frontend/main-window.c @@ -0,0 +1,81 @@ +/* + * This file is part of linux-steam-integration. + * + * Copyright © 2016-2017 Ikey Doherty + * + * linux-steam-integration is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + */ + +#define _GNU_SOURCE + +#include "main-window.h" + +struct _LsiSettingsWindow { + GtkWindow parent; + int __reserved1; +}; + +struct _LsiSettingsWindowClass { + GtkWindowClass parent_class; +}; + +G_DEFINE_TYPE(LsiSettingsWindow, lsi_settings_window, GTK_TYPE_WINDOW) + +/** + * lsi_settings_window_new: + * + * Construct a new LsiSettingsWindow object + */ +GtkWidget *lsi_settings_window_new() +{ + return g_object_new(LSI_TYPE_SETTINGS_WINDOW, "type", GTK_WINDOW_TOPLEVEL, NULL); +} + +/** + * lsi_settings_window_dispose: + * + * Clean up a LsiSettingsWindow instance + */ +static void lsi_settings_window_dispose(GObject *obj) +{ + G_OBJECT_CLASS(lsi_settings_window_parent_class)->dispose(obj); +} + +/** + * lsi_settings_window_class_init: + * + * Handle class initialisation + */ +static void lsi_settings_window_class_init(LsiSettingsWindowClass *klazz) +{ + GObjectClass *obj_class = G_OBJECT_CLASS(klazz); + + /* gobject vtable hookup */ + obj_class->dispose = lsi_settings_window_dispose; +} + +/** + * lsi_settings_window_init: + * + * Handle construction of the LsiSettingsWindow + */ +static void lsi_settings_window_init(LsiSettingsWindow *self) +{ + /* TODO: Just about anything */ +} + +/* + * Editor modelines - https://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 8 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=8 tabstop=8 expandtab: + * :indentSize=8:tabSize=8:noTabs=true: + */ diff --git a/src/frontend/main-window.h b/src/frontend/main-window.h new file mode 100644 index 0000000..fff6185 --- /dev/null +++ b/src/frontend/main-window.h @@ -0,0 +1,49 @@ +/* + * This file is part of linux-steam-integration. + * + * Copyright © 2016-2017 Ikey Doherty + * + * linux-steam-integration is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + */ + +#pragma once + +#include +#include + +G_BEGIN_DECLS + +typedef struct _LsiSettingsWindow LsiSettingsWindow; +typedef struct _LsiSettingsWindowClass LsiSettingsWindowClass; + +#define LSI_TYPE_SETTINGS_WINDOW lsi_settings_window_get_type() +#define LSI_SETTINGS_WINDOW(o) \ + (G_TYPE_CHECK_INSTANCE_CAST((o), LSI_TYPE_SETTINGS_WINDOW, LsiSettingsWindow)) +#define LSI_IS_SETTINGS_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), LSI_TYPE_SETTINGS_WINDOW)) +#define LSI_SETTINGS_WINDOW_CLASS(o) \ + (G_TYPE_CHECK_CLASS_CAST((o), LSI_TYPE_SETTINGS_WINDOW, LsiSettingsWindowClass)) +#define LSI_IS_SETTINGS_WINDOW_CLASS(o) (G_TYPE_CHECK_CLASS_TYPE((o), LSI_TYPE_SETTINGS_WINDOW)) +#define LSI_SETTINGS_WINDOW_GET_CLASS(o) \ + (G_TYPE_INSTANCE_GET_CLASS((o), LSI_TYPE_SETTINGS_WINDOW, LsiSettingsWindowClass)) + +GtkWidget *lsi_settings_window_new(void); + +GType lsi_settings_window_get_type(void); + +G_END_DECLS + +/* + * Editor modelines - https://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 8 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=8 tabstop=8 expandtab: + * :indentSize=8:tabSize=8:noTabs=true: + */ diff --git a/src/frontend/meson.build b/src/frontend/meson.build index b29b296..83c9d74 100644 --- a/src/frontend/meson.build +++ b/src/frontend/meson.build @@ -3,6 +3,7 @@ if with_frontend == true frontend_sources = [ 'main.c', + 'main-window.c', ] frontend = executable(