more work on the controller page, made integer controller properties
2004-06-25 Michael Natterer <mitch@gimp.org> * app/gui/preferences-dialog.c: more work on the controller page, made integer controller properties editable. * modules/controller_midi.c: allow to specify the MIDI channel to generate events from. Default to -1 (all channels).
This commit is contained in:

committed by
Michael Natterer

parent
5fe683a51e
commit
6d864c4346
@ -1,3 +1,11 @@
|
||||
2004-06-25 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gui/preferences-dialog.c: more work on the controller page,
|
||||
made integer controller properties editable.
|
||||
|
||||
* modules/controller_midi.c: allow to specify the MIDI channel to
|
||||
generate events from. Default to -1 (all channels).
|
||||
|
||||
2004-06-24 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
|
||||
* plug-ins/gfig/gfig.[ch]:
|
||||
|
@ -1875,7 +1875,7 @@ prefs_dialog_new (Gimp *gimp,
|
||||
"name"));
|
||||
gtk_widget_show (vbox3);
|
||||
|
||||
vbox4 = prefs_frame_new (controller_class->name,
|
||||
vbox4 = prefs_frame_new (_("General"),
|
||||
GTK_CONTAINER (vbox3), FALSE);
|
||||
|
||||
entry = gimp_prop_entry_new (G_OBJECT (info), "name", -1);
|
||||
@ -1889,7 +1889,7 @@ prefs_dialog_new (Gimp *gimp,
|
||||
_("Enable this controller"),
|
||||
GTK_BOX (vbox4));
|
||||
|
||||
vbox4 = prefs_frame_new (_("Controller Specific Settings"),
|
||||
vbox4 = prefs_frame_new (controller_class->name,
|
||||
GTK_CONTAINER (vbox3), TRUE);
|
||||
|
||||
property_specs =
|
||||
@ -1921,15 +1921,29 @@ prefs_dialog_new (Gimp *gimp,
|
||||
else
|
||||
widget = gimp_prop_label_new (G_OBJECT (controller),
|
||||
prop_spec->name);
|
||||
}
|
||||
|
||||
if (widget)
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
||||
g_param_spec_get_nick (prop_spec),
|
||||
0.0, 0.5,
|
||||
widget,
|
||||
1, FALSE);
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_INT (prop_spec))
|
||||
{
|
||||
if (prop_spec->flags & G_PARAM_WRITABLE)
|
||||
{
|
||||
widget = gimp_prop_spin_button_new (G_OBJECT (controller),
|
||||
prop_spec->name,
|
||||
1, 8, 0);
|
||||
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
||||
g_param_spec_get_nick (prop_spec),
|
||||
0.0, 0.5,
|
||||
widget,
|
||||
1, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_free (property_specs);
|
||||
|
||||
|
@ -1875,7 +1875,7 @@ prefs_dialog_new (Gimp *gimp,
|
||||
"name"));
|
||||
gtk_widget_show (vbox3);
|
||||
|
||||
vbox4 = prefs_frame_new (controller_class->name,
|
||||
vbox4 = prefs_frame_new (_("General"),
|
||||
GTK_CONTAINER (vbox3), FALSE);
|
||||
|
||||
entry = gimp_prop_entry_new (G_OBJECT (info), "name", -1);
|
||||
@ -1889,7 +1889,7 @@ prefs_dialog_new (Gimp *gimp,
|
||||
_("Enable this controller"),
|
||||
GTK_BOX (vbox4));
|
||||
|
||||
vbox4 = prefs_frame_new (_("Controller Specific Settings"),
|
||||
vbox4 = prefs_frame_new (controller_class->name,
|
||||
GTK_CONTAINER (vbox3), TRUE);
|
||||
|
||||
property_specs =
|
||||
@ -1921,15 +1921,29 @@ prefs_dialog_new (Gimp *gimp,
|
||||
else
|
||||
widget = gimp_prop_label_new (G_OBJECT (controller),
|
||||
prop_spec->name);
|
||||
}
|
||||
|
||||
if (widget)
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
||||
g_param_spec_get_nick (prop_spec),
|
||||
0.0, 0.5,
|
||||
widget,
|
||||
1, FALSE);
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_INT (prop_spec))
|
||||
{
|
||||
if (prop_spec->flags & G_PARAM_WRITABLE)
|
||||
{
|
||||
widget = gimp_prop_spin_button_new (G_OBJECT (controller),
|
||||
prop_spec->name,
|
||||
1, 8, 0);
|
||||
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
||||
g_param_spec_get_nick (prop_spec),
|
||||
0.0, 0.5,
|
||||
widget,
|
||||
1, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_free (property_specs);
|
||||
|
||||
|
@ -48,7 +48,8 @@ typedef struct
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_DEVICE
|
||||
PROP_DEVICE,
|
||||
PROP_CHANNEL
|
||||
};
|
||||
|
||||
|
||||
@ -67,6 +68,8 @@ struct _ControllerMidi
|
||||
GimpController parent_instance;
|
||||
|
||||
gchar *device;
|
||||
gint midi_channel;
|
||||
|
||||
GIOChannel *io;
|
||||
guint io_id;
|
||||
|
||||
@ -110,6 +113,7 @@ static const gchar * midi_get_event_blurb (GimpController *controller,
|
||||
static gboolean midi_set_device (ControllerMidi *controller,
|
||||
const gchar *device);
|
||||
static void midi_event (ControllerMidi *midi,
|
||||
gint channel,
|
||||
gint event_id,
|
||||
gdouble value);
|
||||
|
||||
@ -191,11 +195,20 @@ midi_class_init (ControllerMidiClass *klass)
|
||||
|
||||
g_object_class_install_property (object_class, PROP_DEVICE,
|
||||
g_param_spec_string ("device",
|
||||
_("Device:"), NULL,
|
||||
_("Device:"),
|
||||
_("The name of the device to read MIDI events from."),
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
GIMP_CONTROLLER_PARAM_SERIALIZE));
|
||||
g_object_class_install_property (object_class, PROP_CHANNEL,
|
||||
g_param_spec_int ("channel",
|
||||
_("Channel:"),
|
||||
_("The MIDI channel to read events from. Set to -1 for reading from all MIDI channels."),
|
||||
-1, 15, -1,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
GIMP_CONTROLLER_PARAM_SERIALIZE));
|
||||
|
||||
controller_class->name = _("Midi Events");
|
||||
|
||||
@ -208,7 +221,9 @@ static void
|
||||
midi_init (ControllerMidi *midi)
|
||||
{
|
||||
midi->device = NULL;
|
||||
midi->midi_channel = -1;
|
||||
midi->io = NULL;
|
||||
midi->io_id = 0;
|
||||
|
||||
midi->swallow = TRUE; /* get rid of data bytes at start of stream */
|
||||
midi->command = 0x0;
|
||||
@ -242,6 +257,9 @@ midi_set_property (GObject *object,
|
||||
case PROP_DEVICE:
|
||||
midi_set_device (midi, g_value_get_string (value));
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
midi->midi_channel = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@ -261,6 +279,9 @@ midi_get_property (GObject *object,
|
||||
case PROP_DEVICE:
|
||||
g_value_set_string (value, midi->device);
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
g_value_set_int (value, midi->midi_channel);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@ -393,9 +414,14 @@ midi_set_device (ControllerMidi *midi,
|
||||
|
||||
static void
|
||||
midi_event (ControllerMidi *midi,
|
||||
gint channel,
|
||||
gint event_id,
|
||||
gdouble value)
|
||||
{
|
||||
if (channel == -1 ||
|
||||
midi->midi_channel == -1 ||
|
||||
channel == midi->midi_channel)
|
||||
{
|
||||
GimpControllerEvent event = { 0, };
|
||||
|
||||
event.any.type = GIMP_CONTROLLER_EVENT_VALUE;
|
||||
@ -408,6 +434,7 @@ midi_event (ControllerMidi *midi,
|
||||
gimp_controller_event (GIMP_CONTROLLER (midi), &event);
|
||||
|
||||
g_value_unset (&event.value.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -556,7 +583,7 @@ midi_read_event (GIOChannel *io,
|
||||
midi->channel,
|
||||
midi->key, midi->velocity));
|
||||
|
||||
midi_event (midi, midi->key,
|
||||
midi_event (midi, midi->channel, midi->key,
|
||||
(gdouble) midi->velocity / 127.0);
|
||||
}
|
||||
else if (midi->command == 0x8)
|
||||
@ -564,7 +591,7 @@ midi_read_event (GIOChannel *io,
|
||||
D (g_print ("MIDI (ch %02d): note off (%02x vel %02x)\n",
|
||||
midi->channel, midi->key, midi->velocity));
|
||||
|
||||
midi_event (midi, midi->key + 128,
|
||||
midi_event (midi, midi->channel, midi->key + 128,
|
||||
(gdouble) midi->velocity / 127.0);
|
||||
}
|
||||
else
|
||||
@ -591,7 +618,7 @@ midi_read_event (GIOChannel *io,
|
||||
D (g_print ("MIDI (ch %02d): controller %d (value %d)\n",
|
||||
midi->channel, midi->key, midi->velocity));
|
||||
|
||||
midi_event (midi, midi->key + 128 + 128,
|
||||
midi_event (midi, midi->channel, midi->key + 128 + 128,
|
||||
(gdouble) midi->velocity / 127.0);
|
||||
|
||||
midi->key = -1;
|
||||
|
Reference in New Issue
Block a user