From: Sebastian Dröge Date: Mon, 20 Feb 2012 14:29:49 +0000 (+0100) Subject: seek: Make the seek-bar insensitive for DVD menus X-Git-Tag: RELEASE-0.11.3~94^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a24c72cccaa8d9e84ff15285b5af403d168ed3c9;p=platform%2Fupstream%2Fgst-plugins-base.git seek: Make the seek-bar insensitive for DVD menus --- diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index 70aa0e5..e9eb17f 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -1606,6 +1606,7 @@ stop_cb (GtkButton * button, gpointer data) connect_bus_signals (pipeline); } #endif + gtk_widget_set_sensitive (GTK_WIDGET (hscale), TRUE); } return; @@ -2649,6 +2650,53 @@ msg_step_done (GstBus * bus, GstMessage * message, GstPipeline * data) } static void +msg (GstBus * bus, GstMessage * message, GstPipeline * data) +{ + GstNavigationMessageType nav_type; + + nav_type = gst_navigation_message_get_type (message); + switch (nav_type) { + case GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED:{ + GstQuery *query; + gboolean res; + + /* Heuristic to detect if we're dealing with a DVD menu */ + query = gst_navigation_query_new_commands (); + res = gst_element_query (GST_ELEMENT (GST_MESSAGE_SRC (message)), query); + + if (res) { + gboolean is_menu = FALSE; + guint i, n; + + if (gst_navigation_query_parse_commands_length (query, &n)) { + for (i = 0; i < n; i++) { + GstNavigationCommand cmd; + + if (!gst_navigation_query_parse_commands_nth (query, i, &cmd)) + break; + + is_menu |= (cmd == GST_NAVIGATION_COMMAND_ACTIVATE); + is_menu |= (cmd == GST_NAVIGATION_COMMAND_LEFT); + is_menu |= (cmd == GST_NAVIGATION_COMMAND_RIGHT); + is_menu |= (cmd == GST_NAVIGATION_COMMAND_UP); + is_menu |= (cmd == GST_NAVIGATION_COMMAND_DOWN); + } + } + + gtk_widget_set_sensitive (GTK_WIDGET (hscale), !is_menu); + } else { + g_assert_not_reached (); + } + + gst_query_unref (query); + break; + } + default: + break; + } +} + +static void connect_bus_signals (GstElement * pipeline) { GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); @@ -2692,6 +2740,7 @@ connect_bus_signals (GstElement * pipeline) pipeline); g_signal_connect (bus, "sync-message::step-done", (GCallback) msg_sync_step_done, pipeline); + g_signal_connect (bus, "message", (GCallback) msg, pipeline); gst_object_unref (bus); }