2010-07-20 16:53:15 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2010 Brandon Lewis <brandon.lewis@collabora.co.uk>
|
|
|
|
* 2010 Nokia Corporation
|
|
|
|
*
|
|
|
|
* This 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.
|
|
|
|
*
|
|
|
|
* This 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 this library; if not, write to the
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-07-20 16:53:15 +00:00
|
|
|
*/
|
|
|
|
|
2010-07-27 13:25:20 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-07-19 17:02:41 +00:00
|
|
|
#include <gtk/gtk.h>
|
2010-07-20 15:05:26 +00:00
|
|
|
#include <glib.h>
|
2011-12-30 16:18:18 +00:00
|
|
|
#include <glib/gprintf.h>
|
2010-07-20 15:05:26 +00:00
|
|
|
#include <ges/ges.h>
|
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
/* Application Data ********************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains most of the application data so that signal handlers
|
|
|
|
* and other callbacks have easy access.
|
|
|
|
*/
|
|
|
|
|
2010-07-20 15:55:06 +00:00
|
|
|
typedef struct App
|
|
|
|
{
|
2010-08-04 14:25:00 +00:00
|
|
|
/* back-end objects */
|
2010-07-20 15:55:06 +00:00
|
|
|
GESTimeline *timeline;
|
2013-07-01 14:27:54 +00:00
|
|
|
GESPipeline *pipeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2010-10-22 14:57:45 +00:00
|
|
|
GESTrack *audio_track;
|
|
|
|
GESTrack *video_track;
|
|
|
|
guint audio_tracks;
|
|
|
|
guint video_tracks;
|
2010-08-04 14:25:00 +00:00
|
|
|
|
|
|
|
/* application state */
|
2010-10-11 10:38:11 +00:00
|
|
|
gchar *pending_uri;
|
2010-08-04 14:25:00 +00:00
|
|
|
int n_objects;
|
|
|
|
|
|
|
|
int n_selected;
|
|
|
|
GList *selected_objects;
|
|
|
|
GType selected_type;
|
2010-08-04 16:25:24 +00:00
|
|
|
gboolean first_selected;
|
|
|
|
gboolean last_selected;
|
2010-08-04 14:25:00 +00:00
|
|
|
|
2010-08-05 14:12:45 +00:00
|
|
|
gboolean ignore_input;
|
2010-08-04 14:25:00 +00:00
|
|
|
GstState state;
|
|
|
|
|
2010-07-20 17:41:58 +00:00
|
|
|
GtkListStore *model;
|
2010-07-21 11:53:01 +00:00
|
|
|
GtkTreeSelection *selection;
|
2010-08-04 14:25:00 +00:00
|
|
|
|
|
|
|
/* widgets */
|
|
|
|
GtkWidget *main_window;
|
2011-03-17 15:38:38 +00:00
|
|
|
GtkWidget *add_effect_dlg;
|
2010-07-21 13:23:18 +00:00
|
|
|
GtkWidget *properties;
|
2010-07-23 16:43:37 +00:00
|
|
|
GtkWidget *filesource_properties;
|
|
|
|
GtkWidget *text_properties;
|
2010-08-04 14:25:00 +00:00
|
|
|
GtkWidget *generic_duration;
|
|
|
|
GtkWidget *background_properties;
|
2011-03-17 15:38:38 +00:00
|
|
|
GtkWidget *audio_effect_entry;
|
|
|
|
GtkWidget *video_effect_entry;
|
2010-08-04 14:25:00 +00:00
|
|
|
|
2010-07-21 16:03:06 +00:00
|
|
|
GtkHScale *duration;
|
2010-07-21 18:21:01 +00:00
|
|
|
GtkHScale *in_point;
|
2010-08-04 14:25:00 +00:00
|
|
|
GtkHScale *volume;
|
|
|
|
|
2010-07-22 10:54:01 +00:00
|
|
|
GtkAction *add_file;
|
2011-03-17 15:38:38 +00:00
|
|
|
GtkAction *add_effect;
|
2010-08-03 13:03:24 +00:00
|
|
|
GtkAction *add_test;
|
|
|
|
GtkAction *add_title;
|
2010-08-03 13:54:25 +00:00
|
|
|
GtkAction *add_transition;
|
2010-07-22 10:20:59 +00:00
|
|
|
GtkAction *delete;
|
2010-07-22 10:43:13 +00:00
|
|
|
GtkAction *play;
|
2010-08-04 15:17:59 +00:00
|
|
|
GtkAction *stop;
|
2010-08-04 16:02:14 +00:00
|
|
|
GtkAction *move_up;
|
|
|
|
GtkAction *move_down;
|
2010-10-22 14:57:45 +00:00
|
|
|
GtkToggleAction *audio_track_action;
|
|
|
|
GtkToggleAction *video_track_action;
|
2010-08-04 14:25:00 +00:00
|
|
|
|
2010-07-23 16:43:37 +00:00
|
|
|
GtkComboBox *halign;
|
|
|
|
GtkComboBox *valign;
|
2010-08-04 14:25:00 +00:00
|
|
|
GtkComboBox *background_type;
|
|
|
|
|
2010-07-23 16:43:37 +00:00
|
|
|
GtkEntry *text;
|
2010-07-27 13:25:20 +00:00
|
|
|
GtkEntry *seconds;
|
2010-08-04 14:25:00 +00:00
|
|
|
|
2010-08-03 12:38:42 +00:00
|
|
|
GtkSpinButton *frequency;
|
2010-07-20 15:55:06 +00:00
|
|
|
} App;
|
|
|
|
|
2010-10-08 11:32:15 +00:00
|
|
|
static int n_instances = 0;
|
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
/* Prototypes for auto-connected signal handlers ***************************/
|
2010-07-20 15:05:26 +00:00
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
/**
|
|
|
|
* These are declared non-static for signal auto-connection
|
|
|
|
*/
|
2010-07-20 15:05:26 +00:00
|
|
|
|
2010-10-08 11:32:15 +00:00
|
|
|
gboolean window_delete_event_cb (GtkObject * window, GdkEvent * event,
|
|
|
|
App * app);
|
2010-10-11 10:38:11 +00:00
|
|
|
void new_activate_cb (GtkMenuItem * item, App * app);
|
|
|
|
void open_activate_cb (GtkMenuItem * item, App * app);
|
2010-10-11 10:53:35 +00:00
|
|
|
void save_as_activate_cb (GtkMenuItem * item, App * app);
|
2013-09-16 14:19:13 +00:00
|
|
|
void launch_project_activate_cb (GtkMenuItem * item, App * app);
|
2010-08-04 14:57:18 +00:00
|
|
|
void quit_item_activate_cb (GtkMenuItem * item, App * app);
|
2010-07-22 10:08:28 +00:00
|
|
|
void delete_activate_cb (GtkAction * item, App * app);
|
2010-07-22 10:17:24 +00:00
|
|
|
void play_activate_cb (GtkAction * item, App * app);
|
2010-08-04 15:27:01 +00:00
|
|
|
void stop_activate_cb (GtkAction * item, App * app);
|
2010-08-04 16:31:34 +00:00
|
|
|
void move_up_activate_cb (GtkAction * item, App * app);
|
|
|
|
void move_down_activate_cb (GtkAction * item, App * app);
|
2011-03-17 15:38:38 +00:00
|
|
|
void add_effect_activate_cb (GtkAction * item, App * app);
|
2010-07-22 10:08:28 +00:00
|
|
|
void add_file_activate_cb (GtkAction * item, App * app);
|
2010-07-23 16:36:54 +00:00
|
|
|
void add_text_activate_cb (GtkAction * item, App * app);
|
2010-08-02 15:24:24 +00:00
|
|
|
void add_test_activate_cb (GtkAction * item, App * app);
|
2010-10-22 14:57:45 +00:00
|
|
|
void audio_track_activate_cb (GtkToggleAction * item, App * app);
|
|
|
|
void video_track_activate_cb (GtkToggleAction * item, App * app);
|
2010-08-03 17:31:23 +00:00
|
|
|
void add_transition_activate_cb (GtkAction * item, App * app);
|
2010-07-21 13:23:18 +00:00
|
|
|
void app_selection_changed_cb (GtkTreeSelection * selection, App * app);
|
2010-07-23 16:42:13 +00:00
|
|
|
void halign_changed_cb (GtkComboBox * widget, App * app);
|
|
|
|
void valign_changed_cb (GtkComboBox * widget, App * app);
|
2010-08-04 14:57:18 +00:00
|
|
|
void background_type_changed_cb (GtkComboBox * widget, App * app);
|
|
|
|
void frequency_value_changed_cb (GtkSpinButton * widget, App * app);
|
2011-03-17 15:38:38 +00:00
|
|
|
void on_apply_effect_cb (GtkButton * button, App * app);
|
|
|
|
void on_cancel_add_effect_cb (GtkButton * button, App * app);
|
|
|
|
gboolean add_effect_dlg_delete_event_cb (GtkWidget * widget, GdkEvent * event,
|
|
|
|
gpointer * app);
|
2010-07-23 16:42:13 +00:00
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
gboolean
|
|
|
|
duration_scale_change_value_cb (GtkRange * range,
|
|
|
|
GtkScrollType unused, gdouble value, App * app);
|
2010-07-27 13:25:20 +00:00
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
gboolean
|
|
|
|
in_point_scale_change_value_cb (GtkRange * range,
|
|
|
|
GtkScrollType unused, gdouble value, App * app);
|
2010-08-02 17:06:06 +00:00
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
gboolean
|
|
|
|
volume_change_value_cb (GtkRange * range,
|
|
|
|
GtkScrollType unused, gdouble value, App * app);
|
2010-08-03 12:43:41 +00:00
|
|
|
|
2010-07-22 10:48:34 +00:00
|
|
|
/* UI state functions *******************************************************/
|
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
/**
|
|
|
|
* Update properties of UI elements that depend on more than one thing.
|
|
|
|
*/
|
|
|
|
|
2011-03-17 15:38:38 +00:00
|
|
|
static void
|
|
|
|
update_effect_sensitivity (App * app)
|
|
|
|
{
|
|
|
|
GList *i;
|
|
|
|
gboolean ok = TRUE;
|
|
|
|
|
|
|
|
/* effects will work for multiple FileSource */
|
|
|
|
for (i = app->selected_objects; i; i = i->next) {
|
2013-01-20 15:44:57 +00:00
|
|
|
if (!GES_IS_URI_CLIP (i->data)) {
|
2011-03-17 15:38:38 +00:00
|
|
|
ok = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_action_set_sensitive (app->add_effect,
|
|
|
|
ok && (app->n_selected > 0) && (app->state != GST_STATE_PLAYING)
|
|
|
|
&& (app->state != GST_STATE_PAUSED));
|
|
|
|
}
|
|
|
|
|
2010-07-22 10:51:07 +00:00
|
|
|
static void
|
|
|
|
update_delete_sensitivity (App * app)
|
|
|
|
{
|
|
|
|
/* delete will work for multiple items */
|
|
|
|
gtk_action_set_sensitive (app->delete,
|
2010-08-04 15:34:51 +00:00
|
|
|
(app->n_selected > 0) && (app->state != GST_STATE_PLAYING)
|
|
|
|
&& (app->state != GST_STATE_PAUSED));
|
2010-07-22 10:51:07 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 13:59:38 +00:00
|
|
|
static void
|
|
|
|
update_add_transition_sensitivity (App * app)
|
|
|
|
{
|
|
|
|
gtk_action_set_sensitive (app->add_transition,
|
2010-08-05 16:32:17 +00:00
|
|
|
(app->state != GST_STATE_PLAYING) && (app->state != GST_STATE_PAUSED));
|
2010-08-03 13:59:38 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 16:02:14 +00:00
|
|
|
static void
|
|
|
|
update_move_up_down_sensitivity (App * app)
|
|
|
|
{
|
|
|
|
gboolean can_move;
|
|
|
|
|
|
|
|
can_move = (app->n_selected == 1) &&
|
|
|
|
(app->state != GST_STATE_PLAYING) && (app->state != GST_STATE_PAUSED);
|
|
|
|
|
2010-08-04 16:25:24 +00:00
|
|
|
gtk_action_set_sensitive (app->move_up, can_move && (!app->first_selected));
|
|
|
|
gtk_action_set_sensitive (app->move_down, can_move && (!app->last_selected));
|
2010-08-04 16:02:14 +00:00
|
|
|
}
|
|
|
|
|
2010-08-05 13:46:34 +00:00
|
|
|
static void
|
|
|
|
update_play_sensitivity (App * app)
|
|
|
|
{
|
2013-11-22 20:49:49 +00:00
|
|
|
gtk_action_set_sensitive (app->play, app->n_objects);
|
2010-08-05 13:46:34 +00:00
|
|
|
}
|
|
|
|
|
2010-07-20 17:13:06 +00:00
|
|
|
/* Backend callbacks ********************************************************/
|
|
|
|
|
2010-08-05 16:11:49 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
test_source_notify_volume_changed_cb (GESClip * clip, GParamSpec *
|
2010-08-05 16:11:49 +00:00
|
|
|
unused G_GNUC_UNUSED, App * app)
|
|
|
|
{
|
|
|
|
gdouble volume;
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
g_object_get (G_OBJECT (clip), "volume", &volume, NULL);
|
2010-08-05 16:11:49 +00:00
|
|
|
|
|
|
|
gtk_range_set_value (GTK_RANGE (app->volume), volume);
|
|
|
|
}
|
|
|
|
|
2010-08-05 13:46:34 +00:00
|
|
|
static void
|
|
|
|
layer_notify_valid_changed_cb (GObject * object, GParamSpec * unused
|
|
|
|
G_GNUC_UNUSED, App * app)
|
|
|
|
{
|
|
|
|
update_play_sensitivity (app);
|
|
|
|
}
|
|
|
|
|
2010-07-21 11:54:24 +00:00
|
|
|
static gboolean
|
2013-02-15 02:34:48 +00:00
|
|
|
find_row_for_object (GtkListStore * model, GtkTreeIter * ret, GESClip * clip)
|
2010-07-21 11:54:24 +00:00
|
|
|
{
|
|
|
|
gtk_tree_model_get_iter_first ((GtkTreeModel *) model, ret);
|
|
|
|
|
|
|
|
while (gtk_list_store_iter_is_valid (model, ret)) {
|
2013-02-15 02:34:48 +00:00
|
|
|
GESClip *clip2;
|
|
|
|
gtk_tree_model_get ((GtkTreeModel *) model, ret, 2, &clip2, -1);
|
|
|
|
if (clip2 == clip) {
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (clip2);
|
2010-07-21 11:54:24 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (clip2);
|
2010-07-21 11:54:24 +00:00
|
|
|
gtk_tree_model_iter_next ((GtkTreeModel *) model, ret);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-02-08 20:11:22 +00:00
|
|
|
/* this callback is registered for every clip, and updates the
|
2010-07-21 16:15:06 +00:00
|
|
|
* corresponding duration cell in the model */
|
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
clip_notify_duration_cb (GESClip * clip,
|
2010-07-21 16:15:06 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, App * app)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
guint64 duration = 0;
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
g_object_get (clip, "duration", &duration, NULL);
|
|
|
|
find_row_for_object (app->model, &iter, clip);
|
2010-07-21 16:15:06 +00:00
|
|
|
gtk_list_store_set (app->model, &iter, 1, duration, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* these guys are only connected to filesources that are the target of the
|
|
|
|
* current selection */
|
|
|
|
|
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
filesource_notify_duration_cb (GESClip * clip,
|
2010-07-21 16:15:06 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, App * app)
|
|
|
|
{
|
2010-07-21 18:21:01 +00:00
|
|
|
guint64 duration, max_inpoint;
|
2013-02-15 02:34:48 +00:00
|
|
|
duration = GES_TIMELINE_ELEMENT_DURATION (clip);
|
|
|
|
max_inpoint = GES_TIMELINE_ELEMENT_MAX_DURATION (clip) - duration;
|
2010-07-21 18:21:01 +00:00
|
|
|
|
|
|
|
gtk_range_set_value (GTK_RANGE (app->duration), duration);
|
|
|
|
gtk_range_set_fill_level (GTK_RANGE (app->in_point), max_inpoint);
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
if (max_inpoint < GES_TIMELINE_ELEMENT_INPOINT (clip))
|
|
|
|
g_object_set (clip, "in-point", max_inpoint, NULL);
|
2010-07-21 18:21:01 +00:00
|
|
|
|
2010-07-21 16:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
filesource_notify_max_duration_cb (GESClip * clip,
|
2010-07-21 16:15:06 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, App * app)
|
|
|
|
{
|
2011-01-08 14:25:22 +00:00
|
|
|
gtk_range_set_range (GTK_RANGE (app->duration), 0, (gdouble)
|
2013-02-15 02:34:48 +00:00
|
|
|
GES_TIMELINE_ELEMENT_MAX_DURATION (clip));
|
2011-01-08 14:25:22 +00:00
|
|
|
gtk_range_set_range (GTK_RANGE (app->in_point), 0, (gdouble)
|
2013-02-15 02:34:48 +00:00
|
|
|
GES_TIMELINE_ELEMENT_MAX_DURATION (clip));
|
2010-07-21 18:21:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
filesource_notify_in_point_cb (GESClip * clip,
|
2010-07-21 18:21:01 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, App * app)
|
|
|
|
{
|
|
|
|
gtk_range_set_value (GTK_RANGE (app->in_point),
|
2013-02-15 02:34:48 +00:00
|
|
|
GES_TIMELINE_ELEMENT_INPOINT (clip));
|
2010-07-21 16:15:06 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 16:25:24 +00:00
|
|
|
static void
|
|
|
|
app_update_first_last_selected (App * app)
|
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
/* keep track of whether the first or last items are selected */
|
|
|
|
path = gtk_tree_path_new_from_indices (0, -1);
|
|
|
|
app->first_selected =
|
|
|
|
gtk_tree_selection_path_is_selected (app->selection, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_indices (app->n_objects - 1, -1);
|
|
|
|
app->last_selected =
|
|
|
|
gtk_tree_selection_path_is_selected (app->selection, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
}
|
|
|
|
|
2010-07-23 17:14:21 +00:00
|
|
|
static void
|
|
|
|
object_count_changed (App * app)
|
2010-07-21 16:15:06 +00:00
|
|
|
{
|
2010-08-04 16:25:24 +00:00
|
|
|
app_update_first_last_selected (app);
|
|
|
|
update_move_up_down_sensitivity (app);
|
2010-08-05 13:46:34 +00:00
|
|
|
update_play_sensitivity (app);
|
2010-07-21 16:15:06 +00:00
|
|
|
}
|
|
|
|
|
2010-07-22 11:13:20 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
title_source_text_changed_cb (GESClip * clip,
|
2010-07-23 17:14:21 +00:00
|
|
|
GParamSpec * arg G_GNUC_UNUSED, App * app)
|
2010-07-22 11:13:20 +00:00
|
|
|
{
|
2010-07-23 17:14:21 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar *text;
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
g_object_get (clip, "text", &text, NULL);
|
2010-07-23 17:14:21 +00:00
|
|
|
if (text) {
|
2013-02-15 02:34:48 +00:00
|
|
|
find_row_for_object (app->model, &iter, clip);
|
2010-07-23 17:14:21 +00:00
|
|
|
gtk_list_store_set (app->model, &iter, 0, text, -1);
|
|
|
|
}
|
2010-07-22 11:13:20 +00:00
|
|
|
}
|
|
|
|
|
2010-07-20 17:13:06 +00:00
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
layer_object_added_cb (GESLayer * layer, GESClip * clip, App * app)
|
2010-07-20 17:13:06 +00:00
|
|
|
{
|
2010-07-21 09:40:18 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gchar *description;
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
GST_INFO ("layer clip added cb %p %p %p", layer, clip, app);
|
2010-07-21 09:40:18 +00:00
|
|
|
|
|
|
|
gtk_list_store_append (app->model, &iter);
|
2010-07-23 17:14:21 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
if (GES_IS_URI_CLIP (clip)) {
|
|
|
|
g_object_get (G_OBJECT (clip), "uri", &description, NULL);
|
|
|
|
gtk_list_store_set (app->model, &iter, 0, description, 2, clip, -1);
|
2010-07-23 17:14:21 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
else if (GES_IS_TITLE_CLIP (clip)) {
|
|
|
|
gtk_list_store_set (app->model, &iter, 2, clip, -1);
|
|
|
|
g_signal_connect (G_OBJECT (clip), "notify::text",
|
2010-07-23 17:14:21 +00:00
|
|
|
G_CALLBACK (title_source_text_changed_cb), app);
|
2013-02-15 02:34:48 +00:00
|
|
|
title_source_text_changed_cb (clip, NULL, app);
|
2010-07-23 17:14:21 +00:00
|
|
|
}
|
2010-07-21 16:03:06 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
else if (GES_IS_TEST_CLIP (clip)) {
|
|
|
|
gtk_list_store_set (app->model, &iter, 2, clip, 0, "Test Source", -1);
|
2010-08-02 15:24:24 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
else if (GES_IS_BASE_TRANSITION_CLIP (clip)) {
|
|
|
|
gtk_list_store_set (app->model, &iter, 2, clip, 0, "Transition", -1);
|
2010-08-03 17:31:23 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_connect (G_OBJECT (clip), "notify::duration",
|
2013-01-20 15:42:29 +00:00
|
|
|
G_CALLBACK (clip_notify_duration_cb), app);
|
2013-02-15 02:34:48 +00:00
|
|
|
clip_notify_duration_cb (clip, NULL, app);
|
2010-07-23 17:14:21 +00:00
|
|
|
|
2010-07-22 11:13:20 +00:00
|
|
|
app->n_objects++;
|
|
|
|
object_count_changed (app);
|
2010-07-20 17:13:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
layer_object_removed_cb (GESLayer * layer, GESClip * clip, App * app)
|
2010-07-20 17:13:06 +00:00
|
|
|
{
|
2010-07-21 11:54:24 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
GST_INFO ("layer clip removed cb %p %p %p", layer, clip, app);
|
2010-07-21 11:54:24 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
if (!find_row_for_object (GTK_LIST_STORE (app->model), &iter, clip)) {
|
|
|
|
g_print ("clip deleted but we don't own it");
|
2010-07-21 11:54:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-07-22 11:13:20 +00:00
|
|
|
app->n_objects--;
|
|
|
|
object_count_changed (app);
|
2010-07-21 11:54:24 +00:00
|
|
|
|
|
|
|
gtk_list_store_remove (app->model, &iter);
|
2010-07-20 17:13:06 +00:00
|
|
|
}
|
|
|
|
|
2010-08-05 10:52:13 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
layer_object_moved_cb (GESClip * layer, GESClip * clip,
|
2010-08-05 10:52:13 +00:00
|
|
|
gint old, gint new, App * app)
|
|
|
|
{
|
|
|
|
GtkTreeIter a, b;
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
/* we can take the old position as given, but the new position might have to
|
|
|
|
* be adjusted. */
|
|
|
|
new = new < 0 ? (app->n_objects - 1) : new;
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_indices (old, -1);
|
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (app->model), &a, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_indices (new, -1);
|
|
|
|
gtk_tree_model_get_iter (GTK_TREE_MODEL (app->model), &b, path);
|
|
|
|
gtk_tree_path_free (path);
|
|
|
|
|
|
|
|
gtk_list_store_swap (app->model, &a, &b);
|
|
|
|
app_selection_changed_cb (app->selection, app);
|
|
|
|
update_move_up_down_sensitivity (app);
|
|
|
|
}
|
|
|
|
|
2010-07-22 10:43:13 +00:00
|
|
|
static void
|
|
|
|
pipeline_state_changed_cb (App * app)
|
|
|
|
{
|
2010-08-04 15:34:51 +00:00
|
|
|
gboolean playing_or_paused;
|
|
|
|
|
2010-07-22 10:43:13 +00:00
|
|
|
if (app->state == GST_STATE_PLAYING)
|
|
|
|
gtk_action_set_stock_id (app->play, GTK_STOCK_MEDIA_PAUSE);
|
|
|
|
else
|
|
|
|
gtk_action_set_stock_id (app->play, GTK_STOCK_MEDIA_PLAY);
|
2010-07-22 10:48:34 +00:00
|
|
|
|
2010-07-22 10:51:07 +00:00
|
|
|
update_delete_sensitivity (app);
|
2010-08-03 13:59:38 +00:00
|
|
|
update_add_transition_sensitivity (app);
|
2010-08-04 16:02:14 +00:00
|
|
|
update_move_up_down_sensitivity (app);
|
2010-07-22 10:54:01 +00:00
|
|
|
|
2010-08-04 15:34:51 +00:00
|
|
|
playing_or_paused = (app->state == GST_STATE_PLAYING) ||
|
|
|
|
(app->state == GST_STATE_PAUSED);
|
|
|
|
|
|
|
|
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);
|
2010-10-22 14:57:45 +00:00
|
|
|
gtk_action_set_sensitive ((GtkAction *) app->audio_track_action,
|
|
|
|
!playing_or_paused);
|
|
|
|
gtk_action_set_sensitive ((GtkAction *) app->video_track_action,
|
|
|
|
!playing_or_paused);
|
2010-08-04 15:34:51 +00:00
|
|
|
gtk_widget_set_sensitive (app->properties, !playing_or_paused);
|
2010-07-22 10:43:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-28 01:58:21 +00:00
|
|
|
static void
|
|
|
|
project_bus_message_cb (GstBus * bus, GstMessage * message,
|
|
|
|
GMainLoop * mainloop)
|
|
|
|
{
|
|
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
g_printerr ("ERROR\n");
|
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
g_printerr ("Done\n");
|
|
|
|
g_main_loop_quit (mainloop);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-22 10:43:13 +00:00
|
|
|
static void
|
|
|
|
bus_message_cb (GstBus * bus, GstMessage * message, App * app)
|
|
|
|
{
|
|
|
|
const GstStructure *s;
|
|
|
|
s = gst_message_get_structure (message);
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
|
|
|
case GST_MESSAGE_ERROR:
|
|
|
|
g_print ("ERROR\n");
|
|
|
|
break;
|
|
|
|
case GST_MESSAGE_EOS:
|
2010-08-03 13:17:25 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (app->pipeline), GST_STATE_READY);
|
2010-07-22 10:43:13 +00:00
|
|
|
break;
|
|
|
|
case GST_MESSAGE_STATE_CHANGED:
|
|
|
|
if (s && GST_MESSAGE_SRC (message) == GST_OBJECT_CAST (app->pipeline)) {
|
|
|
|
GstState old, new, pending;
|
|
|
|
gst_message_parse_state_changed (message, &old, &new, &pending);
|
|
|
|
app->state = new;
|
|
|
|
pipeline_state_changed_cb (app);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
/* Static UI Callbacks ******************************************************/
|
2010-07-20 16:53:15 +00:00
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
static gboolean
|
|
|
|
check_time (const gchar * time)
|
|
|
|
{
|
2012-08-09 08:14:57 +00:00
|
|
|
static GRegex *re = NULL;
|
2010-08-04 14:57:18 +00:00
|
|
|
|
2012-08-09 08:14:57 +00:00
|
|
|
if (!re) {
|
|
|
|
if (NULL == (re =
|
|
|
|
g_regex_new ("^[0-9][0-9]:[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?$",
|
|
|
|
G_REGEX_EXTENDED, 0, NULL)))
|
|
|
|
return FALSE;
|
2010-08-04 14:57:18 +00:00
|
|
|
}
|
|
|
|
|
2012-08-09 08:14:57 +00:00
|
|
|
if (g_regex_match (re, time, 0, NULL))
|
2010-08-04 14:57:18 +00:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint64
|
|
|
|
str_to_time (const gchar * str)
|
|
|
|
{
|
|
|
|
guint64 ret;
|
|
|
|
guint64 h, m;
|
|
|
|
gdouble s;
|
|
|
|
gchar buf[15];
|
|
|
|
|
|
|
|
buf[0] = str[0];
|
|
|
|
buf[1] = str[1];
|
|
|
|
buf[2] = '\0';
|
|
|
|
|
|
|
|
h = strtoull (buf, NULL, 10);
|
|
|
|
|
|
|
|
buf[0] = str[3];
|
|
|
|
buf[1] = str[4];
|
|
|
|
buf[2] = '\0';
|
|
|
|
|
|
|
|
m = strtoull (buf, NULL, 10);
|
|
|
|
|
|
|
|
strncpy (buf, &str[6], sizeof (buf));
|
|
|
|
s = strtod (buf, NULL);
|
|
|
|
|
|
|
|
ret = (h * 3600 * GST_SECOND) +
|
|
|
|
(m * 60 * GST_SECOND) + ((guint64) (s * GST_SECOND));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
text_notify_text_changed_cb (GtkEntry * widget, GParamSpec * unused, App * app)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
const gchar *text;
|
|
|
|
|
2010-08-05 14:12:45 +00:00
|
|
|
if (app->ignore_input)
|
|
|
|
return;
|
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
text = gtk_entry_get_text (widget);
|
|
|
|
|
|
|
|
for (tmp = app->selected_objects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_set (G_OBJECT (tmp->data), "text", text, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
seconds_notify_text_changed_cb (GtkEntry * widget, GParamSpec * unused,
|
|
|
|
App * app)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
const gchar *text;
|
|
|
|
|
2010-08-05 14:12:45 +00:00
|
|
|
if (app->ignore_input)
|
|
|
|
return;
|
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
text = gtk_entry_get_text (app->seconds);
|
|
|
|
|
|
|
|
if (!check_time (text)) {
|
|
|
|
gtk_entry_set_icon_from_stock (app->seconds,
|
|
|
|
GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_DIALOG_WARNING);
|
|
|
|
} else {
|
|
|
|
gtk_entry_set_icon_from_stock (app->seconds,
|
|
|
|
GTK_ENTRY_ICON_SECONDARY, NULL);
|
|
|
|
for (tmp = app->selected_objects; tmp; tmp = tmp->next) {
|
2013-01-20 15:42:29 +00:00
|
|
|
g_object_set (GES_CLIP (tmp->data), "duration",
|
2010-08-04 14:57:18 +00:00
|
|
|
(guint64) str_to_time (text), NULL);
|
|
|
|
}
|
|
|
|
}
|
2010-07-21 13:43:28 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
static void
|
|
|
|
duration_cell_func (GtkTreeViewColumn * column, GtkCellRenderer * renderer,
|
|
|
|
GtkTreeModel * model, GtkTreeIter * iter, gpointer user)
|
|
|
|
{
|
|
|
|
gchar buf[30];
|
|
|
|
guint64 duration;
|
|
|
|
|
|
|
|
gtk_tree_model_get (model, iter, 1, &duration, -1);
|
|
|
|
g_snprintf (buf, sizeof (buf), "%u:%02u:%02u.%09u", GST_TIME_ARGS (duration));
|
|
|
|
g_object_set (renderer, "text", &buf, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* UI Initialization ********************************************************/
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
connect_to_filesource (GESClip * clip, App * app)
|
2010-07-21 15:00:35 +00:00
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_connect (G_OBJECT (clip), "notify::max-duration",
|
2010-07-21 15:00:35 +00:00
|
|
|
G_CALLBACK (filesource_notify_max_duration_cb), app);
|
2013-02-15 02:34:48 +00:00
|
|
|
filesource_notify_max_duration_cb (clip, NULL, app);
|
2010-07-21 16:15:56 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_connect (G_OBJECT (clip), "notify::duration",
|
2010-07-21 16:15:56 +00:00
|
|
|
G_CALLBACK (filesource_notify_duration_cb), app);
|
2013-02-15 02:34:48 +00:00
|
|
|
filesource_notify_duration_cb (clip, NULL, app);
|
2010-07-21 18:21:01 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_connect (G_OBJECT (clip), "notify::in-point",
|
2010-07-21 18:21:01 +00:00
|
|
|
G_CALLBACK (filesource_notify_in_point_cb), app);
|
2013-02-15 02:34:48 +00:00
|
|
|
filesource_notify_in_point_cb (clip, NULL, app);
|
2010-07-21 15:00:35 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
disconnect_from_filesource (GESClip * clip, App * app)
|
2010-07-21 15:00:35 +00:00
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (clip),
|
2010-07-21 15:00:35 +00:00
|
|
|
filesource_notify_duration_cb, app);
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (clip),
|
2010-07-21 15:00:35 +00:00
|
|
|
filesource_notify_max_duration_cb, app);
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
connect_to_title_source (GESClip * clip, App * app)
|
|
|
|
{
|
|
|
|
GESTitleClip *titleclip;
|
|
|
|
titleclip = GES_TITLE_CLIP (clip);
|
|
|
|
gtk_combo_box_set_active (app->halign,
|
|
|
|
ges_title_clip_get_halignment (titleclip));
|
|
|
|
gtk_combo_box_set_active (app->valign,
|
|
|
|
ges_title_clip_get_valignment (titleclip));
|
|
|
|
gtk_entry_set_text (app->text, ges_title_clip_get_text (titleclip));
|
2010-07-23 16:56:48 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
disconnect_from_title_source (GESClip * clip, App * app)
|
2010-07-23 16:56:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-02 17:06:06 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
connect_to_test_source (GESClip * clip, App * app)
|
2010-08-02 17:06:06 +00:00
|
|
|
{
|
2010-08-03 12:39:56 +00:00
|
|
|
GObjectClass *klass;
|
|
|
|
GParamSpecDouble *pspec;
|
2010-08-02 17:06:06 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
GESTestClip *testclip;
|
|
|
|
testclip = GES_TEST_CLIP (clip);
|
2011-01-07 18:36:31 +00:00
|
|
|
gtk_combo_box_set_active (app->background_type,
|
2013-02-15 02:34:48 +00:00
|
|
|
ges_test_clip_get_vpattern (testclip));
|
2010-08-02 17:06:06 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_connect (G_OBJECT (testclip), "notify::volume",
|
2010-08-03 12:39:56 +00:00
|
|
|
G_CALLBACK (test_source_notify_volume_changed_cb), app);
|
2013-02-15 02:34:48 +00:00
|
|
|
test_source_notify_volume_changed_cb (clip, NULL, app);
|
2010-08-03 12:39:56 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
klass = G_OBJECT_GET_CLASS (G_OBJECT (testclip));
|
2010-08-03 12:39:56 +00:00
|
|
|
|
2010-08-03 12:53:22 +00:00
|
|
|
pspec = G_PARAM_SPEC_DOUBLE (g_object_class_find_property (klass, "volume"));
|
2010-08-03 12:39:56 +00:00
|
|
|
gtk_range_set_range (GTK_RANGE (app->volume), pspec->minimum, pspec->maximum);
|
2010-08-03 12:53:22 +00:00
|
|
|
|
|
|
|
pspec = G_PARAM_SPEC_DOUBLE (g_object_class_find_property (klass, "freq"));
|
|
|
|
gtk_spin_button_set_range (app->frequency, pspec->minimum, pspec->maximum);
|
|
|
|
gtk_spin_button_set_value (app->frequency,
|
2013-02-15 02:34:48 +00:00
|
|
|
ges_test_clip_get_frequency (GES_TEST_CLIP (clip)));
|
2010-08-03 12:39:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
disconnect_from_test_source (GESClip * clip, App * app)
|
2010-08-03 12:39:56 +00:00
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (G_OBJECT (clip),
|
2010-08-03 12:39:56 +00:00
|
|
|
test_source_notify_volume_changed_cb, app);
|
2010-08-02 17:06:06 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
connect_to_object (GESClip * clip, App * app)
|
2010-07-23 16:56:48 +00:00
|
|
|
{
|
2010-08-05 15:48:07 +00:00
|
|
|
gchar buf[30];
|
|
|
|
guint64 duration;
|
|
|
|
|
2010-08-05 14:12:45 +00:00
|
|
|
app->ignore_input = TRUE;
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
duration = GES_TIMELINE_ELEMENT_DURATION (clip);
|
2010-08-05 15:48:07 +00:00
|
|
|
g_snprintf (buf, sizeof (buf), "%02u:%02u:%02u.%09u",
|
|
|
|
GST_TIME_ARGS (duration));
|
|
|
|
gtk_entry_set_text (app->seconds, buf);
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
if (GES_IS_URI_CLIP (clip)) {
|
|
|
|
connect_to_filesource (clip, app);
|
|
|
|
} else if (GES_IS_TITLE_CLIP (clip)) {
|
|
|
|
connect_to_title_source (clip, app);
|
|
|
|
} else if (GES_IS_TEST_CLIP (clip)) {
|
|
|
|
connect_to_test_source (clip, app);
|
2010-07-23 16:56:48 +00:00
|
|
|
}
|
2010-08-05 14:12:45 +00:00
|
|
|
|
|
|
|
app->ignore_input = FALSE;
|
2010-07-23 16:56:48 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static void
|
2013-02-15 02:34:48 +00:00
|
|
|
disconnect_from_object (GESClip * clip, App * app)
|
|
|
|
{
|
|
|
|
if (GES_IS_URI_CLIP (clip)) {
|
|
|
|
disconnect_from_filesource (clip, app);
|
|
|
|
} else if (GES_IS_TITLE_CLIP (clip)) {
|
|
|
|
disconnect_from_title_source (clip, app);
|
|
|
|
} else if (GES_IS_TEST_CLIP (clip)) {
|
|
|
|
disconnect_from_test_source (clip, app);
|
2010-07-23 16:56:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-02 15:26:24 +00:00
|
|
|
static GtkListStore *
|
|
|
|
get_video_patterns (void)
|
|
|
|
{
|
|
|
|
GEnumClass *enum_class;
|
2013-01-17 03:58:28 +00:00
|
|
|
GESTestClip *tr;
|
|
|
|
GESTestClipClass *klass;
|
2010-08-02 15:26:24 +00:00
|
|
|
GParamSpec *pspec;
|
|
|
|
GEnumValue *v;
|
|
|
|
GtkListStore *m;
|
|
|
|
GtkTreeIter i;
|
|
|
|
|
|
|
|
m = gtk_list_store_new (1, G_TYPE_STRING);
|
|
|
|
|
2013-01-17 03:58:28 +00:00
|
|
|
tr = ges_test_clip_new ();
|
|
|
|
klass = GES_TEST_CLIP_GET_CLASS (tr);
|
2010-08-02 15:26:24 +00:00
|
|
|
|
|
|
|
pspec = g_object_class_find_property (G_OBJECT_CLASS (klass), "vpattern");
|
|
|
|
|
|
|
|
enum_class = G_ENUM_CLASS (g_type_class_ref (pspec->value_type));
|
|
|
|
|
|
|
|
for (v = enum_class->values; v->value_nick != NULL; v++) {
|
|
|
|
gtk_list_store_append (m, &i);
|
|
|
|
gtk_list_store_set (m, &i, 0, v->value_name, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_type_class_unref (enum_class);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tr);
|
2010-08-02 15:26:24 +00:00
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:57:18 +00:00
|
|
|
#define GET_WIDGET(dest,name,type) {\
|
|
|
|
if (!(dest =\
|
|
|
|
type(gtk_builder_get_object(builder, name))))\
|
|
|
|
goto fail;\
|
|
|
|
}
|
|
|
|
|
2010-10-11 10:37:51 +00:00
|
|
|
|
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
layer_added_cb (GESTimeline * timeline, GESLayer * layer, App * app)
|
2010-10-11 10:37:51 +00:00
|
|
|
{
|
2013-11-22 20:49:49 +00:00
|
|
|
if (!GES_IS_LAYER (layer)) {
|
2010-10-11 10:37:51 +00:00
|
|
|
GST_ERROR ("This timeline contains a layer type other than "
|
2013-11-22 20:49:49 +00:00
|
|
|
"GESLayer. Timeline editing disabled");
|
2010-10-11 10:37:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(app->layer)) {
|
|
|
|
app->layer = layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (layer != app->layer) {
|
|
|
|
GST_ERROR ("This demo doesn't support editing timelines with multiple"
|
|
|
|
" layers");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-08 20:19:39 +00:00
|
|
|
g_signal_connect (app->layer, "clip-added",
|
2010-10-11 10:37:51 +00:00
|
|
|
G_CALLBACK (layer_object_added_cb), app);
|
2013-02-08 20:19:39 +00:00
|
|
|
g_signal_connect (app->layer, "clip-removed",
|
2010-10-11 10:37:51 +00:00
|
|
|
G_CALLBACK (layer_object_removed_cb), app);
|
|
|
|
g_signal_connect (app->layer, "object-moved",
|
|
|
|
G_CALLBACK (layer_object_moved_cb), app);
|
|
|
|
g_signal_connect (app->layer, "notify::valid",
|
|
|
|
G_CALLBACK (layer_notify_valid_changed_cb), app);
|
|
|
|
}
|
|
|
|
|
2010-10-22 14:57:45 +00:00
|
|
|
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;
|
|
|
|
}
|
2010-10-11 10:37:51 +00:00
|
|
|
|
|
|
|
|
2010-10-22 14:57:45 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static gboolean
|
2010-07-20 15:59:59 +00:00
|
|
|
create_ui (App * app)
|
2010-07-19 17:02:41 +00:00
|
|
|
{
|
|
|
|
GtkBuilder *builder;
|
2010-07-21 09:40:18 +00:00
|
|
|
GtkTreeView *timeline;
|
2010-07-21 17:01:33 +00:00
|
|
|
GtkTreeViewColumn *duration_col;
|
|
|
|
GtkCellRenderer *duration_renderer;
|
2010-08-02 15:26:24 +00:00
|
|
|
GtkCellRenderer *background_type_renderer;
|
|
|
|
GtkListStore *backgrounds;
|
2010-07-22 10:43:13 +00:00
|
|
|
GstBus *bus;
|
2010-07-19 17:02:41 +00:00
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
/* construct widget tree */
|
|
|
|
|
2010-07-19 17:02:41 +00:00
|
|
|
builder = gtk_builder_new ();
|
|
|
|
gtk_builder_add_from_file (builder, "ges-ui.glade", NULL);
|
2010-07-20 17:41:58 +00:00
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
/* get a bunch of widgets from the XML tree */
|
2010-07-20 17:41:58 +00:00
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
GET_WIDGET (timeline, "timeline_treeview", GTK_TREE_VIEW);
|
|
|
|
GET_WIDGET (app->properties, "properties", GTK_WIDGET);
|
2010-07-23 16:43:37 +00:00
|
|
|
GET_WIDGET (app->filesource_properties, "filesource_properties", GTK_WIDGET);
|
|
|
|
GET_WIDGET (app->text_properties, "text_properties", GTK_WIDGET);
|
2010-07-21 13:43:28 +00:00
|
|
|
GET_WIDGET (app->main_window, "window", GTK_WIDGET);
|
2011-03-17 15:38:38 +00:00
|
|
|
GET_WIDGET (app->add_effect_dlg, "add_effect_dlg", GTK_WIDGET);
|
|
|
|
GET_WIDGET (app->audio_effect_entry, "entry1", GTK_WIDGET);
|
|
|
|
GET_WIDGET (app->video_effect_entry, "entry2", GTK_WIDGET);
|
2010-07-21 16:03:06 +00:00
|
|
|
GET_WIDGET (app->duration, "duration_scale", GTK_HSCALE);
|
2010-07-21 18:21:01 +00:00
|
|
|
GET_WIDGET (app->in_point, "in_point_scale", GTK_HSCALE);
|
2010-07-23 16:43:37 +00:00
|
|
|
GET_WIDGET (app->halign, "halign", GTK_COMBO_BOX);
|
|
|
|
GET_WIDGET (app->valign, "valign", GTK_COMBO_BOX);
|
|
|
|
GET_WIDGET (app->text, "text", GTK_ENTRY);
|
2010-07-21 17:01:33 +00:00
|
|
|
GET_WIDGET (duration_col, "duration_column", GTK_TREE_VIEW_COLUMN);
|
|
|
|
GET_WIDGET (duration_renderer, "duration_renderer", GTK_CELL_RENDERER);
|
2010-07-22 10:54:01 +00:00
|
|
|
GET_WIDGET (app->add_file, "add_file", GTK_ACTION);
|
2011-03-17 15:38:38 +00:00
|
|
|
GET_WIDGET (app->add_effect, "add_effect", GTK_ACTION);
|
2010-08-03 13:03:24 +00:00
|
|
|
GET_WIDGET (app->add_title, "add_text", GTK_ACTION);
|
|
|
|
GET_WIDGET (app->add_test, "add_test", GTK_ACTION);
|
2010-08-03 13:54:25 +00:00
|
|
|
GET_WIDGET (app->add_transition, "add_transition", GTK_ACTION);
|
2010-07-22 10:20:59 +00:00
|
|
|
GET_WIDGET (app->delete, "delete", GTK_ACTION);
|
2010-07-22 10:43:13 +00:00
|
|
|
GET_WIDGET (app->play, "play", GTK_ACTION);
|
2010-08-04 15:17:59 +00:00
|
|
|
GET_WIDGET (app->stop, "stop", GTK_ACTION);
|
2010-08-04 16:02:14 +00:00
|
|
|
GET_WIDGET (app->move_up, "move_up", GTK_ACTION);
|
|
|
|
GET_WIDGET (app->move_down, "move_down", GTK_ACTION);
|
2010-07-27 13:25:20 +00:00
|
|
|
GET_WIDGET (app->seconds, "seconds", GTK_ENTRY);
|
|
|
|
GET_WIDGET (app->generic_duration, "generic_duration", GTK_WIDGET);
|
2010-08-02 15:22:39 +00:00
|
|
|
GET_WIDGET (app->background_type, "background_type", GTK_COMBO_BOX);
|
|
|
|
GET_WIDGET (app->background_properties, "background_properties", GTK_WIDGET);
|
2010-08-03 12:38:42 +00:00
|
|
|
GET_WIDGET (app->frequency, "frequency", GTK_SPIN_BUTTON);
|
|
|
|
GET_WIDGET (app->volume, "volume", GTK_HSCALE);
|
2010-10-22 14:57:45 +00:00
|
|
|
GET_WIDGET (app->audio_track_action, "audio_track", GTK_TOGGLE_ACTION);
|
|
|
|
GET_WIDGET (app->video_track_action, "video_track", GTK_TOGGLE_ACTION);
|
2010-07-20 17:41:58 +00:00
|
|
|
|
2010-07-23 16:43:37 +00:00
|
|
|
/* get text notifications */
|
|
|
|
|
|
|
|
g_signal_connect (app->text, "notify::text",
|
|
|
|
G_CALLBACK (text_notify_text_changed_cb), app);
|
|
|
|
|
2010-07-27 13:25:20 +00:00
|
|
|
g_signal_connect (app->seconds, "notify::text",
|
|
|
|
G_CALLBACK (seconds_notify_text_changed_cb), app);
|
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
/* we care when the tree selection changes */
|
2010-07-21 11:53:01 +00:00
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
if (!(app->selection = gtk_tree_view_get_selection (timeline)))
|
2010-07-21 11:53:01 +00:00
|
|
|
goto fail;
|
|
|
|
|
2010-08-03 13:40:44 +00:00
|
|
|
gtk_tree_selection_set_mode (app->selection, GTK_SELECTION_MULTIPLE);
|
|
|
|
|
2010-07-21 13:23:18 +00:00
|
|
|
g_signal_connect (app->selection, "changed",
|
|
|
|
G_CALLBACK (app_selection_changed_cb), app);
|
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
/* create the model for the treeview */
|
2010-07-21 09:40:18 +00:00
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
if (!(app->model =
|
|
|
|
gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_OBJECT)))
|
|
|
|
goto fail;
|
2010-08-02 15:26:24 +00:00
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
gtk_tree_view_set_model (timeline, GTK_TREE_MODEL (app->model));
|
2010-07-19 17:02:41 +00:00
|
|
|
|
2010-07-21 17:01:33 +00:00
|
|
|
/* register custom cell data function */
|
|
|
|
|
|
|
|
gtk_tree_view_column_set_cell_data_func (duration_col, duration_renderer,
|
|
|
|
duration_cell_func, NULL, NULL);
|
|
|
|
|
2010-08-02 15:26:24 +00:00
|
|
|
/* initialize combo boxes */
|
|
|
|
|
|
|
|
if (!(backgrounds = get_video_patterns ()))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!(background_type_renderer = gtk_cell_renderer_text_new ()))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
gtk_combo_box_set_model (app->background_type, (GtkTreeModel *)
|
|
|
|
backgrounds);
|
|
|
|
|
|
|
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (app->background_type),
|
|
|
|
background_type_renderer, FALSE);
|
|
|
|
|
|
|
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (app->background_type),
|
|
|
|
background_type_renderer, "text", 0);
|
|
|
|
|
2010-10-11 10:37:51 +00:00
|
|
|
g_signal_connect (app->timeline, "layer-added", G_CALLBACK
|
|
|
|
(layer_added_cb), app);
|
2010-10-22 14:57:45 +00:00
|
|
|
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);
|
2010-07-20 17:13:06 +00:00
|
|
|
|
2010-10-11 10:37:51 +00:00
|
|
|
/* register callbacks on GES objects */
|
2010-07-22 10:43:13 +00:00
|
|
|
bus = gst_pipeline_get_bus (GST_PIPELINE (app->pipeline));
|
|
|
|
gst_bus_add_signal_watch (bus);
|
|
|
|
g_signal_connect (bus, "message", G_CALLBACK (bus_message_cb), app);
|
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
/* success */
|
2010-10-22 14:57:45 +00:00
|
|
|
gtk_builder_connect_signals (builder, app);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (G_OBJECT (builder));
|
2010-07-20 17:41:58 +00:00
|
|
|
return TRUE;
|
2010-07-21 09:40:18 +00:00
|
|
|
|
|
|
|
fail:
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (G_OBJECT (builder));
|
2010-07-21 09:40:18 +00:00
|
|
|
return FALSE;
|
2010-07-20 15:05:26 +00:00
|
|
|
}
|
|
|
|
|
2010-07-21 13:43:28 +00:00
|
|
|
#undef GET_WIDGET
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
/* application methods ******************************************************/
|
|
|
|
|
|
|
|
static void selection_foreach (GtkTreeModel * model, GtkTreePath * path,
|
|
|
|
GtkTreeIter * iter, gpointer user);
|
|
|
|
|
|
|
|
static void
|
2010-08-04 15:27:01 +00:00
|
|
|
app_toggle_playpause (App * app)
|
2010-08-04 14:36:15 +00:00
|
|
|
{
|
|
|
|
if (app->state != GST_STATE_PLAYING) {
|
|
|
|
gst_element_set_state (GST_ELEMENT (app->pipeline), GST_STATE_PLAYING);
|
|
|
|
} else {
|
|
|
|
gst_element_set_state (GST_ELEMENT (app->pipeline), GST_STATE_PAUSED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-04 15:27:01 +00:00
|
|
|
static void
|
|
|
|
app_stop_playback (App * app)
|
|
|
|
{
|
|
|
|
if ((app->state != GST_STATE_NULL) && (app->state != GST_STATE_READY)) {
|
|
|
|
gst_element_set_state (GST_ELEMENT (app->pipeline), GST_STATE_READY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GList *objects;
|
|
|
|
guint n;
|
|
|
|
} select_info;
|
|
|
|
|
|
|
|
static void
|
|
|
|
app_update_selection (App * app)
|
|
|
|
{
|
|
|
|
GList *cur;
|
|
|
|
GType type;
|
|
|
|
select_info info = { NULL, 0 };
|
|
|
|
|
|
|
|
/* clear old selection */
|
|
|
|
for (cur = app->selected_objects; cur; cur = cur->next) {
|
|
|
|
disconnect_from_object (cur->data, app);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (cur->data);
|
2010-08-04 14:36:15 +00:00
|
|
|
cur->data = NULL;
|
|
|
|
}
|
|
|
|
g_list_free (app->selected_objects);
|
|
|
|
app->selected_objects = NULL;
|
|
|
|
app->n_selected = 0;
|
|
|
|
|
|
|
|
/* get new selection */
|
|
|
|
gtk_tree_selection_selected_foreach (GTK_TREE_SELECTION (app->selection),
|
|
|
|
selection_foreach, &info);
|
|
|
|
app->selected_objects = info.objects;
|
|
|
|
app->n_selected = info.n;
|
|
|
|
|
|
|
|
type = G_TYPE_NONE;
|
|
|
|
if (app->selected_objects) {
|
|
|
|
type = G_TYPE_FROM_INSTANCE (app->selected_objects->data);
|
|
|
|
for (cur = app->selected_objects; cur; cur = cur->next) {
|
|
|
|
if (type != G_TYPE_FROM_INSTANCE (cur->data)) {
|
|
|
|
type = G_TYPE_NONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type != G_TYPE_NONE) {
|
|
|
|
for (cur = app->selected_objects; cur; cur = cur->next) {
|
|
|
|
connect_to_object (cur->data, app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
app->selected_type = type;
|
2010-08-04 16:25:24 +00:00
|
|
|
app_update_first_last_selected (app);
|
2010-08-04 14:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
selection_foreach (GtkTreeModel * model, GtkTreePath * path, GtkTreeIter
|
|
|
|
* iter, gpointer user)
|
|
|
|
{
|
|
|
|
select_info *info = (select_info *) user;
|
2013-02-15 02:34:48 +00:00
|
|
|
GESClip *clip;
|
2010-08-04 14:36:15 +00:00
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
gtk_tree_model_get (model, iter, 2, &clip, -1);
|
|
|
|
info->objects = g_list_append (info->objects, clip);
|
2010-08-04 14:36:15 +00:00
|
|
|
|
|
|
|
info->n++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
app_get_selected_objects (App * app)
|
|
|
|
{
|
|
|
|
return g_list_copy (app->selected_objects);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
app_delete_objects (App * app, GList * objects)
|
|
|
|
{
|
|
|
|
GList *cur;
|
|
|
|
|
|
|
|
for (cur = objects; cur; cur = cur->next) {
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_remove_clip (app->layer, GES_CLIP (cur->data));
|
2010-08-04 14:36:15 +00:00
|
|
|
cur->data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (objects);
|
|
|
|
}
|
|
|
|
|
2010-08-04 16:49:19 +00:00
|
|
|
/* the following two methods assume exactly one clip is selected and that the
|
|
|
|
* requested action is valid */
|
|
|
|
|
|
|
|
static void
|
|
|
|
app_move_selected_up (App * app)
|
|
|
|
{
|
2013-11-22 20:49:49 +00:00
|
|
|
GST_FIXME ("This function is not implement, please implement it :)");
|
2010-08-04 16:49:19 +00:00
|
|
|
}
|
|
|
|
|
2011-03-17 15:38:38 +00:00
|
|
|
static void
|
2013-03-14 16:53:25 +00:00
|
|
|
app_add_effect_on_selected_clips (App * app, const gchar * bin_desc)
|
2011-03-17 15:38:38 +00:00
|
|
|
{
|
|
|
|
GList *objects, *tmp;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *effect = NULL;
|
2011-03-17 15:38:38 +00:00
|
|
|
|
|
|
|
/* No crash if the video is playing */
|
|
|
|
gst_element_set_state (GST_ELEMENT (app->pipeline), GST_STATE_PAUSED);
|
2013-04-23 23:04:04 +00:00
|
|
|
objects = ges_layer_get_clips (app->layer);
|
2011-03-17 15:38:38 +00:00
|
|
|
|
|
|
|
for (tmp = objects; tmp; tmp = tmp->next) {
|
2013-01-26 15:40:51 +00:00
|
|
|
effect = GES_TRACK_ELEMENT (ges_effect_new (bin_desc));
|
2013-03-01 01:27:50 +00:00
|
|
|
ges_container_add (GES_CONTAINER (tmp->data),
|
|
|
|
GES_TIMELINE_ELEMENT (effect));
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp->data);
|
2011-03-17 15:38:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
add_effect_dlg_delete_event_cb (GtkWidget * widget, GdkEvent * event,
|
|
|
|
gpointer * app)
|
|
|
|
{
|
|
|
|
gtk_widget_hide_all (((App *) app)->add_effect_dlg);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
on_cancel_add_effect_cb (GtkButton * button, App * app)
|
|
|
|
{
|
|
|
|
gtk_widget_hide_all (app->add_effect_dlg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
on_apply_effect_cb (GtkButton * button, App * app)
|
|
|
|
{
|
|
|
|
const gchar *effect;
|
|
|
|
|
|
|
|
effect = gtk_entry_get_text (GTK_ENTRY (app->video_effect_entry));
|
|
|
|
if (g_strcmp0 (effect, ""))
|
2013-03-14 16:53:25 +00:00
|
|
|
app_add_effect_on_selected_clips (app, effect);
|
2011-03-17 15:38:38 +00:00
|
|
|
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (app->video_effect_entry), "");
|
|
|
|
|
|
|
|
effect = gtk_entry_get_text (GTK_ENTRY (app->audio_effect_entry));
|
|
|
|
if (g_strcmp0 (effect, ""))
|
2013-03-14 16:53:25 +00:00
|
|
|
app_add_effect_on_selected_clips (app, effect);
|
2011-03-17 15:38:38 +00:00
|
|
|
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (app->audio_effect_entry), "");
|
|
|
|
|
|
|
|
gtk_widget_hide_all (app->add_effect_dlg);
|
|
|
|
}
|
|
|
|
|
2010-08-04 16:49:19 +00:00
|
|
|
static void
|
|
|
|
app_move_selected_down (App * app)
|
|
|
|
{
|
2013-11-22 20:49:49 +00:00
|
|
|
GST_FIXME ("This function is not implement, please implement it :)");
|
2010-08-04 16:49:19 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static void
|
|
|
|
app_add_file (App * app, gchar * uri)
|
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
GESClip *clip;
|
2010-08-04 14:36:15 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("adding file %s", uri);
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
clip = GES_CLIP (ges_uri_clip_new (uri));
|
2013-11-22 20:49:49 +00:00
|
|
|
ges_timeline_element_set_start (GES_TIMELINE_ELEMENT (clip),
|
|
|
|
ges_layer_get_duration (app->layer));
|
2010-08-04 14:36:15 +00:00
|
|
|
|
2013-11-22 20:49:49 +00:00
|
|
|
ges_layer_add_clip (app->layer, clip);
|
2010-08-04 14:36:15 +00:00
|
|
|
}
|
|
|
|
|
2011-08-28 01:58:21 +00:00
|
|
|
static void
|
|
|
|
app_launch_project (App * app, gchar * uri)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
|
|
|
GMainLoop *mainloop;
|
2013-07-01 14:27:54 +00:00
|
|
|
GESPipeline *pipeline;
|
2011-08-28 01:58:21 +00:00
|
|
|
GstBus *bus;
|
2013-09-16 14:19:13 +00:00
|
|
|
GESProject *project;
|
2011-08-28 01:58:21 +00:00
|
|
|
|
|
|
|
uri = g_strsplit (uri, "//", 2)[1];
|
|
|
|
printf ("we will launch this uri : %s\n", uri);
|
2013-09-16 14:19:13 +00:00
|
|
|
project = ges_project_new (uri);
|
|
|
|
timeline = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), NULL));
|
2013-07-01 14:27:54 +00:00
|
|
|
pipeline = ges_pipeline_new ();
|
2011-08-28 01:58:21 +00:00
|
|
|
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
|
|
|
mainloop = g_main_loop_new (NULL, FALSE);
|
|
|
|
|
2014-02-04 09:45:58 +00:00
|
|
|
ges_pipeline_set_timeline (pipeline, timeline);
|
2014-02-17 11:34:04 +00:00
|
|
|
ges_pipeline_set_mode (pipeline, GES_PIPELINE_MODE_PREVIEW_VIDEO);
|
2011-08-28 01:58:21 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
|
|
|
gst_bus_add_signal_watch (bus);
|
|
|
|
g_signal_connect (bus, "message", G_CALLBACK (project_bus_message_cb),
|
|
|
|
mainloop);
|
|
|
|
g_main_loop_run (mainloop);
|
2013-09-16 14:19:13 +00:00
|
|
|
g_object_unref (project);
|
2011-08-28 01:58:21 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static void
|
|
|
|
app_add_title (App * app)
|
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
GESClip *clip;
|
2010-08-04 14:36:15 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("adding title");
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
clip = GES_CLIP (ges_title_clip_new ());
|
2013-11-22 20:49:49 +00:00
|
|
|
g_object_set (G_OBJECT (clip), "duration", GST_SECOND,
|
|
|
|
"start", ges_layer_get_duration (app->layer), NULL);
|
|
|
|
ges_layer_add_clip (app->layer, clip);
|
2010-08-04 14:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
app_add_test (App * app)
|
|
|
|
{
|
2013-02-15 02:34:48 +00:00
|
|
|
GESClip *clip;
|
2010-08-04 14:36:15 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("adding test");
|
|
|
|
|
2013-02-15 02:34:48 +00:00
|
|
|
clip = GES_CLIP (ges_test_clip_new ());
|
2013-11-22 20:49:49 +00:00
|
|
|
g_object_set (G_OBJECT (clip), "duration", GST_SECOND,
|
|
|
|
"start", ges_layer_get_duration (app->layer), NULL);
|
2010-08-04 14:36:15 +00:00
|
|
|
|
2013-11-22 20:49:49 +00:00
|
|
|
ges_layer_add_clip (app->layer, clip);
|
2010-08-04 14:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
app_add_transition (App * app)
|
|
|
|
{
|
2013-11-22 20:49:49 +00:00
|
|
|
GST_FIXME ("This function is not implement, please implement it :)");
|
2010-08-04 14:36:15 +00:00
|
|
|
}
|
|
|
|
|
2010-10-11 10:53:35 +00:00
|
|
|
static void
|
|
|
|
app_save_to_uri (App * app, gchar * uri)
|
|
|
|
{
|
2012-11-24 03:09:28 +00:00
|
|
|
ges_timeline_save_to_uri (app->timeline, uri, NULL, FALSE, NULL);
|
2010-10-11 10:53:35 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 14:57:45 +00:00
|
|
|
static void
|
|
|
|
app_add_audio_track (App * app)
|
|
|
|
{
|
|
|
|
if (app->audio_tracks)
|
|
|
|
return;
|
|
|
|
|
2013-03-28 17:51:45 +00:00
|
|
|
app->audio_track = GES_TRACK (ges_audio_track_new ());
|
2010-10-22 14:57:45 +00:00
|
|
|
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;
|
|
|
|
|
2013-03-28 17:51:45 +00:00
|
|
|
app->video_track = GES_TRACK (ges_video_track_new ());
|
2010-10-22 14:57:45 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:36:15 +00:00
|
|
|
static void
|
|
|
|
app_dispose (App * app)
|
|
|
|
{
|
|
|
|
if (app) {
|
|
|
|
if (app->pipeline) {
|
|
|
|
gst_element_set_state (GST_ELEMENT (app->pipeline), GST_STATE_NULL);
|
|
|
|
gst_object_unref (app->pipeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (app);
|
|
|
|
}
|
2010-10-08 11:32:15 +00:00
|
|
|
|
|
|
|
n_instances--;
|
|
|
|
|
|
|
|
if (n_instances == 0) {
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
2010-08-04 14:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static App *
|
2010-10-11 10:37:51 +00:00
|
|
|
app_init (void)
|
2010-08-04 14:36:15 +00:00
|
|
|
{
|
|
|
|
App *ret;
|
|
|
|
ret = g_new0 (App, 1);
|
2010-10-08 11:32:15 +00:00
|
|
|
n_instances++;
|
2010-08-04 14:36:15 +00:00
|
|
|
|
|
|
|
ret->selected_type = G_TYPE_NONE;
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
2010-10-11 10:37:51 +00:00
|
|
|
if (!(ret->timeline = ges_timeline_new ()))
|
2010-08-04 14:36:15 +00:00
|
|
|
goto fail;
|
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
if (!(ret->pipeline = ges_pipeline_new ()))
|
2010-08-04 14:36:15 +00:00
|
|
|
goto fail;
|
|
|
|
|
2014-02-04 09:45:58 +00:00
|
|
|
if (!ges_pipeline_set_timeline (ret->pipeline, ret->timeline))
|
2010-08-04 14:36:15 +00:00
|
|
|
goto fail;
|
|
|
|
|
2010-10-11 10:37:51 +00:00
|
|
|
if (!(create_ui (ret)))
|
2010-08-04 14:36:15 +00:00
|
|
|
goto fail;
|
|
|
|
|
2010-10-11 10:37:51 +00:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
app_dispose (ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static App *
|
|
|
|
app_new (void)
|
|
|
|
{
|
|
|
|
App *ret;
|
|
|
|
GESTrack *a = NULL, *v = NULL;
|
|
|
|
|
|
|
|
ret = app_init ();
|
|
|
|
|
|
|
|
/* add base audio and video track */
|
|
|
|
|
2013-03-28 17:51:45 +00:00
|
|
|
if (!(a = GES_TRACK (ges_audio_track_new ())))
|
2010-08-04 14:36:15 +00:00
|
|
|
goto fail;
|
|
|
|
|
2010-10-11 10:37:51 +00:00
|
|
|
if (!(ges_timeline_add_track (ret->timeline, a)))
|
|
|
|
goto fail;
|
|
|
|
|
2013-03-28 17:51:45 +00:00
|
|
|
if (!(v = GES_TRACK (ges_video_track_new ())))
|
2010-10-11 10:37:51 +00:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!(ges_timeline_add_track (ret->timeline, v)))
|
|
|
|
goto fail;
|
|
|
|
|
2013-11-22 20:49:49 +00:00
|
|
|
if (!(ret->layer = ges_layer_new ()))
|
2010-10-11 10:37:51 +00:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!(ges_timeline_add_layer (ret->timeline, ret->layer)))
|
2010-08-04 14:36:15 +00:00
|
|
|
goto fail;
|
|
|
|
|
2010-10-22 14:57:45 +00:00
|
|
|
ret->audio_track = a;
|
|
|
|
ret->video_track = v;
|
2010-08-04 14:36:15 +00:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
fail:
|
2010-10-11 10:37:51 +00:00
|
|
|
|
|
|
|
if (a)
|
|
|
|
gst_object_unref (a);
|
|
|
|
if (v)
|
|
|
|
gst_object_unref (v);
|
2010-08-04 14:36:15 +00:00
|
|
|
app_dispose (ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-10-11 10:38:11 +00:00
|
|
|
static gboolean
|
|
|
|
load_file_async (App * app)
|
|
|
|
{
|
2012-11-24 03:09:28 +00:00
|
|
|
ges_timeline_load_from_uri (app->timeline, app->pending_uri, NULL);
|
2010-10-11 10:38:11 +00:00
|
|
|
|
|
|
|
g_free (app->pending_uri);
|
|
|
|
app->pending_uri = NULL;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
app_new_from_uri (gchar * uri)
|
|
|
|
{
|
|
|
|
App *ret;
|
|
|
|
|
|
|
|
ret = app_init ();
|
|
|
|
ret->pending_uri = g_strdup (uri);
|
|
|
|
g_idle_add ((GSourceFunc) load_file_async, ret);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:26:39 +00:00
|
|
|
/* UI callbacks ************************************************************/
|
|
|
|
|
2010-08-05 14:19:35 +00:00
|
|
|
gboolean
|
2010-10-08 11:32:15 +00:00
|
|
|
window_delete_event_cb (GtkObject * window, GdkEvent * event, App * app)
|
2010-08-04 14:26:39 +00:00
|
|
|
{
|
2010-10-08 11:32:15 +00:00
|
|
|
app_dispose (app);
|
|
|
|
return FALSE;
|
2010-08-04 14:26:39 +00:00
|
|
|
}
|
|
|
|
|
2010-10-11 10:38:11 +00:00
|
|
|
void
|
|
|
|
new_activate_cb (GtkMenuItem * item, App * app)
|
|
|
|
{
|
|
|
|
app_new ();
|
|
|
|
}
|
|
|
|
|
2011-08-28 01:58:21 +00:00
|
|
|
void
|
2013-09-16 14:19:13 +00:00
|
|
|
launch_project_activate_cb (GtkMenuItem * item, App * app)
|
2011-08-28 01:58:21 +00:00
|
|
|
{
|
|
|
|
GtkFileChooserDialog *dlg;
|
|
|
|
GtkFileFilter *filter;
|
|
|
|
|
|
|
|
GST_DEBUG ("add file signal handler");
|
|
|
|
|
|
|
|
filter = gtk_file_filter_new ();
|
|
|
|
gtk_file_filter_set_name (filter, "pitivi projects");
|
|
|
|
gtk_file_filter_add_pattern (filter, "*.xptv");
|
|
|
|
dlg = (GtkFileChooserDialog *)
|
|
|
|
gtk_file_chooser_dialog_new ("Preview Project...",
|
|
|
|
GTK_WINDOW (app->main_window),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
GTK_STOCK_CANCEL,
|
|
|
|
GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
|
|
|
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dlg), filter);
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (dlg), "select-multiple", FALSE, NULL);
|
|
|
|
|
|
|
|
if (gtk_dialog_run ((GtkDialog *) dlg) == GTK_RESPONSE_OK) {
|
|
|
|
gchar *uri;
|
|
|
|
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dlg));
|
|
|
|
gtk_widget_destroy ((GtkWidget *) dlg);
|
|
|
|
app_launch_project (app, uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-11 10:38:11 +00:00
|
|
|
void
|
|
|
|
open_activate_cb (GtkMenuItem * item, App * app)
|
|
|
|
{
|
|
|
|
GtkFileChooserDialog *dlg;
|
|
|
|
|
|
|
|
GST_DEBUG ("add file signal handler");
|
|
|
|
|
|
|
|
dlg = (GtkFileChooserDialog *) gtk_file_chooser_dialog_new ("Open Project...",
|
|
|
|
GTK_WINDOW (app->main_window),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
GTK_STOCK_CANCEL,
|
|
|
|
GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (dlg), "select-multiple", FALSE, NULL);
|
|
|
|
|
|
|
|
if (gtk_dialog_run ((GtkDialog *) dlg) == GTK_RESPONSE_OK) {
|
|
|
|
gchar *uri;
|
|
|
|
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dlg));
|
|
|
|
app_new_from_uri (uri);
|
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
gtk_widget_destroy ((GtkWidget *) dlg);
|
|
|
|
}
|
|
|
|
|
2010-10-11 10:53:35 +00:00
|
|
|
void
|
|
|
|
save_as_activate_cb (GtkMenuItem * item, App * app)
|
|
|
|
{
|
|
|
|
GtkFileChooserDialog *dlg;
|
|
|
|
|
|
|
|
GST_DEBUG ("save as signal handler");
|
|
|
|
|
|
|
|
dlg = (GtkFileChooserDialog *)
|
|
|
|
gtk_file_chooser_dialog_new ("Save project as...",
|
|
|
|
GTK_WINDOW (app->main_window), GTK_FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (dlg), "select-multiple", FALSE, NULL);
|
|
|
|
|
|
|
|
if (gtk_dialog_run ((GtkDialog *) dlg) == GTK_RESPONSE_OK) {
|
|
|
|
gchar *uri;
|
|
|
|
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dlg));
|
|
|
|
app_save_to_uri (app, uri);
|
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
gtk_widget_destroy ((GtkWidget *) dlg);
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:26:39 +00:00
|
|
|
void
|
|
|
|
quit_item_activate_cb (GtkMenuItem * item, App * app)
|
|
|
|
{
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
delete_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
2013-02-08 19:39:18 +00:00
|
|
|
/* get a gslist of selected track elements */
|
2010-08-04 14:26:39 +00:00
|
|
|
GList *objects = NULL;
|
|
|
|
|
|
|
|
objects = app_get_selected_objects (app);
|
|
|
|
app_delete_objects (app, objects);
|
|
|
|
}
|
|
|
|
|
2011-03-17 15:38:38 +00:00
|
|
|
void
|
|
|
|
add_effect_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
|
|
|
gtk_widget_show_all (app->add_effect_dlg);
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:26:39 +00:00
|
|
|
void
|
|
|
|
add_file_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
|
|
|
GtkFileChooserDialog *dlg;
|
|
|
|
|
|
|
|
GST_DEBUG ("add file signal handler");
|
|
|
|
|
|
|
|
dlg = (GtkFileChooserDialog *) gtk_file_chooser_dialog_new ("Add File...",
|
|
|
|
GTK_WINDOW (app->main_window),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
GTK_STOCK_CANCEL,
|
|
|
|
GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (dlg), "select-multiple", TRUE, NULL);
|
|
|
|
|
|
|
|
if (gtk_dialog_run ((GtkDialog *) dlg) == GTK_RESPONSE_OK) {
|
|
|
|
GSList *uris;
|
|
|
|
GSList *cur;
|
|
|
|
uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dlg));
|
|
|
|
for (cur = uris; cur; cur = cur->next)
|
|
|
|
app_add_file (app, cur->data);
|
|
|
|
g_slist_free (uris);
|
|
|
|
}
|
|
|
|
gtk_widget_destroy ((GtkWidget *) dlg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
add_text_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
|
|
|
app_add_title (app);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
add_test_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
|
|
|
app_add_test (app);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
add_transition_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
|
|
|
app_add_transition (app);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
play_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
2010-08-04 15:27:01 +00:00
|
|
|
app_toggle_playpause (app);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
stop_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
|
|
|
app_stop_playback (app);
|
2010-08-04 14:26:39 +00:00
|
|
|
}
|
|
|
|
|
2010-08-04 16:31:34 +00:00
|
|
|
void
|
|
|
|
move_up_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
2010-08-04 16:49:19 +00:00
|
|
|
app_move_selected_up (app);
|
2010-08-04 16:31:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
move_down_activate_cb (GtkAction * item, App * app)
|
|
|
|
{
|
2010-08-04 16:49:19 +00:00
|
|
|
app_move_selected_down (app);
|
2010-08-04 16:31:34 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 14:57:45 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-04 14:26:39 +00:00
|
|
|
void
|
|
|
|
app_selection_changed_cb (GtkTreeSelection * selection, App * app)
|
|
|
|
{
|
|
|
|
app_update_selection (app);
|
|
|
|
|
|
|
|
update_delete_sensitivity (app);
|
2011-03-17 15:38:38 +00:00
|
|
|
update_effect_sensitivity (app);
|
2010-08-04 14:26:39 +00:00
|
|
|
update_add_transition_sensitivity (app);
|
2010-08-04 16:02:14 +00:00
|
|
|
update_move_up_down_sensitivity (app);
|
2010-08-04 14:26:39 +00:00
|
|
|
|
|
|
|
gtk_widget_set_visible (app->properties, app->n_selected > 0);
|
|
|
|
|
|
|
|
gtk_widget_set_visible (app->filesource_properties,
|
2013-01-20 15:44:57 +00:00
|
|
|
app->selected_type == GES_TYPE_URI_CLIP);
|
2010-08-04 14:26:39 +00:00
|
|
|
|
|
|
|
gtk_widget_set_visible (app->text_properties,
|
2013-01-17 03:55:03 +00:00
|
|
|
app->selected_type == GES_TYPE_TITLE_CLIP);
|
2010-08-04 14:26:39 +00:00
|
|
|
|
|
|
|
gtk_widget_set_visible (app->generic_duration,
|
2010-08-05 15:48:07 +00:00
|
|
|
app->selected_type != G_TYPE_NONE &&
|
|
|
|
app->selected_type != G_TYPE_INVALID);
|
2010-08-04 14:26:39 +00:00
|
|
|
|
|
|
|
gtk_widget_set_visible (app->background_properties,
|
2013-01-17 03:58:28 +00:00
|
|
|
app->selected_type == GES_TYPE_TEST_CLIP);
|
2010-08-04 14:26:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
duration_scale_change_value_cb (GtkRange * range, GtkScrollType unused,
|
|
|
|
gdouble value, App * app)
|
|
|
|
{
|
|
|
|
GList *i;
|
|
|
|
|
|
|
|
for (i = app->selected_objects; i; i = i->next) {
|
|
|
|
guint64 duration, maxduration;
|
2013-01-15 13:52:17 +00:00
|
|
|
maxduration = GES_TIMELINE_ELEMENT_MAX_DURATION (i->data);
|
2010-08-04 14:26:39 +00:00
|
|
|
duration = (value < maxduration ? (value > 0 ? value : 0) : maxduration);
|
|
|
|
g_object_set (G_OBJECT (i->data), "duration", (guint64) duration, NULL);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
in_point_scale_change_value_cb (GtkRange * range, GtkScrollType unused,
|
|
|
|
gdouble value, App * app)
|
|
|
|
{
|
|
|
|
GList *i;
|
|
|
|
|
|
|
|
for (i = app->selected_objects; i; i = i->next) {
|
|
|
|
guint64 in_point, maxduration;
|
2013-01-15 13:52:17 +00:00
|
|
|
maxduration = GES_TIMELINE_ELEMENT_MAX_DURATION (i->data) -
|
|
|
|
GES_TIMELINE_ELEMENT_DURATION (i->data);
|
2010-08-04 14:26:39 +00:00
|
|
|
in_point = (value < maxduration ? (value > 0 ? value : 0) : maxduration);
|
|
|
|
g_object_set (G_OBJECT (i->data), "in-point", (guint64) in_point, NULL);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
halign_changed_cb (GtkComboBox * widget, App * app)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
int active;
|
|
|
|
|
2010-08-05 14:12:45 +00:00
|
|
|
if (app->ignore_input)
|
|
|
|
return;
|
|
|
|
|
2010-08-04 14:26:39 +00:00
|
|
|
active = gtk_combo_box_get_active (app->halign);
|
|
|
|
|
|
|
|
for (tmp = app->selected_objects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_set (G_OBJECT (tmp->data), "halignment", active, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
valign_changed_cb (GtkComboBox * widget, App * app)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
int active;
|
|
|
|
|
2010-08-05 14:12:45 +00:00
|
|
|
if (app->ignore_input)
|
|
|
|
return;
|
|
|
|
|
2010-08-04 14:26:39 +00:00
|
|
|
active = gtk_combo_box_get_active (app->valign);
|
|
|
|
|
|
|
|
for (tmp = app->selected_objects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_set (G_OBJECT (tmp->data), "valignment", active, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
background_type_changed_cb (GtkComboBox * widget, App * app)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
gint p;
|
2010-08-05 14:12:45 +00:00
|
|
|
|
|
|
|
if (app->ignore_input)
|
|
|
|
return;
|
|
|
|
|
2010-08-04 14:26:39 +00:00
|
|
|
p = gtk_combo_box_get_active (widget);
|
|
|
|
|
|
|
|
for (tmp = app->selected_objects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_set (G_OBJECT (tmp->data), "vpattern", (gint) p, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
frequency_value_changed_cb (GtkSpinButton * widget, App * app)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
gdouble value;
|
|
|
|
|
2010-08-05 14:12:45 +00:00
|
|
|
if (app->ignore_input)
|
|
|
|
return;
|
|
|
|
|
2010-08-04 14:26:39 +00:00
|
|
|
value = gtk_spin_button_get_value (widget);
|
|
|
|
|
|
|
|
for (tmp = app->selected_objects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_set (G_OBJECT (tmp->data), "freq", (gdouble) value, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
volume_change_value_cb (GtkRange * widget, GtkScrollType unused, gdouble
|
|
|
|
value, App * app)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
value = value >= 0 ? (value <= 2.0 ? value : 2.0) : 0;
|
|
|
|
|
|
|
|
for (tmp = app->selected_objects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_set (G_OBJECT (tmp->data), "volume", (gdouble) value, NULL);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-07-20 16:53:15 +00:00
|
|
|
/* main *********************************************************************/
|
|
|
|
|
2010-07-20 15:05:26 +00:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2010-07-20 15:55:06 +00:00
|
|
|
App *app;
|
2010-07-20 15:05:26 +00:00
|
|
|
|
|
|
|
/* intialize GStreamer and GES */
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* initialize UI */
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
2010-07-20 16:38:54 +00:00
|
|
|
if ((app = app_new ())) {
|
|
|
|
gtk_main ();
|
|
|
|
}
|
2010-07-20 15:55:06 +00:00
|
|
|
|
2010-07-19 17:02:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|