ges-ui: allow enabling/disabling audio/video tracks

This commit is contained in:
Brandon Lewis 2010-10-22 15:57:45 +01:00 committed by Edward Hervey
parent c91d1dd32d
commit 107b5fcf5e
2 changed files with 206 additions and 28 deletions

View file

@ -39,6 +39,10 @@ typedef struct App
GESTimeline *timeline;
GESTimelinePipeline *pipeline;
GESTimelineLayer *layer;
GESTrack *audio_track;
GESTrack *video_track;
guint audio_tracks;
guint video_tracks;
/* application state */
gchar *pending_uri;
@ -77,6 +81,8 @@ typedef struct App
GtkAction *stop;
GtkAction *move_up;
GtkAction *move_down;
GtkToggleAction *audio_track_action;
GtkToggleAction *video_track_action;
GtkComboBox *halign;
GtkComboBox *valign;
@ -110,6 +116,8 @@ void move_down_activate_cb (GtkAction * item, App * app);
void add_file_activate_cb (GtkAction * item, App * app);
void add_text_activate_cb (GtkAction * item, App * app);
void add_test_activate_cb (GtkAction * item, App * app);
void audio_track_activate_cb (GtkToggleAction * item, App * app);
void video_track_activate_cb (GtkToggleAction * item, App * app);
void add_transition_activate_cb (GtkAction * item, App * app);
void app_selection_changed_cb (GtkTreeSelection * selection, App * app);
void halign_changed_cb (GtkComboBox * widget, App * app);
@ -403,6 +411,10 @@ pipeline_state_changed_cb (App * app)
gtk_action_set_sensitive (app->add_file, !playing_or_paused);
gtk_action_set_sensitive (app->add_title, !playing_or_paused);
gtk_action_set_sensitive (app->add_test, !playing_or_paused);
gtk_action_set_sensitive ((GtkAction *) app->audio_track_action,
!playing_or_paused);
gtk_action_set_sensitive ((GtkAction *) app->video_track_action,
!playing_or_paused);
gtk_widget_set_sensitive (app->properties, !playing_or_paused);
}
@ -711,7 +723,53 @@ layer_added_cb (GESTimeline * timeline, GESTimelineLayer * layer, App * app)
G_CALLBACK (layer_notify_valid_changed_cb), app);
}
static void
update_track_actions (App * app)
{
g_signal_handlers_disconnect_by_func (app->audio_track_action,
audio_track_activate_cb, app);
g_signal_handlers_disconnect_by_func (app->video_track_action,
video_track_activate_cb, app);
gtk_toggle_action_set_active (app->audio_track_action, app->audio_tracks);
gtk_toggle_action_set_active (app->video_track_action, app->video_tracks);
gtk_action_set_sensitive ((GtkAction *) app->audio_track_action,
app->audio_tracks <= 1);
gtk_action_set_sensitive ((GtkAction *) app->video_track_action,
app->video_tracks <= 1);
g_signal_connect (G_OBJECT (app->audio_track_action), "activate",
G_CALLBACK (audio_track_activate_cb), app);
g_signal_connect (G_OBJECT (app->video_track_action), "activate",
G_CALLBACK (video_track_activate_cb), app);
}
static void
track_added_cb (GESTimeline * timeline, GESTrack * track, App * app)
{
if (track->type == GES_TRACK_TYPE_AUDIO) {
app->audio_tracks++;
if (!app->audio_track)
app->audio_track = track;
}
if (track->type == GES_TRACK_TYPE_VIDEO) {
app->video_tracks++;
if (!app->video_track)
app->video_track = track;
}
update_track_actions (app);
}
static void
track_removed_cb (GESTimeline * timeline, GESTrack * track, App * app)
{
if (track->type == GES_TRACK_TYPE_AUDIO)
app->audio_tracks--;
if (track->type == GES_TRACK_TYPE_VIDEO)
app->video_tracks--;
update_track_actions (app);
}
static gboolean
create_ui (App * app)
@ -728,7 +786,6 @@ create_ui (App * app)
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, "ges-ui.glade", NULL);
gtk_builder_connect_signals (builder, app);
/* get a bunch of widgets from the XML tree */
@ -759,6 +816,8 @@ create_ui (App * app)
GET_WIDGET (app->background_properties, "background_properties", GTK_WIDGET);
GET_WIDGET (app->frequency, "frequency", GTK_SPIN_BUTTON);
GET_WIDGET (app->volume, "volume", GTK_HSCALE);
GET_WIDGET (app->audio_track_action, "audio_track", GTK_TOGGLE_ACTION);
GET_WIDGET (app->video_track_action, "video_track", GTK_TOGGLE_ACTION);
/* get text notifications */
@ -810,6 +869,10 @@ create_ui (App * app)
g_signal_connect (app->timeline, "layer-added", G_CALLBACK
(layer_added_cb), app);
g_signal_connect (app->timeline, "track-added", G_CALLBACK
(track_added_cb), app);
g_signal_connect (app->timeline, "track-removed", G_CALLBACK
(track_removed_cb), app);
/* register callbacks on GES objects */
bus = gst_pipeline_get_bus (GST_PIPELINE (app->pipeline));
@ -817,7 +880,7 @@ create_ui (App * app)
g_signal_connect (bus, "message", G_CALLBACK (bus_message_cb), app);
/* success */
gtk_builder_connect_signals (builder, app);
g_object_unref (G_OBJECT (builder));
return TRUE;
@ -1026,6 +1089,46 @@ app_save_to_uri (App * app, gchar * uri)
ges_timeline_save_to_uri (app->timeline, uri);
}
static void
app_add_audio_track (App * app)
{
if (app->audio_tracks)
return;
app->audio_track = ges_track_audio_raw_new ();
ges_timeline_add_track (app->timeline, app->audio_track);
}
static void
app_remove_audio_track (App * app)
{
if (!app->audio_tracks)
return;
ges_timeline_remove_track (app->timeline, app->audio_track);
app->audio_track = NULL;
}
static void
app_add_video_track (App * app)
{
if (app->video_tracks)
return;
app->video_track = ges_track_video_raw_new ();
ges_timeline_add_track (app->timeline, app->video_track);
}
static void
app_remove_video_track (App * app)
{
if (!app->video_tracks)
return;
ges_timeline_remove_track (app->timeline, app->video_track);
app->video_track = NULL;
}
static void
app_dispose (App * app)
{
@ -1104,6 +1207,8 @@ app_new (void)
if (!(ges_timeline_add_layer (ret->timeline, ret->layer)))
goto fail;
ret->audio_track = a;
ret->video_track = v;
return ret;
fail:
@ -1290,6 +1395,26 @@ move_down_activate_cb (GtkAction * item, App * app)
app_move_selected_down (app);
}
void
audio_track_activate_cb (GtkToggleAction * item, App * app)
{
if (gtk_toggle_action_get_active (item)) {
app_add_audio_track (app);
} else {
app_remove_audio_track (app);
}
}
void
video_track_activate_cb (GtkToggleAction * item, App * app)
{
if (gtk_toggle_action_get_active (item)) {
app_add_video_track (app);
} else {
app_remove_video_track (app);
}
}
void
app_selection_changed_cb (GtkTreeSelection * selection, App * app)
{

View file

@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
@ -59,8 +59,8 @@
<child>
<object class="GtkImageMenuItem" id="new_item">
<property name="label">gtk-new</property>
<property name="use_underline">True</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="new_activate_cb"/>
</object>
@ -68,8 +68,8 @@
<child>
<object class="GtkImageMenuItem" id="open_item">
<property name="label">gtk-open</property>
<property name="use_underline">True</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="open_activate_cb"/>
</object>
@ -84,9 +84,9 @@
<child>
<object class="GtkImageMenuItem" id="as_item">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<property name="visible">True</property>
<signal name="activate" handler="save_as_activate_cb"/>
</object>
</child>
@ -126,8 +126,8 @@
<child>
<object class="GtkImageMenuItem" id="delete_item">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">delete</property>
<property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@ -153,22 +153,22 @@
<child>
<object class="GtkMenuItem" id="add_file_item">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">add_file</property>
<property name="use_action_appearance">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">add_text</property>
<property name="use_action_appearance">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menuitem5">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">add_test</property>
<property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@ -176,8 +176,8 @@
<child>
<object class="GtkImageMenuItem" id="imagemenuitem1">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">add_transition</property>
<property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@ -190,8 +190,8 @@
<child>
<object class="GtkImageMenuItem" id="menuitem8">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">move_up</property>
<property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@ -199,8 +199,8 @@
<child>
<object class="GtkImageMenuItem" id="menuitem9">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">move_down</property>
<property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@ -214,8 +214,8 @@
<child>
<object class="GtkImageMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">play</property>
<property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@ -223,8 +223,8 @@
<child>
<object class="GtkImageMenuItem" id="menuitem6">
<property name="visible">True</property>
<property name="use_action_appearance">True</property>
<property name="related_action">stop</property>
<property name="use_action_appearance">True</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@ -405,6 +405,41 @@
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem" id="toolbutton10">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToggleToolButton" id="toolbutton11">
<property name="visible">True</property>
<property name="related_action">audio_track</property>
<property name="use_action_appearance">True</property>
<property name="label" translatable="yes">toolbutton11</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToggleToolButton" id="toolbutton12">
<property name="visible">True</property>
<property name="related_action">video_track</property>
<property name="use_action_appearance">True</property>
<property name="label" translatable="yes">toolbutton12</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -493,7 +528,7 @@
<object class="GtkEntry" id="seconds">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="position">1</property>
@ -665,7 +700,7 @@
<object class="GtkSpinButton" id="frequency">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="invisible_char"></property>
<property name="adjustment">adjustment2</property>
<signal name="value_changed" handler="frequency_value_changed_cb"/>
</object>
@ -737,7 +772,7 @@
<object class="GtkEntry" id="text">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="position">1</property>
@ -836,16 +871,16 @@
<object class="GtkTreeSelection" id="selection"/>
<object class="GtkSizeGroup" id="LabelSizeGroup">
<widgets>
<widget name="label4"/>
<widget name="label_inpoint"/>
<widget name="label_duration"/>
<widget name="label_duration"/>
<widget name="label_inpoint"/>
<widget name="label2"/>
<widget name="label3"/>
<widget name="label4"/>
<widget name="label5"/>
<widget name="label6"/>
<widget name="label5"/>
<widget name="label4"/>
<widget name="label3"/>
<widget name="label2"/>
<widget name="label_inpoint"/>
<widget name="label_duration"/>
<widget name="label_duration"/>
<widget name="label_inpoint"/>
<widget name="label4"/>
</widgets>
</object>
<object class="GtkAction" id="delete">
@ -858,7 +893,7 @@
<object class="GtkAction" id="add_file">
<property name="label">Add File...</property>
<property name="short_label">File</property>
<property name="icon_name">video-x-generic</property>
<property name="icon_name">applications-multimedia</property>
<property name="always_show_image">True</property>
<signal name="activate" handler="add_file_activate_cb"/>
</object>
@ -922,4 +957,22 @@
<property name="stock_id">gtk-go-down</property>
<signal name="activate" handler="move_down_activate_cb"/>
</object>
<object class="GtkToggleAction" id="audio_track">
<property name="label">Audio</property>
<property name="short_label">Audio</property>
<property name="tooltip">Play Audio Track</property>
<property name="icon_name">audio-x-generic</property>
<property name="always_show_image">True</property>
<property name="active">True</property>
<signal name="activate" handler="audio_track_activate_cb"/>
</object>
<object class="GtkToggleAction" id="video_track">
<property name="label">Video</property>
<property name="short_label">Video</property>
<property name="tooltip">Render Video Track</property>
<property name="icon_name">video-x-generic</property>
<property name="always_show_image">True</property>
<property name="active">True</property>
<signal name="activate" handler="video_track_activate_cb"/>
</object>
</interface>