[retro-gtk/wip/aplazas/demo: 3/3] Add retro-gtk-demo
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/demo: 3/3] Add retro-gtk-demo
- Date: Tue, 9 May 2017 06:08:38 +0000 (UTC)
commit 483463bed3fd076ab1374e08486ea0cbc881860d
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Apr 5 08:56:21 2017 +0200
Add retro-gtk-demo
Add the a demo application, serving as an example of how to use
retro-gtk and allowing to test it.
Makefile.am | 2 +-
configure.ac | 5 ++
demos/Makefile.am | 3 +
demos/retro-gtk-demo/Makefile.am | 70 ++++++++++++++++++++
.../libretro-cores/bsnes_balanced.libretro | 11 +++
.../libretro-cores/libretro-bsnes.json | 30 ++++++++
demos/retro-gtk-demo/main.c | 20 ++++++
demos/retro-gtk-demo/org.gnome.RetroGtkDemo.json | 50 ++++++++++++++
demos/retro-gtk-demo/retro-demo-application.c | 58 ++++++++++++++++
demos/retro-gtk-demo/retro-demo-application.h | 18 +++++
demos/retro-gtk-demo/retro-demo-window.c | 52 +++++++++++++++
demos/retro-gtk-demo/retro-demo-window.h | 19 +++++
demos/retro-gtk-demo/retro-demo-window.ui | 24 +++++++
demos/retro-gtk-demo/retro-demo.gresource.xml | 7 ++
14 files changed, 368 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 02b3f72..9a23d7c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@
NULL =
-SUBDIRS = retro-gtk po
+SUBDIRS = retro-gtk demos po
dist_doc_DATA = \
README \
diff --git a/configure.ac b/configure.ac
index d40e67e..92675c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,6 +14,9 @@ AM_PROG_AR
AM_PROG_VALAC
+# GResource
+AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
+
GOBJECT_INTROSPECTION_CHECK([0.6.7])
dnl ***************************************************************************
@@ -48,6 +51,8 @@ AC_SUBST(retro_gtk_pkg_modules)
AC_OUTPUT([
Makefile
+demos/Makefile
+demos/retro-gtk-demo/Makefile
retro-gtk/retro-gtk-0.10.pc
retro-gtk/Makefile
po/Makefile.in])
diff --git a/demos/Makefile.am b/demos/Makefile.am
new file mode 100644
index 0000000..10b0945
--- /dev/null
+++ b/demos/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = retro-gtk-demo
+
+-include $(top_srcdir)/git.mk
diff --git a/demos/retro-gtk-demo/Makefile.am b/demos/retro-gtk-demo/Makefile.am
new file mode 100644
index 0000000..28489d7
--- /dev/null
+++ b/demos/retro-gtk-demo/Makefile.am
@@ -0,0 +1,70 @@
+NULL =
+
+bin_PROGRAMS = retro-gtk-demo
+
+BUILT_SOURCES = \
+ retro-demo-resources.c \
+ retro-demo-resources.h \
+ $(NULL)
+
+retro_gtk_demo_SOURCES = \
+ main.c \
+ retro-demo-application.c \
+ retro-demo-window.c \
+ $(BUILT_SOURCES) \
+ $(NULL)
+
+retro_gtk_demo_CFLAGS = \
+ $(RETRO_GTK_CFLAGS) \
+ $(GAMEPADS_CFLAGS) \
+ $(UDEV_CFLAGS) \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+ -DGAMES_PLUGINS_DIR=\"$(libdir)/gnome-games/plugins\" \
+ $(NULL)
+
+retro_gtk_demo_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_builddir)/retro-gtk \
+ -I$(top_srcdir)/retro-gtk \
+ -DRETRO_GTK_USE_UNSTABLE_API \
+ $(NULL)
+
+retro_gtk_demo_DEPENDENCIES = \
+ $(top_builddir)/retro-gtk/libretro-gtk.la \
+ $(NULL)
+
+retro_gtk_demo_LDADD = \
+ $(RETRO_GTK_LIBS) \
+ $(top_builddir)/retro-gtk/libretro-gtk.la \
+ $(NULL)
+
+gresource = $(srcdir)/retro-demo.gresource.xml
+
+resource_files = $(shell \
+ $(GLIB_COMPILE_RESOURCES) \
+ --sourcedir=$(srcdir) \
+ --generate-dependencies \
+ $(gresource))
+
+retro-demo-resources.c: $(gresource) $(resource_files)
+ $(AM_V_GEN) \
+ $(GLIB_COMPILE_RESOURCES) \
+ --target=$@ \
+ --sourcedir=$(srcdir) \
+ --generate-source \
+ --c-name retro_gtk_demo \
+ $<
+
+retro-demo-resources.h: $(gresource) $(resource_files)
+ $(AM_V_GEN) \
+ $(GLIB_COMPILE_RESOURCES) \
+ --target=$@ \
+ --sourcedir=$(srcdir) \
+ --generate-header \
+ --c-name retro_gtk_demo \
+ $<
+
+CLEANFILES = $(BUILT_SOURCES)
+EXTRA_DIST = $(resource_files) $(gresource)
+
+-include $(top_srcdir)/git.mk
diff --git a/demos/retro-gtk-demo/libretro-cores/bsnes_balanced.libretro
b/demos/retro-gtk-demo/libretro-cores/bsnes_balanced.libretro
new file mode 100644
index 0000000..b105c53
--- /dev/null
+++ b/demos/retro-gtk-demo/libretro-cores/bsnes_balanced.libretro
@@ -0,0 +1,11 @@
+[Libretro]
+Type=Emulator
+Version=1.0
+Name=bsnes Balanced
+Module=bsnes_balanced_libretro.so
+LibretroVersion=1
+Authors=byuu;
+License=GPL-3.0;
+
+[Platform:SuperNintendoEntertainmentSystem]
+MimeType=application/vnd.nintendo.snes.rom;
diff --git a/demos/retro-gtk-demo/libretro-cores/libretro-bsnes.json
b/demos/retro-gtk-demo/libretro-cores/libretro-bsnes.json
new file mode 100644
index 0000000..d89e384
--- /dev/null
+++ b/demos/retro-gtk-demo/libretro-cores/libretro-bsnes.json
@@ -0,0 +1,30 @@
+ {
+ "name": "libretro-bsnes",
+ "no-autogen": true,
+ "make-args": [
+ "prefix=/app",
+ "core_installdir=/app/lib/libretro",
+ "profile=balanced"
+ ],
+ "make-install-args": [
+ "prefix=/app",
+ "core_installdir=/app/lib/libretro",
+ "profile=balanced"
+ ],
+ "post-install": [
+ /* TODO: Send that upstream */
+ "mkdir -p /app/lib/libretro/",
+ "install -m644 -p bsnes_balanced.libretro /app/lib/libretro/"
+ ],
+ "sources": [
+ {
+ "type": "git",
+ "url": "https://github.com/libretro/bsnes-libretro.git",
+ "branch": "libretro"
+ },
+ {
+ "type": "file",
+ "path": "libretro-cores/bsnes_balanced.libretro"
+ }
+ ]
+ }
diff --git a/demos/retro-gtk-demo/main.c b/demos/retro-gtk-demo/main.c
new file mode 100644
index 0000000..597cfe8
--- /dev/null
+++ b/demos/retro-gtk-demo/main.c
@@ -0,0 +1,20 @@
+// This file is part of retro-gtk. License: GPLv3
+
+#include "retro-demo-application.h"
+
+gint
+main (gint argc,
+ gchar *argv[])
+{
+ RetroDemoApplication *app;
+ int status;
+
+ g_set_prgname ("retro-gtk-demo");
+ g_set_application_name ("org.gnome.RetroGtkDemo");
+
+ app = retro_demo_application_new();
+ status = g_application_run (G_APPLICATION (app), argc, argv);
+ g_object_unref (app);
+
+ return status;
+}
diff --git a/demos/retro-gtk-demo/org.gnome.RetroGtkDemo.json
b/demos/retro-gtk-demo/org.gnome.RetroGtkDemo.json
new file mode 100644
index 0000000..a19d4d0
--- /dev/null
+++ b/demos/retro-gtk-demo/org.gnome.RetroGtkDemo.json
@@ -0,0 +1,50 @@
+{
+ "app-id": "org.gnome.RetroGtkDemo",
+ "runtime": "org.gnome.Platform",
+ "runtime-version": "master",
+ "sdk": "org.gnome.Sdk",
+ "command": "retro-gtk-demo",
+ "tags": ["nightly"],
+ "desktop-file-name-prefix": "(Nightly) ",
+ "finish-args": [
+ /* X11 + XShm access */
+ "--share=ipc", "--socket=x11",
+ /* Wayland access */
+ "--socket=wayland",
+ /* PulseAudio access */
+ "--device=dri", "--socket=pulseaudio",
+ /* Needed to find the ROMs */
+ "--filesystem=home:ro"
+ ],
+ "build-options" : {
+ "cflags": "-O2 -g",
+ "cxxflags": "-O2 -g"
+ },
+ "cleanup": ["/include", "/lib/pkgconfig",
+ "/share/pkgconfig", "/share/aclocal",
+ "/man", "/share/man", "/share/gtk-doc",
+ "*.la", "*.a",
+ "/lib/girepository-1.0",
+ "/share/dbus-1", "/share/doc", "/share/gir-1.0"
+ ],
+ "modules": [
+ /* Emulator cores for libretro
+
+ We build them first, because some of them are very big, and they
+ change more rarely than the rest of the modules. */
+ "libretro-cores/libretro-bsnes.json",
+ /* End libretro cores */
+ {
+ "name": "retro-gtk",
+ "config-opts": [
+ "--disable-static"
+ ],
+ "sources": [
+ {
+ "type": "git",
+ "url": "https://git.gnome.org/browse/retro-gtk"
+ }
+ ]
+ }
+ ]
+}
diff --git a/demos/retro-gtk-demo/retro-demo-application.c b/demos/retro-gtk-demo/retro-demo-application.c
new file mode 100644
index 0000000..ad430d2
--- /dev/null
+++ b/demos/retro-gtk-demo/retro-demo-application.c
@@ -0,0 +1,58 @@
+// This file is part of retro-gtk. License: GPLv3
+
+#include "retro-demo-application.h"
+
+#include "retro-demo-window.h"
+
+struct _RetroDemoApplication
+{
+ GtkApplication parent_instance;
+};
+
+G_DEFINE_TYPE (RetroDemoApplication, retro_demo_application, GTK_TYPE_APPLICATION)
+
+RetroDemoApplication *
+retro_demo_application_new (void)
+{
+ return g_object_new (RETRO_TYPE_DEMO_APPLICATION, NULL);
+}
+
+static void
+retro_demo_application_finalize (GObject *object)
+{
+ RetroDemoApplication *self = (RetroDemoApplication *)object;
+
+ G_OBJECT_CLASS (retro_demo_application_parent_class)->finalize (object);
+}
+
+
+static void
+retro_demo_application_real_activate (GApplication* base)
+{
+ GtkSettings *settings;
+ RetroDemoWindow *window;
+
+ settings = gtk_settings_get_default ();
+ g_object_set (G_OBJECT (settings), "gtk-application-prefer-dark-theme", TRUE, NULL);
+
+ window = retro_demo_window_new ();
+ gtk_widget_show (GTK_WIDGET (window));
+ gtk_application_add_window (GTK_APPLICATION (base), GTK_WINDOW (window));
+}
+
+static void
+retro_demo_application_class_init (RetroDemoApplicationClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = retro_demo_application_finalize;
+
+ G_APPLICATION_CLASS (klass)->activate = retro_demo_application_real_activate;
+}
+
+static void
+retro_demo_application_init (RetroDemoApplication *self)
+{
+ g_application_set_application_id (G_APPLICATION (self), "org.gnome.RetroGtkDemo");
+ g_application_set_flags (G_APPLICATION (self), G_APPLICATION_FLAGS_NONE);
+}
diff --git a/demos/retro-gtk-demo/retro-demo-application.h b/demos/retro-gtk-demo/retro-demo-application.h
new file mode 100644
index 0000000..40c7abc
--- /dev/null
+++ b/demos/retro-gtk-demo/retro-demo-application.h
@@ -0,0 +1,18 @@
+// This file is part of retro-gtk. License: GPLv3
+
+#ifndef RETRO_DEMO_APPLICATION_H
+#define RETRO_DEMO_APPLICATION_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define RETRO_TYPE_DEMO_APPLICATION (retro_demo_application_get_type())
+
+G_DECLARE_FINAL_TYPE (RetroDemoApplication, retro_demo_application, RETRO, DEMO_APPLICATION, GtkApplication)
+
+RetroDemoApplication *retro_demo_application_new (void);
+
+G_END_DECLS
+
+#endif /* RETRO_DEMO_APPLICATION_H */
diff --git a/demos/retro-gtk-demo/retro-demo-window.c b/demos/retro-gtk-demo/retro-demo-window.c
new file mode 100644
index 0000000..a236c49
--- /dev/null
+++ b/demos/retro-gtk-demo/retro-demo-window.c
@@ -0,0 +1,52 @@
+// This file is part of retro-gtk. License: GPLv3
+
+#include "retro-demo-window.h"
+
+#include <retro-gtk.h>
+
+struct _RetroDemoWindow
+{
+ GtkApplicationWindow parent_instance;
+
+ GtkBuilder *builder;
+ GtkHeaderBar *header_bar;
+ GtkButton *open_core_button;
+ GtkButton *open_game_button;
+ RetroCairoDisplay *display;
+};
+
+G_DEFINE_TYPE (RetroDemoWindow, retro_demo_window, GTK_TYPE_APPLICATION_WINDOW)
+
+#define UI_RESOURCE "/org/gnome/retro-gtk/demo/retro-demo-window.ui"
+
+RetroDemoWindow *
+retro_demo_window_new (void)
+{
+ return g_object_new (RETRO_TYPE_DEMO_WINDOW, NULL);
+}
+
+static void
+retro_demo_window_finalize (GObject *object)
+{
+ RetroDemoWindow *self = (RetroDemoWindow *)object;
+
+ G_OBJECT_CLASS (retro_demo_window_parent_class)->finalize (object);
+}
+
+static void
+retro_demo_window_class_init (RetroDemoWindowClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = retro_demo_window_finalize;
+
+ gtk_widget_class_set_template_from_resource (widget_class, UI_RESOURCE);
+ gtk_widget_class_bind_template_child (widget_class, RetroDemoWindow, display);
+}
+
+static void
+retro_demo_window_init (RetroDemoWindow *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/demos/retro-gtk-demo/retro-demo-window.h b/demos/retro-gtk-demo/retro-demo-window.h
new file mode 100644
index 0000000..2f6fae8
--- /dev/null
+++ b/demos/retro-gtk-demo/retro-demo-window.h
@@ -0,0 +1,19 @@
+// This file is part of retro-gtk. License: GPLv3
+
+#ifndef RETRO_DEMO_WINDOW_H
+#define RETRO_DEMO_WINDOW_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define RETRO_TYPE_DEMO_WINDOW (retro_demo_window_get_type())
+
+G_DECLARE_FINAL_TYPE (RetroDemoWindow, retro_demo_window, RETRO, DEMO_WINDOW, GtkApplicationWindow)
+
+RetroDemoWindow *retro_demo_window_new (void);
+
+G_END_DECLS
+
+#endif /* RETRO_DEMO_WINDOW_H */
+
diff --git a/demos/retro-gtk-demo/retro-demo-window.ui b/demos/retro-gtk-demo/retro-demo-window.ui
new file mode 100644
index 0000000..bdb0d8d
--- /dev/null
+++ b/demos/retro-gtk-demo/retro-demo-window.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.16"/>
+ <template class="RetroDemoWindow" parent="GtkApplicationWindow">
+ <property name="can_focus">False</property>
+ <property name="default_width">768</property>
+ <property name="default_height">600</property>
+ <property name="show_menubar">False</property>
+ <!-- <signal name="delete-event" after="yes" handler="on_delete_event"/> -->
+ <!-- <signal name="key-press-event" after="yes" handler="on_key_pressed"/> -->
+ <!-- <signal name="window-state-event" after="yes" handler="on_window_state_event"/> -->
+ <!-- <signal name="notify::has-toplevel-focus" after="yes" handler="on_toplevel_focus"/> -->
+ <child>
+ <object class="RetroCairoDisplay" id="display">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="header_bar">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/demos/retro-gtk-demo/retro-demo.gresource.xml b/demos/retro-gtk-demo/retro-demo.gresource.xml
new file mode 100644
index 0000000..4d5539c
--- /dev/null
+++ b/demos/retro-gtk-demo/retro-demo.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/retro-gtk/demo">
+ <file preprocess="xml-stripblanks">retro-demo-window.ui</file>
+ </gresource>
+</gresources>
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]