[retro-gtk] core: Add Core.set_medias()



commit 6b653a3b7a246d19032a4227e9726adfdc82ca0a
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Jul 6 14:15:54 2017 +0200

    core: Add Core.set_medias()
    
    This will be used to simplify loading the games and by extension to
    simplify preparing the cores, exposing less of the internal working.
    
    By extension, simplifying the public API will help porting the library
    to C.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777489

 retro-gtk/core.vala    |    2 ++
 retro-gtk/retro-core.c |   26 ++++++++++++++++++++++++++
 retro-gtk/retro-core.h |    1 +
 3 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/retro-gtk/core.vala b/retro-gtk/core.vala
index 03c657d..66f9992 100644
--- a/retro-gtk/core.vala
+++ b/retro-gtk/core.vala
@@ -266,6 +266,8 @@ public class Core : Object {
                is_initiated = true;
        }
 
+       public extern void set_medias ([CCode (array_null_terminated = true, array_length = false)] string[] 
uris);
+
        public extern void set_controller_port_device (uint port, DeviceType device);
 
        /**
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index df25c4e..41cf852 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -109,6 +109,23 @@ retro_core_on_input_key_event (RetroCore                *self,
 /* Public */
 
 void
+retro_core_set_medias (RetroCore  *self,
+                       gchar     **uris)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_if_fail (self != NULL);
+  g_return_if_fail (!retro_core_get_is_initiated (self));
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  if (internal->media_uris != NULL)
+    g_strfreev (internal->media_uris);
+
+  internal->media_uris = g_strdupv (uris);
+}
+
+void
 retro_core_set_controller_port_device (RetroCore       *self,
                                        guint            port,
                                        RetroDeviceType  device)
@@ -403,5 +420,14 @@ retro_core_environment_internal_setup (RetroCore *self)
 void
 retro_core_environment_internal_release (RetroCore *self)
 {
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_if_fail (self != NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  if (internal->media_uris != NULL)
+    g_strfreev (internal->media_uris);
+
   g_free (self->environment_internal);
 }
diff --git a/retro-gtk/retro-core.h b/retro-gtk/retro-core.h
index 3d4a578..55d2199 100644
--- a/retro-gtk/retro-core.h
+++ b/retro-gtk/retro-core.h
@@ -17,6 +17,7 @@ typedef struct {
 typedef struct _RetroCoreEnvironmentInternal RetroCoreEnvironmentInternal;
 
 struct _RetroCoreEnvironmentInternal {
+  gchar **media_uris;
   gfloat aspect_ratio;
   gboolean overscan;
   RetroPixelFormat pixel_format;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]