totem r5527 - in trunk: . src



Author: hadess
Date: Tue Jul 29 14:15:53 2008
New Revision: 5527
URL: http://svn.gnome.org/viewvc/totem?rev=5527&view=rev

Log:
2008-07-29  Bastien Nocera  <hadess hadess net>

	* src/Makefile.am:
	* src/totem-dvb-setup.c (totem_dvb_setup_helper),
	(child_watch_func), (totem_dvb_setup_device):
	* src/totem-dvb-setup.h:
	* src/totem.c (totem_dvb_setup_result), (totem_action_load_media):
	Add support for a helper script in $(libexecdir)/totem-dvb-scanner
	that would scan for channels on the specified adapter when loading
	the channels list fails



Added:
   trunk/src/totem-dvb-setup.c
   trunk/src/totem-dvb-setup.h
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/totem.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Tue Jul 29 14:15:53 2008
@@ -116,7 +116,9 @@
 	totem-cell-renderer-video.c	\
 	totem-cell-renderer-video.h	\
 	totem-video-list.c		\
-	totem-video-list.h
+	totem-video-list.h		\
+	totem-dvb-setup.c		\
+	totem-dvb-setup.h
 
 totem_CPPFLAGS = \
 	-I$(top_srcdir)/		\

Added: trunk/src/totem-dvb-setup.c
==============================================================================
--- (empty file)
+++ trunk/src/totem-dvb-setup.c	Tue Jul 29 14:15:53 2008
@@ -0,0 +1,130 @@
+/* totem-dvb-setup.c
+
+   Copyright (C) 2008 Bastien Nocera
+
+   The Gnome Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301  USA.
+
+   Author: Bastien Nocera <hadess hadess net>
+ */
+
+#include "config.h"
+
+#include <gdk/gdk.h>
+
+#include "totem-dvb-setup.h"
+#include "debug.h"
+
+#ifdef GDK_WINDOWING_X11
+
+static gboolean in_progress = FALSE;
+
+#include <gdk/gdkx.h>
+#include <sys/wait.h>
+
+typedef struct {
+	TotemDvbSetupResultFunc func;
+	char *device;
+	gpointer user_data;
+} TotemDvbSetupHelper;
+
+static const char *
+totem_dvb_setup_helper (void)
+{
+	char *path = NULL;
+
+	if (path == NULL)
+		path = g_build_filename (LIBEXECDIR, "totem-dvb-scanner", NULL);
+	return path;
+}
+
+static void
+child_watch_func (GPid pid,
+		  gint status,
+		  gpointer data)
+{
+	TotemDvbSetupHelper *helper = (TotemDvbSetupHelper *) data;
+	int ret;
+
+	if (!WIFEXITED (status))
+		ret = TOTEM_DVB_SETUP_CRASHED;
+	else
+		ret = WEXITSTATUS (status);
+
+	helper->func (ret, helper->device, helper->user_data);
+
+	in_progress = FALSE;
+
+	g_free (helper->device);
+	g_free (helper);
+}
+
+int
+totem_dvb_setup_device (const char *device,
+			GtkWindow *parent,
+			TotemDvbSetupResultFunc func,
+			gpointer user_data)
+{
+	GPtrArray *arr;
+	char *tmp, **argv;
+	GPid pid;
+	TotemDvbSetupHelper *helper;
+
+	if (in_progress != FALSE)
+		return TOTEM_DVB_SETUP_FAILURE;
+
+	if (g_file_test (totem_dvb_setup_helper(), G_FILE_TEST_IS_EXECUTABLE) == FALSE)
+		return TOTEM_DVB_SETUP_MISSING;
+
+	arr = g_ptr_array_new ();
+	g_ptr_array_add (arr, g_strdup (totem_dvb_setup_helper ()));
+	tmp = g_strdup_printf ("--transient-for=%u", (unsigned int) GDK_WINDOW_XID (GTK_WIDGET (parent)->window));
+	g_ptr_array_add (arr, tmp);
+	g_ptr_array_add (arr, g_strdup (device));
+	argv = (gchar **) arr->pdata;
+	g_ptr_array_add (arr, NULL);
+
+	if (g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL,
+			   NULL, &pid, NULL) == FALSE) {
+		g_ptr_array_free (arr, TRUE);
+		return TOTEM_DVB_SETUP_FAILURE;
+	}
+
+	g_ptr_array_free (arr, TRUE);
+
+	helper = g_new (TotemDvbSetupHelper, 1);
+	helper->user_data = user_data;
+	helper->func = func;
+	helper->device = g_strdup (device);
+
+	in_progress = TRUE;
+
+	g_child_watch_add (pid, child_watch_func, helper);
+
+	return TOTEM_DVB_SETUP_STARTED_OK;
+}
+
+#else /* GDK_WINDOWING_X11 */
+
+int
+totem_dvb_setup_device (const char *device,
+			GtkWindow *parent,
+			TotemDvbSetupResultFunc func,
+			gpointer user_data)
+{
+	return TOTEM_DVB_SETUP_FAILURE;
+}
+
+#endif /* GDK_WINDOWING_X11 */

