totem r5590 - in trunk: . src src/plugins/lirc



Author: hadess
Date: Thu Aug 21 13:27:21 2008
New Revision: 5590
URL: http://svn.gnome.org/viewvc/totem?rev=5590&view=rev

Log:
2008-08-21  Bastien Nocera  <hadess hadess net>

	* src/totem.c (totem_action_remote): Allow passing an
	offset for the backward/forward seeking, through the url
	parameter

	* src/plugins/lirc/totem-lirc.c (totem_lirc_get_url),
	(totem_lirc_to_command), (totem_lirc_read_code):
	Parse seek_backward and seek_forward and allow users
	to append a seek offset, meaning you can configure different
	keys for different seeking lengths

	* src/plugins/lirc/totem_lirc_default: document the above

	(Closes: #470672)



Modified:
   trunk/ChangeLog
   trunk/src/plugins/lirc/totem-lirc.c
   trunk/src/plugins/lirc/totem_lirc_default
   trunk/src/totem.c

Modified: trunk/src/plugins/lirc/totem-lirc.c
==============================================================================
--- trunk/src/plugins/lirc/totem-lirc.c	(original)
+++ trunk/src/plugins/lirc/totem-lirc.c	Thu Aug 21 13:27:21 2008
@@ -125,8 +125,21 @@
 	G_OBJECT_CLASS (totem_lirc_plugin_parent_class)->finalize (object);
 }
 
+static char *
+totem_lirc_get_url (const char *str)
+{
+	char *s;
+
+	if (str == NULL)
+		return NULL;
+	s = strchr (str, ':');
+	if (s == NULL)
+		return NULL;
+	return g_strdup (s + 1);
+}
+
 static TotemRemoteCommand
-totem_lirc_to_command (const gchar *str)
+totem_lirc_to_command (const gchar *str, char **url)
 {
 	if (strcmp (str, TOTEM_IR_COMMAND_PLAY) == 0)
 		return TOTEM_REMOTE_COMMAND_PLAY;
@@ -140,11 +153,13 @@
 		return TOTEM_REMOTE_COMMAND_NEXT;
 	else if (strcmp (str, TOTEM_IR_COMMAND_PREVIOUS) == 0)
 		return TOTEM_REMOTE_COMMAND_PREVIOUS;
-	else if (strcmp (str, TOTEM_IR_COMMAND_SEEK_FORWARD) == 0)
+	else if (g_str_has_prefix (str, TOTEM_IR_COMMAND_SEEK_FORWARD) != FALSE) {
+		*url = totem_lirc_get_url (str);
 		return TOTEM_REMOTE_COMMAND_SEEK_FORWARD;
-	else if (strcmp (str, TOTEM_IR_COMMAND_SEEK_BACKWARD) == 0)
+	} else if (g_str_has_prefix (str, TOTEM_IR_COMMAND_SEEK_BACKWARD) != FALSE) {
+		*url = totem_lirc_get_url (str);
 		return TOTEM_REMOTE_COMMAND_SEEK_BACKWARD;
-	else if (strcmp (str, TOTEM_IR_COMMAND_VOLUME_UP) == 0)
+	} else if (strcmp (str, TOTEM_IR_COMMAND_VOLUME_UP) == 0)
 		return TOTEM_REMOTE_COMMAND_VOLUME_UP;
 	else if (strcmp (str, TOTEM_IR_COMMAND_VOLUME_DOWN) == 0)
 		return TOTEM_REMOTE_COMMAND_VOLUME_DOWN;
@@ -188,7 +203,7 @@
 totem_lirc_read_code (GIOChannel *source, GIOCondition condition, TotemLircPlugin *pi)
 {
 	char *code;
-	char *str = NULL;
+	char *str = NULL, *url = NULL;
 	int ok;
 	TotemRemoteCommand cmd;
 
@@ -218,9 +233,10 @@
 			break;
 		}
 
-		cmd = totem_lirc_to_command (str);
+		cmd = totem_lirc_to_command (str, &url);
 
-		totem_action_remote (pi->totem, cmd, NULL);
+		totem_action_remote (pi->totem, cmd, url);
+		g_free (url);
 	} while (TRUE);
 
 	g_free (code);

Modified: trunk/src/plugins/lirc/totem_lirc_default
==============================================================================
--- trunk/src/plugins/lirc/totem_lirc_default	(original)
+++ trunk/src/plugins/lirc/totem_lirc_default	Thu Aug 21 13:27:21 2008
@@ -25,6 +25,12 @@
 	config = stop
 end
 
+# For seek_forward and seek_backward you can
+# append ":20" to seek 20 seconds in the
+# aforementioned direction
+#
+# Eg. seek_forward:60 -> seek forward 60 seconds
+# seek_backward:5 -> seek backwards 5 seconds
 begin
 	prog = Totem
 	remote = *

Modified: trunk/src/totem.c
==============================================================================
--- trunk/src/totem.c	(original)
+++ trunk/src/totem.c	Thu Aug 21 13:27:21 2008
@@ -2178,12 +2178,33 @@
 			g_free (subtitle);
 		}
 	};
-	case TOTEM_REMOTE_COMMAND_SEEK_FORWARD:
-		totem_action_seek_relative (totem, SEEK_FORWARD_OFFSET * 1000);
+	case TOTEM_REMOTE_COMMAND_SEEK_FORWARD: {
+		double offset = 0;
+
+		g_message ("TOTEM_REMOTE_COMMAND_SEEK_FORWARD");
+
+		if (url != NULL)
+			offset = g_ascii_strtod (url, NULL);
+		if (offset == 0) {
+			g_message ("seeking empty");
+			totem_action_seek_relative (totem, SEEK_FORWARD_OFFSET * 1000);
+		} else {
+			g_message ("seeking relative %ld", offset);
+			totem_action_seek_relative (totem, offset * 1000);
+		}
 		break;
-	case TOTEM_REMOTE_COMMAND_SEEK_BACKWARD:
-		totem_action_seek_relative (totem, SEEK_BACKWARD_OFFSET * 1000);
+	}
+	case TOTEM_REMOTE_COMMAND_SEEK_BACKWARD: {
+		double offset = 0;
+
+		if (url != NULL)
+			offset = g_ascii_strtod (url, NULL);
+		if (offset == 0)
+			totem_action_seek_relative (totem, SEEK_BACKWARD_OFFSET * 1000);
+		else
+			totem_action_seek_relative (totem,  - (offset * 1000));
 		break;
+	}
 	case TOTEM_REMOTE_COMMAND_VOLUME_UP:
 		totem_action_volume_relative (totem, VOLUME_UP_OFFSET);
 		break;



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