diff --git a/editor/Makefile.am b/editor/Makefile.am index d1b3bb859f..8961856f41 100644 --- a/editor/Makefile.am +++ b/editor/Makefile.am @@ -14,6 +14,7 @@ libgsteditor_la_SOURCES = \ gsteditorbin.c \ gsteditorcanvas.c \ gsteditorpad.c \ + gsteditorpadtemplate.c \ gsteditorconnection.c \ gsteditorimage.c \ gsteditorpalette.c \ diff --git a/editor/editor.c b/editor/editor.c index 8fa6ee45cf..5d6ed7ab35 100644 --- a/editor/editor.c +++ b/editor/editor.c @@ -52,7 +52,9 @@ main (int argc, char *argv[]) gst_editor_project_view_new(project); + gdk_threads_enter (); gtk_main(); + gdk_threads_leave (); return(0); } diff --git a/editor/gsteditor.h b/editor/gsteditor.h index 9bcedc0fae..105e18087a 100644 --- a/editor/gsteditor.h +++ b/editor/gsteditor.h @@ -35,6 +35,8 @@ typedef struct _GstEditorCanvas GstEditorCanvas; typedef struct _GstEditorCanvasClass GstEditorCanvasClass; typedef struct _GstEditorPad GstEditorPad; typedef struct _GstEditorPadClass GstEditorPadClass; +typedef struct _GstEditorPadTemplate GstEditorPadTemplate; +typedef struct _GstEditorPadTemplateClass GstEditorPadTemplateClass; typedef struct _GstEditorConnection GstEditorConnection; typedef struct _GstEditorConnectionClass GstEditorConnectionClass; @@ -142,6 +144,9 @@ struct _GstEditorElement { GList *srcpads,*sinkpads; gboolean padlistchange; + /* list of padtemplates */ + GList *srcpadtemps,*sinkpadtemps; + /* interaction state */ gboolean dragging,resizing,moved,hesitating; gdouble offx,offy,dragx,dragy; @@ -168,8 +173,6 @@ void gst_editor_element_construct(GstEditorElement *element, const gchar *first_arg_name, va_list args); void gst_editor_element_repack(GstEditorElement *element); -GstEditorPad *gst_editor_element_add_pad(GstEditorElement *element, - GstPad *pad); void gst_editor_element_set_name(GstEditorElement *element, const gchar *name); const gchar *gst_editor_element_get_name(GstEditorElement *element); @@ -314,6 +317,75 @@ void gst_editor_pad_repack(GstEditorPad *pad); +#define GST_TYPE_EDITOR_PADTEMPLATE \ + (gst_editor_padtemplate_get_type()) +#define GST_EDITOR_PADTEMPLATE(obj) \ + (GTK_CHECK_CAST((obj),GST_TYPE_EDITOR_PADTEMPLATE,GstEditorPadTemplate)) +#define GST_EDITOR_PADTEMPLATE_CLASS(klass) \ + (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EDITOR_PADTEMPLATE,GstEditorPadTemplateClass)) +#define GST_IS_EDITOR_PADTEMPLATE(obj) \ + (GTK_CHECK_TYPE((obj),GST_TYPE_EDITOR_PADTEMPLATE)) +#define GST_IS_EDITOR_PADTEMPLATE_CLASS(obj) \ + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_PADTEMPLATE)) + +struct _GstEditorPadTemplate { + GtkObject object; + + /* parent element */ + GstEditorElement *parent; + + /* toplevel canvas */ + GstEditorCanvas *canvas; + + /* the padtemplate we're associated with */ + GstPadTemplate *padtemplate; + + /* pads created from this template */ + GList *pads; + + /* if this is a sink (convenience) */ + gboolean issrc; + + /* whether we've been realized or not */ + gboolean realized; + + /* connections */ + GstEditorConnection *connection; + GstEditorConnection *ghostconnection; + + /* visual stuff */ + GnomeCanvasGroup *group; + GnomeCanvasItem *border,*title,*padtemplatebox; + gboolean sinkpadtemplate; // is this a sink padtemplate? + gdouble x,y; // location + gdouble width,height; // actual size + gdouble boxwidth,boxheight; // size of padtemplate box + gboolean resize; // does it need resizing? + + /* interaction state */ + gboolean dragging,resizing,moved; + gdouble dragx,dragy; + + /* connection */ +// GnomeCanvasItem *connection; // can't use +//GstEditorConnection +}; + +struct _GstEditorPadTemplateClass { + GtkObjectClass parent_class; + + void (*realize) (GstEditorPadTemplate *padtemplate); +}; + +GtkType gst_editor_padtemplate_get_type(); +GstEditorPadTemplate *gst_editor_padtemplate_new(GstEditorElement *parent,GstPadTemplate *padtemplate, + const gchar *first_arg_name, ...); +void gst_editor_padtemplate_construct(GstEditorPadTemplate *element, + GstEditorElement *parent, + const gchar *first_arg_name,va_list args); +void gst_editor_padtemplate_repack(GstEditorPadTemplate *padtemplate); + + #define GST_TYPE_EDITOR_CONNECTION \ (gst_editor_connection_get_type()) #define GST_EDITOR_CONNECTION(obj) \ diff --git a/editor/gsteditorbin.c b/editor/gsteditorbin.c index 3f070067a7..4ea1b8f50d 100644 --- a/editor/gsteditorbin.c +++ b/editor/gsteditorbin.c @@ -353,6 +353,7 @@ gst_editor_bin_object_added (GstEditorBin *editorbin, GstObject *bin, GstObject g_print ("gsteditorbin: object added\n"); } + void gst_editor_bin_add (GstEditorBin *bin, GstEditorElement *element) { diff --git a/editor/gsteditorelement.c b/editor/gsteditorelement.c index 4b6064d3fb..f5c0fc3df0 100644 --- a/editor/gsteditorelement.c +++ b/editor/gsteditorelement.c @@ -50,19 +50,22 @@ 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); - /* 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_add_pad_wrapper (GstEditorElement *element, + GstPad *pad); +static void gst_editor_element_add_pad (GstEditorElement *element, + GstPad *pad); +GstEditorPadTemplate* gst_editor_element_add_padtemplate (GstEditorElement *element, + GstPadTemplate *pad); static void gst_editor_element_sync_state (GstEditorElement *element); +static void gst_editor_element_sync_state_wrapper (GstEditorElement *element); static void gst_editor_element_move (GstEditorElement *element, gdouble dx,gdouble dy); - +static void gst_editor_element_position_changed (GstEditorElement *element, + GstEditorElement *parent); static gchar *_gst_editor_element_states[] = { "S","R","P","F" }; @@ -367,7 +370,6 @@ gst_editor_element_realize (GstEditorElement *element) gint i; gdouble x1,y1,x2,y2; GList *pads; - GstPad *pad; // g_print("realizing editor element %p\n",element); @@ -375,9 +377,17 @@ gst_editor_element_realize (GstEditorElement *element) g_return_if_fail(element->parent != NULL); // set the state signal of the actual element - gtk_signal_connect(GTK_OBJECT(element->element),"state_change", - GTK_SIGNAL_FUNC(gst_editor_element_state_change), - element); + gtk_signal_connect_object (GTK_OBJECT(element->element),"state_change", + GTK_SIGNAL_FUNC(gst_editor_element_sync_state_wrapper), + GTK_OBJECT (element)); + + gtk_signal_connect_object (GTK_OBJECT(element->element),"new_pad", + GTK_SIGNAL_FUNC(gst_editor_element_add_pad_wrapper), + GTK_OBJECT (element)); + + gtk_signal_connect_object (GTK_OBJECT(element->parent),"position_changed", + GTK_SIGNAL_FUNC(gst_editor_element_position_changed), + GTK_OBJECT (element)); // create the bounds if we haven't had them set // g_print("centering element at %.2fx%.2f (%.2fx%.2f)\n", @@ -454,10 +464,22 @@ gst_editor_element_realize (GstEditorElement *element) GTK_SIGNAL_FUNC(gst_editor_element_state_event), GINT_TO_POINTER(i)); } + + // get all the padtemplates + pads = gst_element_get_padtemplate_list(element->element); + while (pads) { + GstPadTemplate *temp = (GstPadTemplate *) pads->data; + + gst_editor_element_add_padtemplate (element,temp); + + pads = g_list_next(pads); + } + // get all the pads pads = gst_element_get_pad_list(element->element); while (pads) { - pad = GST_PAD(pads->data); + GstPad *pad = GST_PAD(pads->data); + gst_editor_element_add_pad(element,pad); pads = g_list_next(pads); @@ -489,6 +511,7 @@ gst_editor_element_resize (GstEditorElement *element) gdouble groupwidth,groupheight; GList *pads; GstEditorPad *editorpad; + GstEditorPadTemplate *editorpadtemplate; gint i; if (element->resize != TRUE) return; @@ -552,12 +575,28 @@ gst_editor_element_resize (GstEditorElement *element) element->srcs++; pads = g_list_next(pads); } + pads = element->sinkpadtemps; + while (pads) { + editorpadtemplate = GST_EDITOR_PADTEMPLATE(pads->data); + element->sinkwidth = MAX(element->sinkwidth,editorpadtemplate->width); + element->sinkheight = MAX(element->sinkheight,editorpadtemplate->height); + element->sinks++; + pads = g_list_next(pads); + } + pads = element->srcpadtemps; + while (pads) { + editorpadtemplate = GST_EDITOR_PADTEMPLATE(pads->data); + element->srcwidth = MAX(element->srcwidth,editorpadtemplate->width); + element->srcheight = MAX(element->srcheight,editorpadtemplate->height); + element->srcs++; + pads = g_list_next(pads); + } // add in the needed space element->minheight += MAX((element->sinkheight*element->sinks), (element->srcheight*element->srcs)) + 4.0; element->minwidth = MAX(element->minwidth, - ((element->sinkwidth*element->sinks) + - (element->srcwidth*element->srcs) + 4.0)); + ((element->sinkwidth) + + (element->srcwidth) + 4.0)); // g_print("have %d sinks (%.2fx%.2f) and %d srcs (%.2fx%.2f)\n", // element->sinks,element->sinkwidth,element->sinkheight, // element->srcs,element->srcwidth,element->srcheight); @@ -569,6 +608,8 @@ gst_editor_element_resize (GstEditorElement *element) element->width = MAX(element->width,element->minwidth); element->height = MAX(element->height,element->minheight); // g_print("is now %.2fx%.2f\n",element->width,element->height); + + gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[SIZE_CHANGED], element); } void @@ -576,6 +617,7 @@ gst_editor_element_repack (GstEditorElement *element) { GList *pads; GstEditorPad *editorpad; + GstEditorPadTemplate *editorpadtemplate; gint sinks; gint srcs; gdouble x1,y1,x2,y2; @@ -642,13 +684,25 @@ gst_editor_element_repack (GstEditorElement *element) sinks--; pads = g_list_next(pads); } + pads = element->sinkpadtemps; + while (pads) { + editorpadtemplate = GST_EDITOR_PADTEMPLATE(pads->data); + gtk_object_set(GTK_OBJECT(editorpadtemplate), + "x",x1, + "y",y2 - 2.0 - element->stateheight - + (element->sinkheight * sinks), + NULL); + gst_editor_padtemplate_repack(editorpadtemplate); + sinks--; + pads = g_list_next(pads); + } srcs = element->srcs; pads = element->srcpads; while (pads) { editorpad = GST_EDITOR_PAD(pads->data); gtk_object_set(GTK_OBJECT(editorpad), - "x",x2 - element->srcwidth, + "x",x2 - editorpad->width, "y",y2 - 2.0 - element->stateheight - (element->srcheight * srcs), NULL); @@ -656,14 +710,37 @@ gst_editor_element_repack (GstEditorElement *element) srcs--; pads = g_list_next(pads); } + pads = element->srcpadtemps; + while (pads) { + editorpadtemplate = GST_EDITOR_PADTEMPLATE(pads->data); + gtk_object_set(GTK_OBJECT(editorpadtemplate), + "x",x2 - editorpadtemplate->width, + "y",y2 - 2.0 - element->stateheight - + (element->srcheight * srcs), + NULL); + gst_editor_padtemplate_repack(editorpadtemplate); + srcs--; + pads = g_list_next(pads); + } + gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[SIZE_CHANGED], element); // g_print("done resizing element\n"); } +static void +gst_editor_element_add_pad_wrapper (GstEditorElement *element, + GstPad *pad) +{ + gdk_threads_enter (); + gst_editor_element_add_pad (element, pad); + element->resize = TRUE; + gst_editor_element_repack (element); + gdk_threads_leave (); +} -GstEditorPad* -gst_editor_element_add_pad (GstEditorElement *element, - GstPad *pad) +static void +gst_editor_element_add_pad_func (GstEditorElement *element, + GstPad *pad) { GstEditorPad *editorpad; @@ -681,9 +758,69 @@ gst_editor_element_add_pad (GstEditorElement *element, g_print("HUH?!? Don't know which direction this pad is...\n"); gst_editor_element_repack(element); - return editorpad; } +static void +gst_editor_element_add_pad (GstEditorElement *element, + GstPad *pad) +{ + GstPadTemplate *temp; + + temp = pad->padtemplate; + if (!temp) { + gst_editor_element_add_pad_func (element,pad); + } + else { + // find the template + GList *temppads; + + temppads = element->sinkpadtemps; + while (temppads) { + GstEditorPadTemplate *editorpadtemp = (GstEditorPadTemplate *) temppads->data; + + if (editorpadtemp->padtemplate == temp) { + gst_editor_padtemplate_add_pad (editorpadtemp, pad); + break; + } + temppads = g_list_next (temppads); + } + temppads = element->srcpadtemps; + while (temppads) { + GstEditorPadTemplate *editorpadtemp = (GstEditorPadTemplate *) temppads->data; + + if (editorpadtemp->padtemplate == temp) { + gst_editor_padtemplate_add_pad (editorpadtemp, pad); + break; + } + temppads = g_list_next (temppads); + } + } +} + +GstEditorPadTemplate* +gst_editor_element_add_padtemplate (GstEditorElement *element, + GstPadTemplate *pad) +{ + GstEditorPadTemplate *editorpad; + + g_print ("gsteditorelement: new padtemplate\n"); + + editorpad = gst_editor_padtemplate_new (element, pad, NULL); + + if (pad->direction == GST_PAD_SINK) { + element->sinkpadtemps = g_list_prepend(element->sinkpadtemps,editorpad); + element->sinks++; +// g_print("added 'new' pad to sink list\n"); + } else if (pad->direction == GST_PAD_SRC) { +// g_print("added 'new' pad to src list\n"); + element->srcpadtemps = g_list_prepend(element->srcpadtemps,editorpad); + element->srcs++; + } else + g_print("HUH?!? Don't know which direction this pad is...\n"); + + gst_editor_element_repack(element); + return editorpad; +} static gint gst_editor_element_group_event (GnomeCanvasItem *item, @@ -717,12 +854,8 @@ gst_editor_element_event(GnomeCanvasItem *item, switch(event->type) { case GDK_ENTER_NOTIFY: - gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->border), - "fill_color_rgba", 0xeeeeee80, NULL); return TRUE; case GDK_LEAVE_NOTIFY: - gnome_canvas_item_set(GNOME_CANVAS_ITEM(element->border), - "fill_color", "white", NULL); return TRUE; case GDK_BUTTON_PRESS: { @@ -893,7 +1026,9 @@ gst_editor_element_state_event(GnomeCanvasItem *item, return FALSE; if (id < 4) { + gdk_threads_leave (); gst_editor_element_set_state(element,id,TRUE); + gdk_threads_enter (); } else g_warning("Uh, shouldn't have gotten here, unknown state\n"); //g_print("in element statebox_event, setting inchild"); @@ -919,14 +1054,11 @@ gst_editor_element_set_state(GstEditorElement *element, static void -gst_editor_element_state_change(GstElement *element, - gint state, - GstEditorElement *editorelement) +gst_editor_element_sync_state_wrapper (GstEditorElement *element) { - 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); + gdk_threads_enter (); + gst_editor_element_sync_state (element); + gdk_threads_leave (); } static void @@ -951,35 +1083,21 @@ gst_editor_element_sync_state (GstEditorElement *element) } } +static void +gst_editor_element_position_changed (GstEditorElement *element, + GstEditorElement *parent) +{ + if (element != parent) + gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[POSITION_CHANGED], element); +} + static void gst_editor_element_move(GstEditorElement *element, gdouble dx,gdouble dy) { - GList *pads; - GstEditorPad *pad; - // this is a 'little' trick to keep from repacking the whole thing... element->x += dx;element->y += dy; gnome_canvas_item_move(GNOME_CANVAS_ITEM(element->group),dx,dy); - pads = element->srcpads; - while (pads) { - pad = GST_EDITOR_PAD(pads->data); - if (pad->connection) { -// g_print("updating pad's connection\n"); - pad->connection->resize = TRUE; - gst_editor_connection_resize(pad->connection); - } - pads = g_list_next(pads); - } - pads = element->sinkpads; - while (pads) { - pad = GST_EDITOR_PAD(pads->data); - if (pad->connection) { -// g_print("updating pad's connection\n"); - pad->connection->resize = TRUE; - gst_editor_connection_resize(pad->connection); - } - pads = g_list_next(pads); - } + gtk_signal_emit(GTK_OBJECT(element),gst_editor_element_signals[POSITION_CHANGED], element); } diff --git a/editor/gsteditorpad.c b/editor/gsteditorpad.c index 78bba30bdb..baf9a994bf 100644 --- a/editor/gsteditorpad.c +++ b/editor/gsteditorpad.c @@ -30,6 +30,8 @@ static void gst_editor_pad_set_arg(GtkObject *object,GtkArg *arg,guint id); static void gst_editor_pad_get_arg(GtkObject *object,GtkArg *arg,guint id); static void gst_editor_pad_realize(GstEditorPad *pad); +static void gst_editor_pad_position_changed(GstEditorPad *pad, GstEditorElement *element); + /* class implementation functions */ //static void gst_editor_pad_update(GnomeCanvasItem *item,double *affine, // ArtSVP *clip_path,int flags); @@ -60,7 +62,9 @@ enum { static GtkObjectClass *parent_class; //static guint gst_editor_pad_signals[LAST_SIGNAL] = { 0 }; -GtkType gst_editor_pad_get_type() { +GtkType +gst_editor_pad_get_type (void) +{ static GtkType pad_type = 0; if (!pad_type) { @@ -79,7 +83,9 @@ GtkType gst_editor_pad_get_type() { return pad_type; } -static void gst_editor_pad_class_init(GstEditorPadClass *klass) { +static void +gst_editor_pad_class_init (GstEditorPadClass *klass) +{ GtkObjectClass *object_class; object_class = (GtkObjectClass*)klass; @@ -103,7 +109,9 @@ static void gst_editor_pad_class_init(GstEditorPadClass *klass) { object_class->get_arg = gst_editor_pad_get_arg; } -static void gst_editor_pad_init(GstEditorPad *pad) { +static void +gst_editor_pad_init(GstEditorPad *pad) +{ } GstEditorPad* @@ -142,12 +150,17 @@ gst_editor_pad_new(GstEditorElement *parent,GstPad *pad, } } + gtk_signal_connect_object (GTK_OBJECT (parent), "position_changed", + gst_editor_pad_position_changed, editorpad); + return editorpad; } -void gst_editor_pad_construct(GstEditorPad *pad, - GstEditorElement *parent, - const gchar *first_arg_name,va_list args) { +void +gst_editor_pad_construct(GstEditorPad *pad, + GstEditorElement *parent, + const gchar *first_arg_name,va_list args) +{ GtkObject *obj = GTK_OBJECT(pad); GSList *arg_list = NULL, *info_list = NULL; gchar *error; @@ -175,7 +188,9 @@ void gst_editor_pad_construct(GstEditorPad *pad, (padclass->realize)(pad); } -static void gst_editor_pad_set_arg(GtkObject *object,GtkArg *arg,guint id) { +static void +gst_editor_pad_set_arg (GtkObject *object,GtkArg *arg,guint id) +{ GstEditorPad *pad; /* get the major types of this object */ @@ -206,7 +221,9 @@ static void gst_editor_pad_set_arg(GtkObject *object,GtkArg *arg,guint id) { } } -static void gst_editor_pad_get_arg(GtkObject *object,GtkArg *arg,guint id) { +static void +gst_editor_pad_get_arg (GtkObject *object,GtkArg *arg,guint id) +{ GstEditorPad *pad; /* get the major types of this object */ @@ -231,7 +248,9 @@ static void gst_editor_pad_get_arg(GtkObject *object,GtkArg *arg,guint id) { } } -static void gst_editor_pad_realize(GstEditorPad *pad) { +static void +gst_editor_pad_realize (GstEditorPad *pad) +{ // g_print("realizing editor pad %p\n",pad); /* we must be attached to an element */ @@ -283,7 +302,9 @@ static void gst_editor_pad_realize(GstEditorPad *pad) { } -static void gst_editor_pad_resize(GstEditorPad *pad) { +static void +gst_editor_pad_resize (GstEditorPad *pad) +{ gdouble minwidth,minheight; // g_print("resizing pad\n"); @@ -311,7 +332,9 @@ static void gst_editor_pad_resize(GstEditorPad *pad) { gst_editor_connection_resize(pad->connection); } -void gst_editor_pad_repack(GstEditorPad *pad) { +void +gst_editor_pad_repack (GstEditorPad *pad) +{ gdouble x1,y1,x2,y2; if (!pad->realized) return; @@ -387,9 +410,11 @@ static gint gst_editor_pad_event(GnomeCanvasItem *item,GdkEvent *event) { */ /* FIXME FIXME FIXME */ -static gint gst_editor_pad_padbox_event(GnomeCanvasItem *item, - GdkEvent *event, - GstEditorPad *pad) { +static gint +gst_editor_pad_padbox_event(GnomeCanvasItem *item, + GdkEvent *event, + GstEditorPad *pad) +{ GstEditorElement *element; GstEditorBin *bin; @@ -403,14 +428,10 @@ static gint gst_editor_pad_padbox_event(GnomeCanvasItem *item, 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; case GDK_BUTTON_PRESS: // g_print("have button press in pad '%s'\n", @@ -426,3 +447,16 @@ static gint gst_editor_pad_padbox_event(GnomeCanvasItem *item, } return FALSE; } + +static void +gst_editor_pad_position_changed(GstEditorPad *pad, + GstEditorElement *element) +{ + GList *pads; + + if (pad->connection) { +// g_print("updating pad's connection\n"); + pad->connection->resize = TRUE; + gst_editor_connection_resize(pad->connection); + } +} diff --git a/editor/gsteditorpalette.c b/editor/gsteditorpalette.c index 827e9242cc..6e06b313d1 100644 --- a/editor/gsteditorpalette.c +++ b/editor/gsteditorpalette.c @@ -35,14 +35,15 @@ static void gst_editor_palette_make(GstEditorPalette *palette); struct _palette_entry { gchar *tooltip; GtkType (*type) (void); + gchar *factoryname; }; #define CORE_ELEMENT_SIZE 4 struct _palette_entry _palette_contents_core[CORE_ELEMENT_SIZE] = { - {"Bin", gst_bin_get_type }, - {"Thread", gst_thread_get_type }, - {"Pipeline", gst_pipeline_get_type }, - {"Tee", gst_tee_get_type }, + {"Bin", gst_bin_get_type, "bin" }, + {"Thread", gst_thread_get_type, "thread" }, + {"Pipeline", gst_pipeline_get_type, "pipeline" }, + {"Tee", gst_tee_get_type, "tee" }, }; enum { @@ -58,7 +59,9 @@ enum { static GtkObjectClass *parent_class; static guint gst_editor_palette_signals[LAST_SIGNAL] = { 0 }; -GtkType gst_editor_palette_get_type() { +GtkType +gst_editor_palette_get_type (void) +{ static GtkType palette_type = 0; if (!palette_type) { @@ -77,7 +80,9 @@ GtkType gst_editor_palette_get_type() { return palette_type; } -static void gst_editor_palette_class_init(GstEditorPaletteClass *klass) { +static void +gst_editor_palette_class_init (GstEditorPaletteClass *klass) +{ GtkObjectClass *object_class; object_class = (GtkObjectClass*)klass; @@ -102,7 +107,9 @@ static void gst_editor_palette_class_init(GstEditorPaletteClass *klass) { object_class->get_arg = gst_editor_palette_get_arg; } -static void gst_editor_palette_init(GstEditorPalette *palette) { +static void +gst_editor_palette_init (GstEditorPalette *palette) +{ palette->tooltips = gtk_tooltips_new(); } @@ -112,13 +119,14 @@ typedef struct { } connect_struct; /* we need more control here so... */ -static void gst_editor_palette_connect_func (const gchar *handler_name, - GtkObject *object, - const gchar *signal_name, - const gchar *signal_data, - GtkObject *connect_object, - gboolean after, - gpointer user_data) +static void +gst_editor_palette_connect_func (const gchar *handler_name, + GtkObject *object, + const gchar *signal_name, + const gchar *signal_data, + GtkObject *connect_object, + gboolean after, + gpointer user_data) { GtkSignalFunc func; connect_struct *data = (connect_struct *)user_data; @@ -133,7 +141,9 @@ static void gst_editor_palette_connect_func (const gchar *handler_name, } } -GstEditorPalette *gst_editor_palette_new() { +GstEditorPalette* +gst_editor_palette_new() +{ GstEditorPalette *palette; GtkWidget *palette_window; connect_struct data; @@ -164,11 +174,19 @@ typedef struct { struct _palette_entry *entry; } _signal_data; -static void gst_editor_palette_element_clicked(GtkButton *button, _signal_data *data) { - gtk_signal_emit(GTK_OBJECT(data->palette),gst_editor_palette_signals[SIGNAL_ELEMENT_SELECTED], data->entry->type()); +static void +gst_editor_palette_element_clicked(GtkButton *button, _signal_data *data) +{ + GstElementFactory *factory; + + factory = gst_elementfactory_find (data->entry->factoryname); + + gtk_signal_emit(GTK_OBJECT(data->palette),gst_editor_palette_signals[SIGNAL_ELEMENT_SELECTED], factory); } -static void gst_editor_palette_make(GstEditorPalette *palette) { +static void +gst_editor_palette_make (GstEditorPalette *palette) +{ GtkWidget *button; GstEditorImage *editimage; GtkWidget *image; @@ -212,7 +230,9 @@ static void gst_editor_palette_make(GstEditorPalette *palette) { } } -static void gst_editor_palette_set_arg(GtkObject *object,GtkArg *arg,guint id) { +static void +gst_editor_palette_set_arg (GtkObject *object,GtkArg *arg,guint id) +{ GstEditorPalette *palette; /* get the major types of this object */ @@ -225,7 +245,9 @@ static void gst_editor_palette_set_arg(GtkObject *object,GtkArg *arg,guint id) { } } -static void gst_editor_palette_get_arg(GtkObject *object,GtkArg *arg,guint id) { +static void +gst_editor_palette_get_arg (GtkObject *object,GtkArg *arg,guint id) +{ GstEditorPalette *palette; /* get the major types of this object */ diff --git a/editor/gsteditorpalette.h b/editor/gsteditorpalette.h index 3ae2ad8e07..7e474d6dc6 100644 --- a/editor/gsteditorpalette.h +++ b/editor/gsteditorpalette.h @@ -51,7 +51,7 @@ struct _GstEditorPaletteClass { GtkObjectClass parent_class; void (*element_selected) (GstEditorPalette *palette, - GstEditorElement *element); + GstElementFactory *factory); void (*in_selection_mode) (GstEditorPalette *palette, GstEditorElement *element); }; diff --git a/editor/gsteditorprojectview.c b/editor/gsteditorprojectview.c index 43a0a20e9d..86bd658c31 100644 --- a/editor/gsteditorprojectview.c +++ b/editor/gsteditorprojectview.c @@ -114,11 +114,11 @@ gst_editor_project_connect_func (const gchar *handler_name, static void gst_editor_project_element_selected (GstEditorProjectView *view, - GtkType type, GstEditorPalette *palette) + GstElementFactory *factory, GstEditorPalette *palette) { GstElement *element; - element = gtk_type_new(type); + element = gst_elementfactory_create (factory, "new_element"); g_return_if_fail(element != NULL); g_return_if_fail(GST_IS_ELEMENT(element)); diff --git a/editor/gsteditorproperty.c b/editor/gsteditorproperty.c index 5c08d5e67c..224bdf7fa4 100644 --- a/editor/gsteditorproperty.c +++ b/editor/gsteditorproperty.c @@ -224,10 +224,10 @@ make_readable_name (gchar *name) len = strlen(new); inupper = TRUE; for (i=0; iproperties; + + while (propslist) { + gchar *data[2]; + 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); + } + } + } +} + static GtkWidget* gst_editor_pads_create (GstEditorProperty *property, GstEditorElement *element) { @@ -263,8 +306,6 @@ gst_editor_pads_create (GstEditorProperty *property, GstEditorElement *element) GtkWidget *tree; gchar *columns[2]; - pads = gst_element_get_pad_list(realelement); - columns[0] = "name"; columns[1] = "info"; @@ -272,6 +313,9 @@ gst_editor_pads_create (GstEditorProperty *property, GstEditorElement *element) gtk_clist_set_column_width (GTK_CLIST (tree), 0, 150); gtk_clist_freeze (GTK_CLIST (tree)); + + pads = gst_element_get_pad_list(realelement); + while (pads) { GstPad *pad = (GstPad *)pads->data; GstCaps *caps = gst_pad_get_caps (pad); @@ -292,45 +336,39 @@ gst_editor_pads_create (GstEditorProperty *property, GstEditorElement *element) 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; + gst_editor_add_caps_to_tree (caps, tree, padnode); - 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); } + + pads = gst_element_get_padtemplate_list(realelement); + while (pads) { + GstPadTemplate *templ = (GstPadTemplate *)pads->data; + GstCaps *caps = templ->caps; + 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 (templ->name_template); + data[1] = mime; + padnode = gtk_ctree_insert_node (GTK_CTREE (tree), NULL, NULL, data, 0, + NULL, NULL, NULL, NULL, FALSE, TRUE); + + gst_editor_add_caps_to_tree (caps, tree, padnode); + + pads = g_list_next (pads); + } + gtk_clist_thaw (GTK_CLIST (tree)); gtk_widget_show(tree); @@ -471,9 +509,20 @@ widget_bool_toggled (GtkToggleButton *button, arg_data *arg) toggled = gtk_toggle_button_get_active(button); gtk_object_set (GTK_OBJECT (button), "label", (toggled? _("Yes"):_("No")), NULL); + gdk_threads_leave (); gtk_object_set (GTK_OBJECT (arg->element), arg->arg->name, toggled, NULL); + gdk_threads_enter (); } +static void +widget_adjustment_value_changed (GtkAdjustment *adjustment, + arg_data *arg) +{ + gdk_threads_leave (); + gtk_object_set (GTK_OBJECT (arg->element), arg->arg->name, (gint) adjustment->value, NULL); + gdk_threads_enter (); +} + static void on_file_selected (GtkEditable *entry, arg_data *fs) { @@ -518,11 +567,16 @@ create_property_entry (GtkArg *arg, GstElement *element) { gint value; GtkAdjustment *spinner_adj; + arg_data *data = g_new0(arg_data, 1); + + data->element = element; + data->arg = arg; value = GTK_VALUE_INT(*arg); spinner_adj = (GtkAdjustment *) gtk_adjustment_new(50.0, 0.0, 10000000.0, 1.0, 5.0, 5.0); entry = gtk_spin_button_new(spinner_adj, 1.0, 0); gtk_spin_button_set_value(GTK_SPIN_BUTTON(entry), (gfloat) value); + gtk_signal_connect(GTK_OBJECT(spinner_adj), "value_changed", widget_adjustment_value_changed, data); break; } case GTK_TYPE_FLOAT: diff --git a/gst/elements/gstqueue.c b/gst/elements/gstqueue.c index 7a86bea0a1..eaf637d3c7 100644 --- a/gst/elements/gstqueue.c +++ b/gst/elements/gstqueue.c @@ -206,7 +206,7 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) /* put the buffer on the tail of the list */ queue->queue = g_slist_append (queue->queue, buf); // STATUS("%s: +\n"); - g_print("(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad)); + DEBUG("(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad)); /* if we were empty, but aren't any more, signal a condition */ tosignal = (queue->level_buffers >= 0); @@ -266,7 +266,7 @@ gst_queue_get (GstPad *pad) queue->level_buffers--; // STATUS("%s: -\n"); - g_print("(%s:%s)- ",GST_DEBUG_PAD_NAME(pad)); + DEBUG("(%s:%s)- ",GST_DEBUG_PAD_NAME(pad)); tosignal = queue->level_buffers < queue->max_buffers; GST_UNLOCK(queue); diff --git a/gst/gstbin.c b/gst/gstbin.c index 984ec53991..8b05aa559b 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -17,7 +17,7 @@ * Boston, MA 02111-1307, USA. */ -//#define GST_DEBUG_ENABLED +#define GST_DEBUG_ENABLED #include "gstbin.h" #include "gstdebug.h" diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index d28a821b36..9d55996ec6 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -368,7 +368,7 @@ gst_pipeline_autoplug (GstPipeline *pipeline) // check to other paths for mathing elements (factories) for (i=1; idata)) { + if (!factories[i] || (factory != (GstElementFactory *)(factories[i]->data))) { goto differ; } factories[i] = g_list_next(factories[i]); diff --git a/gst/gstscheduler.c b/gst/gstscheduler.c index 1200921a92..70ed58c483 100644 --- a/gst/gstscheduler.c +++ b/gst/gstscheduler.c @@ -17,7 +17,7 @@ * Boston, MA 02111-1307, USA. */ -//#define GST_DEBUG_ENABLED +#define GST_DEBUG_ENABLED #include "gstscheduler.h" #include "gstdebug.h" @@ -393,6 +393,7 @@ void gst_bin_schedule_func(GstBin *bin) { pads = g_list_next (pads); DEBUG("have pad %s:%s\n",GST_DEBUG_PAD_NAME(pad)); + DEBUG("peer pad %p\n", pad->peer); // only bother with if the pad's peer's parent is this bin or it's DECOUPLED // only add it if it's in the list of un-visited elements still if ((g_list_find (elements, pad->peer->parent) != NULL) || diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index 7a86bea0a1..eaf637d3c7 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -206,7 +206,7 @@ gst_queue_chain (GstPad *pad, GstBuffer *buf) /* put the buffer on the tail of the list */ queue->queue = g_slist_append (queue->queue, buf); // STATUS("%s: +\n"); - g_print("(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad)); + DEBUG("(%s:%s)+ ",GST_DEBUG_PAD_NAME(pad)); /* if we were empty, but aren't any more, signal a condition */ tosignal = (queue->level_buffers >= 0); @@ -266,7 +266,7 @@ gst_queue_get (GstPad *pad) queue->level_buffers--; // STATUS("%s: -\n"); - g_print("(%s:%s)- ",GST_DEBUG_PAD_NAME(pad)); + DEBUG("(%s:%s)- ",GST_DEBUG_PAD_NAME(pad)); tosignal = queue->level_buffers < queue->max_buffers; GST_UNLOCK(queue); diff --git a/test/mp3tovorbis.c b/test/mp3tovorbis.c index 2587745998..a87692f18d 100644 --- a/test/mp3tovorbis.c +++ b/test/mp3tovorbis.c @@ -32,6 +32,7 @@ int main(int argc,char *argv[]) { g_return_val_if_fail(encodefactory != NULL, -1); sinkfactory = gst_elementfactory_find("fdsink"); g_return_val_if_fail(sinkfactory != NULL, -1); + sink = gst_elementfactory_create(sinkfactory,"sink"); src = gst_elementfactory_create(srcfactory,"src"); g_return_val_if_fail(src != NULL, -1); diff --git a/tests/registry.c b/tests/registry.c index 828db6851b..81de368cdc 100644 --- a/tests/registry.c +++ b/tests/registry.c @@ -24,7 +24,7 @@ dump_factories (void) while (factories) { GstElementFactory *factory = (GstElementFactory *)factories->data; - g_print ("factory: %s\n", factory->name); + g_print ("factory: %s %d\n", factory->name, factory->type); factories = g_list_next (factories); } @@ -80,8 +80,8 @@ load_something (gchar *name) GstElementFactory *factory; GstElement *element; - factory = gst_elementfactory_find ("foo"); - g_print ("factory \"foo\" %s\n", (factory?"found":"not found")); + //factory = gst_elementfactory_find ("foo"); + //g_print ("factory \"foo\" %s\n", (factory?"found":"not found")); factory = gst_elementfactory_find (name); g_print ("factory \"%s\" %s\n", name, (factory?"found":"not found")); @@ -129,13 +129,13 @@ int main(int argc,char *argv[]) gst_init(&argc,&argv); - dump_plugins (); - dump_factories (); - dump_types (); + //dump_plugins (); + //dump_factories (); + //dump_types (); - print_some_providers ("audio/mp3"); + //print_some_providers ("audio/mp3"); - load_something ("mpg123"); + load_something ("fdsink"); print_some_providers ("audio/mp3");