2000-10-01 21:46:33 +00:00
|
|
|
/* Gnome-Streamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <gnome.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2001-01-02 01:44:53 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2000-10-01 21:46:33 +00:00
|
|
|
#include <glade/glade.h>
|
|
|
|
#include "gsteditorproject.h"
|
|
|
|
#include "gsteditorpalette.h"
|
|
|
|
#include "gsteditorproperty.h"
|
|
|
|
#include "gsteditorimage.h"
|
|
|
|
|
|
|
|
/* class functions */
|
2000-12-16 17:12:28 +00:00
|
|
|
static void gst_editor_project_view_class_init (GstEditorProjectViewClass *klass);
|
|
|
|
static void gst_editor_project_view_init (GstEditorProjectView *project_view);
|
|
|
|
|
|
|
|
static void gst_editor_project_view_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
|
|
|
static void gst_editor_project_view_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
2000-10-01 21:46:33 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static GtkObjectClass *parent_class;
|
|
|
|
//static guint gst_editor_project_view_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
GtkType
|
|
|
|
gst_editor_project_view_get_type(void)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
static GtkType project_view_type = 0;
|
|
|
|
|
|
|
|
if (!project_view_type) {
|
|
|
|
static const GtkTypeInfo project_view_info = {
|
|
|
|
"GstEditorProjectView",
|
|
|
|
sizeof(GstEditorProjectView),
|
|
|
|
sizeof(GstEditorProjectViewClass),
|
|
|
|
(GtkClassInitFunc)gst_editor_project_view_class_init,
|
|
|
|
(GtkObjectInitFunc)gst_editor_project_view_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GtkClassInitFunc)NULL,
|
|
|
|
};
|
|
|
|
project_view_type = gtk_type_unique(gtk_object_get_type(),&project_view_info);
|
|
|
|
}
|
|
|
|
return project_view_type;
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
static void
|
|
|
|
gst_editor_project_view_class_init (GstEditorProjectViewClass *klass)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
GtkObjectClass *object_class;
|
|
|
|
|
|
|
|
object_class = (GtkObjectClass*)klass;
|
|
|
|
|
|
|
|
parent_class = gtk_type_class(gtk_object_get_type());
|
|
|
|
|
|
|
|
object_class->set_arg = gst_editor_project_view_set_arg;
|
|
|
|
object_class->get_arg = gst_editor_project_view_get_arg;
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
static void
|
|
|
|
gst_editor_project_view_init (GstEditorProjectView *project)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
2000-12-16 17:12:28 +00:00
|
|
|
GstEditorProjectView *view;
|
2000-10-01 21:46:33 +00:00
|
|
|
GModule *symbols;
|
|
|
|
} connect_struct;
|
|
|
|
|
|
|
|
/* we need more control here so... */
|
2000-12-16 17:12:28 +00:00
|
|
|
static void
|
|
|
|
gst_editor_project_connect_func (const gchar *handler_name,
|
2000-10-01 21:46:33 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
if (!g_module_symbol(data->symbols, handler_name, (gpointer *)&func))
|
|
|
|
g_warning("GstEditorProject: could not find signal handler '%s'.", handler_name);
|
|
|
|
else {
|
|
|
|
if (after)
|
2000-12-16 17:12:28 +00:00
|
|
|
gtk_signal_connect_after(object, signal_name, func, (gpointer) data->view);
|
2000-10-01 21:46:33 +00:00
|
|
|
else
|
2000-12-16 17:12:28 +00:00
|
|
|
gtk_signal_connect(object, signal_name, func, (gpointer) data->view);
|
2000-10-01 21:46:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
static void
|
|
|
|
gst_editor_project_element_selected (GstEditorProjectView *view,
|
2000-12-28 02:51:07 +00:00
|
|
|
GstElementFactory *factory, GstEditorPalette *palette)
|
2000-12-16 17:12:28 +00:00
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
GstElement *element;
|
|
|
|
|
2000-12-28 02:51:07 +00:00
|
|
|
element = gst_elementfactory_create (factory, "new_element");
|
2000-10-01 21:46:33 +00:00
|
|
|
|
|
|
|
g_return_if_fail(element != NULL);
|
|
|
|
g_return_if_fail(GST_IS_ELEMENT(element));
|
|
|
|
|
|
|
|
gst_editor_project_add_toplevel_element(view->project, element);
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
static void
|
|
|
|
on_name_change (GstEditorProjectView *view,
|
|
|
|
GstEditorElement *element, GstEditor *editor)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
gint row;
|
|
|
|
gchar *text;
|
|
|
|
guint8 spacing;
|
|
|
|
GdkPixmap *pixmap;
|
|
|
|
GdkBitmap *mask;
|
|
|
|
|
|
|
|
row = gtk_clist_find_row_from_data(GTK_CLIST(view->list), editor);
|
|
|
|
|
|
|
|
gtk_clist_get_pixtext(GTK_CLIST(view->list), row, 0, &text, &spacing, &pixmap, &mask);
|
|
|
|
gtk_clist_set_pixtext(GTK_CLIST(view->list), row, 0, gst_editor_get_name(editor),
|
|
|
|
spacing, pixmap, mask);
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
static void
|
|
|
|
view_on_element_added (GstEditorProjectView *view, GstElement *element)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
gchar *name;
|
|
|
|
gint row;
|
|
|
|
GstEditorImage *image;
|
|
|
|
GstEditor *editor;
|
|
|
|
|
|
|
|
image = gst_editor_image_get_for_type(GTK_OBJECT_TYPE(element));
|
2000-12-25 01:33:06 +00:00
|
|
|
name = (gchar *)gst_element_get_name(element);
|
2000-10-01 21:46:33 +00:00
|
|
|
row = gtk_clist_append(GTK_CLIST(view->list), &name);
|
|
|
|
editor = gst_editor_new(element);
|
|
|
|
|
|
|
|
gtk_signal_connect_object(GTK_OBJECT(editor), "name_changed", on_name_change, GTK_OBJECT(view));
|
|
|
|
gtk_clist_set_row_data(GTK_CLIST(view->list), row, editor);
|
|
|
|
gtk_clist_set_pixtext(GTK_CLIST(view->list), row, 0, name, 3, image->pixmap, image->bitmap);
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
typedef struct {
|
|
|
|
GtkWidget *selection;
|
|
|
|
GstEditorProjectView *view;
|
|
|
|
} file_select;
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_save_as_file_selected (GtkWidget *button,
|
|
|
|
file_select *data)
|
|
|
|
{
|
|
|
|
GtkWidget *selector = data->selection;
|
|
|
|
GstEditorProjectView *view = data->view;
|
|
|
|
|
|
|
|
gchar *file_name = gtk_file_selection_get_filename (GTK_FILE_SELECTION(selector));
|
|
|
|
gst_editor_project_save_as (view->project, file_name);
|
|
|
|
|
|
|
|
g_free (data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
on_save_as1_activate (GtkWidget *widget,
|
|
|
|
GstEditorProjectView *view)
|
|
|
|
{
|
|
|
|
GtkWidget *file_selector;
|
|
|
|
file_select *file_data = g_new0 (file_select, 1);
|
|
|
|
|
|
|
|
file_selector = gtk_file_selection_new("Please select a file for saving.");
|
|
|
|
|
|
|
|
file_data->selection = file_selector;
|
|
|
|
file_data->view = view;
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
|
|
|
|
"clicked", GTK_SIGNAL_FUNC (on_save_as_file_selected),
|
|
|
|
file_data);
|
|
|
|
|
|
|
|
/* Ensure that the dialog box is destroyed when the user clicks a button. */
|
|
|
|
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
|
|
|
|
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
|
|
|
(gpointer) file_selector);
|
|
|
|
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->cancel_button),
|
|
|
|
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
|
|
|
(gpointer) file_selector);
|
|
|
|
|
|
|
|
/* Display that dialog */
|
|
|
|
gtk_widget_show (file_selector);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_load_file_selected (GtkWidget *button,
|
|
|
|
file_select *data)
|
|
|
|
{
|
|
|
|
GtkWidget *selector = data->selection;
|
|
|
|
GstEditorProjectView *view = data->view;
|
|
|
|
|
|
|
|
gchar *file_name = gtk_file_selection_get_filename (GTK_FILE_SELECTION(selector));
|
2000-12-25 01:33:06 +00:00
|
|
|
gst_editor_project_load (view->project, file_name);
|
2000-12-16 17:12:28 +00:00
|
|
|
|
|
|
|
g_free (data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
on_open1_activate (GtkWidget *widget,
|
|
|
|
GstEditorProjectView *view)
|
|
|
|
{
|
|
|
|
GtkWidget *file_selector;
|
|
|
|
file_select *file_data = g_new0 (file_select, 1);
|
|
|
|
|
|
|
|
file_selector = gtk_file_selection_new("Please select a file to load.");
|
|
|
|
|
|
|
|
file_data->selection = file_selector;
|
|
|
|
file_data->view = view;
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
|
|
|
|
"clicked", GTK_SIGNAL_FUNC (on_load_file_selected),
|
|
|
|
file_data);
|
|
|
|
|
|
|
|
/* Ensure that the dialog box is destroyed when the user clicks a button. */
|
|
|
|
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button),
|
|
|
|
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
|
|
|
(gpointer) file_selector);
|
|
|
|
gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->cancel_button),
|
|
|
|
"clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
|
|
|
(gpointer) file_selector);
|
|
|
|
|
|
|
|
/* Display that dialog */
|
|
|
|
gtk_widget_show (file_selector);
|
|
|
|
}
|
|
|
|
|
|
|
|
GstEditorProjectView*
|
|
|
|
gst_editor_project_view_new (GstEditorProject *project)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
GstEditorProjectView *view;
|
|
|
|
GtkWidget *main_window;
|
|
|
|
connect_struct data;
|
|
|
|
GModule *symbols;
|
|
|
|
GstEditorPalette *palette;
|
2000-12-16 17:12:28 +00:00
|
|
|
GList *elements;
|
2001-01-02 01:44:53 +00:00
|
|
|
struct stat statbuf;
|
2000-10-01 21:46:33 +00:00
|
|
|
|
|
|
|
view = GST_EDITOR_PROJECT_VIEW(gtk_type_new(GST_TYPE_EDITOR_PROJECT_VIEW));
|
|
|
|
|
|
|
|
view->project = project;
|
|
|
|
|
|
|
|
symbols = g_module_open(NULL, 0);
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
data.view = view;
|
2000-10-01 21:46:33 +00:00
|
|
|
data.symbols = symbols;
|
|
|
|
|
2001-01-02 01:44:53 +00:00
|
|
|
|
|
|
|
if (stat(DATADIR"editor.glade", &statbuf) == 0) {
|
|
|
|
g_print ("loading from %s\n", DATADIR"editor.glade");
|
|
|
|
view->xml = glade_xml_new(DATADIR"editor.glade", "main_project_window");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_print ("loading from %s\n", "editor.glade");
|
|
|
|
view->xml = glade_xml_new ("editor.glade", "main_project_window");
|
|
|
|
}
|
|
|
|
g_assert (view->xml != NULL);
|
|
|
|
|
2000-10-01 21:46:33 +00:00
|
|
|
glade_xml_signal_autoconnect_full (view->xml, gst_editor_project_connect_func, &data);
|
|
|
|
|
|
|
|
main_window = glade_xml_get_widget(view->xml, "main_project_window");
|
|
|
|
gtk_widget_show(main_window);
|
|
|
|
|
|
|
|
palette = gst_editor_palette_new();
|
|
|
|
gtk_signal_connect_object(GTK_OBJECT(palette), "element_selected", gst_editor_project_element_selected, GTK_OBJECT(view));
|
|
|
|
|
|
|
|
view->list = glade_xml_get_widget(view->xml, "clist1");
|
|
|
|
gtk_clist_set_row_height(GTK_CLIST(view->list), 21);
|
|
|
|
|
|
|
|
gst_editor_property_get();
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
elements = project->toplevelelements;
|
|
|
|
|
|
|
|
while (elements) {
|
|
|
|
GstElement *element = (GstElement *)elements->data;
|
|
|
|
|
|
|
|
view_on_element_added (view, element);
|
|
|
|
|
|
|
|
elements = g_list_next (elements);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_signal_connect_object(GTK_OBJECT(project), "element_added", view_on_element_added, GTK_OBJECT(view));
|
|
|
|
|
2000-10-01 21:46:33 +00:00
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
static void
|
|
|
|
gst_editor_project_view_set_arg (GtkObject *object,GtkArg *arg,guint id)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
GstEditorProjectView *project_view;
|
|
|
|
|
|
|
|
/* get the major types of this object */
|
|
|
|
project_view = GST_EDITOR_PROJECT_VIEW(object);
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
default:
|
|
|
|
g_warning("gsteditorproject_view: unknown arg!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
static void
|
|
|
|
gst_editor_project_view_get_arg (GtkObject *object,GtkArg *arg,guint id)
|
|
|
|
{
|
2000-10-01 21:46:33 +00:00
|
|
|
GstEditorProjectView *project_view;
|
|
|
|
|
|
|
|
/* get the major types of this object */
|
|
|
|
project_view = GST_EDITOR_PROJECT_VIEW(object);
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
default:
|
|
|
|
arg->type = GTK_TYPE_INVALID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|