comparison src/madplug/fileinfo.c @ 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 1d3b02d1842b
children 38fb3bb3e21e
comparison
equal deleted inserted replaced
1316:25f5cd05a52f 1319:a0320227c751
27 #include "mp3.xpm" 27 #include "mp3.xpm"
28 28
29 #include <math.h> 29 #include <math.h>
30 #include <audacious/util.h> 30 #include <audacious/util.h>
31 #include <gtk/gtk.h> 31 #include <gtk/gtk.h>
32 #include <gdk/gdkkeysyms.h>
32 33
33 /* yaz */ 34 /* yaz */
34 #include <langinfo.h> 35 #include <langinfo.h>
35 36
36 #ifndef NOGUI 37 #ifndef NOGUI
275 change_buttons(GtkWidget * object) 276 change_buttons(GtkWidget * object)
276 { 277 {
277 gtk_widget_set_sensitive(GTK_WIDGET(object), TRUE); 278 gtk_widget_set_sensitive(GTK_WIDGET(object), TRUE);
278 } 279 }
279 280
281 #ifndef NOGUI
282 static gboolean
283 on_fileinfo_window_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
284 {
285 g_return_val_if_fail(GTK_IS_WIDGET (widget), FALSE);
286
287 if (event->keyval == GDK_Escape)
288 {
289 gtk_widget_hide(widget);
290 }
291
292 return FALSE;
293 }
294 #endif
295
280 void create_window() 296 void create_window()
281 { 297 {
282 GtkWidget *vbox, *hbox, *left_vbox, *table; 298 GtkWidget *vbox, *hbox, *left_vbox, *table;
283 GtkWidget *mpeg_frame, *mpeg_box; 299 GtkWidget *mpeg_frame, *mpeg_box;
284 GtkWidget *label, *filename_hbox; 300 GtkWidget *label, *filename_hbox;
291 GDK_WINDOW_TYPE_HINT_DIALOG); 307 GDK_WINDOW_TYPE_HINT_DIALOG);
292 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); 308 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
293 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 309 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
294 g_signal_connect(G_OBJECT(window), "destroy", 310 g_signal_connect(G_OBJECT(window), "destroy",
295 G_CALLBACK(close_window), &window); 311 G_CALLBACK(close_window), &window);
312 g_signal_connect(G_OBJECT(window), "key-press-event",
313 G_CALLBACK(on_fileinfo_window_key_press), &window);
296 gtk_container_set_border_width(GTK_CONTAINER(window), 10); 314 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
297 315
298 vbox = gtk_vbox_new(FALSE, 10); 316 vbox = gtk_vbox_new(FALSE, 10);
299 gtk_container_add(GTK_CONTAINER(window), vbox); 317 gtk_container_add(GTK_CONTAINER(window), vbox);
300 318
538 g_signal_connect_swapped(G_OBJECT(cancel), "clicked", 556 g_signal_connect_swapped(G_OBJECT(cancel), "clicked",
539 G_CALLBACK(gtk_widget_destroy), 557 G_CALLBACK(gtk_widget_destroy),
540 G_OBJECT(window)); 558 G_OBJECT(window));
541 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); 559 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
542 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); 560 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
561 gtk_window_set_focus(GTK_WINDOW(window), cancel);
543 562
544 gtk_widget_show_all(window); 563 gtk_widget_show_all(window);
545 } 564 }
546 565
547 static void id3_frame_to_entry(char *framename, GtkEntry * entry) 566 static void id3_frame_to_entry(char *framename, GtkEntry * entry)