[Swfdec-commits] 2 commits - swfdec-gtk/Makefile.am swfdec-gtk/swfdec-gtk.h swfdec-gtk/swfdec_gtk_player.c swfdec-gtk/swfdec_gtk_system.c swfdec-gtk/swfdec_gtk_system.h swfdec/swfdec_player.c
Benjamin Otte
company at kemper.freedesktop.org
Mon Feb 18 03:29:30 PST 2008
swfdec-gtk/Makefile.am | 2
swfdec-gtk/swfdec-gtk.h | 1
swfdec-gtk/swfdec_gtk_player.c | 9 +-
swfdec-gtk/swfdec_gtk_system.c | 159 +++++++++++++++++++++++++++++++++++++++++
swfdec-gtk/swfdec_gtk_system.h | 57 ++++++++++++++
swfdec/swfdec_player.c | 2
6 files changed, 227 insertions(+), 3 deletions(-)
New commits:
commit 9525e3ca261af976d8563ed4944eca2e92a6ef78
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Feb 18 12:29:21 2008 +0100
add a gtk system object
diff --git a/swfdec-gtk/Makefile.am b/swfdec-gtk/Makefile.am
index dfe7527..169da5a 100644
--- a/swfdec-gtk/Makefile.am
+++ b/swfdec-gtk/Makefile.am
@@ -15,6 +15,7 @@ libswfdec_gtk_ at SWFDEC_MAJORMINOR@_la_SOURCES = \
swfdec_gtk_loader.c \
swfdec_gtk_player.c \
swfdec_gtk_socket.c \
+ swfdec_gtk_system.c \
swfdec_gtk_widget.c
noinst_HEADERS = \
@@ -36,6 +37,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@include_HEADERS = \
swfdec_gtk_loader.h \
swfdec_gtk_player.h \
swfdec_gtk_socket.h \
+ swfdec_gtk_system.h \
swfdec_gtk_widget.h
EXTRA_DIST = \
diff --git a/swfdec-gtk/swfdec-gtk.h b/swfdec-gtk/swfdec-gtk.h
index 1f5359f..8070b7d 100644
--- a/swfdec-gtk/swfdec-gtk.h
+++ b/swfdec-gtk/swfdec-gtk.h
@@ -24,6 +24,7 @@
#include <swfdec-gtk/swfdec_gtk_loader.h>
#include <swfdec-gtk/swfdec_gtk_player.h>
#include <swfdec-gtk/swfdec_gtk_socket.h>
+#include <swfdec-gtk/swfdec_gtk_system.h>
#include <swfdec-gtk/swfdec_gtk_widget.h>
#endif
diff --git a/swfdec-gtk/swfdec_gtk_player.c b/swfdec-gtk/swfdec_gtk_player.c
index 4fa905b..aefb464 100644
--- a/swfdec-gtk/swfdec_gtk_player.c
+++ b/swfdec-gtk/swfdec_gtk_player.c
@@ -33,6 +33,7 @@
#include "swfdec-gtk/swfdec_gtk_loader.h"
#include "swfdec-gtk/swfdec_gtk_player.h"
#include "swfdec-gtk/swfdec_gtk_socket.h"
+#include "swfdec-gtk/swfdec_gtk_system.h"
#include "swfdec-gtk/swfdec_playback.h"
#include "swfdec-gtk/swfdec_source.h"
@@ -253,11 +254,15 @@ SwfdecPlayer *
swfdec_gtk_player_new (SwfdecAsDebugger *debugger)
{
SwfdecPlayer *player;
-
+ SwfdecSystem *sys;
+
swfdec_init ();
+
+ sys = swfdec_gtk_system_new (NULL);
player = g_object_new (SWFDEC_TYPE_GTK_PLAYER,
"loader-type", SWFDEC_TYPE_GTK_LOADER, "socket-type", SWFDEC_TYPE_GTK_SOCKET,
- "debugger", debugger, NULL);
+ "system", sys, "debugger", debugger, NULL);
+ g_object_unref (sys);
return player;
}
diff --git a/swfdec-gtk/swfdec_gtk_system.c b/swfdec-gtk/swfdec_gtk_system.c
new file mode 100644
index 0000000..1c94bc1
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_system.c
@@ -0,0 +1,159 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library 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.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <locale.h>
+#include <string.h>
+#include <time.h>
+#include <gtk/gtk.h>
+
+#include "swfdec_gtk_system.h"
+
+struct _SwfdecGtkSystemPrivate
+{
+ GdkScreen * screen; /* the screen we monitor */
+};
+
+/*** gtk-doc ***/
+
+/**
+ * SECTION:SwfdecGtkSystem
+ * @title: SwfdecGtkSystem
+ * @short_description: an improved #SwfdecSystem
+ *
+ * The #SwfdecGtkSystem automatically determines system values queriable by the
+ * Flash player.
+ *
+ * @see_also: SwfdecSystem
+ */
+
+/**
+ * SwfdecGtkSystem:
+ *
+ * The structure for the Swfdec Gtk system contains no public fields.
+ */
+
+/*** SWFDEC_GTK_SYSTEM ***/
+
+G_DEFINE_TYPE (SwfdecGtkSystem, swfdec_gtk_system, SWFDEC_TYPE_SYSTEM)
+
+static void
+swfdec_gtk_system_dispose (GObject *object)
+{
+ SwfdecGtkSystem *system = SWFDEC_GTK_SYSTEM (object);
+
+ g_object_unref (system->priv->screen);
+
+ G_OBJECT_CLASS (swfdec_gtk_system_parent_class)->dispose (object);
+}
+
+static void
+swfdec_gtk_system_class_init (SwfdecGtkSystemClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+
+ g_type_class_add_private (g_class, sizeof (SwfdecGtkSystemPrivate));
+
+ object_class->dispose = swfdec_gtk_system_dispose;
+}
+
+static void
+swfdec_gtk_system_init (SwfdecGtkSystem * system)
+{
+ system->priv = G_TYPE_INSTANCE_GET_PRIVATE (system, SWFDEC_TYPE_GTK_SYSTEM, SwfdecGtkSystemPrivate);
+}
+
+/*** DETERMINING THE VALUES ***/
+
+static char *
+swfdec_gtk_system_get_language (void)
+{
+ /* we use LC_MESSAGES here, because we want the display language. See
+ * documentation for System.capabilities.language
+ */
+ char *locale = setlocale (LC_MESSAGES, NULL);
+ char *lang;
+
+ if (locale == NULL)
+ return g_strdup ("en");
+
+ /* "POSIX" and "C" => "en" */
+ if (g_str_equal (locale, "C") || g_str_equal (locale, "POSIX"))
+ return g_strdup ("en");
+
+ /* special case chinese */
+ if (g_str_has_prefix (locale, "zh_")) {
+ lang = g_strndup (locale, strcspn (locale, ".@"));
+ lang[2] = '-';
+ return lang;
+ }
+
+ /* get language part */
+ return g_strndup (locale, strcspn (locale, "_.@"));
+}
+
+static int
+swfdec_gtk_system_get_utc_offset (void)
+{
+ tzset ();
+ return timezone / 60;
+}
+
+/*** PUBLIC API ***/
+
+/**
+ * swfdec_gtk_system_new:
+ * @screen: the GdkScreen to take information from or %NULL for the default
+ *
+ * Creates a new #SwfdecGtkSystem object.
+ *
+ * Returns: The new object
+ **/
+SwfdecSystem *
+swfdec_gtk_system_new (GdkScreen *screen)
+{
+ SwfdecSystem *system;
+ char *lang;
+ guint dpi;
+
+ if (screen == NULL)
+ screen = gdk_screen_get_default ();
+ g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+
+ lang = swfdec_gtk_system_get_language ();
+ if (gdk_screen_get_resolution (screen) > 0)
+ dpi = gdk_screen_get_resolution (screen);
+ else
+ dpi = 96;
+
+ system = g_object_new (SWFDEC_TYPE_GTK_SYSTEM,
+ "language", lang, "utc-offset", swfdec_gtk_system_get_utc_offset (),
+ "dpi", dpi, "screen-height", gdk_screen_get_height (screen),
+ "screen-width", gdk_screen_get_width (screen),
+ NULL);
+ SWFDEC_GTK_SYSTEM (system)->priv->screen = g_object_ref (screen);
+
+ g_free (lang);
+
+ return system;
+}
+
diff --git a/swfdec-gtk/swfdec_gtk_system.h b/swfdec-gtk/swfdec_gtk_system.h
new file mode 100644
index 0000000..fdbf2c2
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_system.h
@@ -0,0 +1,57 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library 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.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_GTK_SYSTEM_H_
+#define _SWFDEC_GTK_SYSTEM_H_
+
+#include <swfdec/swfdec.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecGtkSystem SwfdecGtkSystem;
+typedef struct _SwfdecGtkSystemPrivate SwfdecGtkSystemPrivate;
+typedef struct _SwfdecGtkSystemClass SwfdecGtkSystemClass;
+
+#define SWFDEC_TYPE_GTK_SYSTEM (swfdec_gtk_system_get_type())
+#define SWFDEC_IS_GTK_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GTK_SYSTEM))
+#define SWFDEC_IS_GTK_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GTK_SYSTEM))
+#define SWFDEC_GTK_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GTK_SYSTEM, SwfdecGtkSystem))
+#define SWFDEC_GTK_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_SYSTEM, SwfdecGtkSystemClass))
+#define SWFDEC_GTK_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GTK_SYSTEM, SwfdecGtkSystemClass))
+
+struct _SwfdecGtkSystem
+{
+ SwfdecSystem system;
+
+ SwfdecGtkSystemPrivate * priv;
+};
+
+struct _SwfdecGtkSystemClass
+{
+ SwfdecSystemClass system_class;
+};
+
+GType swfdec_gtk_system_get_type (void);
+
+SwfdecSystem * swfdec_gtk_system_new (GdkScreen * screen);
+
+
+G_END_DECLS
+#endif
commit bf96f642ffc2c0ee46f72b3c574490bc3d9b087a
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Feb 18 12:22:24 2008 +0100
fix wrong enum value n property declaration
diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
index 53c0b22..bab43c3 100644
--- a/swfdec/swfdec_player.c
+++ b/swfdec/swfdec_player.c
@@ -1706,7 +1706,7 @@ swfdec_player_class_init (SwfdecPlayerClass *klass)
g_object_class_install_property (object_class, PROP_SCRIPTING,
g_param_spec_object ("scripting", "scripting", "external scripting implementation",
SWFDEC_TYPE_PLAYER_SCRIPTING, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_SCALE,
+ g_object_class_install_property (object_class, PROP_SYSTEM,
g_param_spec_object ("system", "system", "object holding system information",
SWFDEC_TYPE_SYSTEM, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_MAX_RUNTIME,
More information about the Swfdec-commits
mailing list