guarded the whole header with GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION

2004-11-24  Michael Natterer  <mitch@gimp.org>

	* libgimpwidgets/gimpcontroller.[ch]: guarded the whole header
	with GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION because it's no
	fixed API yet. Added a "state" property bacause "name" was abused
	as the controller's state. Added "help_domain" to the controller
	class.

	* libgimpwidgets/gimpwidgets.h: don't include gimpcontroller.h

	* modules/controller_linux_input.c
	* modules/controller_midi.c: set the "name" property to the name
	retrieved from the device, or to a default string if no name is
	available. Store the status in the "state" property. Added and
	changed some strings, but it's better to have the controller
	strings untranslated than to have no tooltips at all or misleading
	labels.

	* app/widgets/gimpcontrollerkeyboard.c
	* app/widgets/gimpcontrollerwheel.c: set default strings for both.

	* app/widgets/gimpcontrollereditor.c: added a GUI for the "state"
	property.

	* app/widgets/gimpcontrollerkeyboard.h
	* app/widgets/gimpcontrollerwheel.h
	* app/widgets/gimpcontrollerinfo.c
	* app/widgets/gimpcontrollers.c: #define
	GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION (just as in all files
	above).

	* app/widgets/gimphelp-ids.h: added the IDs of all controller
	modules and also of all other modules. The defines are not
	actually used, but this file is the canonical place to collect all
	the core's help IDs.
This commit is contained in:
Michael Natterer 2004-11-24 02:17:12 +00:00 committed by Michael Natterer
parent 7eed9323db
commit 6d63d50040
14 changed files with 171 additions and 51 deletions

View File

@ -1,3 +1,39 @@
2004-11-24 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpcontroller.[ch]: guarded the whole header
with GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION because it's no
fixed API yet. Added a "state" property bacause "name" was abused
as the controller's state. Added "help_domain" to the controller
class.
* libgimpwidgets/gimpwidgets.h: don't include gimpcontroller.h
* modules/controller_linux_input.c
* modules/controller_midi.c: set the "name" property to the name
retrieved from the device, or to a default string if no name is
available. Store the status in the "state" property. Added and
changed some strings, but it's better to have the controller
strings untranslated than to have no tooltips at all or misleading
labels.
* app/widgets/gimpcontrollerkeyboard.c
* app/widgets/gimpcontrollerwheel.c: set default strings for both.
* app/widgets/gimpcontrollereditor.c: added a GUI for the "state"
property.
* app/widgets/gimpcontrollerkeyboard.h
* app/widgets/gimpcontrollerwheel.h
* app/widgets/gimpcontrollerinfo.c
* app/widgets/gimpcontrollers.c: #define
GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION (just as in all files
above).
* app/widgets/gimphelp-ids.h: added the IDs of all controller
modules and also of all other modules. The defines are not
actually used, but this file is the canonical place to collect all
the core's help IDs.
2004-11-23 Sven Neumann <sven@gimp.org>
* app/core/gimp-templates.[ch]

View File

@ -24,6 +24,8 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
#include "libgimpwidgets/gimpcontroller.h"
#include "widgets-types.h"
@ -220,7 +222,7 @@ gimp_controller_editor_constructor (GType type,
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
table = gtk_table_new (1, 2, FALSE);
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
@ -234,6 +236,12 @@ gimp_controller_editor_constructor (GType type,
"name"),
1, TRUE);
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("State:"), 0.0, 0.5,
gimp_prop_label_new (G_OBJECT (controller),
"state"),
1, TRUE);
property_specs =
g_object_class_list_properties (G_OBJECT_CLASS (controller_class),
&n_property_specs);

View File

@ -27,6 +27,8 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
#include "libgimpwidgets/gimpcontroller.h"
#include "widgets-types.h"

View File

@ -30,6 +30,7 @@
#include "widgets-types.h"
#include "gimpcontrollerkeyboard.h"
#include "gimphelp-ids.h"
#include "gimp-intl.h"
@ -204,6 +205,7 @@ gimp_controller_keyboard_class_init (GimpControllerKeyboardClass *klass)
object_class->constructor = gimp_controller_keyboard_constructor;
controller_class->name = _("Keyboard");
controller_class->help_id = GIMP_HELP_CONTROLLER_KEYBOARD;
controller_class->get_n_events = gimp_controller_keyboard_get_n_events;
controller_class->get_event_name = gimp_controller_keyboard_get_event_name;
@ -224,7 +226,10 @@ gimp_controller_keyboard_constructor (GType type,
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
g_object_set (object, "name", _("Main Keyboard"), NULL);
g_object_set (object,
"name", _("Keyboard Events"),
"state", _("Ready"),
NULL);
return object;
}

