make application_(un)set signals
[swfdec.git] / vivified / ui / vivi_player.c
blobecff252b789a9e55c4c1a1e507e473c925fbda61
1 /* Vivified
2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
24 #include "vivi_player.h"
25 #include <libswfdec-gtk/swfdec-gtk.h>
27 G_DEFINE_TYPE (ViviPlayer, vivi_player, VIVI_TYPE_VIVI_DOCKLET)
29 static void
30 vivi_player_notify_app (ViviApplication *app, GParamSpec *pspec, ViviPlayer *player)
32 if (g_str_equal (pspec->name, "player")) {
33 swfdec_gtk_widget_set_player (SWFDEC_GTK_WIDGET (player->player), vivi_application_get_player (app));
34 } else if (g_str_equal (pspec->name, "interrupted")) {
35 swfdec_gtk_widget_set_interactive (SWFDEC_GTK_WIDGET (player->player),
36 !vivi_application_get_interrupted (app));
40 static void
41 vivi_player_application_set (ViviViviDocklet *docklet, ViviApplication *app)
43 ViviPlayer *player = VIVI_PLAYER (docklet);
45 g_signal_connect (app, "notify", G_CALLBACK (vivi_player_notify_app), player);
46 swfdec_gtk_widget_set_player (SWFDEC_GTK_WIDGET (player->player), vivi_application_get_player (app));
49 static void
50 vivi_player_application_unset (ViviViviDocklet *docklet, ViviApplication *app)
52 g_signal_handlers_disconnect_by_func (app, vivi_player_notify_app, docklet);
55 static void
56 vivi_player_class_init (ViviPlayerClass *klass)
58 ViviViviDockletClass *vivi_docklet_class = VIVI_VIVI_DOCKLET_CLASS (klass);
60 vivi_docklet_class->application_set = vivi_player_application_set;
61 vivi_docklet_class->application_unset = vivi_player_application_unset;
64 static void
65 vivi_player_init (ViviPlayer *player)
67 GtkWidget *box;
69 box = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
70 gtk_container_add (GTK_CONTAINER (player), box);
71 /* the player */
72 player->player = swfdec_gtk_widget_new (NULL);
73 gtk_container_add (GTK_CONTAINER (box), player->player);
75 gtk_widget_show_all (box);
78 GtkWidget *
79 vivi_player_new (ViviApplication *app)
81 return g_object_new (VIVI_TYPE_PLAYER, "title", "Player", "application", app, NULL);