mirror of https://github.com/GNOME/gimp.git
added GimpController::get_event_blurb() which returns the strings that
2004-06-16 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpcontroller.[ch]: added GimpController::get_event_blurb() which returns the strings that were returned by get_event_name(). The latter returns untranslatable event identifiers now. * app/widgets/gimpcontrollerwheel.c * modules/controller_linux_input.c: changed accordingly. * app/widgets/gimpcontrollerinfo.c * app/widgets/gimpcontrollers.c: changed the event mapping from event-id -> action-name to event-name -> action-name. * etc/controllerrc: changed accordingly (finally readable now).
This commit is contained in:
parent
ba2e6c675f
commit
569af0ac93
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2004-06-16 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpcontroller.[ch]: added
|
||||
GimpController::get_event_blurb() which returns the strings that
|
||||
were returned by get_event_name(). The latter returns
|
||||
untranslatable event identifiers now.
|
||||
|
||||
* app/widgets/gimpcontrollerwheel.c
|
||||
* modules/controller_linux_input.c: changed accordingly.
|
||||
|
||||
* app/widgets/gimpcontrollerinfo.c
|
||||
* app/widgets/gimpcontrollers.c: changed the event mapping from
|
||||
event-id -> action-name to event-name -> action-name.
|
||||
|
||||
* etc/controllerrc: changed accordingly (finally readable now).
|
||||
|
||||
2004-06-16 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
|
|
|
@ -94,8 +94,8 @@ static void
|
|||
gimp_controller_info_init (GimpControllerInfo *info)
|
||||
{
|
||||
info->controller = NULL;
|
||||
info->mapping = g_hash_table_new_full (g_int_hash,
|
||||
g_int_equal,
|
||||
info->mapping = g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
(GDestroyNotify) g_free,
|
||||
(GDestroyNotify) g_object_unref);
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ gimp_controllers_restore (Gimp *gimp,
|
|||
g_message (error->message);
|
||||
g_clear_error (&error);
|
||||
|
||||
gimp_config_file_backup_on_error (filename, "sessionrc", NULL);
|
||||
gimp_config_file_backup_on_error (filename, "controllerrc", NULL);
|
||||
}
|
||||
|
||||
gimp_scanner_destroy (scanner);
|
||||
|
@ -335,11 +335,11 @@ gimp_controller_deserialize (GimpControllerManager *manager,
|
|||
{
|
||||
GtkAction *action = NULL;
|
||||
GList *list;
|
||||
gint event_id;
|
||||
gchar *event_name;
|
||||
gchar *action_name;
|
||||
|
||||
token = G_TOKEN_INT;
|
||||
if (! gimp_scanner_parse_int (scanner, &event_id))
|
||||
if (! gimp_scanner_parse_string (scanner, &event_name))
|
||||
goto error;
|
||||
|
||||
token = G_TOKEN_STRING;
|
||||
|
@ -360,15 +360,12 @@ gimp_controller_deserialize (GimpControllerManager *manager,
|
|||
|
||||
if (action)
|
||||
{
|
||||
gint *key = g_new (gint, 1);
|
||||
|
||||
*key = event_id;
|
||||
|
||||
g_hash_table_insert (info->mapping, key,
|
||||
g_hash_table_insert (info->mapping, event_name,
|
||||
g_object_ref (action));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (event_name);
|
||||
g_printerr ("%s: action '%s' not found\n",
|
||||
G_STRFUNC, action_name);
|
||||
}
|
||||
|
@ -429,15 +426,20 @@ gimp_controller_info_event (GimpController *controller,
|
|||
{
|
||||
GtkAction *action;
|
||||
const gchar *class_name;
|
||||
const gchar *event_name;
|
||||
const gchar *event_blurb;
|
||||
|
||||
class_name = GIMP_CONTROLLER_GET_CLASS (controller)->name;
|
||||
|
||||
g_print ("Received '%s' (class '%s')\n"
|
||||
" controller event '%s'\n",
|
||||
controller->name, class_name,
|
||||
gimp_controller_get_event_name (controller, event->any.event_id));
|
||||
event_name = gimp_controller_get_event_name (controller, event->any.event_id);
|
||||
event_blurb = gimp_controller_get_event_blurb (controller, event->any.event_id);
|
||||
|
||||
action = g_hash_table_lookup (info->mapping, &event->any.event_id);
|
||||
g_print ("Received '%s' (class '%s')\n"
|
||||
" controller event '%s (%s)'\n",
|
||||
controller->name, class_name,
|
||||
event_name, event_blurb);
|
||||
|
||||
action = g_hash_table_lookup (info->mapping, event_name);
|
||||
|
||||
if (action)
|
||||
{
|
||||
|
|
|
@ -40,6 +40,7 @@ struct _WheelEvent
|
|||
GdkScrollDirection direction;
|
||||
GdkModifierType modifiers;
|
||||
const gchar *name;
|
||||
const gchar *blurb;
|
||||
};
|
||||
|
||||
|
||||
|
@ -48,6 +49,8 @@ static void gimp_controller_wheel_class_init (GimpControllerWheelCl
|
|||
static gint gimp_controller_wheel_get_n_events (GimpController *controller);
|
||||
static const gchar * gimp_controller_wheel_get_event_name (GimpController *controller,
|
||||
gint event_id);
|
||||
static const gchar * gimp_controller_wheel_get_event_blurb (GimpController *controller,
|
||||
gint event_id);
|
||||
|
||||
|
||||
static GimpControllerClass *parent_class = NULL;
|
||||
|
@ -55,71 +58,103 @@ static GimpControllerClass *parent_class = NULL;
|
|||
static const WheelEvent wheel_events[] =
|
||||
{
|
||||
{ GDK_SCROLL_UP, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-up-shift-control-alt",
|
||||
N_("Alt + Control + Shift + Scroll Up") },
|
||||
{ GDK_SCROLL_UP, GDK_MOD1_MASK | GDK_CONTROL_MASK,
|
||||
"scroll-up-control-alt",
|
||||
N_("Alt + Control + Scroll Up") },
|
||||
{ GDK_SCROLL_UP, GDK_MOD1_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-up-shift-alt",
|
||||
N_("Alt + Shift + Scroll Up") },
|
||||
{ GDK_SCROLL_UP, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-up-shift-control",
|
||||
N_("Control + Shift + Scroll Up") },
|
||||
{ GDK_SCROLL_UP, GDK_MOD1_MASK,
|
||||
"scroll-up-alt",
|
||||
N_("Alt + Scroll Up") },
|
||||
{ GDK_SCROLL_UP, GDK_CONTROL_MASK,
|
||||
"scroll-up-control",
|
||||
N_("Control + Scroll Up") },
|
||||
{ GDK_SCROLL_UP, GDK_SHIFT_MASK,
|
||||
"scroll-up-shift",
|
||||
N_("Shift + Scroll Up") },
|
||||
{ GDK_SCROLL_UP, 0,
|
||||
"scroll-up",
|
||||
N_("Scroll Up") },
|
||||
|
||||
{ GDK_SCROLL_DOWN, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-down-shift-control-alt",
|
||||
N_("Alt + Control + Shift + Scroll Down") },
|
||||
{ GDK_SCROLL_DOWN, GDK_MOD1_MASK | GDK_CONTROL_MASK,
|
||||
"scroll-down-control-alt",
|
||||
N_("Alt + Control + Scroll Down") },
|
||||
{ GDK_SCROLL_DOWN, GDK_MOD1_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-down-shift-alt",
|
||||
N_("Alt + Shift + Scroll Down") },
|
||||
{ GDK_SCROLL_DOWN, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-down-shift-control",
|
||||
N_("Control + Shift + Scroll Down") },
|
||||
{ GDK_SCROLL_DOWN, GDK_MOD1_MASK,
|
||||
"scroll-down-alt",
|
||||
N_("Alt + Scroll Down") },
|
||||
{ GDK_SCROLL_DOWN, GDK_CONTROL_MASK,
|
||||
"scroll-down-control",
|
||||
N_("Control + Scroll Down") },
|
||||
{ GDK_SCROLL_DOWN, GDK_SHIFT_MASK,
|
||||
"scroll-down-shift",
|
||||
N_("Shift + Scroll Down") },
|
||||
{ GDK_SCROLL_DOWN, 0,
|
||||
"scroll-down",
|
||||
N_("Scroll Down") },
|
||||
|
||||
{ GDK_SCROLL_LEFT, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-left-shift-control-alt",
|
||||
N_("Alt + Control + Shift + Scroll Left") },
|
||||
{ GDK_SCROLL_LEFT, GDK_MOD1_MASK | GDK_CONTROL_MASK,
|
||||
"scroll-left-control-alt",
|
||||
N_("Alt + Control + Scroll Left") },
|
||||
{ GDK_SCROLL_LEFT, GDK_MOD1_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-left-shift-alt",
|
||||
N_("Alt + Shift + Scroll Left") },
|
||||
{ GDK_SCROLL_LEFT, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-left-shift-control",
|
||||
N_("Control + Shift + Scroll Left") },
|
||||
{ GDK_SCROLL_LEFT, GDK_MOD1_MASK,
|
||||
"scroll-left-alt",
|
||||
N_("Alt + Scroll Left") },
|
||||
{ GDK_SCROLL_LEFT, GDK_CONTROL_MASK,
|
||||
"scroll-left-control",
|
||||
N_("Control + Scroll Left") },
|
||||
{ GDK_SCROLL_LEFT, GDK_SHIFT_MASK,
|
||||
"scroll-left-shift",
|
||||
N_("Shift + Scroll Left") },
|
||||
{ GDK_SCROLL_LEFT, 0,
|
||||
"scroll-left",
|
||||
N_("Scroll Left") },
|
||||
|
||||
{ GDK_SCROLL_RIGHT, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-right-shift-control-alt",
|
||||
N_("Alt + Control + Shift + Scroll Right") },
|
||||
{ GDK_SCROLL_RIGHT, GDK_MOD1_MASK | GDK_CONTROL_MASK,
|
||||
"scroll-right-control-alt",
|
||||
N_("Alt + Control + Scroll Right") },
|
||||
{ GDK_SCROLL_RIGHT, GDK_MOD1_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-right-shift-alt",
|
||||
N_("Alt + Shift + Scroll Right") },
|
||||
{ GDK_SCROLL_RIGHT, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"scroll-right-shift-control",
|
||||
N_("Control + Shift + Scroll Right") },
|
||||
{ GDK_SCROLL_RIGHT, GDK_MOD1_MASK,
|
||||
"scroll-right-alt",
|
||||
N_("Alt + Scroll Right") },
|
||||
{ GDK_SCROLL_RIGHT, GDK_CONTROL_MASK,
|
||||
"scroll-right-control",
|
||||
N_("Control + Scroll Right") },
|
||||
{ GDK_SCROLL_RIGHT, GDK_SHIFT_MASK,
|
||||
"scroll-right-shift",
|
||||
N_("Shift + Scroll Right") },
|
||||
{ GDK_SCROLL_RIGHT, 0,
|
||||
"scroll-right",
|
||||
N_("Scroll Right") }
|
||||
};
|
||||
|
||||
|
@ -163,6 +198,7 @@ gimp_controller_wheel_class_init (GimpControllerWheelClass *klass)
|
|||
|
||||
controller_class->get_n_events = gimp_controller_wheel_get_n_events;
|
||||
controller_class->get_event_name = gimp_controller_wheel_get_event_name;
|
||||
controller_class->get_event_blurb = gimp_controller_wheel_get_event_blurb;
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -181,6 +217,16 @@ gimp_controller_wheel_get_event_name (GimpController *controller,
|
|||
return gettext (wheel_events[event_id].name);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
gimp_controller_wheel_get_event_blurb (GimpController *controller,
|
||||
gint event_id)
|
||||
{
|
||||
if (event_id < 0 || event_id >= G_N_ELEMENTS (wheel_events))
|
||||
return NULL;
|
||||
|
||||
return gettext (wheel_events[event_id].blurb);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_controller_wheel_scrolled (GimpControllerWheel *wheel,
|
||||
const GdkEventScroll *sevent)
|
||||
|
|
|
@ -2,31 +2,29 @@
|
|||
|
||||
(controller "GimpControllerWheel"
|
||||
(options
|
||||
(name "Main Mouse Wheel")
|
||||
(enabled TRUE))
|
||||
(mapping 0 "context-font-next")
|
||||
(mapping 1 "context-gradient-next")
|
||||
(mapping 2 "context-pattern-next")
|
||||
(mapping 3 "context-brush-next")
|
||||
(mapping 4 "context-opacity-increase-skip")
|
||||
(mapping 8 "context-font-previous")
|
||||
(mapping 9 "context-gradient-previous")
|
||||
(mapping 10 "context-pattern-previous")
|
||||
(mapping 11 "context-brush-previous")
|
||||
(mapping 12 "context-opacity-decrease-skip"))
|
||||
(name "Main Mouse Wheel"))
|
||||
(mapping "scroll-up-shift-control-alt" "context-font-next")
|
||||
(mapping "scroll-up-control-alt" "context-gradient-next")
|
||||
(mapping "scroll-up-shift-alt" "context-pattern-next")
|
||||
(mapping "scroll-up-shift-control" "context-brush-next")
|
||||
(mapping "scroll-up-alt" "context-opacity-increase-skip")
|
||||
(mapping "scroll-down-shift-control-alt" "context-font-previous")
|
||||
(mapping "scroll-down-control-alt" "context-gradient-previous")
|
||||
(mapping "scroll-down-shift-alt" "context-pattern-previous")
|
||||
(mapping "scroll-down-shift-control" "context-brush-previous")
|
||||
(mapping "scroll-down-alt" "context-opacity-decrease-skip"))
|
||||
|
||||
(controller "ControllerLinuxInput"
|
||||
(options
|
||||
(name "ShuttlePRO")
|
||||
(device "/dev/input/event2"))
|
||||
(mapping 0 "tools-rect-select")
|
||||
(mapping 1 "tools-ellipse-select")
|
||||
(mapping 2 "tools-bucket-fill")
|
||||
(mapping 3 "tools-blend")
|
||||
(mapping 4 "tools-pencil")
|
||||
(mapping 5 "tools-paintbrush")
|
||||
(mapping 6 "tools-eraser")
|
||||
(mapping 7 "tools-airbrush")
|
||||
(mapping 13 "context-brush-radius-decrease")
|
||||
(mapping 14 "context-brush-radius-increase"))
|
||||
|
||||
(mapping "button-0" "tools-rect-select")
|
||||
(mapping "button-1" "tools-ellipse-select")
|
||||
(mapping "button-2" "tools-bucket-fill")
|
||||
(mapping "button-3" "tools-blend")
|
||||
(mapping "button-4" "tools-pencil")
|
||||
(mapping "button-5" "tools-paintbrush")
|
||||
(mapping "button-6" "tools-eraser")
|
||||
(mapping "button-7" "tools-airbrush")
|
||||
(mapping "wheel-turn-left" "context-brush-radius-decrease")
|
||||
(mapping "wheel-turn-right" "context-brush-radius-increase"))
|
||||
|
|
|
@ -228,6 +228,19 @@ gimp_controller_get_event_name (GimpController *controller,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_controller_get_event_blurb (GimpController *controller,
|
||||
gint event_id)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_CONTROLLER (controller), NULL);
|
||||
|
||||
if (GIMP_CONTROLLER_GET_CLASS (controller)->get_event_blurb)
|
||||
return GIMP_CONTROLLER_GET_CLASS (controller)->get_event_blurb (controller,
|
||||
event_id);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_controller_set_enabled (GimpController *controller,
|
||||
gboolean enabled)
|
||||
|
|
|
@ -98,6 +98,8 @@ struct _GimpControllerClass
|
|||
gint (* get_n_events) (GimpController *controller);
|
||||
const gchar * (* get_event_name) (GimpController *controller,
|
||||
gint event_id);
|
||||
const gchar * (* get_event_blurb) (GimpController *controller,
|
||||
gint event_id);
|
||||
|
||||
/* signals */
|
||||
gboolean (* event) (GimpController *controller,
|
||||
|
@ -117,6 +119,8 @@ GimpController * gimp_controller_new (GType controller_type
|
|||
gint gimp_controller_get_n_events (GimpController *controller);
|
||||
const gchar * gimp_controller_get_event_name (GimpController *controller,
|
||||
gint event_id);
|
||||
const gchar * gimp_controller_get_event_blurb (GimpController *controller,
|
||||
gint event_id);
|
||||
|
||||
void gimp_controller_set_enabled (GimpController *controller,
|
||||
gboolean enabled);
|
||||
|
|
|
@ -77,6 +77,7 @@ struct _LinuxInputEvent
|
|||
__u16 type;
|
||||
__u16 code;
|
||||
const gchar *name;
|
||||
const gchar *blurb;
|
||||
};
|
||||
|
||||
|
||||
|
@ -95,6 +96,8 @@ static void linux_input_get_property (GObject *object,
|
|||
static gint linux_input_get_n_events (GimpController *controller);
|
||||
static const gchar * linux_input_get_event_name (GimpController *controller,
|
||||
gint event_id);
|
||||
static const gchar * linux_input_get_event_blurb (GimpController *controller,
|
||||
gint event_id);
|
||||
|
||||
static gboolean linux_input_set_device (ControllerLinuxInput *controller,
|
||||
const gchar *device);
|
||||
|
@ -116,21 +119,21 @@ static const GimpModuleInfo linux_input_info =
|
|||
|
||||
static const LinuxInputEvent input_events[] =
|
||||
{
|
||||
{ EV_KEY, BTN_0, N_("Button 0") },
|
||||
{ EV_KEY, BTN_1, N_("Button 1") },
|
||||
{ EV_KEY, BTN_2, N_("Button 2") },
|
||||
{ EV_KEY, BTN_3, N_("Button 3") },
|
||||
{ EV_KEY, BTN_4, N_("Button 4") },
|
||||
{ EV_KEY, BTN_5, N_("Button 5") },
|
||||
{ EV_KEY, BTN_6, N_("Button 6") },
|
||||
{ EV_KEY, BTN_7, N_("Button 7") },
|
||||
{ EV_KEY, BTN_8, N_("Button 8") },
|
||||
{ EV_KEY, BTN_9, N_("Button 9") },
|
||||
{ EV_KEY, BTN_LEFT, N_("Button Left") },
|
||||
{ EV_KEY, BTN_RIGHT, N_("Button Right") },
|
||||
{ EV_KEY, BTN_MIDDLE, N_("Button Middle") },
|
||||
{ EV_REL, REL_WHEEL, N_("Wheel Turn Left") },
|
||||
{ EV_REL, REL_WHEEL, N_("Wheel Turn Right") },
|
||||
{ EV_KEY, BTN_0, "button-0", N_("Button 0") },
|
||||
{ EV_KEY, BTN_1, "button-1", N_("Button 1") },
|
||||
{ EV_KEY, BTN_2, "button-2", N_("Button 2") },
|
||||
{ EV_KEY, BTN_3, "button-3", N_("Button 3") },
|
||||
{ EV_KEY, BTN_4, "button-4", N_("Button 4") },
|
||||
{ EV_KEY, BTN_5, "button-5", N_("Button 5") },
|
||||
{ EV_KEY, BTN_6, "button-6", N_("Button 6") },
|
||||
{ EV_KEY, BTN_7, "button-7", N_("Button 7") },
|
||||
{ EV_KEY, BTN_8, "button-8", N_("Button 8") },
|
||||
{ EV_KEY, BTN_9, "button-9", N_("Button 9") },
|
||||
{ EV_KEY, BTN_LEFT, "button-left", N_("Button Left") },
|
||||
{ EV_KEY, BTN_RIGHT, "button-right", N_("Button Right") },
|
||||
{ EV_KEY, BTN_MIDDLE, "button-middle", N_("Button Middle") },
|
||||
{ EV_REL, REL_WHEEL, "wheel-turn-left", N_("Wheel Turn Left") },
|
||||
{ EV_REL, REL_WHEEL, "wheel-rurn-right", N_("Wheel Turn Right") },
|
||||
};
|
||||
|
||||
static GType controller_type = 0;
|
||||
|
@ -201,6 +204,7 @@ linux_input_class_init (ControllerLinuxInputClass *klass)
|
|||
|
||||
controller_class->get_n_events = linux_input_get_n_events;
|
||||
controller_class->get_event_name = linux_input_get_event_name;
|
||||
controller_class->get_event_blurb = linux_input_get_event_blurb;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -267,6 +271,16 @@ linux_input_get_event_name (GimpController *controller,
|
|||
return gettext (input_events[event_id].name);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
linux_input_get_event_blurb (GimpController *controller,
|
||||
gint event_id)
|
||||
{
|
||||
if (event_id < 0 || event_id >= G_N_ELEMENTS (input_events))
|
||||
return NULL;
|
||||
|
||||
return gettext (input_events[event_id].blurb);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
linux_input_set_device (ControllerLinuxInput *controller,
|
||||
const gchar *device)
|
||||
|
@ -301,7 +315,7 @@ linux_input_set_device (ControllerLinuxInput *controller,
|
|||
}
|
||||
else
|
||||
{
|
||||
g_printerr ("Cannot open device '%s': %s",
|
||||
g_printerr ("Cannot open device '%s': %s\n",
|
||||
device, g_strerror (errno));
|
||||
}
|
||||
}
|
||||
|
@ -361,4 +375,3 @@ linux_input_read_event (GIOChannel *io,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue