diff --git a/editor/editor.glade b/editor/editor.glade
index fa6e225105..b992d167d4 100644
--- a/editor/editor.glade
+++ b/editor/editor.glade
@@ -601,7 +601,7 @@
GtkScrolledWindow
- scrolledwindow6
+ pads_window
GTK_POLICY_ALWAYS
GTK_POLICY_ALWAYS
GTK_UPDATE_CONTINUOUS
@@ -613,40 +613,7 @@
- GtkCTree
- ctree2
- True
- 2
- 187,80
- GTK_SELECTION_SINGLE
- True
- GTK_SHADOW_IN
-
-
- GtkLabel
- CTree:title
- label20
-
- GTK_JUSTIFY_CENTER
- False
- 0.5
- 0.5
- 0
- 0
-
-
-
- GtkLabel
- CTree:title
- label21
-
- GTK_JUSTIFY_CENTER
- False
- 0.5
- 0.5
- 0
- 0
-
+ Placeholder
diff --git a/editor/editor.ts b/editor/editor.ts
index 6e0775b298..e0a4b92ef2 100644
--- a/editor/editor.ts
+++ b/editor/editor.ts
@@ -23,8 +23,6 @@ gchar *s = N_("Standard Elements");
gchar *s = N_("Tree select...");
gchar *s = N_("Properties");
gchar *s = N_("Element");
-gchar *s = N_("Pad");
-gchar *s = N_("Value");
gchar *s = N_("Pads");
gchar *s = N_("Signal");
gchar *s = N_("Handler");
diff --git a/editor/gsteditor.c b/editor/gsteditor.c
index e5eca3ad64..3205d5d45c 100644
--- a/editor/gsteditor.c
+++ b/editor/gsteditor.c
@@ -35,16 +35,18 @@ enum {
ARG_NAME,
};
-static void gst_editor_class_init(GstEditorClass *klass);
-static void gst_editor_init(GstEditor *editor);
+static void gst_editor_class_init (GstEditorClass *klass);
+static void gst_editor_init (GstEditor *editor);
-static void gst_editor_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_editor_get_arg(GtkObject *object,GtkArg *arg,guint id);
+static void gst_editor_set_arg (GtkObject *object, GtkArg *arg, guint id);
+static void gst_editor_get_arg (GtkObject *object, GtkArg *arg, guint id);
static GtkFrame *parent_class = NULL;
static guint gst_editor_signals[LAST_SIGNAL] = { 0 };
-GtkType gst_editor_get_type(void) {
+GtkType
+gst_editor_get_type (void)
+{
static GtkType editor_type = 0;
if (!editor_type) {
@@ -58,12 +60,14 @@ GtkType gst_editor_get_type(void) {
NULL,
(GtkClassInitFunc)NULL,
};
- editor_type = gtk_type_unique(gtk_window_get_type(),&editor_info);
+ editor_type = gtk_type_unique (gtk_window_get_type (), &editor_info);
}
return editor_type;
}
-static void gst_editor_class_init(GstEditorClass *klass) {
+static void
+gst_editor_class_init (GstEditorClass *klass)
+{
GtkObjectClass *object_class;
object_class = (GtkObjectClass*)klass;
@@ -85,10 +89,14 @@ static void gst_editor_class_init(GstEditorClass *klass) {
object_class->get_arg = gst_editor_get_arg;
}
-static void gst_editor_init(GstEditor *editor) {
+static void
+gst_editor_init(GstEditor *editor)
+{
}
-static void on_name_changed(GstEditorElement *element, gpointer data) {
+static void
+on_name_changed (GstEditorElement *element, gpointer data)
+{
gtk_signal_emit(GTK_OBJECT(element),gst_editor_signals[NAME_CHANGED], NULL);
}
/**
@@ -110,14 +118,18 @@ gst_editor_new (GstElement *element)
editor->element = element;
/* create the editor canvas */
- editor->canvas = gst_editor_canvas_new(GST_BIN(editor->element),NULL);
+ if (element) {
+ editor->canvas = gst_editor_canvas_new_with_bin (gst_editor_bin_new (GST_BIN (element), NULL));
+ }
+ else {
+ editor->canvas = gst_editor_canvas_new ();
+ }
- gtk_signal_connect_object(GTK_OBJECT(editor->canvas), "name_changed", on_name_changed, GTK_OBJECT(editor));
/* create the scrolled window */
editor->scrollwindow = gtk_scrolled_window_new(NULL,NULL);
/* get the canvas widget */
- editor->canvaswidget = gst_editor_canvas_get_canvas(editor->canvas);
+ editor->canvaswidget = GTK_WIDGET (editor->canvas);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(editor->scrollwindow),
editor->canvaswidget);
@@ -127,38 +139,20 @@ gst_editor_new (GstElement *element)
gtk_widget_set_usize(GTK_WIDGET(editor),400,400);
- if (GST_IS_BIN (element)) {
- GList *elements;
-
- elements = gst_bin_get_list (GST_BIN(element));
-
- while (elements) {
- GstElement *child = (GstElement *)elements->data;
-
- if (GST_IS_BIN (child)) {
- g_print ("new bin \n");
- gst_editor_bin_new (GST_EDITOR_BIN(editor->canvas),GST_BIN(child),
- "x",10.0,"y",10.0,"width",50.0,"height",20.0,NULL);
- }
- else {
- g_print ("new element \n");
- gst_editor_element_new (GST_EDITOR_BIN(editor->canvas),child,
- "x",10.0,"y",10.0,"width",50.0,"height",20.0,NULL);
- }
- elements = g_list_next (elements);
- }
- }
-
gtk_widget_show_all(GTK_WIDGET(editor));
return editor;
}
-char *gst_editor_get_name(GstEditor *editor) {
- return gst_element_get_name(GST_ELEMENT(editor->element));
+const gchar*
+gst_editor_get_name (GstEditor *editor)
+{
+ return gst_element_get_name (GST_ELEMENT (editor->element));
}
-static void gst_editor_set_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_set_arg(GtkObject *object, GtkArg *arg, guint id)
+{
GstEditor *editor = GST_EDITOR(object);
switch (id) {
@@ -173,13 +167,15 @@ static void gst_editor_set_arg(GtkObject *object,GtkArg *arg,guint id) {
}
}
-static void gst_editor_get_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_get_arg (GtkObject *object, GtkArg *arg, guint id)
+{
GstEditor *editor = GST_EDITOR(object);
switch (id) {
case ARG_NAME:
GTK_VALUE_STRING(*arg) =
- gst_element_get_name(GST_ELEMENT(editor->element));
+ (gchar *)gst_element_get_name(GST_ELEMENT(editor->element));
break;
default:
arg->type = GTK_TYPE_INVALID;
diff --git a/editor/gsteditor.h b/editor/gsteditor.h
index bf295c59e7..9bcedc0fae 100644
--- a/editor/gsteditor.h
+++ b/editor/gsteditor.h
@@ -76,12 +76,12 @@ struct _GstEditorClass {
GtkType gst_editor_get_type();
GstEditor *gst_editor_new(GstElement *element);
-char *gst_editor_get_name(GstEditor *editor);
+const gchar *gst_editor_get_name(GstEditor *editor);
#define GST_EDITOR_SET_OBJECT(item,object) \
(gtk_object_set_data(GTK_OBJECT(item),"gsteditorobject",(object)))
-#define GST_EDTIOR_GET_OBJECT(item) \
+#define GST_EDITOR_GET_OBJECT(item) \
(gtk_object_get_data(GTK_OBJECT(item),"gsteditorobject"))
@@ -136,6 +136,7 @@ struct _GstEditorElement {
GnomeCanvasGroup *insidegroup; // contents if any
gboolean resize; // does it need resizing?
+ gboolean active; // is it active (currently selected)
/* list of pads */
GList *srcpads,*sinkpads;
@@ -149,21 +150,21 @@ struct _GstEditorElement {
struct _GstEditorElementClass {
GnomeCanvasGroupClass parent_class;
- void (*name_changed) (GstEditorElement *element);
- void (*realize) (GstEditorElement *element);
- gint (*event) (GnomeCanvasItem *item,GdkEvent *event,
- GstEditorElement *element);
- gint (*button_event) (GnomeCanvasItem *item,GdkEvent *event,
- GstEditorElement *element);
+ void (*name_changed) (GstEditorElement *element);
+ void (*position_changed) (GstEditorElement *element);
+ void (*size_changed) (GstEditorElement *element);
+ void (*realize) (GstEditorElement *element);
+ gint (*event) (GnomeCanvasItem *item,GdkEvent *event,
+ GstEditorElement *element);
+ gint (*button_event) (GnomeCanvasItem *item,GdkEvent *event,
+ GstEditorElement *element);
};
GtkType gst_editor_element_get_type();
-GstEditorElement *gst_editor_element_new(GstEditorBin *parent,
- GstElement *element,
+GstEditorElement *gst_editor_element_new(GstElement *element,
const gchar *first_arg_name,...);
void gst_editor_element_construct(GstEditorElement *element,
- GstEditorBin *parent,
const gchar *first_arg_name,
va_list args);
void gst_editor_element_repack(GstEditorElement *element);
@@ -207,11 +208,13 @@ struct _GstEditorBinClass {
GtkType gst_editor_bin_get_type();
-GstEditorBin *gst_editor_bin_new(GstEditorBin *parent,GstBin *bin,
- const gchar *first_arg_name,...);
-void gst_editor_bin_connection_drag(GstEditorBin *bin,
- gdouble wx,gdouble wy);
-void gst_editor_bin_start_banding(GstEditorBin *bin,GstEditorPad *pad);
+
+GstEditorBin* gst_editor_bin_new (GstBin *bin, const gchar *first_arg_name,...);
+void gst_editor_bin_add (GstEditorBin *bin, GstEditorElement *element);
+
+void gst_editor_bin_connection_drag (GstEditorBin *bin,
+ gdouble wx,gdouble wy);
+void gst_editor_bin_start_banding (GstEditorBin *bin,GstEditorPad *pad);
#define GST_TYPE_EDITOR_CANVAS \
@@ -225,25 +228,24 @@ void gst_editor_bin_start_banding(GstEditorBin *bin,GstEditorPad *pad);
#define GST_IS_EDITOR_CANVAS_CLASS(obj) \
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_CANVAS))
+GtkType gst_editor_canvas_get_type();
struct _GstEditorCanvas {
- GstEditorBin bin;
+ GnomeCanvas canvas;
- gboolean inchild;
-
- GnomeCanvas *canvas;
+ GstEditorBin *bin;
};
struct _GstEditorCanvasClass {
GnomeCanvasClass parent_class;
};
+GstEditorCanvas* gst_editor_canvas_new (void);
+GstEditorCanvas* gst_editor_canvas_new_with_bin (GstEditorBin *bin);
-GtkType gst_editor_canvas_get_type();
-GstEditorCanvas *gst_editor_canvas_new(GstBin *bin,
- const gchar *first_arg_name,...);
-GtkWidget *gst_editor_canvas_get_canvas(GstEditorCanvas *canvas);
-void gst_editor_bin_add(GstEditorBin *parent,GstEditorElement *element);
+void gst_editor_canvas_set_bin (GstEditorCanvas *canvas,
+ GstEditorBin *element);
+GstEditorElement* gst_editor_canvas_get_bin (GstEditorCanvas *canvas);
#define GST_TYPE_EDITOR_PAD \
@@ -356,7 +358,7 @@ struct _GstEditorConnectionClass {
};
GtkType gst_editor_connection_get_type();
-GstEditorConnection *gst_editor_connection_new(GstEditorBin *parent,
+GstEditorConnection *gst_editor_connection_new(GstEditorElement *parent,
GstEditorPad *frompad);
void gst_editor_connection_resize(GstEditorConnection *connection);
diff --git a/editor/gsteditorbin.c b/editor/gsteditorbin.c
index 3d80373a97..3f070067a7 100644
--- a/editor/gsteditorbin.c
+++ b/editor/gsteditorbin.c
@@ -33,23 +33,31 @@ enum {
ARG_0,
};
-static void gst_editor_bin_class_init(GstEditorBinClass *klass);
-static void gst_editor_bin_init(GstEditorBin *bin);
+static void gst_editor_bin_class_init (GstEditorBinClass *klass);
+static void gst_editor_bin_init (GstEditorBin *bin);
+
//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);
-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);
+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);
static GstEditorElementClass *parent_class = NULL;
-GtkType gst_editor_bin_get_type(void) {
+GtkType
+gst_editor_bin_get_type (void)
+{
static GtkType bin_type = 0;
if (!bin_type) {
@@ -68,7 +76,9 @@ GtkType gst_editor_bin_get_type(void) {
return bin_type;
}
-static void gst_editor_bin_class_init(GstEditorBinClass *klass) {
+static void
+gst_editor_bin_class_init (GstEditorBinClass *klass)
+{
GstEditorElementClass *element_class;
element_class = (GstEditorElementClass*)klass;
@@ -77,42 +87,104 @@ static void gst_editor_bin_class_init(GstEditorBinClass *klass) {
element_class->event = gst_editor_bin_event;
element_class->button_event = gst_editor_bin_button_event;
+ element_class->realize = gst_editor_bin_realize;
}
-static void gst_editor_bin_init(GstEditorBin *bin) {
+static void
+gst_editor_bin_init (GstEditorBin *bin)
+{
GstEditorElement *element = GST_EDITOR_ELEMENT(bin);
element->insidewidth = 200;
element->insideheight = 100;
}
-GstEditorBin *gst_editor_bin_new(GstEditorBin *parent,GstBin *bin,
- const gchar *first_arg_name,...) {
+GstEditorBin*
+gst_editor_bin_new (GstBin *bin, const gchar *first_arg_name,...)
+{
GstEditorBin *editorbin;
+ GList *children;
va_list args;
+ gdouble xpos;
- g_return_val_if_fail(parent != NULL, NULL);
- g_return_val_if_fail(GST_IS_EDITOR_BIN(parent), NULL);
g_return_val_if_fail(bin != NULL, NULL);
g_return_val_if_fail(GST_IS_BIN(bin), NULL);
editorbin = GST_EDITOR_BIN(gtk_type_new(GST_TYPE_EDITOR_BIN));
GST_EDITOR_ELEMENT(editorbin)->element = GST_ELEMENT(bin);
+ GST_EDITOR_SET_OBJECT(bin, editorbin);
+
+ gtk_signal_connect_object (GTK_OBJECT (bin), "object_added",
+ gst_editor_bin_object_added, GTK_OBJECT (editorbin));
va_start(args,first_arg_name);
- gst_editor_element_construct(GST_EDITOR_ELEMENT(editorbin),parent,
- first_arg_name,args);
+ gst_editor_element_construct(GST_EDITOR_ELEMENT(editorbin), first_arg_name,args);
va_end(args);
-
+ 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);
return editorbin;
}
+static void
+gst_editor_bin_realize (GstEditorElement *element)
+{
+ GList *children;
+ GstEditorBin *bin = GST_EDITOR_BIN(element);
-static gint gst_editor_bin_event(GnomeCanvasItem *item,
- GdkEvent *event,
- GstEditorElement *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)
+{
+}
+
+static gint
+gst_editor_bin_event(GnomeCanvasItem *item,
+ GdkEvent *event,
+ GstEditorElement *element)
+{
GstEditorBin *bin = GST_EDITOR_BIN(element);
// g_print("bin got %d event at %.2fx%.2f\n",event->type,
@@ -135,7 +207,7 @@ static gint gst_editor_bin_event(GnomeCanvasItem *item,
}
bin->connecting = FALSE;
//g_print("in bin, setting inchild for button release\n");
- element->canvas->inchild = TRUE;
+ //element->canvas->inchild = TRUE;
return TRUE;
}
break;
@@ -160,36 +232,55 @@ static gint gst_editor_bin_event(GnomeCanvasItem *item,
}
-static gint gst_editor_bin_button_event(GnomeCanvasItem *item,
- GdkEvent *event,
- GstEditorElement *element) {
+static gint
+gst_editor_bin_button_event(GnomeCanvasItem *item,
+ GdkEvent *event,
+ GstEditorElement *element)
+{
GstEditorBin *bin = GST_EDITOR_BIN(element);
GstEditorElement *newelement;
+ GdkEventButton *buttonevent;
// g_print("bin got button event\n");
if (event->type != GDK_BUTTON_RELEASE) return FALSE;
+ buttonevent = (GdkEventButton *) event;
+
+ if (buttonevent->button != 1) return FALSE;
+
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);
- newelement = gst_editor_create_item(bin,event->button.x,event->button.y);
- if (newelement != NULL);
+ 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);
+
return TRUE;
+ }
return FALSE;
}
-void gst_editor_bin_start_banding(GstEditorBin *bin,GstEditorPad *pad) {
+void
+gst_editor_bin_start_banding (GstEditorBin *bin,GstEditorPad *pad)
+{
GdkCursor *cursor;
// g_print("starting to band\n");
g_return_if_fail(GST_IS_EDITOR_PAD(pad));
- bin->connection = gst_editor_connection_new(bin,pad);
- bin->connections = g_list_prepend(bin->connections,bin->connection);
- cursor = gdk_cursor_new(GDK_SB_RIGHT_ARROW);
+ 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);
gnome_canvas_item_grab(
GNOME_CANVAS_ITEM(GST_EDITOR_ELEMENT(bin)->group),
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
@@ -199,8 +290,10 @@ void gst_editor_bin_start_banding(GstEditorBin *bin,GstEditorPad *pad) {
}
-void gst_editor_bin_connection_drag(GstEditorBin *bin,
- gdouble wx,gdouble wy) {
+void
+gst_editor_bin_connection_drag (GstEditorBin *bin,
+ gdouble wx,gdouble wy)
+{
GstEditorElement *element;
gdouble bx,by;
GnomeCanvasItem *underitem, *under = NULL;
@@ -213,9 +306,9 @@ void gst_editor_bin_connection_drag(GstEditorBin *bin,
// first see if we're on top of an interesting pad
underitem = gnome_canvas_get_item_at(
- GST_EDITOR_ELEMENT(bin)->canvas->canvas,wx,wy);
+ &GST_EDITOR_ELEMENT(bin)->canvas->canvas,wx,wy);
if (underitem != NULL)
- under = GST_EDTIOR_GET_OBJECT(underitem);
+ under = GST_EDITOR_GET_OBJECT(underitem);
if ((under != NULL) && GST_IS_EDITOR_PAD(under)) {
destpad = GST_EDITOR_PAD(under);
if (destpad != bin->connection->frompad)
@@ -254,16 +347,20 @@ void gst_editor_bin_connection_drag(GstEditorBin *bin,
*/
}
+static void
+gst_editor_bin_object_added (GstEditorBin *editorbin, GstObject *bin, GstObject *child)
+{
+ g_print ("gsteditorbin: object added\n");
+}
-void gst_editor_bin_add(GstEditorBin *bin,GstEditorElement *element) {
+void
+gst_editor_bin_add (GstEditorBin *bin, GstEditorElement *element)
+{
/* set the element's parent */
element->parent = bin;
/* set the canvas */
- if (GST_IS_EDITOR_CANVAS(bin))
- element->canvas = GST_EDITOR_CANVAS(bin);
- else
- element->canvas = GST_EDITOR_ELEMENT(bin)->canvas;
+ element->canvas = GST_EDITOR_ELEMENT(bin)->canvas;
/* add element to list of bin's children */
bin->elements = g_list_prepend(bin->elements,element);
diff --git a/editor/gsteditorcanvas.c b/editor/gsteditorcanvas.c
index 897053e291..26d5b1dbbd 100644
--- a/editor/gsteditorcanvas.c
+++ b/editor/gsteditorcanvas.c
@@ -31,24 +31,15 @@ enum {
enum {
ARG_0,
- ARG_CANVAS,
};
-static void gst_editor_canvas_class_init(GstEditorCanvasClass *klass);
-static void gst_editor_canvas_init(GstEditorCanvas *editorcanvas);
-static void gst_editor_canvas_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_editor_canvas_get_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_editor_canvas_realize(GstEditorElement *element);
+static void gst_editor_canvas_class_init (GstEditorCanvasClass *klass);
+static void gst_editor_canvas_init (GstEditorCanvas *editorcanvas);
+static void gst_editor_canvas_set_arg (GtkObject *object,GtkArg *arg,guint id);
+static void gst_editor_canvas_get_arg (GtkObject *object,GtkArg *arg,guint id);
-static gint gst_editor_canvas_button_release(GtkWidget *widget,
- GdkEvent *event,
- GstEditorCanvas *canvas);
-static gint gst_editor_canvas_event(GnomeCanvasItem *item,
- GdkEvent *event,
- GstEditorElement *element);
-static void gst_editor_canvas_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_editor_canvas_get_arg(GtkObject *object,GtkArg *arg,guint id);
+static void gst_editor_canvas_realize (GtkWidget *widget);
//gint gst_editor_canvas_verbose_event(GtkWidget *widget,GdkEvent *event);
@@ -56,7 +47,9 @@ static void gst_editor_canvas_get_arg(GtkObject *object,GtkArg *arg,guint id);
static GstEditorBinClass *parent_class = NULL;
-GtkType gst_editor_canvas_get_type(void) {
+GtkType
+gst_editor_canvas_get_type (void)
+{
static GtkType editor_canvas_type = 0;
if (!editor_canvas_type) {
@@ -70,76 +63,84 @@ GtkType gst_editor_canvas_get_type(void) {
NULL,
(GtkClassInitFunc)NULL,
};
- editor_canvas_type = gtk_type_unique(gst_editor_bin_get_type(),&editor_canvas_info);
+ editor_canvas_type = gtk_type_unique (gnome_canvas_get_type (), &editor_canvas_info);
}
return editor_canvas_type;
}
-static void gst_editor_canvas_class_init(GstEditorCanvasClass *klass) {
+static void
+gst_editor_canvas_class_init (GstEditorCanvasClass *klass)
+{
GtkObjectClass *object_class;
- GstEditorElementClass *element_class;
+ GtkWidgetClass *widget_class;
object_class = (GtkObjectClass*)klass;
+ widget_class = (GtkWidgetClass *)klass;
- element_class = (GstEditorElementClass*)klass;
-
- parent_class = gtk_type_class(gst_editor_bin_get_type());
-
- gtk_object_add_arg_type("GstEditorCanvas::canvas",GTK_TYPE_POINTER,
- GTK_ARG_READABLE,ARG_CANVAS);
+ parent_class = gtk_type_class (gnome_canvas_get_type ());
object_class->set_arg = gst_editor_canvas_set_arg;
object_class->get_arg = gst_editor_canvas_get_arg;
- element_class->realize = gst_editor_canvas_realize;
+ widget_class->realize = gst_editor_canvas_realize;
}
-static void gst_editor_canvas_init(GstEditorCanvas *editorcanvas) {
+static void
+gst_editor_canvas_init (GstEditorCanvas *editorcanvas)
+{
}
-GstEditorCanvas *gst_editor_canvas_new(GstBin *bin,
- const gchar *first_arg_name,...) {
+GstEditorCanvas*
+gst_editor_canvas_new (void)
+{
GstEditorCanvas *editorcanvas;
- va_list args;
-
- g_return_val_if_fail(bin != NULL, NULL);
- g_return_val_if_fail(GST_IS_BIN(bin), NULL);
editorcanvas = GST_EDITOR_CANVAS(gtk_type_new(GST_TYPE_EDITOR_CANVAS));
- GST_EDITOR_ELEMENT(editorcanvas)->element = GST_ELEMENT(bin);
- GST_EDITOR_ELEMENT(editorcanvas)->parent = GST_EDITOR_BIN(editorcanvas);
-
- va_start(args,first_arg_name);
- gst_editor_element_construct(GST_EDITOR_ELEMENT(editorcanvas),NULL,
- first_arg_name,args);
- va_end(args);
return editorcanvas;
}
-static void gst_editor_canvas_realize(GstEditorElement *element) {
- GstEditorCanvas *canvas = GST_EDITOR_CANVAS(element);
+GstEditorCanvas*
+gst_editor_canvas_new_with_bin (GstEditorBin *bin)
+{
+ GstEditorCanvas *editorcanvas;
- canvas->canvas = GNOME_CANVAS(gnome_canvas_new());
- element->canvas = canvas;
- gtk_signal_connect(GTK_OBJECT(canvas->canvas),
- "event",
- GTK_SIGNAL_FUNC(gst_editor_canvas_event),
- canvas);
- gtk_signal_connect_after(GTK_OBJECT(canvas->canvas),
- "button_release_event",
- GTK_SIGNAL_FUNC(gst_editor_canvas_button_release),
- canvas);
- GST_EDITOR_SET_OBJECT(canvas->canvas,canvas);
+ g_return_val_if_fail(bin != NULL, NULL);
- element->group = gnome_canvas_root(canvas->canvas);
+ editorcanvas = gst_editor_canvas_new ();
+ editorcanvas->bin = bin;
- if (GST_EDITOR_ELEMENT_CLASS(parent_class)->realize) {
- GST_EDITOR_ELEMENT_CLASS(parent_class)->realize(element);
+ GST_EDITOR_ELEMENT(bin)->parent = bin;
+ GST_EDITOR_ELEMENT(bin)->canvas = editorcanvas;
+
+ return editorcanvas;
+}
+
+static void
+gst_editor_canvas_realize (GtkWidget *widget)
+{
+ GstEditorCanvas *canvas = GST_EDITOR_CANVAS (widget);
+
+ if (GTK_WIDGET_CLASS(parent_class)->realize) {
+ GTK_WIDGET_CLASS(parent_class)->realize(GTK_WIDGET(canvas));
+ }
+
+ if (canvas->bin) {
+ GstEditorElementClass *element_class;
+
+ GST_EDITOR_ELEMENT(canvas->bin)->group = gnome_canvas_root(GNOME_CANVAS(canvas));
+
+ element_class = GST_EDITOR_ELEMENT_CLASS(GTK_OBJECT(canvas->bin)->klass);
+
+ if (element_class->realize) {
+ element_class->realize(GST_EDITOR_ELEMENT(canvas->bin));
+ }
}
}
-static void gst_editor_canvas_set_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_canvas_set_arg (GtkObject *object,GtkArg *arg,guint id)
+{
GstEditorCanvas *canvas;
canvas = GST_EDITOR_CANVAS(object);
@@ -151,111 +152,17 @@ static void gst_editor_canvas_set_arg(GtkObject *object,GtkArg *arg,guint id) {
}
}
-static void gst_editor_canvas_get_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_canvas_get_arg (GtkObject *object,GtkArg *arg,guint id)
+{
GstEditorCanvas *canvas;
canvas = GST_EDITOR_CANVAS(object);
switch (id) {
- case ARG_CANVAS:
- GTK_VALUE_POINTER(*arg) = canvas->canvas;
- break;
default:
arg->type = GTK_TYPE_INVALID;
break;
}
}
-GtkWidget *gst_editor_canvas_get_canvas(GstEditorCanvas *canvas) {
- return GTK_WIDGET(canvas->canvas);
-}
-
-
-static gint gst_editor_canvas_button_release(GtkWidget *widget,
- GdkEvent *event,
- GstEditorCanvas *canvas) {
- //GstEditorBin *bin = GST_EDITOR_BIN(canvas);
- gdouble x,y;
- GstEditorElement *element;
-
-// g_print("canvas got button press at %.2fx%.2f\n",
-// event->button.x,event->button.y);
- if (event->type != GDK_BUTTON_RELEASE) return FALSE;
-
- // if we're connecting a pair of objects in the canvas, fall through
-// if (bin->connection) {
-// g_print("we're in a connection, not handling\n");
-// return FALSE;
-// }
-
- if (canvas->inchild) {
-// g_print("inchild, not responding to button_release\n");
- canvas->inchild = FALSE;
- return FALSE;
- }
-
- gnome_canvas_window_to_world(GNOME_CANVAS(widget),
- event->button.x,event->button.y,&x,&y);
-// g_print("calling gst_editor_create_item()\n");
- if ((element = gst_editor_create_item(GST_EDITOR_BIN(canvas),x,y)) != NULL)
- return TRUE;
- return FALSE;
-}
-
-
-/* FIXME: guerilla prototype... */
-void gst_editor_bin_connection_drag(GstEditorBin *bin,
- gdouble wx,gdouble wy);
-
-static gint gst_editor_canvas_event(GnomeCanvasItem *item,
- GdkEvent *event,
- GstEditorElement *element) {
-// if (GST_EDITOR_ELEMENT_CLASS(parent_class)->event)
-// return (*GST_EDITOR_ELEMENT_CLASS(parent_class)->event)(
-// element->group,event,element);
-
- GstEditorBin *bin = GST_EDITOR_BIN(element);
- GstEditorCanvas *canvas = GST_EDITOR_CANVAS(element);
-
- //g_print("canvas got event %d at %.2fx%.2f\n",event->type,
- // event->button.x,event->button.y);
-
- switch (event->type) {
- case GDK_BUTTON_RELEASE:
- if (bin->connecting) {
-// g_print("canvas got button release 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
- gtk_object_destroy(GTK_OBJECT(bin->connection));
- bin->connecting = FALSE;
-//g_print("finished dragging connection on canvas, setting inchild\n");
- element->canvas->inchild = TRUE;
- return TRUE;
- } else {
-// g_print("got release, calling button_release()\n");
-// gst_editor_canvas_button_release(canvas->canvas,event,canvas);
- return FALSE;
- }
- break;
- case GDK_MOTION_NOTIFY:
- if (bin->connecting) {
- gdouble x,y;
- x = event->button.x;y = event->button.y;
- gnome_canvas_window_to_world(canvas->canvas,
- event->button.x,event->button.y,&x,&y);
-// g_print("canvas has motion during connection draw at
-//%.2fx%.2f\n",
-// x,y);
- gst_editor_bin_connection_drag(bin,x,y);
- return TRUE;
- }
- break;
- default:
- break;
- }
- return FALSE;
-}
diff --git a/editor/gsteditorconnection.c b/editor/gsteditorconnection.c
index 1f7f28be97..3709ec7be3 100644
--- a/editor/gsteditorconnection.c
+++ b/editor/gsteditorconnection.c
@@ -6,12 +6,14 @@
#include "gsteditor.h"
/* class functions */
-static void gst_editor_connection_class_init(GstEditorConnectionClass *klass);
-static void gst_editor_connection_init(GstEditorConnection *connection);
-static void gst_editor_connection_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_editor_connection_get_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_editor_connection_destroy(GtkObject *object);
-static void gst_editor_connection_realize(GstEditorConnection *connection);
+static void gst_editor_connection_class_init (GstEditorConnectionClass *klass);
+static void gst_editor_connection_init (GstEditorConnection *connection);
+
+static void gst_editor_connection_set_arg (GtkObject *object,GtkArg *arg,guint id);
+static void gst_editor_connection_get_arg (GtkObject *object,GtkArg *arg,guint id);
+
+static void gst_editor_connection_destroy (GtkObject *object);
+static void gst_editor_connection_realize (GstEditorConnection *connection);
/* events fired by items within self */
//static gint gst_editor_connection_line_event(GnomeCanvasItem *item,
@@ -37,7 +39,9 @@ enum {
static GtkObjectClass *parent_class;
//static guint gst_editor_connection_signals[LAST_SIGNAL] = { 0 };
-GtkType gst_editor_connection_get_type() {
+GtkType
+gst_editor_connection_get_type (void)
+{
static GtkType connection_type = 0;
if (!connection_type) {
@@ -51,12 +55,14 @@ GtkType gst_editor_connection_get_type() {
NULL,
(GtkClassInitFunc)NULL,
};
- connection_type = gtk_type_unique(gtk_object_get_type(),&connection_info);
+ connection_type = gtk_type_unique (gtk_object_get_type (), &connection_info);
}
return connection_type;
}
-static void gst_editor_connection_class_init(GstEditorConnectionClass *klass) {
+static void
+gst_editor_connection_class_init (GstEditorConnectionClass *klass)
+{
GtkObjectClass *object_class;
object_class = (GtkObjectClass*)klass;
@@ -78,19 +84,24 @@ static void gst_editor_connection_class_init(GstEditorConnectionClass *klass) {
object_class->set_arg = gst_editor_connection_set_arg;
object_class->get_arg = gst_editor_connection_get_arg;
+
object_class->destroy = gst_editor_connection_destroy;
}
-static void gst_editor_connection_init(GstEditorConnection *connection) {
+static void
+gst_editor_connection_init (GstEditorConnection *connection)
+{
connection->points = gnome_canvas_points_new(2);
}
-GstEditorConnection *gst_editor_connection_new(GstEditorBin *parent,
- GstEditorPad *frompad) {
+GstEditorConnection*
+gst_editor_connection_new (GstEditorElement *parent,
+ GstEditorPad *frompad)
+{
GstEditorConnection *connection;
g_return_val_if_fail(parent != NULL, NULL);
- g_return_val_if_fail(GST_IS_EDITOR_BIN(parent), NULL);
+ g_return_val_if_fail(GST_IS_EDITOR_ELEMENT(parent), NULL);
g_return_val_if_fail(frompad != NULL, NULL);
g_return_val_if_fail(GST_IS_EDITOR_PAD(frompad), NULL);
@@ -98,7 +109,7 @@ GstEditorConnection *gst_editor_connection_new(GstEditorBin *parent,
connection->frompad = frompad;
connection->frompad->connection = connection;
connection->fromsrc = connection->frompad->issrc;
- connection->parent = GST_EDITOR_ELEMENT(parent);
+ connection->parent = parent;
gst_editor_connection_realize(connection);
@@ -106,7 +117,9 @@ GstEditorConnection *gst_editor_connection_new(GstEditorBin *parent,
}
-static void gst_editor_connection_set_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_connection_set_arg (GtkObject *object,GtkArg *arg,guint id)
+{
GstEditorConnection *connection;
/* get the major types of this object */
@@ -151,7 +164,9 @@ static void gst_editor_connection_set_arg(GtkObject *object,GtkArg *arg,guint id
gst_editor_connection_resize(connection);
}
-static void gst_editor_connection_get_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_connection_get_arg (GtkObject *object,GtkArg *arg,guint id)
+{
GstEditorConnection *connection;
/* get the major types of this object */
@@ -171,7 +186,9 @@ static void gst_editor_connection_get_arg(GtkObject *object,GtkArg *arg,guint id
}
-static void gst_editor_connection_realize(GstEditorConnection *connection) {
+static void
+gst_editor_connection_realize (GstEditorConnection *connection)
+{
connection->points->coords[0] = 0.0;
connection->points->coords[1] = 0.0;
connection->points->coords[2] = 0.0;
@@ -182,13 +199,17 @@ static void gst_editor_connection_realize(GstEditorConnection *connection) {
"points",connection->points,"width_units",2.0, NULL);
}
-static void gst_editor_connection_destroy(GtkObject *object) {
+static void
+gst_editor_connection_destroy (GtkObject *object)
+{
GstEditorConnection *connection = GST_EDITOR_CONNECTION(object);
gtk_object_destroy(GTK_OBJECT(connection->line));
}
-void gst_editor_connection_resize(GstEditorConnection *connection) {
+void
+gst_editor_connection_resize (GstEditorConnection *connection)
+{
gdouble x1,y1,x2,y2;
if (connection->resize != TRUE) return;
@@ -241,8 +262,10 @@ void gst_editor_connection_resize(GstEditorConnection *connection) {
"points",connection->points,NULL);
}
-void gst_editor_connection_set_endpoint(GstEditorConnection *connection,
- gdouble x,gdouble y) {
+void
+gst_editor_connection_set_endpoint (GstEditorConnection *connection,
+ gdouble x,gdouble y)
+{
connection->x = x;
connection->y = y;
if (connection->topad) {
@@ -256,8 +279,10 @@ void gst_editor_connection_set_endpoint(GstEditorConnection *connection,
gst_editor_connection_resize(connection);
}
-void gst_editor_connection_set_endpad(GstEditorConnection *connection,
- GstEditorPad *pad) {
+void
+gst_editor_connection_set_endpad (GstEditorConnection *connection,
+ GstEditorPad *pad)
+{
// first check for the trivial case
if (connection->topad == pad) return;
@@ -277,7 +302,9 @@ void gst_editor_connection_set_endpad(GstEditorConnection *connection,
gst_editor_connection_resize(connection);
}
-void gst_editor_connection_connect(GstEditorConnection *connection) {
+void
+gst_editor_connection_connect (GstEditorConnection *connection)
+{
if (connection->ghost) {
g_print("uhhh.... Boo!\n");
} else {
diff --git a/editor/gsteditorconnection.h b/editor/gsteditorconnection.h
index 84ad6ed6d9..a1e8d5422d 100644
--- a/editor/gsteditorconnection.h
+++ b/editor/gsteditorconnection.h
@@ -57,8 +57,9 @@ struct _GstEditorConnectionClass {
};
GtkType gst_editor_connection_get_type();
-GstEditorConnection *gst_editor_connection_new(GstEditorBin *parent,
- GstEditorPad *frompad);
+
+GstEditorConnection* gst_editor_connection_new (GstEditorBin *parent,
+ GstEditorPad *frompad);
#endif /* __GST_EDITOR_CONNECTION_H__ */
diff --git a/editor/gsteditorcreate.c b/editor/gsteditorcreate.c
index 26c78dc133..8d8b29b384 100644
--- a/editor/gsteditorcreate.c
+++ b/editor/gsteditorcreate.c
@@ -24,9 +24,11 @@
#include "gsteditor.h"
#include "gstelementselect.h"
+#include "gsteditorcreate.h"
-GstEditorElement *gst_editor_create_item(GstEditorBin *bin,
- gdouble x,gdouble y) {
+GstEditorElement*
+gst_editor_create_item(gdouble x,gdouble y)
+{
GstElementFactory *factory;
GstElement *element;
GstEditorElement *editorelement;
@@ -39,11 +41,10 @@ GstEditorElement *gst_editor_create_item(GstEditorBin *bin,
if (GST_IS_BIN(element)) {
// g_print("factory is a bin\n");
editorelement = GST_EDITOR_ELEMENT(gst_editor_bin_new(
- GST_EDITOR_BIN(bin),GST_BIN(element),
- "x",x,"y",y,"width",50.0,"height",20.0,NULL));
+ GST_BIN(element), "x",x,"y",y,"width",50.0,"height",20.0,NULL));
} else {
// g_print("factory is an element\n");
- editorelement = gst_editor_element_new(bin,element,
+ editorelement = gst_editor_element_new(element,
"x",x,"y",y,"width",50.0,"height",20.0,NULL);
}
// g_print("created element \"%s\" at %.2fx%.2f\n",
diff --git a/editor/gsteditorcreate.h b/editor/gsteditorcreate.h
index 448de9157d..a057d080d7 100644
--- a/editor/gsteditorcreate.h
+++ b/editor/gsteditorcreate.h
@@ -20,5 +20,4 @@
#include "gsteditor.h"
-GstEditorElement *gst_editor_create_item(GstEditorBin *bin,
- gdouble x,gdouble y);
+GstEditorElement *gst_editor_create_item(gdouble x,gdouble y);
diff --git a/editor/gsteditorelement.c b/editor/gsteditorelement.c
index 1d84ea6276..4b6064d3fb 100644
--- a/editor/gsteditorelement.c
+++ b/editor/gsteditorelement.c
@@ -28,38 +28,40 @@
#include "gsteditorproperty.h"
/* class functions */
-static void gst_editor_element_class_init(GstEditorElementClass *klass);
-static void gst_editor_element_init(GstEditorElement *element);
-static void gst_editor_element_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_editor_element_get_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_editor_element_realize(GstEditorElement *element);
-static gint gst_editor_element_event(GnomeCanvasItem *item,
- GdkEvent *event,
- GstEditorElement *element);
+static void gst_editor_element_class_init (GstEditorElementClass *klass);
+static void gst_editor_element_init (GstEditorElement *element);
+
+static void gst_editor_element_set_arg (GtkObject *object,GtkArg *arg,guint id);
+static void gst_editor_element_get_arg (GtkObject *object,GtkArg *arg,guint id);
+
+static void gst_editor_element_realize (GstEditorElement *element);
+static gint gst_editor_element_event (GnomeCanvasItem *item,
+ GdkEvent *event,
+ GstEditorElement *element);
/* events fired by items within self */
-static gint gst_editor_element_resizebox_event(GnomeCanvasItem *item,
- GdkEvent *event,
- GstEditorElement *element);
-static gint gst_editor_element_group_event(GnomeCanvasItem *item,
- GdkEvent *event,
- GstEditorElement *element);
-static gint gst_editor_element_state_event(GnomeCanvasItem *item,
- GdkEvent *event,
- gpointer data);
+static gint gst_editor_element_resizebox_event (GnomeCanvasItem *item,
+ GdkEvent *event,
+ GstEditorElement *element);
+static gint gst_editor_element_group_event (GnomeCanvasItem *item,
+ GdkEvent *event,
+ GstEditorElement *element);
+static gint gst_editor_element_state_event (GnomeCanvasItem *item,
+ GdkEvent *event,
+ gpointer data);
/* external events (from GstElement) */
-static void gst_editor_element_state_change(GstElement *element,
- gint state,
- GstEditorElement *editorelement);
+static void gst_editor_element_state_change (GstElement *element,
+ gint state,
+ GstEditorElement *editorelement);
/* utility functions */
-static void gst_editor_element_resize(GstEditorElement *element);
-static void gst_editor_element_set_state(GstEditorElement *element,
- gint id,gboolean set);
-static void gst_editor_element_sync_state(GstEditorElement *element);
-static void gst_editor_element_move(GstEditorElement *element,
- gdouble dx,gdouble dy);
+static void gst_editor_element_resize (GstEditorElement *element);
+static void gst_editor_element_set_state (GstEditorElement *element,
+ gint id,gboolean set);
+static void gst_editor_element_sync_state (GstEditorElement *element);
+static void gst_editor_element_move (GstEditorElement *element,
+ gdouble dx,gdouble dy);
static gchar *_gst_editor_element_states[] = { "S","R","P","F" };
@@ -82,17 +84,22 @@ enum {
ARG_X2,
ARG_Y2,
ARG_ELEMENT,
+ ARG_ACTIVE,
};
enum {
NAME_CHANGED,
+ POSITION_CHANGED,
+ SIZE_CHANGED,
LAST_SIGNAL
};
static GtkObjectClass *parent_class;
static guint gst_editor_element_signals[LAST_SIGNAL] = { 0 };
-GtkType gst_editor_element_get_type() {
+GtkType
+gst_editor_element_get_type(void)
+{
static GtkType element_type = 0;
if (!element_type) {
@@ -111,7 +118,9 @@ GtkType gst_editor_element_get_type() {
return element_type;
}
-static void gst_editor_element_class_init(GstEditorElementClass *klass) {
+static void
+gst_editor_element_class_init (GstEditorElementClass *klass)
+{
GtkObjectClass *object_class;
object_class = (GtkObjectClass*)klass;
@@ -119,10 +128,20 @@ static void gst_editor_element_class_init(GstEditorElementClass *klass) {
parent_class = gtk_type_class(gtk_object_get_type());
gst_editor_element_signals[NAME_CHANGED] =
- gtk_signal_new("name_changed",GTK_RUN_FIRST,object_class->type,
- GTK_SIGNAL_OFFSET(GstEditorElementClass,name_changed),
- gtk_marshal_NONE__POINTER,GTK_TYPE_NONE,1,
- GST_TYPE_EDITOR_ELEMENT);
+ gtk_signal_new ("name_changed", GTK_RUN_FIRST, object_class->type,
+ GTK_SIGNAL_OFFSET (GstEditorElementClass, name_changed),
+ gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
+ GST_TYPE_EDITOR_ELEMENT);
+ gst_editor_element_signals[POSITION_CHANGED] =
+ gtk_signal_new ("position_changed", GTK_RUN_FIRST, object_class->type,
+ GTK_SIGNAL_OFFSET (GstEditorElementClass, position_changed),
+ gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
+ GST_TYPE_EDITOR_ELEMENT);
+ gst_editor_element_signals[SIZE_CHANGED] =
+ gtk_signal_new ("size_changed", GTK_RUN_FIRST, object_class->type,
+ GTK_SIGNAL_OFFSET (GstEditorElementClass, size_changed),
+ gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1,
+ GST_TYPE_EDITOR_ELEMENT);
gtk_object_class_add_signals(object_class,gst_editor_element_signals,LAST_SIGNAL);
@@ -139,15 +158,17 @@ static void gst_editor_element_class_init(GstEditorElementClass *klass) {
GTK_ARG_READWRITE|GTK_ARG_CONSTRUCT_ONLY,
ARG_HEIGHT);
gtk_object_add_arg_type("GstEditorElement::x1",GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE,ARG_X1);
+ GTK_ARG_READWRITE, ARG_X1);
gtk_object_add_arg_type("GstEditorElement::y1",GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE,ARG_Y1);
+ GTK_ARG_READWRITE, ARG_Y1);
gtk_object_add_arg_type("GstEditorElement::x2",GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE,ARG_X2);
+ GTK_ARG_READWRITE, ARG_X2);
gtk_object_add_arg_type("GstEditorElement::y2",GTK_TYPE_DOUBLE,
- GTK_ARG_READWRITE,ARG_Y2);
+ GTK_ARG_READWRITE, ARG_Y2);
gtk_object_add_arg_type("GstEditorElement::element",GTK_TYPE_POINTER,
- GTK_ARG_READABLE,ARG_ELEMENT);
+ GTK_ARG_READABLE, ARG_ELEMENT);
+ gtk_object_add_arg_type("GstEditorElement::active",GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE, ARG_ACTIVE);
klass->realize = gst_editor_element_realize;
klass->event = gst_editor_element_event;
@@ -156,32 +177,37 @@ static void gst_editor_element_class_init(GstEditorElementClass *klass) {
object_class->get_arg = gst_editor_element_get_arg;
}
-static void gst_editor_element_init(GstEditorElement *element) {
+static void
+gst_editor_element_init (GstEditorElement *element)
+{
+ element->active = FALSE;
}
-GstEditorElement *gst_editor_element_new(GstEditorBin *parent,
- GstElement *element,
- const gchar *first_arg_name, ...) {
+GstEditorElement*
+gst_editor_element_new (GstElement *element,
+ const gchar *first_arg_name, ...)
+{
GstEditorElement *editorelement;
va_list args;
- g_return_val_if_fail(parent != NULL, NULL);
- g_return_val_if_fail(GST_IS_EDITOR_BIN(parent), NULL);
g_return_val_if_fail(element != NULL, NULL);
g_return_val_if_fail(GST_IS_ELEMENT(element), NULL);
editorelement = GST_EDITOR_ELEMENT(gtk_type_new(GST_TYPE_EDITOR_ELEMENT));
editorelement->element = element;
+ GST_EDITOR_SET_OBJECT(element, editorelement);
va_start(args,first_arg_name);
- gst_editor_element_construct(editorelement,parent,first_arg_name,args);
+ gst_editor_element_construct(editorelement,first_arg_name,args);
va_end(args);
return editorelement;
}
-void gst_editor_element_set_name(GstEditorElement *element,
- const gchar *name) {
+void
+gst_editor_element_set_name (GstEditorElement *element,
+ const gchar *name)
+{
g_return_if_fail(GST_IS_EDITOR_ELEMENT(element));
g_return_if_fail(name != NULL);
@@ -190,22 +216,22 @@ void gst_editor_element_set_name(GstEditorElement *element,
gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[NAME_CHANGED], element);
}
-const gchar *gst_editor_element_get_name(GstEditorElement *element) {
+const gchar*
+gst_editor_element_get_name (GstEditorElement *element)
+{
g_return_val_if_fail(GST_IS_EDITOR_ELEMENT(element), NULL);
return gst_element_get_name(element->element);
}
void
-gst_editor_element_construct(GstEditorElement *element,
- GstEditorBin *parent,
- const gchar *first_arg_name,
- va_list args)
+gst_editor_element_construct (GstEditorElement *element,
+ const gchar *first_arg_name,
+ va_list args)
{
GtkObject *obj = GTK_OBJECT(element);
GSList *arg_list = NULL, *info_list = NULL;
gchar *error;
- GstEditorElementClass *elementclass;
// g_print("in gst_editor_element_construct()\n");
@@ -221,18 +247,11 @@ gst_editor_element_construct(GstEditorElement *element,
gtk_object_arg_set(obj,arg->data,info->data);
gtk_args_collect_cleanup(arg_list,info_list);
}
-
- if (parent)
- gst_editor_bin_add(parent,element);
- else if (!GST_IS_EDITOR_BIN(element))
- g_warning("floating element...\n");
-
- elementclass = GST_EDITOR_ELEMENT_CLASS(GTK_OBJECT(element)->klass);
- if (elementclass->realize)
- (elementclass->realize)(element);
}
-static void gst_editor_element_set_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_element_set_arg (GtkObject *object, GtkArg *arg, guint id)
+{
GstEditorElement *element;
/* get the major types of this object */
@@ -271,13 +290,20 @@ static void gst_editor_element_set_arg(GtkObject *object,GtkArg *arg,guint id) {
element->height = MAX(GTK_VALUE_DOUBLE(*arg),element->minheight);
element->resize = TRUE;
break;
+ case ARG_ACTIVE:
+ element->active = GTK_VALUE_BOOL(*arg);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->border),
+ "width_units", (element->active ? 2.0 : 1.0), NULL);
+ break;
default:
g_warning("gsteditorelement: unknown arg!");
break;
}
}
-static void gst_editor_element_get_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_element_get_arg(GtkObject *object, GtkArg *arg, guint id)
+{
GstEditorElement *element;
/* get the major types of this object */
@@ -311,13 +337,32 @@ static void gst_editor_element_get_arg(GtkObject *object,GtkArg *arg,guint id) {
case ARG_ELEMENT:
GTK_VALUE_POINTER(*arg) = element->element;
break;
+ case ARG_ACTIVE:
+ GTK_VALUE_BOOL(*arg) = element->active;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
}
}
-static void gst_editor_element_realize(GstEditorElement *element) {
+static GtkMenu*
+gst_editor_element_get_popup_menu (GstEditorElement *element)
+{
+ GtkMenu *menu;
+
+ menu = GTK_MENU (gtk_menu_new ());
+ gtk_menu_append (menu, gtk_menu_item_new_with_label ("cut"));
+ gtk_menu_append (menu, gtk_menu_item_new_with_label ("copy"));
+ gtk_menu_append (menu, gtk_menu_item_new_with_label ("paste"));
+ gtk_widget_show_all (GTK_WIDGET (menu));
+
+ return menu;
+}
+
+static void
+gst_editor_element_realize (GstEditorElement *element)
+{
GnomeCanvasGroup *parentgroup;
gint i;
gdouble x1,y1,x2,y2;
@@ -359,7 +404,7 @@ static void gst_editor_element_realize(GstEditorElement *element) {
/* create bordering box */
element->border = gnome_canvas_item_new(element->group,
gnome_canvas_rect_get_type(),
- "width_units",2.0,"fill_color","white","outline_color","black",
+ "width_units",1.0,"fill_color","white","outline_color","black",
"x1",x1,"y1",y1,"x2",x2,"y2",y2,NULL);
g_return_if_fail(element->border != NULL);
GST_EDITOR_SET_OBJECT(element->border,element);
@@ -414,6 +459,7 @@ static void gst_editor_element_realize(GstEditorElement *element) {
while (pads) {
pad = GST_PAD(pads->data);
gst_editor_element_add_pad(element,pad);
+
pads = g_list_next(pads);
}
@@ -436,7 +482,9 @@ static void gst_editor_element_realize(GstEditorElement *element) {
}
-static void gst_editor_element_resize(GstEditorElement *element) {
+static void
+gst_editor_element_resize (GstEditorElement *element)
+{
gdouble itemwidth,itemheight;
gdouble groupwidth,groupheight;
GList *pads;
@@ -523,7 +571,9 @@ static void gst_editor_element_resize(GstEditorElement *element) {
// g_print("is now %.2fx%.2f\n",element->width,element->height);
}
-void gst_editor_element_repack(GstEditorElement *element) {
+void
+gst_editor_element_repack (GstEditorElement *element)
+{
GList *pads;
GstEditorPad *editorpad;
gint sinks;
@@ -611,11 +661,14 @@ void gst_editor_element_repack(GstEditorElement *element) {
}
-GstEditorPad *gst_editor_element_add_pad(GstEditorElement *element,
- GstPad *pad) {
+GstEditorPad*
+gst_editor_element_add_pad (GstEditorElement *element,
+ GstPad *pad)
+{
GstEditorPad *editorpad;
- editorpad = gst_editor_pad_new(element,pad,NULL);
+ editorpad = gst_editor_pad_new (element, pad, NULL);
+
if (pad->direction == GST_PAD_SINK) {
element->sinkpads = g_list_prepend(element->sinkpads,editorpad);
element->sinks++;
@@ -627,15 +680,16 @@ GstEditorPad *gst_editor_element_add_pad(GstEditorElement *element,
} else
g_print("HUH?!? Don't know which direction this pad is...\n");
- element->padlistchange = TRUE;
gst_editor_element_repack(element);
return editorpad;
}
-static gint gst_editor_element_group_event(GnomeCanvasItem *item,
- GdkEvent *event,
- GstEditorElement *element) {
+static gint
+gst_editor_element_group_event (GnomeCanvasItem *item,
+ GdkEvent *event,
+ GstEditorElement *element)
+{
switch(event->type) {
case GDK_BUTTON_PRESS:
gst_editor_property_show(gst_editor_property_get(), element);
@@ -651,8 +705,11 @@ static gint gst_editor_element_group_event(GnomeCanvasItem *item,
}
-static gint gst_editor_element_event(GnomeCanvasItem *item,GdkEvent *event,
- GstEditorElement *element) {
+static gint
+gst_editor_element_event(GnomeCanvasItem *item,
+ GdkEvent *event,
+ GstEditorElement *element)
+{
gdouble dx,dy;
GdkCursor *fleur;
@@ -660,25 +717,42 @@ static gint gst_editor_element_event(GnomeCanvasItem *item,GdkEvent *event,
switch(event->type) {
case GDK_ENTER_NOTIFY:
- break;
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->border),
+ "fill_color_rgba", 0xeeeeee80, NULL);
+ return TRUE;
case GDK_LEAVE_NOTIFY:
- break;
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->border),
+ "fill_color", "white", NULL);
+ return TRUE;
case GDK_BUTTON_PRESS:
- // dragxy coords are world coords of button press
- element->dragx = event->button.x;
- element->dragy = event->button.y;
- // set some flags
- element->dragging = TRUE;
- element->moved = FALSE;
- fleur = gdk_cursor_new(GDK_FLEUR);
- gnome_canvas_item_grab(item,
+ {
+ if (event->button.button == 3) {
+ GtkMenu *menu;
+
+ menu = gst_editor_element_get_popup_menu (element);
+
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
+ event->button.button, event->button.time);
+
+ return TRUE;
+ }
+ else {
+ // dragxy coords are world coords of button press
+ element->dragx = event->button.x;
+ element->dragy = event->button.y;
+ // set some flags
+ element->dragging = TRUE;
+ element->moved = FALSE;
+ fleur = gdk_cursor_new (GDK_FLEUR);
+ gnome_canvas_item_grab(item,
GDK_POINTER_MOTION_MASK |
// GDK_ENTER_NOTIFY_MASK |
// GDK_LEAVE_NOTIFY_MASK |
GDK_BUTTON_RELEASE_MASK,
fleur,event->button.time);
- return TRUE;
- break;
+ return TRUE;
+ }
+ }
case GDK_MOTION_NOTIFY:
if (element->dragging) {
dx = event->button.x - element->dragx;
@@ -689,7 +763,6 @@ static gint gst_editor_element_event(GnomeCanvasItem *item,GdkEvent *event,
element->moved = TRUE;
}
return TRUE;
- break;
case GDK_BUTTON_RELEASE:
if (element->dragging) {
element->dragging = FALSE;
@@ -702,9 +775,8 @@ static gint gst_editor_element_event(GnomeCanvasItem *item,GdkEvent *event,
(elementclass->button_event)(item,event,element);
}
//g_print("in element group_event, setting inchild");
- element->canvas->inchild = TRUE;
+ //element->canvas->inchild = TRUE;
return TRUE;
- break;
default:
break;
@@ -713,9 +785,11 @@ static gint gst_editor_element_event(GnomeCanvasItem *item,GdkEvent *event,
}
-static gint gst_editor_element_resizebox_event(GnomeCanvasItem *item,
- GdkEvent *event,
- GstEditorElement *element) {
+static gint
+gst_editor_element_resizebox_event (GnomeCanvasItem *item,
+ GdkEvent *event,
+ GstEditorElement *element)
+{
GdkCursor *bottomright;
gdouble item_x,item_y;
@@ -728,9 +802,15 @@ static gint gst_editor_element_resizebox_event(GnomeCanvasItem *item,
switch(event->type) {
case GDK_ENTER_NOTIFY:
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->resizebox),
+ "fill_color", "red" , NULL);
+ return TRUE;
break;
case GDK_LEAVE_NOTIFY:
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->resizebox),
+ "fill_color", "white" , NULL);
element->hesitating = FALSE;
+ return TRUE;
break;
case GDK_BUTTON_PRESS:
element->dragx = event->button.x;
@@ -761,7 +841,7 @@ static gint gst_editor_element_resizebox_event(GnomeCanvasItem *item,
element->resizing = FALSE;
gnome_canvas_item_ungrab(item,event->button.time);
//g_print("in element resizebox_event, setting inchild");
- element->canvas->inchild = TRUE;
+ //element->canvas->inchild = TRUE;
return TRUE;
}
break;
@@ -772,14 +852,16 @@ static gint gst_editor_element_resizebox_event(GnomeCanvasItem *item,
}
-static gint gst_editor_element_state_event(GnomeCanvasItem *item,
- GdkEvent *event,
- gpointer data) {
+static gint
+gst_editor_element_state_event(GnomeCanvasItem *item,
+ GdkEvent *event,
+ gpointer data)
+{
GstEditorElement *element;
gint id = GPOINTER_TO_INT(data);
GdkCursor *uparrow;
- element = GST_EDTIOR_GET_OBJECT(item);
+ element = GST_EDITOR_GET_OBJECT(item);
switch (event->type) {
case GDK_ENTER_NOTIFY:
@@ -796,17 +878,28 @@ static gint gst_editor_element_state_event(GnomeCanvasItem *item,
gnome_canvas_item_ungrab(item,event->button.time);
break;
case GDK_BUTTON_PRESS:
- return TRUE;
- break;
+ {
+ GdkEventButton *buttonevent = (GdkEventButton *)event;
+
+ if (buttonevent->button == 1)
+ return TRUE;
+ return FALSE;
+ }
case GDK_BUTTON_RELEASE:
+ {
+ GdkEventButton *buttonevent = (GdkEventButton *)event;
+
+ if (buttonevent->button != 1)
+ return FALSE;
+
if (id < 4) {
gst_editor_element_set_state(element,id,TRUE);
} else
g_warning("Uh, shouldn't have gotten here, unknown state\n");
//g_print("in element statebox_event, setting inchild");
- element->canvas->inchild = TRUE;
+ //element->canvas->inchild = TRUE;
return TRUE;
- break;
+ }
default:
break;
}
@@ -814,8 +907,10 @@ static gint gst_editor_element_state_event(GnomeCanvasItem *item,
}
-static void gst_editor_element_set_state(GstEditorElement *element,
- gint id,gboolean set) {
+static void
+gst_editor_element_set_state(GstEditorElement *element,
+ gint id,gboolean set)
+{
gboolean stateset = TRUE; /* if we have no element, set anyway */
//g_print("element set state %d\n", id);
if (element->element)
@@ -823,16 +918,20 @@ static void gst_editor_element_set_state(GstEditorElement *element,
}
-static void gst_editor_element_state_change(GstElement *element,
- gint state,
- GstEditorElement *editorelement) {
+static void
+gst_editor_element_state_change(GstElement *element,
+ gint state,
+ GstEditorElement *editorelement)
+{
g_return_if_fail(editorelement != NULL);
//g_print("gst_editor_element_state_change got state 0x%08x\n",state);
gst_editor_element_sync_state(editorelement);
}
-static void gst_editor_element_sync_state(GstEditorElement *element) {
+static void
+gst_editor_element_sync_state (GstEditorElement *element)
+{
gint id;
GstElementState state = GST_STATE(element->element);
@@ -852,8 +951,10 @@ static void gst_editor_element_sync_state(GstEditorElement *element) {
}
}
-static void gst_editor_element_move(GstEditorElement *element,
- gdouble dx,gdouble dy) {
+static void
+gst_editor_element_move(GstEditorElement *element,
+ gdouble dx,gdouble dy)
+{
GList *pads;
GstEditorPad *pad;
diff --git a/editor/gsteditorpad.c b/editor/gsteditorpad.c
index e2972aeca3..78bba30bdb 100644
--- a/editor/gsteditorpad.c
+++ b/editor/gsteditorpad.c
@@ -106,8 +106,10 @@ static void gst_editor_pad_class_init(GstEditorPadClass *klass) {
static void gst_editor_pad_init(GstEditorPad *pad) {
}
-GstEditorPad *gst_editor_pad_new(GstEditorElement *parent,GstPad *pad,
- const gchar *first_arg_name, ...) {
+GstEditorPad*
+gst_editor_pad_new(GstEditorElement *parent,GstPad *pad,
+ const gchar *first_arg_name, ...)
+{
GstEditorPad *editorpad;
va_list args;
@@ -118,11 +120,28 @@ GstEditorPad *gst_editor_pad_new(GstEditorElement *parent,GstPad *pad,
editorpad = GST_EDITOR_PAD(gtk_type_new(GST_TYPE_EDITOR_PAD));
editorpad->pad = pad;
+ GST_EDITOR_SET_OBJECT(pad, editorpad);
va_start(args,first_arg_name);
gst_editor_pad_construct(editorpad,parent,first_arg_name,args);
va_end(args);
+ if (GST_PAD_CONNECTED (pad)) {
+ GstPad *peerpad;
+ GstEditorPad *peereditorpad;
+
+ peerpad = pad->peer;
+
+ peereditorpad = GST_EDITOR_GET_OBJECT (peerpad);
+
+ if (peereditorpad) {
+ GstEditorConnection *connection;
+
+ connection = gst_editor_connection_new (parent, editorpad);
+ gst_editor_connection_set_endpad (connection, peereditorpad);
+ }
+ }
+
return editorpad;
}
@@ -245,7 +264,8 @@ static void gst_editor_pad_realize(GstEditorPad *pad) {
"x1",0.0,"y1",2.0,"x2",4.0,"y2",pad->height-2.0,NULL);
g_return_if_fail(pad->padbox != NULL);
GST_EDITOR_SET_OBJECT(pad->padbox,pad);
- gtk_signal_connect(GTK_OBJECT(pad->padbox),"event",
+
+ gtk_signal_connect(GTK_OBJECT(pad->group),"event",
GTK_SIGNAL_FUNC(gst_editor_pad_padbox_event),pad);
pad->title = gnome_canvas_item_new(pad->group,
@@ -381,10 +401,14 @@ static gint gst_editor_pad_padbox_event(GnomeCanvasItem *item,
switch(event->type) {
case GDK_ENTER_NOTIFY:
+ gtk_object_set(GTK_OBJECT(pad->border),
+ "fill_color_rgba", 0xBBDDBB00, NULL);
// g_print("entered pad '%s'\n",
// gst_pad_get_name(pad->pad));
break;
case GDK_LEAVE_NOTIFY:
+ gtk_object_set(GTK_OBJECT(pad->border),
+ "fill_color_rgba", 0xCCFFCC00, NULL);
// g_print("left pad '%s'\n",
// gst_pad_get_name(pad->pad));
break;
diff --git a/editor/gsteditorproject.c b/editor/gsteditorproject.c
index 55dbe4291a..c44523e023 100644
--- a/editor/gsteditorproject.c
+++ b/editor/gsteditorproject.c
@@ -124,7 +124,7 @@ gst_editor_project_new_from_file (const guchar *fname)
GstXML *xml;
GList *elements;
- g_return_if_fail (fname != NULL);
+ g_return_val_if_fail (fname != NULL, NULL);
editorproject = gst_editor_project_new();
@@ -143,6 +143,11 @@ gst_editor_project_new_from_file (const guchar *fname)
return editorproject;
}
+void
+gst_editor_project_load (GstEditorProject *project, const guchar *fname)
+{
+}
+
void
gst_editor_project_save_as (GstEditorProject *project, const guchar *fname)
{
@@ -163,7 +168,8 @@ gst_editor_project_save_as (GstEditorProject *project, const guchar *fname)
}
void
-gst_editor_project_add_toplevel_element (GstEditorProject *project, GstElement *element)
+gst_editor_project_add_toplevel_element (GstEditorProject *project,
+ GstElement *element)
{
g_return_if_fail(project != NULL);
g_return_if_fail(GST_IS_EDITOR_PROJECT(project));
diff --git a/editor/gsteditorproject.h b/editor/gsteditorproject.h
index d15e610a18..8f6943e0c6 100644
--- a/editor/gsteditorproject.h
+++ b/editor/gsteditorproject.h
@@ -60,6 +60,7 @@ GtkType gst_editor_project_get_type (void);
GstEditorProject* gst_editor_project_new (void);
GstEditorProject* gst_editor_project_new_from_file (const guchar *fname);
+void gst_editor_project_load (GstEditorProject *project, const guchar *fname);
void gst_editor_project_save (GstEditorProject *project);
void gst_editor_project_save_as (GstEditorProject *project,
const guchar *fname);
diff --git a/editor/gsteditorprojectview.c b/editor/gsteditorprojectview.c
index 39dfda838f..43a0a20e9d 100644
--- a/editor/gsteditorprojectview.c
+++ b/editor/gsteditorprojectview.c
@@ -152,7 +152,7 @@ view_on_element_added (GstEditorProjectView *view, GstElement *element)
GstEditor *editor;
image = gst_editor_image_get_for_type(GTK_OBJECT_TYPE(element));
- name = gst_element_get_name(element);
+ name = (gchar *)gst_element_get_name(element);
row = gtk_clist_append(GTK_CLIST(view->list), &name);
editor = gst_editor_new(element);
@@ -215,7 +215,7 @@ on_load_file_selected (GtkWidget *button,
GstEditorProjectView *view = data->view;
gchar *file_name = gtk_file_selection_get_filename (GTK_FILE_SELECTION(selector));
- //gst_editor_project_load (view->project, file_name);
+ gst_editor_project_load (view->project, file_name);
g_free (data);
}
@@ -286,7 +286,6 @@ gst_editor_project_view_new (GstEditorProject *project)
while (elements) {
GstElement *element = (GstElement *)elements->data;
- g_print ("add\n");
view_on_element_added (view, element);
elements = g_list_next (elements);
diff --git a/editor/gsteditorproperty.c b/editor/gsteditorproperty.c
index 4b9c4ee692..5c08d5e67c 100644
--- a/editor/gsteditorproperty.c
+++ b/editor/gsteditorproperty.c
@@ -21,17 +21,22 @@
#include
#include
#include
+#include
#include "gsteditorproperty.h"
#include "gsteditorimage.h"
/* class functions */
-static void gst_editor_property_class_init(GstEditorPropertyClass *klass);
-static void gst_editor_property_init(GstEditorProperty *property);
-static void gst_editor_property_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_editor_property_get_arg(GtkObject *object,GtkArg *arg,guint id);
+static void gst_editor_property_class_init (GstEditorPropertyClass *klass);
+static void gst_editor_property_init (GstEditorProperty *property);
+
+static void gst_editor_property_set_arg (GtkObject *object,GtkArg *arg,guint id);
+static void gst_editor_property_get_arg (GtkObject *object,GtkArg *arg,guint id);
+
+static GtkWidget* create_property_entry (GtkArg *arg, GstElement *element);
+
+static GtkWidget* gst_editor_property_create (GstEditorProperty *property, GstEditorElement *element);
-static GtkWidget *create_property_entry(GtkArg *arg, GstElement *element);
enum {
ARG_0,
@@ -48,7 +53,9 @@ static guint gst_editor_property_signals[LAST_SIGNAL] = { 0 };
static GstEditorProperty *_the_property = NULL;
-GtkType gst_editor_property_get_type() {
+GtkType
+gst_editor_property_get_type (void)
+{
static GtkType property_type = 0;
if (!property_type) {
@@ -67,7 +74,9 @@ GtkType gst_editor_property_get_type() {
return property_type;
}
-static void gst_editor_property_class_init(GstEditorPropertyClass *klass) {
+static void
+gst_editor_property_class_init (GstEditorPropertyClass *klass)
+{
GtkObjectClass *object_class;
object_class = (GtkObjectClass*)klass;
@@ -92,10 +101,10 @@ static void gst_editor_property_class_init(GstEditorPropertyClass *klass) {
object_class->get_arg = gst_editor_property_get_arg;
}
-static void gst_editor_property_init(GstEditorProperty *property) {
-
- property->panels = g_hash_table_new(NULL, NULL);
- property->current = NULL;
+static void
+gst_editor_property_init (GstEditorProperty *property)
+{
+ property->shown_element = NULL;
}
typedef struct {
@@ -104,7 +113,8 @@ typedef struct {
} connect_struct;
/* we need more control here so... */
-static void gst_editor_property_connect_func (const gchar *handler_name,
+static void
+gst_editor_property_connect_func (const gchar *handler_name,
GtkObject *object,
const gchar *signal_name,
const gchar *signal_data,
@@ -125,7 +135,9 @@ static void gst_editor_property_connect_func (const gchar *handler_name,
}
}
-static GstEditorProperty *gst_editor_property_new() {
+static GstEditorProperty*
+gst_editor_property_new (void)
+{
GstEditorProperty *property;
GtkWidget *property_window;
connect_struct data;
@@ -147,14 +159,18 @@ static GstEditorProperty *gst_editor_property_new() {
return property;
}
-GstEditorProperty *gst_editor_property_get() {
+GstEditorProperty*
+gst_editor_property_get (void)
+{
if (!_the_property) {
_the_property = gst_editor_property_new();
}
return _the_property;
}
-static void gst_editor_property_set_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_property_set_arg (GtkObject *object,GtkArg *arg,guint id)
+{
GstEditorProperty *property;
/* get the major types of this object */
@@ -167,7 +183,9 @@ static void gst_editor_property_set_arg(GtkObject *object,GtkArg *arg,guint id)
}
}
-static void gst_editor_property_get_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_editor_property_get_arg (GtkObject *object,GtkArg *arg,guint id)
+{
GstEditorProperty *property;
/* get the major types of this object */
@@ -180,11 +198,15 @@ static void gst_editor_property_get_arg(GtkObject *object,GtkArg *arg,guint id)
}
}
-static void on_name_changed(GtkEntry *entry, GstEditorElement *element) {
+static void
+on_name_changed (GtkEntry *entry, GstEditorElement *element)
+{
gst_editor_element_set_name(element, gtk_entry_get_text(GTK_ENTRY(entry)));
}
-static gchar *make_readable_name(gchar *name) {
+static gchar*
+make_readable_name (gchar *name)
+{
gchar *new;
gchar *colon;
gboolean inupper;
@@ -211,76 +233,222 @@ static gchar *make_readable_name(gchar *name) {
return new;
}
-void gst_editor_property_show(GstEditorProperty *property, GstEditorElement *element) {
+static gchar*
+gst_editor_props_show_func (GstPropsEntry *entry)
+{
+ switch (entry->propstype) {
+ case GST_PROPS_INT_ID_NUM:
+ return g_strdup_printf ("%d", entry->data.int_data);
+ break;
+ case GST_PROPS_INT_RANGE_ID_NUM:
+ return g_strdup_printf ("%d-%d", entry->data.int_range_data.min, entry->data.int_range_data.max);
+ break;
+ case GST_PROPS_FOURCC_ID_NUM:
+ return g_strdup_printf ("%4.4s", (gchar *)&entry->data.fourcc_data);
+ break;
+ case GST_PROPS_BOOL_ID_NUM:
+ return g_strdup_printf ("%s", (entry->data.bool_data ? "TRUE" : "FALSE"));
+ break;
+ default:
+ break;
+ }
+ return g_strdup ("unknown");
+}
+
+static GtkWidget*
+gst_editor_pads_create (GstEditorProperty *property, GstEditorElement *element)
+{
+ GstElement *realelement = element->element;
+ GList *pads;
+ GtkWidget *tree;
+ gchar *columns[2];
+
+ pads = gst_element_get_pad_list(realelement);
+
+ columns[0] = "name";
+ columns[1] = "info";
+
+ tree = gtk_ctree_new_with_titles (2, 0, columns);
+ gtk_clist_set_column_width (GTK_CLIST (tree), 0, 150);
+
+ gtk_clist_freeze (GTK_CLIST (tree));
+ while (pads) {
+ GstPad *pad = (GstPad *)pads->data;
+ GstCaps *caps = gst_pad_get_caps (pad);
+ gchar *mime;
+ gchar *data[2];
+ GtkCTreeNode *padnode;
+
+ if (caps) {
+ GstType *type;
+ type = gst_type_find_by_id (caps->id);
+ mime = type->mime;
+ }
+ else {
+ mime = "unknown/unknown";
+ }
+
+ data[0] = g_strdup (gst_pad_get_name (pad));
+ data[1] = mime;
+ padnode = gtk_ctree_insert_node (GTK_CTREE (tree), NULL, NULL, data, 0,
+ NULL, NULL, NULL, NULL, FALSE, TRUE);
+ if (caps) {
+ GstProps *props = gst_caps_get_props (caps);
+ if (props) {
+ GSList *propslist = props->properties;
+
+ while (propslist) {
+ GstPropsEntry *entry = (GstPropsEntry *)propslist->data;
+
+ data[0] = g_quark_to_string (entry->propid);
+
+ switch (entry->propstype) {
+ case GST_PROPS_LIST_ID_NUM:
+ {
+ GList *list;
+ guint count = 0;
+ data[1] = "";
+
+ list = entry->data.list_data.entries;
+
+ while (list) {
+ data[1] = g_strconcat (data[1], (count++?", ":""),
+ gst_editor_props_show_func ((GstPropsEntry *)list->data), NULL);
+ list = g_list_next (list);
+ }
+ break;
+ }
+ default:
+ data[1] = gst_editor_props_show_func (entry);
+ break;
+ }
+ gtk_ctree_insert_node (GTK_CTREE (tree), padnode, NULL, data, 0,
+ NULL, NULL, NULL, NULL, TRUE, TRUE);
+
+ propslist = g_slist_next (propslist);
+ }
+ }
+ }
+ pads = g_list_next (pads);
+ }
+ gtk_clist_thaw (GTK_CLIST (tree));
+
+ gtk_widget_show(tree);
+ gtk_object_ref(GTK_OBJECT(tree));
+ return tree;
+}
+
+typedef struct {
+ GtkWidget *properties;
+ GtkWidget *pads;
+ GtkWidget *signals;
+} properties_widgets;
+
+void
+gst_editor_property_show (GstEditorProperty *property, GstEditorElement *element)
+{
GtkType type;
- GtkWidget *table, *vbox;
- GtkWidget *label, *entry, *panel = NULL;
+
+ if (property->shown_element != element) {
+ gtk_object_set (GTK_OBJECT (element), "active",TRUE, NULL);
+ if (property->shown_element) {
+ gtk_object_set (GTK_OBJECT (property->shown_element), "active",FALSE, NULL);
+ }
+ }
+ else return;
type = GTK_OBJECT_TYPE(element->element);
if (type != GTK_TYPE_INVALID) {
- panel = (GtkWidget *)g_hash_table_lookup(property->panels, GINT_TO_POINTER(type));
- vbox = glade_xml_get_widget(property->xml, "property_vbox");
+ GtkWidget *property_box, *pads_window;
+ properties_widgets *widgets;
- if (panel && property->current == (gpointer) panel) return;
+ property_box = glade_xml_get_widget(property->xml, "property_vbox");
+ pads_window = glade_xml_get_widget(property->xml, "pads_window");
- if (property->current)
- gtk_container_remove(GTK_CONTAINER(vbox), GTK_WIDGET(property->current));
+ if (property->shown_element) {
+ properties_widgets *oldwidgets;
- if (panel) {
- gtk_box_pack_start(GTK_BOX(vbox), panel, FALSE, TRUE, 0);
- property->current = (gpointer) panel;
+ oldwidgets = (properties_widgets *) GST_EDITOR_PROPERTY_GET_OBJECT (property->shown_element);
+
+ gtk_container_remove(GTK_CONTAINER(property_box), oldwidgets->properties);
+ gtk_container_remove(GTK_CONTAINER(pads_window), oldwidgets->pads);
}
- else {
- GtkArg *args;
- guint32 *flags;
- guint num_args, i, count;
-
- table = gtk_table_new(1, 2, FALSE);
- gtk_table_set_row_spacings(GTK_TABLE(table), 2);
- gtk_widget_show(table);
- label = gtk_label_new(_("Name:"));
- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
- gtk_object_set(GTK_OBJECT(label), "width", 100, NULL);
- gtk_widget_show(label);
- entry = gtk_entry_new();
- gtk_widget_show(entry);
- gtk_entry_set_text(GTK_ENTRY(entry), gst_element_get_name(element->element));
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
- gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1, GTK_FILL|GTK_EXPAND, 0, 0, 0);
+ widgets = (properties_widgets *)GST_EDITOR_PROPERTY_GET_OBJECT(element);
- gtk_signal_connect(GTK_OBJECT(entry), "changed", on_name_changed, element);
+ if (!widgets) {
+ widgets = g_new0 (properties_widgets, 1);
- args = gtk_object_query_args(type, &flags, &num_args);
- count = 1;
- for (i=0; ielement), 1, &args[i]);
+ widgets->properties = gst_editor_property_create (property, element);
+ widgets->pads = gst_editor_pads_create (property, element);
- entry = create_property_entry(&args[i], element->element);
-
- if (entry) {
- label = gtk_label_new(g_strconcat(make_readable_name(args[i].name), ":", NULL));
- gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
- gtk_object_set(GTK_OBJECT(label), "width", 100, NULL);
- gtk_widget_show(label);
-
- gtk_table_attach(GTK_TABLE(table), label, 0, 1, count, count+1, GTK_FILL, 0, 0, 0);
- gtk_table_attach(GTK_TABLE(table), entry, 1, 2, count, count+1, GTK_FILL|GTK_EXPAND, 0, 0, 0);
-
- count++;
- }
- }
- }
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 2);
- g_hash_table_insert(property->panels, GINT_TO_POINTER(type), table);
- gtk_object_ref(GTK_OBJECT(table));
- property->current = (gpointer) table;
+ GST_EDITOR_PROPERTY_SET_OBJECT(element, widgets);
}
+
+ gtk_box_pack_start(GTK_BOX(property_box), widgets->properties, FALSE, TRUE, 0);
+ gtk_container_add(GTK_CONTAINER(pads_window), widgets->pads);
+
+ property->shown_element = element;
}
}
-static void widget_show_toggled(GtkToggleButton *button, GtkArg *arg) {
+static GtkWidget*
+gst_editor_property_create (GstEditorProperty *property, GstEditorElement *element)
+{
+ GtkWidget *table;
+ GtkType type;
+ GtkArg *args;
+ guint32 *flags;
+ guint num_args, i, count;
+ GtkWidget *label, *entry;
+
+ type = GTK_OBJECT_TYPE(element->element);
+
+ table = gtk_table_new(1, 2, FALSE);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 2);
+
+ label = gtk_label_new(_("Name:"));
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+ gtk_object_set(GTK_OBJECT(label), "width", 100, NULL);
+ gtk_widget_show(label);
+ entry = gtk_entry_new();
+ gtk_widget_show(entry);
+ gtk_entry_set_text(GTK_ENTRY(entry), gst_element_get_name(element->element));
+ gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1, GTK_FILL|GTK_EXPAND, 0, 0, 0);
+
+ gtk_signal_connect(GTK_OBJECT(entry), "changed", on_name_changed, element);
+
+ args = gtk_object_query_args(type, &flags, &num_args);
+ count = 1;
+ for (i=0; ielement), 1, &args[i]);
+
+ entry = create_property_entry(&args[i], element->element);
+
+ if (entry) {
+ label = gtk_label_new(g_strconcat(make_readable_name(args[i].name), ":", NULL));
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+ gtk_object_set(GTK_OBJECT(label), "width", 100, NULL);
+ gtk_widget_show(label);
+
+ gtk_table_attach(GTK_TABLE(table), label, 0, 1, count, count+1, GTK_FILL, 0, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), entry, 1, 2, count, count+1, GTK_FILL|GTK_EXPAND, 0, 0, 0);
+
+ count++;
+ }
+ }
+ }
+
+ gtk_widget_show(table);
+ gtk_object_ref(GTK_OBJECT(table));
+ return table;
+}
+
+static void
+widget_show_toggled (GtkToggleButton *button, GtkArg *arg)
+{
GtkWidget *window;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -293,15 +461,29 @@ static void widget_show_toggled(GtkToggleButton *button, GtkArg *arg) {
typedef struct {
GtkArg *arg;
GstElement *element;
-} file_select;
+} arg_data;
+
+static void
+widget_bool_toggled (GtkToggleButton *button, arg_data *arg)
+{
+ gboolean toggled;
+
+ toggled = gtk_toggle_button_get_active(button);
+ gtk_object_set (GTK_OBJECT (button), "label", (toggled? _("Yes"):_("No")), NULL);
+
+ gtk_object_set (GTK_OBJECT (arg->element), arg->arg->name, toggled, NULL);
+}
-static void on_file_selected(GtkEditable *entry, file_select *fs)
+static void
+on_file_selected (GtkEditable *entry, arg_data *fs)
{
gtk_object_set(GTK_OBJECT(fs->element), fs->arg->name,
gtk_entry_get_text(GTK_ENTRY(entry)), NULL);
}
-static GtkWidget *create_property_entry(GtkArg *arg, GstElement *element) {
+static GtkWidget*
+create_property_entry (GtkArg *arg, GstElement *element)
+{
GtkWidget *entry = NULL;
// basic types
@@ -317,10 +499,16 @@ static GtkWidget *create_property_entry(GtkArg *arg, GstElement *element) {
}
case GTK_TYPE_BOOL:
{
- gboolean toggle;
- toggle = GTK_VALUE_BOOL(*arg);
- entry = gtk_toggle_button_new_with_label((toggle? _("Yes"):_("No")));
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(entry), toggle);
+ gboolean toggled;
+ arg_data *data = g_new0(arg_data, 1);
+
+ data->element = element;
+ data->arg = arg;
+
+ toggled = GTK_VALUE_BOOL(*arg);
+ entry = gtk_toggle_button_new_with_label((toggled? _("Yes"):_("No")));
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(entry), toggled);
+ gtk_signal_connect(GTK_OBJECT(entry), "toggled", widget_bool_toggled, data);
break;
}
case GTK_TYPE_ULONG:
@@ -362,8 +550,10 @@ static GtkWidget *create_property_entry(GtkArg *arg, GstElement *element) {
}
else if (GTK_FUNDAMENTAL_TYPE(arg->type) == GTK_TYPE_ENUM) {
GtkEnumValue *values;
- gint i=0;
+ guint i = 0;
GtkWidget *menu;
+ guint value = GTK_VALUE_ENUM (*arg);
+ guint active = 0;
entry = gtk_option_menu_new();
menu = gtk_menu_new();
@@ -374,12 +564,15 @@ static GtkWidget *create_property_entry(GtkArg *arg, GstElement *element) {
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
+
+ if (value == values[i].value) active = i;
i++;
}
+ gtk_menu_set_active(GTK_MENU(menu), active);
gtk_option_menu_set_menu(GTK_OPTION_MENU(entry), menu);
}
else if (arg->type == GST_TYPE_FILENAME) {
- file_select *fs = g_new0(file_select, 1);
+ arg_data *fs = g_new0(arg_data, 1);
entry = gnome_file_entry_new(NULL, NULL);
@@ -400,18 +593,3 @@ static GtkWidget *create_property_entry(GtkArg *arg, GstElement *element) {
return entry;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/editor/gsteditorproperty.h b/editor/gsteditorproperty.h
index 8fadde8b8c..343b69c022 100644
--- a/editor/gsteditorproperty.h
+++ b/editor/gsteditorproperty.h
@@ -36,6 +36,11 @@
#define GST_IS_EDITOR_PROPERTY_CLASS(obj) \
(GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_PROPERTY))
+#define GST_EDITOR_PROPERTY_SET_OBJECT(item,object) \
+ (gtk_object_set_data(GTK_OBJECT(item),"gsteditorproperty",(object)))
+#define GST_EDITOR_PROPERTY_GET_OBJECT(item) \
+ (gtk_object_get_data(GTK_OBJECT(item),"gsteditorproperty"))
+
typedef struct _GstEditorProperty GstEditorProperty;
typedef struct _GstEditorPropertyClass GstEditorPropertyClass;
@@ -43,8 +48,7 @@ struct _GstEditorProperty {
GtkObject object;
GladeXML *xml;
- GHashTable *panels;
- gpointer *current;
+ GstEditorElement *shown_element;
};
struct _GstEditorPropertyClass {
diff --git a/gst/elements/gstaudiosink.c b/gst/elements/gstaudiosink.c
index a49b15df46..73c25cd5f0 100644
--- a/gst/elements/gstaudiosink.c
+++ b/gst/elements/gstaudiosink.c
@@ -186,6 +186,9 @@ gst_audiosink_init (GstAudioSink *audiosink)
audiosink->fd = -1;
audiosink->clock = gst_clock_get_system();
+ audiosink->format = 16;
+ audiosink->channels = 2;
+ audiosink->frequency = 44100;
gst_clock_register (audiosink->clock, GST_OBJECT (audiosink));
diff --git a/gst/gstbin.h b/gst/gstbin.h
index c34434a124..e01a83eab4 100644
--- a/gst/gstbin.h
+++ b/gst/gstbin.h
@@ -79,6 +79,7 @@ struct _GstBinClass {
/* signals */
void (*object_added) (GstObject *object, GstObject *child);
+ void (*object_removed) (GstObject *object, GstObject *child);
/* change the state of elements of the given type */
gboolean (*change_state_type) (GstBin *bin,
diff --git a/gst/gstelement.h b/gst/gstelement.h
index e0f8858301..dd37c501f5 100644
--- a/gst/gstelement.h
+++ b/gst/gstelement.h
@@ -151,8 +151,8 @@ struct _GstElementClass {
GstElementStateReturn (*change_state) (GstElement *element);
/* create or read XML representation of self */
- xmlNodePtr (*save_thyself) (GstElement *element, xmlNodePtr parent);
- void (*restore_thyself) (GstElement *element, xmlNodePtr self, GHashTable *elements);
+ xmlNodePtr (*save_thyself) (GstElement *element, xmlNodePtr parent);
+ void (*restore_thyself) (GstElement *element, xmlNodePtr self, GHashTable *elements);
};
struct _GstElementDetails {
diff --git a/gst/gstutils.c b/gst/gstutils.c
index 54dae5797e..18706866ea 100644
--- a/gst/gstutils.c
+++ b/gst/gstutils.c
@@ -37,6 +37,23 @@ gint gst_util_get_int_arg(GtkObject *object,guchar *argname) {
return GTK_VALUE_INT(arg);
}
+/**
+ * gst_util_get_bool_arg:
+ * @object: the object to query
+ * @argname: the name of the argument
+ *
+ * retrieves a property of an object as a boolean
+ *
+ * Returns: the property of the object
+ */
+gint gst_util_get_bool_arg(GtkObject *object,guchar *argname) {
+ GtkArg arg;
+
+ arg.name = argname;
+ gtk_object_getv(GTK_OBJECT(object),1,&arg);
+ return GTK_VALUE_BOOL(arg);
+}
+
/**
* gst_util_get_long_arg:
* @object: the object to query
diff --git a/gst/gstutils.h b/gst/gstutils.h
index 6cb4e6d510..c1a7ba0a22 100644
--- a/gst/gstutils.h
+++ b/gst/gstutils.h
@@ -24,6 +24,7 @@
#include
gint gst_util_get_int_arg (GtkObject *object, guchar *argname);
+gboolean gst_util_get_bool_arg (GtkObject *object, guchar *argname);
glong gst_util_get_long_arg (GtkObject *object, guchar *argname);
gfloat gst_util_get_float_arg (GtkObject *object, guchar *argname);
gdouble gst_util_get_double_arg (GtkObject *object, guchar *argname);
diff --git a/gst/gstxml.c b/gst/gstxml.c
index c76e3598b2..4a08f811c6 100644
--- a/gst/gstxml.c
+++ b/gst/gstxml.c
@@ -25,7 +25,9 @@ static void gst_xml_init (GstXML *xml);
static GstObjectClass *parent_class = NULL;
-GtkType gst_xml_get_type(void) {
+GtkType
+gst_xml_get_type(void)
+{
static GtkType xml_type = 0;
if (!xml_type) {
@@ -39,17 +41,20 @@ GtkType gst_xml_get_type(void) {
(GtkArgGetFunc)NULL,
(GtkClassInitFunc)NULL,
};
- xml_type = gtk_type_unique(GST_TYPE_XML,&xml_info);
+ xml_type = gtk_type_unique (GST_TYPE_XML, &xml_info);
}
return xml_type;
}
static void
-gst_xml_class_init(GstXMLClass *klass) {
- parent_class = gtk_type_class(GST_TYPE_OBJECT);
+gst_xml_class_init (GstXMLClass *klass)
+{
+ parent_class = gtk_type_class (GST_TYPE_OBJECT);
}
-static void gst_xml_init(GstXML *xml) {
+static void
+gst_xml_init(GstXML *xml)
+{
}
/**
@@ -60,13 +65,15 @@ static void gst_xml_init(GstXML *xml) {
*
* Returns: a pointer to an XML document
*/
-xmlDocPtr gst_xml_write(GstElement *element) {
+xmlDocPtr
+gst_xml_write (GstElement *element)
+{
xmlDocPtr doc;
- doc = xmlNewDoc("1.0");
- doc->root = xmlNewDocNode(doc,NULL,"GST-Pipeline",NULL);
+ doc = xmlNewDoc ("1.0");
+ doc->root = xmlNewDocNode (doc, NULL, "GST-Pipeline", NULL);
- gst_element_save_thyself(element,doc->root);
+ gst_element_save_thyself (element, doc->root);
return doc;
}
diff --git a/plugins/elements/gstaudiosink.c b/plugins/elements/gstaudiosink.c
index a49b15df46..73c25cd5f0 100644
--- a/plugins/elements/gstaudiosink.c
+++ b/plugins/elements/gstaudiosink.c
@@ -186,6 +186,9 @@ gst_audiosink_init (GstAudioSink *audiosink)
audiosink->fd = -1;
audiosink->clock = gst_clock_get_system();
+ audiosink->format = 16;
+ audiosink->channels = 2;
+ audiosink->frequency = 44100;
gst_clock_register (audiosink->clock, GST_OBJECT (audiosink));