aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2023-08-07 13:40:50 -0400
committerAndrew Lee <alee14498@protonmail.com>2023-08-07 13:40:50 -0400
commitd5f1abb9c84ef7b8d479e2b453947373b24a7306 (patch)
tree5c8643196f34ff8dfa008adbcac007e4b602d405 /src
downloadErable-d5f1abb9c84ef7b8d479e2b453947373b24a7306.tar.gz
Erable-d5f1abb9c84ef7b8d479e2b453947373b24a7306.tar.bz2
Erable-d5f1abb9c84ef7b8d479e2b453947373b24a7306.zip
Initial commitHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/erable-application.c120
-rw-r--r--src/erable-application.h34
-rw-r--r--src/erable-window.c52
-rw-r--r--src/erable-window.h31
-rw-r--r--src/erable-window.ui111
-rw-r--r--src/erable.gresource.xml7
-rw-r--r--src/gtk/help-overlay.ui29
-rw-r--r--src/main.c42
-rw-r--r--src/meson.build20
9 files changed, 446 insertions, 0 deletions
diff --git a/src/erable-application.c b/src/erable-application.c
new file mode 100644
index 0000000..b13583a
--- /dev/null
+++ b/src/erable-application.c
@@ -0,0 +1,120 @@
+/* erable-application.c
+ *
+ * Copyright 2023 Andrew Lee
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include "config.h"
+
+#include "erable-application.h"
+#include "erable-window.h"
+
+struct _ErableApplication
+{
+ AdwApplication parent_instance;
+};
+
+G_DEFINE_TYPE (ErableApplication, erable_application, ADW_TYPE_APPLICATION)
+
+ErableApplication *
+erable_application_new (const char *application_id,
+ GApplicationFlags flags)
+{
+ g_return_val_if_fail (application_id != NULL, NULL);
+
+ return g_object_new (ERABLE_TYPE_APPLICATION,
+ "application-id", application_id,
+ "flags", flags,
+ NULL);
+}
+
+static void
+erable_application_activate (GApplication *app)
+{
+ GtkWindow *window;
+
+ g_assert (ERABLE_IS_APPLICATION (app));
+
+ window = gtk_application_get_active_window (GTK_APPLICATION (app));
+
+ if (window == NULL)
+ window = g_object_new (ERABLE_TYPE_WINDOW,
+ "application", app,
+ NULL);
+
+ gtk_window_present (window);
+}
+
+static void
+erable_application_class_init (ErableApplicationClass *klass)
+{
+ GApplicationClass *app_class = G_APPLICATION_CLASS (klass);
+
+ app_class->activate = erable_application_activate;
+}
+
+static void
+erable_application_about_action (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ static const char *developers[] = {"Andrew Lee", NULL};
+ ErableApplication *self = user_data;
+ GtkWindow *window = NULL;
+
+ g_assert (ERABLE_IS_APPLICATION (self));
+
+ window = gtk_application_get_active_window (GTK_APPLICATION (self));
+
+ adw_show_about_window (window,
+ "application-name", "Erable",
+ "application-icon", "me.alee14.erable",
+ "developer-name", "Andrew Lee",
+ "version", "0.1.0",
+ "developers", developers,
+ "copyright", "© 2023 Andrew Lee\n\nThis application comes with absolutely no warranty. See the GNU General Public License, version 3 or later for details.",
+ NULL);
+}
+
+static void
+erable_application_quit_action (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ ErableApplication *self = user_data;
+
+ g_assert (ERABLE_IS_APPLICATION (self));
+
+ g_application_quit (G_APPLICATION (self));
+}
+
+static const GActionEntry app_actions[] = {
+ { "quit", erable_application_quit_action },
+ { "about", erable_application_about_action },
+};
+
+static void
+erable_application_init (ErableApplication *self)
+{
+ g_action_map_add_action_entries (G_ACTION_MAP (self),
+ app_actions,
+ G_N_ELEMENTS (app_actions),
+ self);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (self),
+ "app.quit",
+ (const char *[]) { "<primary>q", NULL });
+}
diff --git a/src/erable-application.h b/src/erable-application.h
new file mode 100644
index 0000000..8be0fa7
--- /dev/null
+++ b/src/erable-application.h
@@ -0,0 +1,34 @@
+/* erable-application.h
+ *
+ * Copyright 2023 Andrew Lee
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <adwaita.h>
+
+G_BEGIN_DECLS
+
+#define ERABLE_TYPE_APPLICATION (erable_application_get_type())
+
+G_DECLARE_FINAL_TYPE (ErableApplication, erable_application, ERABLE, APPLICATION, AdwApplication)
+
+ErableApplication *erable_application_new (const char *application_id,
+ GApplicationFlags flags);
+
+G_END_DECLS
diff --git a/src/erable-window.c b/src/erable-window.c
new file mode 100644
index 0000000..9ff80f2
--- /dev/null
+++ b/src/erable-window.c
@@ -0,0 +1,52 @@
+/* erable-window.c
+ *
+ * Copyright 2023 Andrew Lee
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include "config.h"
+
+#include "erable-window.h"
+
+struct _ErableWindow
+{
+ AdwApplicationWindow parent_instance;
+
+ /* Template widgets */
+ GtkHeaderBar *header_bar;
+ GtkButton *play_button;
+ GtkButton *browse_button;
+};
+
+G_DEFINE_FINAL_TYPE (ErableWindow, erable_window, ADW_TYPE_APPLICATION_WINDOW)
+
+static void
+erable_window_class_init (ErableWindowClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/me/alee14/erable/erable-window.ui");
+ gtk_widget_class_bind_template_child (widget_class, ErableWindow, header_bar);
+ gtk_widget_class_bind_template_child (widget_class, ErableWindow, play_button);
+ gtk_widget_class_bind_template_child (widget_class, ErableWindow, browse_button);
+}
+
+static void
+erable_window_init (ErableWindow *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/erable-window.h b/src/erable-window.h
new file mode 100644
index 0000000..5672491
--- /dev/null
+++ b/src/erable-window.h
@@ -0,0 +1,31 @@
+/* erable-window.h
+ *
+ * Copyright 2023 Andrew Lee
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <adwaita.h>
+
+G_BEGIN_DECLS
+
+#define ERABLE_TYPE_WINDOW (erable_window_get_type())
+
+G_DECLARE_FINAL_TYPE (ErableWindow, erable_window, ERABLE, WINDOW, AdwApplicationWindow)
+
+G_END_DECLS
diff --git a/src/erable-window.ui b/src/erable-window.ui
new file mode 100644
index 0000000..9f4000a
--- /dev/null
+++ b/src/erable-window.ui
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk" version="4.0"/>
+ <requires lib="Adw" version="1.0"/>
+ <template class="ErableWindow" parent="AdwApplicationWindow">
+ <property name="default-width">600</property>
+ <property name="default-height">600</property>
+ <property name="title">Erable: Alpha Preview</property>
+ <style>
+ <class name="devel"/>
+ </style>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar" id="header_bar">
+ <child type="end">
+ <object class="GtkMenuButton">
+ <property name="icon-name">open-menu-symbolic</property>
+ <property name="menu-model">primary_menu</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <!-- Main -->
+
+ <child>
+ <object class="AdwStatusPage" id="home_page">
+ <property name="title">Welcome!</property>
+ <property name="description">Select music to begin</property>
+ <property name="vexpand">true</property>
+
+ <child>
+
+ <object class="AdwClamp">
+ <property name="maximum-size">230</property>
+
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+
+ <child>
+ <object class="GtkButton" id="play_button">
+ <child>
+ <object class="AdwButtonContent">
+ <property name="label">Play</property>
+ <property name="halign">center</property>
+ </object>
+ </child>
+ <style>
+ <class name="pill"/>
+ <class name="suggested-action"/>
+ <class name="opaque"/>
+ </style>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkButton" id="browse_button">
+ <child>
+ <object class="AdwButtonContent">
+ <property name="label">Browse</property>
+ <property name="halign">center</property>
+ </object>
+ </child>
+ <style>
+ <class name="pill"/>
+ <class name="opaque"/>
+ </style>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="currently_playing">
+ <property name="label">Currently playing: Nothing</property>
+ </object>
+ </child>
+
+ </object>
+ </child>
+
+
+ </object>
+
+ </child>
+ </object>
+
+ </child>
+
+
+ </object>
+ </child>
+ </template>
+ <menu id="primary_menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">app.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+ <attribute name="action">win.show-help-overlay</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About Erable</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/src/erable.gresource.xml b/src/erable.gresource.xml
new file mode 100644
index 0000000..98cda15
--- /dev/null
+++ b/src/erable.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/me/alee14/erable">
+ <file preprocess="xml-stripblanks">erable-window.ui</file>
+ <file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
+ </gresource>
+</gresources>
diff --git a/src/gtk/help-overlay.ui b/src/gtk/help-overlay.ui
new file mode 100644
index 0000000..ef12f02
--- /dev/null
+++ b/src/gtk/help-overlay.ui
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkShortcutsWindow" id="help_overlay">
+ <property name="modal">True</property>
+ <child>
+ <object class="GtkShortcutsSection">
+ <property name="section-name">shortcuts</property>
+ <property name="max-height">10</property>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="title" translatable="yes" context="shortcut window">General</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="title" translatable="yes" context="shortcut window">Show Shortcuts</property>
+ <property name="action-name">win.show-help-overlay</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="title" translatable="yes" context="shortcut window">Quit</property>
+ <property name="action-name">app.quit</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..5a2a977
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,42 @@
+/* main.c
+ *
+ * Copyright 2023 Andrew Lee
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "erable-application.h"
+
+int
+main (int argc,
+ char *argv[])
+{
+ g_autoptr(ErableApplication) app = NULL;
+ int ret;
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ app = erable_application_new ("me.alee14.erable", G_APPLICATION_DEFAULT_FLAGS);
+ ret = g_application_run (G_APPLICATION (app), argc, argv);
+
+ return ret;
+}
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..ca066fe
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,20 @@
+erable_sources = [
+ 'main.c',
+ 'erable-application.c',
+ 'erable-window.c',
+]
+
+erable_deps = [
+ dependency('gtk4'),
+ dependency('libadwaita-1', version: '>= 1.2'),
+]
+
+erable_sources += gnome.compile_resources('erable-resources',
+ 'erable.gresource.xml',
+ c_name: 'erable'
+)
+
+executable('erable', erable_sources,
+ dependencies: erable_deps,
+ install: true,
+)