Added extra Gtk types for better editor properties (FILENAME, enums)

Original commit message from CVS:
Added extra Gtk types for better editor properties (FILENAME, enums)
The disksrcs location property can now be set in the editor: we can
now make our first working mp3 player with gsteditor!!
This commit is contained in:
Wim Taymans 2000-10-11 19:30:07 +00:00
parent 870c6045b2
commit 04bb8b0142
13 changed files with 219 additions and 26 deletions

View file

@ -31,7 +31,7 @@ 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);
static GtkWidget *create_property_entry(GtkArg *arg, GstElement *element);
enum {
ARG_0,
@ -235,12 +235,13 @@ void gst_editor_property_show(GstEditorProperty *property, GstEditorElement *ele
guint32 *flags;
guint num_args, i, count;
table = gtk_table_new(1, 2, TRUE);
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);
@ -256,11 +257,12 @@ void gst_editor_property_show(GstEditorProperty *property, GstEditorElement *ele
if (flags[i] & GTK_ARG_READABLE) {
gtk_object_getv(GTK_OBJECT(element->element), 1, &args[i]);
entry = create_property_entry(&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);
@ -270,7 +272,7 @@ void gst_editor_property_show(GstEditorProperty *property, GstEditorElement *ele
}
}
}
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 0);
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;
@ -288,9 +290,21 @@ static void widget_show_toggled(GtkToggleButton *button, GtkArg *arg) {
gtk_widget_show(window);
}
static GtkWidget *create_property_entry(GtkArg *arg) {
typedef struct {
GtkArg *arg;
GstElement *element;
} file_select;
static void on_file_selected(GtkEditable *entry, file_select *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) {
GtkWidget *entry = NULL;
// basic types
switch (arg->type) {
case GTK_TYPE_STRING:
{
@ -318,7 +332,7 @@ static GtkWidget *create_property_entry(GtkArg *arg) {
GtkAdjustment *spinner_adj;
value = GTK_VALUE_INT(*arg);
spinner_adj = (GtkAdjustment *) gtk_adjustment_new(50.0, 0.0, 100.0, 1.0, 5.0, 5.0);
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);
break;
@ -330,15 +344,15 @@ static GtkWidget *create_property_entry(GtkArg *arg) {
GtkAdjustment *spinner_adj;
value = GTK_VALUE_DOUBLE(*arg);
spinner_adj = (GtkAdjustment *) gtk_adjustment_new(50.0, 0.0, 100.0, 0.1, 5.0, 5.0);
spinner_adj = (GtkAdjustment *) gtk_adjustment_new(50.0, 0.0, 10000000.0, 0.1, 5.0, 5.0);
entry = gtk_spin_button_new(spinner_adj, 1.0, 3);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(entry), (gfloat) value);
break;
}
default:
g_print("unknown type: %d\n", arg->type);
break;
}
// more extensive testing here
if (!entry) {
if (arg->type == GTK_TYPE_WIDGET)
{
@ -346,6 +360,40 @@ static GtkWidget *create_property_entry(GtkArg *arg) {
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(entry), FALSE);
gtk_signal_connect(GTK_OBJECT(entry), "toggled", widget_show_toggled, arg);
}
else if (GTK_FUNDAMENTAL_TYPE(arg->type) == GTK_TYPE_ENUM) {
GtkEnumValue *values;
gint i=0;
GtkWidget *menu;
entry = gtk_option_menu_new();
menu = gtk_menu_new();
values = gtk_type_enum_get_values(arg->type);
while (values[i].value_name) {
GtkWidget *menuitem = gtk_menu_item_new_with_label(values[i].value_nick);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
i++;
}
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);
entry = gnome_file_entry_new(NULL, NULL);
fs->element = element;
fs->arg = arg;
gtk_signal_connect(GTK_OBJECT(gnome_file_entry_gtk_entry(GNOME_FILE_ENTRY(entry))),
"changed",
GTK_SIGNAL_FUNC(on_file_selected),
fs);
}
else {
g_print("unknown type: %d\n", arg->type);
}
}
gtk_widget_show(entry);

View file

@ -28,6 +28,7 @@ libgst_la_SOURCES = \
$(GSTARCH_SRCS) \
gstelement.c \
gstelementfactory.c \
gstextratypes.c \
gstbin.c \
gstpipeline.c \
gstthread.c \
@ -55,6 +56,7 @@ libgstinclude_HEADERS = \
gstclock.h \
gstcpu.h \
gstelement.h \
gstextratypes.h \
gstbin.h \
gstpipeline.h \
gstthread.h \

View file

@ -97,7 +97,7 @@ gst_asyncdisksrc_class_init(GstAsyncDiskSrcClass *klass) {
parent_class = gtk_type_class(GST_TYPE_SRC);
gtk_object_add_arg_type("GstAsyncDiskSrc::location", GTK_TYPE_STRING,
gtk_object_add_arg_type("GstAsyncDiskSrc::location", GST_TYPE_FILENAME,
GTK_ARG_READWRITE, ARG_LOCATION);
gtk_object_add_arg_type("GstAsyncDiskSrc::bytesperread", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_BYTESPERREAD);

View file

@ -65,6 +65,37 @@ enum {
/* FILL ME */
};
#define GST_TYPE_AUDIOSINK_FORMATS (gst_audiosink_formats_get_type())
GtkType
gst_audiosink_formats_get_type(void) {
static GtkType audiosink_formats_type = 0;
static GtkEnumValue audiosink_formats[] = {
{8, "8", "8 Bits"},
{16, "16", "16 Bits"},
{0, NULL, NULL},
};
if (!audiosink_formats_type) {
audiosink_formats_type = gtk_type_register_enum("GstAudiosinkFormats", audiosink_formats);
}
return audiosink_formats_type;
}
#define GST_TYPE_AUDIOSINK_CHANNELS (gst_audiosink_channels_get_type())
GtkType
gst_audiosink_channels_get_type(void) {
static GtkType audiosink_channels_type = 0;
static GtkEnumValue audiosink_channels[] = {
{1, "1", "Mono"},
{2, "2", "Stereo"},
{0, NULL, NULL},
};
if (!audiosink_channels_type) {
audiosink_channels_type = gtk_type_register_enum("GstAudiosinkChannels", audiosink_channels);
}
return audiosink_channels_type;
}
static void gst_audiosink_class_init(GstAudioSinkClass *klass);
static void gst_audiosink_init(GstAudioSink *audiosink);
@ -111,9 +142,9 @@ gst_audiosink_class_init(GstAudioSinkClass *klass) {
gtk_object_add_arg_type("GstAudioSink::mute", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_MUTE);
gtk_object_add_arg_type("GstAudioSink::format", GTK_TYPE_INT,
gtk_object_add_arg_type("GstAudioSink::format", GST_TYPE_AUDIOSINK_FORMATS,
GTK_ARG_READWRITE, ARG_FORMAT);
gtk_object_add_arg_type("GstAudioSink::channels", GTK_TYPE_INT,
gtk_object_add_arg_type("GstAudioSink::channels", GST_TYPE_AUDIOSINK_CHANNELS,
GTK_ARG_READWRITE, ARG_CHANNELS);
gtk_object_add_arg_type("GstAudioSink::frequency", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_FREQUENCY);
@ -246,11 +277,11 @@ static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
audiosink->mute = GTK_VALUE_BOOL(*arg);
break;
case ARG_FORMAT:
audiosink->format = GTK_VALUE_INT(*arg);
audiosink->format = GTK_VALUE_ENUM(*arg);
gst_audiosink_sync_parms(audiosink);
break;
case ARG_CHANNELS:
audiosink->channels = GTK_VALUE_INT(*arg);
audiosink->channels = GTK_VALUE_ENUM(*arg);
gst_audiosink_sync_parms(audiosink);
break;
case ARG_FREQUENCY:
@ -274,10 +305,10 @@ static void gst_audiosink_get_arg(GtkObject *object,GtkArg *arg,guint id) {
GTK_VALUE_BOOL(*arg) = audiosink->mute;
break;
case ARG_FORMAT:
GTK_VALUE_INT(*arg) = audiosink->format;
GTK_VALUE_ENUM(*arg) = audiosink->format;
break;
case ARG_CHANNELS:
GTK_VALUE_INT(*arg) = audiosink->channels;
GTK_VALUE_ENUM(*arg) = audiosink->channels;
break;
case ARG_FREQUENCY:
GTK_VALUE_INT(*arg) = audiosink->frequency;

View file

@ -97,7 +97,7 @@ gst_disksrc_class_init(GstDiskSrcClass *klass) {
parent_class = gtk_type_class(GST_TYPE_SRC);
gtk_object_add_arg_type("GstDiskSrc::location", GTK_TYPE_STRING,
gtk_object_add_arg_type("GstDiskSrc::location", GST_TYPE_FILENAME,
GTK_ARG_READWRITE, ARG_LOCATION);
gtk_object_add_arg_type("GstDiskSrc::bytesperread", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_BYTESPERREAD);

View file

@ -93,7 +93,7 @@ gst_fdsrc_class_init(GstFdSrcClass *klass) {
parent_class = gtk_type_class(GST_TYPE_SRC);
gtk_object_add_arg_type("GstFdSrc::location", GTK_TYPE_STRING,
gtk_object_add_arg_type("GstFdSrc::location", GST_TYPE_FILENAME,
GTK_ARG_WRITABLE, ARG_LOCATION);
gtk_object_add_arg_type("GstFdSrc::bytesperread", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_BYTESPERREAD);

View file

@ -32,6 +32,7 @@
#include <gst/gstbuffer.h>
#include <gst/gstcpu.h>
#include <gst/gstelement.h>
#include <gst/gstextratypes.h>
#include <gst/gstbin.h>
#include <gst/gstpipeline.h>
#include <gst/gstthread.h>

41
gst/gstextratypes.c Normal file
View file

@ -0,0 +1,41 @@
/* 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 <gst/gstextratypes.h>
GtkType gst_extra_get_filename_type(void) {
static GtkType filename_type = 0;
if (!filename_type) {
static const GtkTypeInfo filename_info = {
"GstFilename",
0, //sizeof(GstElement),
0, //sizeof(GstElementClass),
(GtkClassInitFunc)NULL,
(GtkObjectInitFunc)NULL,
(GtkArgSetFunc)NULL,
(GtkArgGetFunc)NULL,
(GtkClassInitFunc)NULL,
};
filename_type = gtk_type_unique(GTK_TYPE_STRING,&filename_info);
}
return filename_type;
}

39
gst/gstextratypes.h Normal file
View file

@ -0,0 +1,39 @@
/* 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.
*/
#ifndef __GST_EXTRA_TYPES_H__
#define __GST_EXTRA_TYPES_H__
#include <gst/gst.h>
#include <gnome-xml/parser.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GST_TYPE_FILENAME (gst_extra_get_filename_type())
GtkType gst_extra_get_filename_type(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GST_EXTRA_TYPES_H__ */

View file

@ -97,7 +97,7 @@ gst_asyncdisksrc_class_init(GstAsyncDiskSrcClass *klass) {
parent_class = gtk_type_class(GST_TYPE_SRC);
gtk_object_add_arg_type("GstAsyncDiskSrc::location", GTK_TYPE_STRING,
gtk_object_add_arg_type("GstAsyncDiskSrc::location", GST_TYPE_FILENAME,
GTK_ARG_READWRITE, ARG_LOCATION);
gtk_object_add_arg_type("GstAsyncDiskSrc::bytesperread", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_BYTESPERREAD);

View file

@ -65,6 +65,37 @@ enum {
/* FILL ME */
};
#define GST_TYPE_AUDIOSINK_FORMATS (gst_audiosink_formats_get_type())
GtkType
gst_audiosink_formats_get_type(void) {
static GtkType audiosink_formats_type = 0;
static GtkEnumValue audiosink_formats[] = {
{8, "8", "8 Bits"},
{16, "16", "16 Bits"},
{0, NULL, NULL},
};
if (!audiosink_formats_type) {
audiosink_formats_type = gtk_type_register_enum("GstAudiosinkFormats", audiosink_formats);
}
return audiosink_formats_type;
}
#define GST_TYPE_AUDIOSINK_CHANNELS (gst_audiosink_channels_get_type())
GtkType
gst_audiosink_channels_get_type(void) {
static GtkType audiosink_channels_type = 0;
static GtkEnumValue audiosink_channels[] = {
{1, "1", "Mono"},
{2, "2", "Stereo"},
{0, NULL, NULL},
};
if (!audiosink_channels_type) {
audiosink_channels_type = gtk_type_register_enum("GstAudiosinkChannels", audiosink_channels);
}
return audiosink_channels_type;
}
static void gst_audiosink_class_init(GstAudioSinkClass *klass);
static void gst_audiosink_init(GstAudioSink *audiosink);
@ -111,9 +142,9 @@ gst_audiosink_class_init(GstAudioSinkClass *klass) {
gtk_object_add_arg_type("GstAudioSink::mute", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_MUTE);
gtk_object_add_arg_type("GstAudioSink::format", GTK_TYPE_INT,
gtk_object_add_arg_type("GstAudioSink::format", GST_TYPE_AUDIOSINK_FORMATS,
GTK_ARG_READWRITE, ARG_FORMAT);
gtk_object_add_arg_type("GstAudioSink::channels", GTK_TYPE_INT,
gtk_object_add_arg_type("GstAudioSink::channels", GST_TYPE_AUDIOSINK_CHANNELS,
GTK_ARG_READWRITE, ARG_CHANNELS);
gtk_object_add_arg_type("GstAudioSink::frequency", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_FREQUENCY);
@ -246,11 +277,11 @@ static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
audiosink->mute = GTK_VALUE_BOOL(*arg);
break;
case ARG_FORMAT:
audiosink->format = GTK_VALUE_INT(*arg);
audiosink->format = GTK_VALUE_ENUM(*arg);
gst_audiosink_sync_parms(audiosink);
break;
case ARG_CHANNELS:
audiosink->channels = GTK_VALUE_INT(*arg);
audiosink->channels = GTK_VALUE_ENUM(*arg);
gst_audiosink_sync_parms(audiosink);
break;
case ARG_FREQUENCY:
@ -274,10 +305,10 @@ static void gst_audiosink_get_arg(GtkObject *object,GtkArg *arg,guint id) {
GTK_VALUE_BOOL(*arg) = audiosink->mute;
break;
case ARG_FORMAT:
GTK_VALUE_INT(*arg) = audiosink->format;
GTK_VALUE_ENUM(*arg) = audiosink->format;
break;
case ARG_CHANNELS:
GTK_VALUE_INT(*arg) = audiosink->channels;
GTK_VALUE_ENUM(*arg) = audiosink->channels;
break;
case ARG_FREQUENCY:
GTK_VALUE_INT(*arg) = audiosink->frequency;

View file

@ -97,7 +97,7 @@ gst_disksrc_class_init(GstDiskSrcClass *klass) {
parent_class = gtk_type_class(GST_TYPE_SRC);
gtk_object_add_arg_type("GstDiskSrc::location", GTK_TYPE_STRING,
gtk_object_add_arg_type("GstDiskSrc::location", GST_TYPE_FILENAME,
GTK_ARG_READWRITE, ARG_LOCATION);
gtk_object_add_arg_type("GstDiskSrc::bytesperread", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_BYTESPERREAD);

View file

@ -93,7 +93,7 @@ gst_fdsrc_class_init(GstFdSrcClass *klass) {
parent_class = gtk_type_class(GST_TYPE_SRC);
gtk_object_add_arg_type("GstFdSrc::location", GTK_TYPE_STRING,
gtk_object_add_arg_type("GstFdSrc::location", GST_TYPE_FILENAME,
GTK_ARG_WRITABLE, ARG_LOCATION);
gtk_object_add_arg_type("GstFdSrc::bytesperread", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_BYTESPERREAD);