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.
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
24 #include "vivi_player.h"
25 #include <libswfdec-gtk/swfdec-gtk.h>
27 G_DEFINE_TYPE (ViviPlayer
, vivi_player
, VIVI_TYPE_VIVI_DOCKLET
)
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
));
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
));
50 vivi_player_application_unset (ViviViviDocklet
*docklet
, ViviApplication
*app
)
52 g_signal_handlers_disconnect_by_func (app
, vivi_player_notify_app
, docklet
);
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
;
65 vivi_player_init (ViviPlayer
*player
)
69 box
= gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
70 gtk_container_add (GTK_CONTAINER (player
), box
);
72 player
->player
= swfdec_gtk_widget_new (NULL
);
73 gtk_container_add (GTK_CONTAINER (box
), player
->player
);
75 gtk_widget_show_all (box
);
79 vivi_player_new (ViviApplication
*app
)
81 return g_object_new (VIVI_TYPE_PLAYER
, "title", "Player", "application", app
, NULL
);