Added: trunk/src/totem-dvb-setup.h
==============================================================================
--- (empty file)
+++ trunk/src/totem-dvb-setup.h	Tue Jul 29 14:15:53 2008
@@ -0,0 +1,47 @@
+/* totem-dvb-setup.h
+
+   Copyright (C) 2004-2005 Bastien Nocera <hadess hadess net>
+
+   The Gnome Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301  USA.
+
+   Author: Bastien Nocera <hadess hadess net>
+ */
+
+#ifndef TOTEM_DVB_SETUP_H
+#define TOTEM_DVB_SETUP_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+enum {
+	TOTEM_DVB_SETUP_MISSING,
+	TOTEM_DVB_SETUP_STARTED_OK,
+	TOTEM_DVB_SETUP_CRASHED,
+	TOTEM_DVB_SETUP_FAILURE,
+	TOTEM_DVB_SETUP_SUCCESS
+};
+
+typedef void (*TotemDvbSetupResultFunc) (int result, const char *device, gpointer user_data);
+
+int totem_dvb_setup_device (const char *device,
+			    GtkWindow *parent,
+			    TotemDvbSetupResultFunc func,
+			    gpointer user_data);
+
+G_END_DECLS
+
+#endif /* TOTEM_DVB_SETUP_H */

Modified: trunk/src/totem.c
==============================================================================
--- trunk/src/totem.c	(original)
+++ trunk/src/totem.c	Tue Jul 29 14:15:53 2008
@@ -52,6 +52,7 @@
 #endif
 
 #include "bacon-video-widget.h"
+#include "totem-dvb-setup.h"
 #include "totem-statusbar.h"
 #include "totem-time-label.h"
 #include "totem-session.h"
@@ -97,6 +98,7 @@
 
 static gboolean totem_action_open_files (Totem *totem, char **list);
 static gboolean totem_action_open_files_list (Totem *totem, GSList *list);
+static gboolean totem_action_load_media (Totem *totem, TotemDiscMediaType type, const char *device);
 static void update_buttons (Totem *totem);
 static void update_media_menu_items (Totem *totem);
 static void playlist_changed_cb (GtkWidget *playlist, Totem *totem);
@@ -516,6 +518,14 @@
 	return TRUE;
 }
 
+static void
+totem_dvb_setup_result (int result, const char *device, gpointer user_data)
+{
+	Totem *totem = (Totem *) user_data;
+
+	totem_action_load_media (totem, MEDIA_TYPE_DVB, device);
+}
+
 static gboolean
 totem_action_load_media (Totem *totem, TotemDiscMediaType type, const char *device)
 {
@@ -551,6 +561,10 @@
 		/* No channels.conf file */
 		} else if (g_error_matches (error, BVW_ERROR, BVW_ERROR_FILE_NOT_FOUND) != FALSE) {
 			g_assert (type == MEDIA_TYPE_DVB);
+
+			if (totem_dvb_setup_device (device, GTK_WINDOW (totem->win), totem_dvb_setup_result, totem) == TOTEM_DVB_SETUP_STARTED_OK)
+				return FALSE;
+
 			link = "http://www.gnome.org/projects/totem/#dvb";;
 			link_text = _("More information about watching TV");
 			msg = g_strdup (_("Totem is missing a channels listing to be able to tune the receiver."));
@@ -567,6 +581,8 @@
 			totem_action_error (msg, _("Please insert another disc to play back."), totem);
 			g_free (msg);
 			return FALSE;
+		} else {
+			g_assert_not_reached ();
 		}
 		totem_interface_error_with_link (msg, secondary, link, link_text, GTK_WINDOW (totem->win), totem);
 		g_free (msg);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]