diff options
author | Benjamin Otte <otte@gnome.org> | 2007-10-21 17:17:22 +0200 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2007-10-21 17:17:22 +0200 |
commit | 40549d9d5a627ed1b5d1390229e18f607dcd57f6 (patch) | |
tree | 203738b1d2a31d2aa66639050bee1223062fd1b1 /player | |
parent | f280b438e5bb319775a6e508a08e34b2227840c0 (diff) |
make these proper GObjects
Diffstat (limited to 'player')
-rw-r--r-- | player/swfdec-window.c | 36 | ||||
-rw-r--r-- | player/swfdec-window.h | 32 |
2 files changed, 57 insertions, 11 deletions
diff --git a/player/swfdec-window.c b/player/swfdec-window.c index 5acfeec..2a9dc1b 100644 --- a/player/swfdec-window.c +++ b/player/swfdec-window.c @@ -24,15 +24,34 @@ #include <glib/gi18n.h> #include "swfdec-window.h" -struct _SwfdecWindow { - gboolean error; /* TRUE if we're in error */ - GtkBuilder * builder; /* builder instance to load from */ - GtkWidget * window; /* the toplevel window */ - SwfdecPlayer * player; /* the player we show or NULL if not initialized yet */ - SwfdecLoader * loader; /* the loader we use to load the content or NULL if not initialized yet */ -}; +G_DEFINE_TYPE (SwfdecWindow, swfdec_window, G_TYPE_OBJECT) -#define SWFDEC_IS_WINDOW(window) ((window) != NULL) +/* global list of windows */ +static GSList *windows = NULL; + +static void +swfdec_window_finalize (GObject *object) +{ + G_OBJECT_CLASS (swfdec_window_parent_class)->finalize (object); + + windows = g_slist_remove (windows, object); + if (windows == NULL) + gtk_main_quit (); +} + +static void +swfdec_window_class_init (SwfdecWindowClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = swfdec_window_finalize; +} + +static void +swfdec_window_init (SwfdecWindow *window) +{ + windows = g_slist_prepend (windows, window); +} /** * swfdec_window_set_url: @@ -116,3 +135,4 @@ swfdec_window_new (const char *url) return window; } + diff --git a/player/swfdec-window.h b/player/swfdec-window.h index 444f400..65ca20a 100644 --- a/player/swfdec-window.h +++ b/player/swfdec-window.h @@ -17,15 +17,39 @@ * Boston, MA 02110-1301 USA */ -#ifndef __SWFDEC_WINDOW_H__ -#define __SWFDEC_WINDOW_H__ - #include <gtk/gtk.h> #include <libswfdec/swfdec.h> #include <libswfdec-gtk/swfdec-gtk.h> +#ifndef __SWFDEC_WINDOW_H__ +#define __SWFDEC_WINDOW_H__ + + typedef struct _SwfdecWindow SwfdecWindow; +typedef struct _SwfdecWindowClass SwfdecWindowClass; + +#define SWFDEC_TYPE_WINDOW (swfdec_window_get_type()) +#define SWFDEC_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_WINDOW)) +#define SWFDEC_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_WINDOW)) +#define SWFDEC_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_WINDOW, SwfdecWindow)) +#define SWFDEC_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_WINDOW, SwfdecWindowClass)) +#define SWFDEC_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_WINDOW, SwfdecWindowClass)) + +struct _SwfdecWindow +{ + GObject object; + gboolean error; /* TRUE if we're in error */ + GtkBuilder * builder; /* builder instance to load from */ + GtkWidget * window; /* the toplevel window */ + SwfdecPlayer * player; /* the player we show or NULL if not initialized yet */ + SwfdecLoader * loader; /* the loader we use to load the content or NULL if not initialized yet */ +}; + +struct _SwfdecWindowClass +{ + GObjectClass object_class; +}; SwfdecWindow * swfdec_window_new (const char * url); @@ -34,4 +58,6 @@ gboolean swfdec_window_set_url (SwfdecWindow * window, void swfdec_window_error (SwfdecWindow * window, const char * msg); + +G_END_DECLS #endif |