Mercurial > audlegacy-plugins
changeset 1319:a0320227c751
From: Eduard Bloch <edi@gmx.de>
Add Escape key binding and default focus in libmad plugin's fileinfo window.
This may be worthwhile to implement in the other plugins.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 20 Jul 2007 23:37:48 -0500 |
parents | 25f5cd05a52f |
children | bd98b757e264 |
files | src/madplug/fileinfo.c |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/madplug/fileinfo.c Fri Jul 20 20:33:46 2007 -0500 +++ b/src/madplug/fileinfo.c Fri Jul 20 23:37:48 2007 -0500 @@ -29,6 +29,7 @@ #include <math.h> #include <audacious/util.h> #include <gtk/gtk.h> +#include <gdk/gdkkeysyms.h> /* yaz */ #include <langinfo.h> @@ -277,6 +278,21 @@ gtk_widget_set_sensitive(GTK_WIDGET(object), TRUE); } +#ifndef NOGUI +static gboolean +on_fileinfo_window_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data) +{ + g_return_val_if_fail(GTK_IS_WIDGET (widget), FALSE); + + if (event->keyval == GDK_Escape) + { + gtk_widget_hide(widget); + } + + return FALSE; +} +#endif + void create_window() { GtkWidget *vbox, *hbox, *left_vbox, *table; @@ -293,6 +309,8 @@ gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(close_window), &window); + g_signal_connect(G_OBJECT(window), "key-press-event", + G_CALLBACK(on_fileinfo_window_key_press), &window); gtk_container_set_border_width(GTK_CONTAINER(window), 10); vbox = gtk_vbox_new(FALSE, 10); @@ -540,6 +558,7 @@ G_OBJECT(window)); GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); + gtk_window_set_focus(GTK_WINDOW(window), cancel); gtk_widget_show_all(window); }