2
* * Copyright (C) 2008-2009 Ali <aliov@xfce.org>
4
* Licensed under the GNU General Public License Version 2
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
34
#include <libxfcegui4/libxfcegui4.h>
38
#include "parole-plugin-player.h"
40
#include "dbus/parole-dbus.h"
42
static gulong exit_source_id = 0;
44
static void G_GNUC_NORETURN
45
force_exit (gpointer data)
47
//g_debug ("Forcing exit");
52
posix_signal_handler (gint sig, ParolePluginPlayer *player)
54
parole_plugin_player_exit (player);
56
exit_source_id = g_timeout_add_seconds (4, (GSourceFunc) force_exit, NULL);
59
int main (int argc, char **argv)
61
ParolePluginPlayer *player;
62
GdkNativeWindow socket_id = 0;
65
GOptionGroup *gst_option_group;
70
GOptionEntry option_entries[] =
72
{ "socket-id", 's', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT, &socket_id, N_("socket"), N_("SOCKET ID") },
73
{ "url", '\0', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &url, N_("url to play"), N_("URL") },
77
if ( !g_thread_supported () )
80
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
82
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
83
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
86
textdomain (GETTEXT_PACKAGE);
88
gtk_init (&argc, &argv);
90
ctx = g_option_context_new (NULL);
92
gst_option_group = gst_init_get_option_group ();
93
g_option_context_add_main_entries (ctx, option_entries, GETTEXT_PACKAGE);
94
g_option_context_set_translation_domain (ctx, GETTEXT_PACKAGE);
95
g_option_context_add_group (ctx, gst_option_group);
97
g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
99
if ( !g_option_context_parse (ctx, &argc, &argv, &error) )
101
g_print ("%s\n", error->message);
102
g_print ("Type %s --help to list all available command line options", argv[0]);
103
g_error_free (error);
104
g_option_context_free (ctx);
107
g_option_context_free (ctx);
109
dbus_name = g_strdup_printf ("org.Parole.Media.Plugin%d", socket_id);
110
parole_dbus_register_name (dbus_name);
112
plug = gtk_plug_new (socket_id);
114
player = parole_plugin_player_new (plug, url);
115
gtk_widget_show_all (plug);
117
if ( xfce_posix_signal_handler_init (&error))
119
xfce_posix_signal_handler_set_handler (SIGKILL,
120
(XfcePosixSignalHandler) posix_signal_handler,
125
g_warning ("Unable to set up POSIX signal handlers: %s", error->message);
126
g_error_free (error);
130
g_object_unref (player);
131
gtk_widget_destroy (plug);
132
parole_dbus_release_name (dbus_name);
135
if ( exit_source_id != 0 )
136
g_source_remove (exit_source_id);
138
//g_debug ("Exiting");