View File

@ -20,10 +20,11 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CONTROLLER_WHELL_H__
#ifndef __GIMP_CONTROLLER_KEYBOARD_H__
#define __GIMP_CONTROLLER_KEYBOARD_H__
#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
#include "libgimpwidgets/gimpcontroller.h"

View File

@ -22,6 +22,8 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
#include "libgimpwidgets/gimpcontroller.h"
#include "widgets-types.h"

View File

@ -29,6 +29,7 @@
#include "widgets-types.h"
#include "gimpcontrollerwheel.h"
#include "gimphelp-ids.h"
#include "gimp-intl.h"
@ -203,6 +204,7 @@ gimp_controller_wheel_class_init (GimpControllerWheelClass *klass)
object_class->constructor = gimp_controller_wheel_constructor;
controller_class->name = _("Mouse Wheel");
controller_class->help_id = GIMP_HELP_CONTROLLER_WHEEL;
controller_class->get_n_events = gimp_controller_wheel_get_n_events;
controller_class->get_event_name = gimp_controller_wheel_get_event_name;
@ -223,7 +225,10 @@ gimp_controller_wheel_constructor (GType type,
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
g_object_set (object, "name", _("Main Mouse Wheel"), NULL);
g_object_set (object,
"name", _("Mouse Wheel Events"),
"state", _("Ready"),
NULL);
return object;
}

View File

@ -24,6 +24,7 @@
#define __GIMP_CONTROLLER_WHEEL_H__
#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
#include "libgimpwidgets/gimpcontroller.h"

View File

@ -432,5 +432,20 @@
#define GIMP_HELP_HELP "gimp-help"
#define GIMP_HELP_HELP_CONTEXT "gimp-help-context"
#define GIMP_HELP_COLORDISPLAY_COLORBLIND "gimp-colordisplay-colorblind"
#define GIMP_HELP_COLORDISPLAY_CONTRAST "gimp-colordisplay-contrast"
#define GIMP_HELP_COLORDISPLAY_GAMMA "gimp-colordisplay-gamma"
#define GIMP_HELP_COLORDISPLAY_GIMP "gimp-colordisplay-gimp"
#define GIMP_HELP_COLORDISPLAY_PROOF "gimp-colordisplay-proof"
#define GIMP_HELP_COLORSELECTOR_CMYK "gimp-colorselector-cmyk"
#define GIMP_HELP_COLORSELECTOR_TRIANGLE "gimp-colorselector-triangle"
#define GIMP_HELP_COLORSELECTOR_WATER "gimp-colorselector-water"
#define GIMP_HELP_CONTROLLER_KEYBOARD "gimp-controller-keyboard"
#define GIMP_HELP_CONTROLLER_LINUX_INPUT "gimp-controller-linux-input"
#define GIMP_HELP_CONTROLLER_MIDI "gimp-controller-midi"
#define GIMP_HELP_CONTROLLER_WHEEL "gimp-controller-wheel"
#endif /* __GIMP_HELP_IDS_H__ */

View File

