2000-01-30 10:44:33 +00:00
|
|
|
/* Gnome-Streamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <gnome.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
#include "gsteditor.h"
|
2000-10-08 22:17:11 +00:00
|
|
|
#include "gsteditorcreate.h"
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
/* signals and args */
|
|
|
|
enum {
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
};
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void gst_editor_bin_class_init (GstEditorBinClass *klass);
|
|
|
|
static void gst_editor_bin_init (GstEditorBin *bin);
|
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
//static void gst_editor_bin_set_arg(GtkObject *object,GtkArg *arg,guint id);
|
|
|
|
//static void gst_editor_bin_get_arg(GtkObject *object,GtkArg *arg,guint id);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void gst_editor_bin_realize (GstEditorElement *bin);
|
|
|
|
static void gst_editor_bin_repack (GstEditorBin *bin);
|
|
|
|
|
|
|
|
static void gst_editor_bin_object_added (GstEditorBin *editorbin, GstObject *bin, GstObject *child);
|
|
|
|
|
|
|
|
static gint gst_editor_bin_event (GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element);
|
|
|
|
static gint gst_editor_bin_button_event (GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element);
|
|
|
|
void gst_editor_bin_connection_drag (GstEditorBin *bin,
|
|
|
|
gdouble wx,gdouble wy);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
static GstEditorElementClass *parent_class = NULL;
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
GtkType
|
|
|
|
gst_editor_bin_get_type (void)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
static GtkType bin_type = 0;
|
|
|
|
|
|
|
|
if (!bin_type) {
|
|
|
|
static const GtkTypeInfo bin_info = {
|
|
|
|
"GstEditorBin",
|
|
|
|
sizeof(GstEditorBin),
|
|
|
|
sizeof(GstEditorBinClass),
|
|
|
|
(GtkClassInitFunc)gst_editor_bin_class_init,
|
|
|
|
(GtkObjectInitFunc)gst_editor_bin_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GtkClassInitFunc)NULL,
|
|
|
|
};
|
|
|
|
bin_type = gtk_type_unique(gst_editor_element_get_type(),&bin_info);
|
|
|
|
}
|
|
|
|
return bin_type;
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_bin_class_init (GstEditorBinClass *klass)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorElementClass *element_class;
|
|
|
|
|
|
|
|
element_class = (GstEditorElementClass*)klass;
|
|
|
|
|
|
|
|
parent_class = gtk_type_class(gst_editor_element_get_type());
|
|
|
|
|
|
|
|
element_class->event = gst_editor_bin_event;
|
|
|
|
element_class->button_event = gst_editor_bin_button_event;
|
2000-12-25 01:33:06 +00:00
|
|
|
element_class->realize = gst_editor_bin_realize;
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_bin_init (GstEditorBin *bin)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorElement *element = GST_EDITOR_ELEMENT(bin);
|
|
|
|
|
|
|
|
element->insidewidth = 200;
|
|
|
|
element->insideheight = 100;
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
GstEditorBin*
|
|
|
|
gst_editor_bin_new (GstBin *bin, const gchar *first_arg_name,...)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorBin *editorbin;
|
2000-12-25 01:33:06 +00:00
|
|
|
GList *children;
|
2000-01-30 10:44:33 +00:00
|
|
|
va_list args;
|
2000-12-25 01:33:06 +00:00
|
|
|
gdouble xpos;
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2000-10-08 22:17:11 +00:00
|
|
|
g_return_val_if_fail(bin != NULL, NULL);
|
|
|
|
g_return_val_if_fail(GST_IS_BIN(bin), NULL);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
editorbin = GST_EDITOR_BIN(gtk_type_new(GST_TYPE_EDITOR_BIN));
|
|
|
|
GST_EDITOR_ELEMENT(editorbin)->element = GST_ELEMENT(bin);
|
2000-12-25 01:33:06 +00:00
|
|
|
GST_EDITOR_SET_OBJECT(bin, editorbin);
|
|
|
|
|
|
|
|
gtk_signal_connect_object (GTK_OBJECT (bin), "object_added",
|
|
|
|
gst_editor_bin_object_added, GTK_OBJECT (editorbin));
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
va_start(args,first_arg_name);
|
2000-12-25 01:33:06 +00:00
|
|
|
gst_editor_element_construct(GST_EDITOR_ELEMENT(editorbin), first_arg_name,args);
|
2000-01-30 10:44:33 +00:00
|
|
|
va_end(args);
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
children = gst_bin_get_list (bin);
|
|
|
|
xpos = 50.0;
|
|
|
|
|
|
|
|
while (children) {
|
|
|
|
GstElement *child = (GstElement *)children->data;
|
|
|
|
|
|
|
|
if (GST_IS_BIN (child)) {
|
|
|
|
GstEditorBin *childbin = gst_editor_bin_new (GST_BIN (child), "x", xpos+60.0, "y", 80.0, NULL);
|
|
|
|
|
|
|
|
gst_editor_bin_add (editorbin, GST_EDITOR_ELEMENT (childbin));
|
|
|
|
xpos += 120.0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GstEditorElement *childelement = gst_editor_element_new (child, "x", xpos, "y", 50.0, NULL);
|
|
|
|
|
|
|
|
gst_editor_bin_add (editorbin, childelement);
|
|
|
|
}
|
|
|
|
|
|
|
|
xpos += 100.0;
|
|
|
|
children = g_list_next (children);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_object_set (GTK_OBJECT (editorbin), "width", xpos-50.0, NULL);
|
2000-12-16 17:12:28 +00:00
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
return editorbin;
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_bin_realize (GstEditorElement *element)
|
|
|
|
{
|
|
|
|
GList *children;
|
|
|
|
GstEditorBin *bin = GST_EDITOR_BIN(element);
|
|
|
|
|
|
|
|
children = bin->elements;
|
|
|
|
|
|
|
|
if (GST_EDITOR_ELEMENT_CLASS(parent_class)->realize) {
|
|
|
|
GST_EDITOR_ELEMENT_CLASS(parent_class)->realize(GST_EDITOR_ELEMENT(bin));
|
|
|
|
}
|
|
|
|
|
|
|
|
while (children) {
|
|
|
|
GstEditorElement *child = (GstEditorElement *)children->data;
|
|
|
|
GstEditorElementClass *elementclass;
|
|
|
|
|
|
|
|
elementclass = GST_EDITOR_ELEMENT_CLASS(GTK_OBJECT(child)->klass);
|
|
|
|
|
|
|
|
if (elementclass->realize)
|
|
|
|
(elementclass->realize) (child);
|
|
|
|
|
|
|
|
children = g_list_next (children);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_editor_bin_repack (bin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_editor_bin_repack (GstEditorBin *bin)
|
|
|
|
{
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static gint
|
|
|
|
gst_editor_bin_event(GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorBin *bin = GST_EDITOR_BIN(element);
|
|
|
|
|
|
|
|
// g_print("bin got %d event at %.2fx%.2f\n",event->type,
|
|
|
|
// event->button.x,event->button.y);
|
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
if (bin->connecting) {
|
|
|
|
// g_print("bin got release event during drag\n");
|
|
|
|
gnome_canvas_item_ungrab(
|
|
|
|
GNOME_CANVAS_ITEM(element->group),
|
|
|
|
event->button.time);
|
|
|
|
if (bin->connection->topad)
|
|
|
|
gst_editor_connection_connect(bin->connection);
|
|
|
|
else {
|
|
|
|
bin->connection->frompad->connection = NULL;
|
|
|
|
g_list_remove(bin->connections,bin->connection);
|
|
|
|
gtk_object_destroy(GTK_OBJECT(bin->connection));
|
|
|
|
bin->connection = NULL;
|
|
|
|
}
|
|
|
|
bin->connecting = FALSE;
|
|
|
|
//g_print("in bin, setting inchild for button release\n");
|
2000-12-25 01:33:06 +00:00
|
|
|
//element->canvas->inchild = TRUE;
|
2000-01-30 10:44:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
if (bin->connecting) {
|
|
|
|
gdouble x,y;
|
|
|
|
x = event->button.x;y = event->button.y;
|
|
|
|
// g_print("bin has motion during connection draw at %.2fx%.2f\n",
|
|
|
|
// x,y);
|
|
|
|
gst_editor_bin_connection_drag(bin,x,y);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_EDITOR_ELEMENT_CLASS(parent_class)->event)
|
|
|
|
return (*GST_EDITOR_ELEMENT_CLASS(parent_class)->event)(item,event,element);
|
2000-10-08 22:17:11 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static gint
|
|
|
|
gst_editor_bin_button_event(GnomeCanvasItem *item,
|
|
|
|
GdkEvent *event,
|
|
|
|
GstEditorElement *element)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorBin *bin = GST_EDITOR_BIN(element);
|
|
|
|
GstEditorElement *newelement;
|
2000-12-25 01:33:06 +00:00
|
|
|
GdkEventButton *buttonevent;
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
// g_print("bin got button event\n");
|
|
|
|
|
|
|
|
if (event->type != GDK_BUTTON_RELEASE) return FALSE;
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
buttonevent = (GdkEventButton *) event;
|
|
|
|
|
|
|
|
if (buttonevent->button != 1) return FALSE;
|
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
gnome_canvas_item_w2i(item,&event->button.x,&event->button.y);
|
|
|
|
// g_print("calling gst_editor_create_item(,%.2f,%.2f)\n",
|
|
|
|
// event->button.x,event->button.y);
|
2000-12-25 01:33:06 +00:00
|
|
|
newelement = gst_editor_create_item(event->button.x,event->button.y);
|
|
|
|
if (newelement != NULL) {
|
|
|
|
GstEditorElementClass *elementclass;
|
|
|
|
|
|
|
|
gst_editor_bin_add (bin, newelement);
|
|
|
|
|
|
|
|
elementclass = GST_EDITOR_ELEMENT_CLASS(GTK_OBJECT(newelement)->klass);
|
|
|
|
if (elementclass->realize)
|
|
|
|
(elementclass->realize)(newelement);
|
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
return TRUE;
|
2000-12-25 01:33:06 +00:00
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
void
|
|
|
|
gst_editor_bin_start_banding (GstEditorBin *bin,GstEditorPad *pad)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GdkCursor *cursor;
|
|
|
|
|
|
|
|
// g_print("starting to band\n");
|
|
|
|
|
|
|
|
g_return_if_fail(GST_IS_EDITOR_PAD(pad));
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
bin->connection = gst_editor_connection_new (GST_EDITOR_ELEMENT (bin), pad);
|
|
|
|
bin->connections = g_list_prepend (bin->connections, bin->connection);
|
|
|
|
|
|
|
|
cursor = gdk_cursor_new (GDK_SB_RIGHT_ARROW);
|
2000-01-30 10:44:33 +00:00
|
|
|
gnome_canvas_item_grab(
|
|
|
|
GNOME_CANVAS_ITEM(GST_EDITOR_ELEMENT(bin)->group),
|
|
|
|
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
|
|
|
|
cursor,GDK_CURRENT_TIME);
|
|
|
|
|
|
|
|
bin->connecting = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
void
|
|
|
|
gst_editor_bin_connection_drag (GstEditorBin *bin,
|
|
|
|
gdouble wx,gdouble wy)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
GstEditorElement *element;
|
|
|
|
gdouble bx,by;
|
|
|
|
GnomeCanvasItem *underitem, *under = NULL;
|
|
|
|
GstEditorPad *destpad;
|
|
|
|
|
|
|
|
element = GST_EDITOR_ELEMENT(bin);
|
|
|
|
|
|
|
|
bx = wx;by = wy;
|
2000-10-08 22:17:11 +00:00
|
|
|
gnome_canvas_item_w2i(GNOME_CANVAS_ITEM(GST_EDITOR_ELEMENT(bin)->group),&bx,&by);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
// first see if we're on top of an interesting pad
|
|
|
|
underitem = gnome_canvas_get_item_at(
|
2000-12-25 01:33:06 +00:00
|
|
|
&GST_EDITOR_ELEMENT(bin)->canvas->canvas,wx,wy);
|
2000-01-30 10:44:33 +00:00
|
|
|
if (underitem != NULL)
|
2000-12-25 01:33:06 +00:00
|
|
|
under = GST_EDITOR_GET_OBJECT(underitem);
|
2000-01-30 10:44:33 +00:00
|
|
|
if ((under != NULL) && GST_IS_EDITOR_PAD(under)) {
|
|
|
|
destpad = GST_EDITOR_PAD(under);
|
|
|
|
if (destpad != bin->connection->frompad)
|
|
|
|
gst_editor_connection_set_endpad(bin->connection,destpad);
|
|
|
|
} else {
|
|
|
|
gst_editor_connection_set_endpoint(bin->connection,bx,by);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This code is a nightmare, it'll be fixed in the next minor version
|
|
|
|
if (
|
|
|
|
((bx < element->sinkwidth) ||
|
|
|
|
(bx > (element->width - element->srcwidth))) &&
|
|
|
|
((by > element->titleheight) &&
|
|
|
|
(by < (element->height - element->stateheight)))
|
|
|
|
) {
|
|
|
|
if (!bin->inpadregion) {
|
|
|
|
GstEditorPad *ghostpad;
|
|
|
|
g_print("I'd be creating a ghost pad right about now...\n");
|
|
|
|
gst_element_add_ghost_pad(
|
|
|
|
GST_EDITOR_ELEMENT(bin)->element,
|
|
|
|
bin->connection->frompad->pad);
|
|
|
|
ghostpad = gst_editor_element_add_pad(GST_EDITOR_ELEMENT(bin),
|
|
|
|
bin->connection->frompad->pad);
|
|
|
|
gst_editor_connection_set_endpad(bin->connection,ghostpad);
|
|
|
|
gtk_object_set(GTK_OBJECT(bin->connection),"ghost",TRUE,NULL);
|
|
|
|
bin->inpadregion = TRUE;
|
|
|
|
} else {
|
|
|
|
g_print("I'd be moving the ghost pad around now...\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (bin->inpadregion) {
|
|
|
|
g_print("I'd be removing the ghost pad now...\n");
|
|
|
|
bin->inpadregion = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
static void
|
|
|
|
gst_editor_bin_object_added (GstEditorBin *editorbin, GstObject *bin, GstObject *child)
|
|
|
|
{
|
|
|
|
g_print ("gsteditorbin: object added\n");
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2000-12-28 02:51:07 +00:00
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
void
|
|
|
|
gst_editor_bin_add (GstEditorBin *bin, GstEditorElement *element)
|
|
|
|
{
|
2000-01-30 10:44:33 +00:00
|
|
|
/* set the element's parent */
|
|
|
|
element->parent = bin;
|
|
|
|
|
|
|
|
/* set the canvas */
|
2000-12-25 01:33:06 +00:00
|
|
|
element->canvas = GST_EDITOR_ELEMENT(bin)->canvas;
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
/* add element to list of bin's children */
|
|
|
|
bin->elements = g_list_prepend(bin->elements,element);
|
|
|
|
|
|
|
|
/* add the real element to the real bin */
|
2000-12-16 17:12:28 +00:00
|
|
|
if (!gst_object_get_parent (GST_OBJECT (element->element))) {
|
|
|
|
gst_bin_add(GST_BIN(GST_EDITOR_ELEMENT(bin)->element),element->element);
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|