@ -28,14 +28,16 @@
#include "gimpwidgetstypes.h"
#include "gimpcontroller.h"
#include "gimpwidgetsmarshal.h"
#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
#include "gimpcontroller.h"
enum
{
PROP_0,
PROP_NAME
PROP_NAME,
PROP_STATE
};
enum
@ -121,6 +123,12 @@ gimp_controller_class_init (GimpControllerClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_STATE,
g_param_spec_string ("state", NULL, NULL,
"Unknown",
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
controller_signals[EVENT] =
g_signal_new ("event",
G_TYPE_FROM_CLASS (klass),
@ -132,6 +140,7 @@ gimp_controller_class_init (GimpControllerClass *klass)
G_TYPE_POINTER);
klass->name = "Unnamed";
klass->help_domain = NULL;
klass->help_id = NULL;
klass->get_n_events = NULL;
@ -154,6 +163,11 @@ gimp_controller_set_property (GObject *object,
g_free (controller->name);
controller->name = g_value_dup_string (value);
break;
case PROP_STATE:
if (controller->state)
g_free (controller->state);
controller->state = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -173,6 +187,9 @@ gimp_controller_get_property (GObject *object,
case PROP_NAME:
g_value_set_string (value, controller->name);
break;
case PROP_STATE:
g_value_set_string (value, controller->state);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;

View File

@ -20,6 +20,10 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
#error GimpController is unstable API under construction
#endif
#ifndef __GIMP_CONTROLLER_H__
#define __GIMP_CONTROLLER_H__
@ -85,6 +89,7 @@ struct _GimpController
GObject parent_instance;
gchar *name;
gchar *state;
};
struct _GimpControllerClass
@ -92,6 +97,7 @@ struct _GimpControllerClass
GObjectClass parent_class;
const gchar *name;
const gchar *help_domain;
const gchar *help_id;
/* virtual functions */

View File

@ -41,7 +41,6 @@
#include <libgimpwidgets/gimpcolorselector.h>
#include <libgimpwidgets/gimpcolorselect.h>
#include <libgimpwidgets/gimpcolorselection.h>
#include <libgimpwidgets/gimpcontroller.h>
#include <libgimpwidgets/gimpdialog.h>
#include <libgimpwidgets/gimpfileentry.h>
#include <libgimpwidgets/gimpframe.h>

View File

@ -35,6 +35,7 @@
#include "libgimpmodule/gimpmodule.h"
#include "libgimpwidgets/gimpwidgets.h"
#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
#include "libgimpwidgets/gimpcontroller.h"
#include "libgimp/libgimp-intl.h"
@ -215,13 +216,15 @@ linux_input_class_init (ControllerLinuxInputClass *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 Linux Input events from."),
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
GIMP_MODULE_PARAM_SERIALIZE));
controller_class->name = _("Linux Input Events");
controller_class->name = _("Linux Input");
controller_class->help_id = "gimp-controller-linux-input";
controller_class->get_n_events = linux_input_get_n_events;
controller_class->get_event_name = linux_input_get_event_name;
@ -344,8 +347,11 @@ linux_input_set_device (ControllerLinuxInput *controller,
controller->device = g_strdup (device);
g_object_set (controller, "name", _("Linux Input Events"), NULL);
if (controller->device && strlen (controller->device))
{
gchar *state;
gint fd;
fd = open (controller->device, O_RDONLY);
@ -361,13 +367,10 @@ linux_input_set_device (ControllerLinuxInput *controller,
{
g_object_set (controller, "name", name, NULL);
}
else
{
gchar *name = g_strdup_printf (_("Reading from %s"),
controller->device);
g_object_set (controller, "name", name, NULL);
g_free (name);
}
state = g_strdup_printf (_("Reading from %s"), controller->device);
g_object_set (controller, "state", state, NULL);
g_free (state);
controller->io = g_io_channel_unix_new (fd);
g_io_channel_set_close_on_unref (controller->io, TRUE);
@ -381,15 +384,15 @@ linux_input_set_device (ControllerLinuxInput *controller,
}
else
{
gchar *name = g_strdup_printf (_("Device not available: %s"),
state = g_strdup_printf (_("Device not available: %s"),
g_strerror (errno));
g_object_set (controller, "name", name, NULL);
g_free (name);
g_object_set (controller, "state", state, NULL);
g_free (state);
}
}
else
{
g_object_set (controller, "name", _("No device configured"), NULL);
g_object_set (controller, "state", _("No device configured"), NULL);
}
return FALSE;
@ -424,16 +427,16 @@ linux_input_read_event (GIOChannel *io,
if (error)
{
gchar *name = g_strdup_printf (_("Device not available: %s"),
gchar *state = g_strdup_printf (_("Device not available: %s"),
error->message);
g_object_set (input, "name", name, NULL);
g_free (name);
g_object_set (input, "state", state, NULL);
g_free (state);
g_clear_error (&error);
}
else
{
g_object_set (input, "name", _("End of file"), NULL);
g_object_set (input, "state", _("End of file"), NULL);
}
return FALSE;
break;

View File

@ -37,6 +37,7 @@
#include "libgimpmodule/gimpmodule.h"
#include "libgimpwidgets/gimpwidgets.h"
#define GIMP_ENABLE_CONTROLLER_UNDER_CONSTRUCTION
#include "libgimpwidgets/gimpcontroller.h"
#include "libgimp/libgimp-intl.h"
@ -158,7 +159,7 @@ struct _GAlsaSource
static const GimpModuleInfo midi_info =
{
GIMP_MODULE_ABI_VERSION,
N_("Midi event controller"),
N_("MIDI event controller"),
"Michael Natterer <mitch@gimp.org>",
"v0.1",
"(c) 2004, released under the GPL",
@ -219,6 +220,7 @@ midi_class_init (ControllerMidiClass *klass)
{
GimpControllerClass *controller_class = GIMP_CONTROLLER_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
gchar *blurb;
parent_class = g_type_class_peek_parent (klass);
@ -226,14 +228,24 @@ midi_class_init (ControllerMidiClass *klass)
object_class->get_property = midi_get_property;
object_class->set_property = midi_set_property;
blurb = g_strconcat (_("The name of the device to read MIDI events from."),
#ifdef HAVE_ALSA
"\n",
_("Enter 'alsa' to use the ALSA sequencer."),
#endif
NULL);
g_object_class_install_property (object_class, PROP_DEVICE,
g_param_spec_string ("device",
_("Device:"),
_("The name of the device to read MIDI events from."),
blurb,
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
GIMP_MODULE_PARAM_SERIALIZE));
g_free (blurb);
g_object_class_install_property (object_class, PROP_CHANNEL,
g_param_spec_int ("channel",
_("Channel:"),
@ -243,7 +255,8 @@ midi_class_init (ControllerMidiClass *klass)
G_PARAM_CONSTRUCT |
GIMP_MODULE_PARAM_SERIALIZE));
controller_class->name = _("Midi Events");
controller_class->name = _("MIDI");
controller_class->help_id = "gimp-controller-midi";
controller_class->get_n_events = midi_get_n_events;
controller_class->get_event_name = midi_get_event_name;
@ -418,6 +431,8 @@ midi_set_device (ControllerMidi *midi,
midi->device = g_strdup (device);
g_object_set (midi, "name", _("MIDI Events"), NULL);
if (midi->device && strlen (midi->device))
{
gint fd;
@ -426,7 +441,8 @@ midi_set_device (ControllerMidi *midi,
if (! g_ascii_strcasecmp (midi->device, "alsa"))
{
GAlsaSource *event_source;
gchar *alsa, *name;
gchar *alsa;
gchar *state;
gint ret;
ret = snd_seq_open (&midi->sequencer, "default",
@ -443,10 +459,10 @@ midi_set_device (ControllerMidi *midi,
if (ret < 0)
{
name = g_strdup_printf (_("Device not available: %s"),
state = g_strdup_printf (_("Device not available: %s"),
snd_strerror (ret));
g_object_set (midi, "name", name, NULL);
g_free (name);
g_object_set (midi, "state", state, NULL);
g_free (state);
if (midi->sequencer)
{
@ -461,11 +477,15 @@ midi_set_device (ControllerMidi *midi,
alsa = g_strdup_printf ("ALSA (%d:%d)",
snd_seq_client_id (midi->sequencer),
ret);
name = g_strdup_printf (_("Reading from %s"), alsa);
g_object_set (midi, "name", name, NULL);
g_free (name);
state = g_strdup_printf (_("Reading from %s"), alsa);
g_free (alsa);
g_object_set (midi,
"name", snd_seq_name (midi->sequencer),
"state", state,
NULL);
g_free (state);
event_source = (GAlsaSource *) g_source_new (&alsa_source_funcs,
sizeof (GAlsaSource));
event_source->controller = midi;
@ -483,9 +503,9 @@ midi_set_device (ControllerMidi *midi,
if (fd >= 0)
{
gchar *name = g_strdup_printf (_("Reading from %s"), midi->device);
g_object_set (midi, "name", name, NULL);
g_free (name);
gchar *state = g_strdup_printf (_("Reading from %s"), midi->device);
g_object_set (midi, "state", state, NULL);
g_free (state);
midi->io = g_io_channel_unix_new (fd);
g_io_channel_set_close_on_unref (midi->io, TRUE);
@ -500,15 +520,15 @@ midi_set_device (ControllerMidi *midi,
}
else
{
gchar *name = g_strdup_printf (_("Device not available: %s"),
gchar *state = g_strdup_printf (_("Device not available: %s"),
g_strerror (errno));
g_object_set (midi, "name", name, NULL);
g_free (name);
g_object_set (midi, "state", state, NULL);
g_free (state);
}
}
else
{
g_object_set (midi, "name", _("No device configured"), NULL);
g_object_set (midi, "state", _("No device configured"), NULL);
}
return FALSE;
@ -571,16 +591,16 @@ midi_read_event (GIOChannel *io,
if (error)
{
gchar *name = g_strdup_printf (_("Device not available: %s"),
gchar *state = g_strdup_printf (_("Device not available: %s"),
error->message);
g_object_set (midi, "name", name, NULL);
g_free (name);
g_object_set (midi, "state", state, NULL);
g_free (state);
g_clear_error (&error);
}
else
{
g_object_set (midi, "name", _("End of file"), NULL);
g_object_set (midi, "state", _("End of file"), NULL);
}
return FALSE;
break;