comparison src/img-view.c @ 84:ba3c39002a24

Fri Oct 20 08:00:08 2006 John Ellis <johne@verizon.net> * img-view.c, layout_image.c, layout_util.c: Keypress signal handler code clean-up round 1: the main windows. Also fixes [Shift]+[F] from deactivating full screen [F].
author gqview
date Fri, 20 Oct 2006 12:03:16 +0000
parents a4c1b7014e6e
children cade6a52a165
comparison
equal deleted inserted replaced
83:4a0091c0c231 84:ba3c39002a24
324 324
325 static gint view_window_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) 325 static gint view_window_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
326 { 326 {
327 ViewWindow *vw = data; 327 ViewWindow *vw = data;
328 ImageWindow *imd; 328 ImageWindow *imd;
329 gint stop_signal = FALSE; 329 gint stop_signal;
330 GtkWidget *menu; 330 GtkWidget *menu;
331 gint x = 0; 331 gint x = 0;
332 gint y = 0; 332 gint y = 0;
333 333
334 imd = view_window_active_image(vw); 334 imd = view_window_active_image(vw);
335 335
336 stop_signal = TRUE;
336 switch (event->keyval) 337 switch (event->keyval)
337 { 338 {
338 case GDK_Left: case GDK_KP_Left: 339 case GDK_Left: case GDK_KP_Left:
339 x -= 1; 340 x -= 1;
340 stop_signal = TRUE;
341 break; 341 break;
342 case GDK_Right: case GDK_KP_Right: 342 case GDK_Right: case GDK_KP_Right:
343 x += 1; 343 x += 1;
344 stop_signal = TRUE;
345 break; 344 break;
346 case GDK_Up: case GDK_KP_Up: 345 case GDK_Up: case GDK_KP_Up:
347 y -= 1; 346 y -= 1;
348 stop_signal = TRUE;
349 break; 347 break;
350 case GDK_Down: case GDK_KP_Down: 348 case GDK_Down: case GDK_KP_Down:
351 y += 1; 349 y += 1;
352 stop_signal = TRUE;
353 break; 350 break;
354 } 351 default:
355 352 stop_signal = FALSE;
356 if ( !(event->state & GDK_CONTROL_MASK) )
357 switch (event->keyval)
358 {
359 case GDK_Page_Up: case GDK_KP_Page_Up:
360 case GDK_BackSpace:
361 case 'B': case 'b':
362 view_step_prev(vw);
363 stop_signal = TRUE;
364 break; 353 break;
365 case GDK_Page_Down: case GDK_KP_Page_Down: 354 }
366 case GDK_space: 355
367 case 'N': case 'n': 356 if (x != 0 || y!= 0)
368 view_step_next(vw); 357 {
369 stop_signal = TRUE; 358 if (event->state & GDK_SHIFT_MASK)
370 break; 359 {
371 case GDK_Home: case GDK_KP_Home: 360 x *= 3;
372 view_step_to_end(vw, FALSE); 361 y *= 3;
373 stop_signal = TRUE; 362 }
374 break; 363
375 case GDK_End: case GDK_KP_End: 364 keyboard_scroll_calc(&x, &y, event);
376 view_step_to_end(vw, TRUE); 365 image_scroll(imd, x, y);
377 stop_signal = TRUE; 366 }
378 break; 367
379 case '+': case '=': case GDK_KP_Add: 368 if (stop_signal) return stop_signal;
380 image_zoom_adjust(imd, get_zoom_increment());
381 break;
382 case '-': case GDK_KP_Subtract:
383 image_zoom_adjust(imd, -get_zoom_increment());
384 break;
385 case 'X': case 'x': case GDK_KP_Multiply:
386 image_zoom_set(imd, 0.0);
387 break;
388 case 'Z': case 'z': case GDK_KP_Divide: case '1':
389 image_zoom_set(imd, 1.0);
390 break;
391 case '2':
392 image_zoom_set(imd, 2.0);
393 break;
394 case '3':
395 image_zoom_set(imd, 3.0);
396 break;
397 case '4':
398 image_zoom_set(imd, 4.0);
399 break;
400 case '7':
401 image_zoom_set(imd, -4.0);
402 break;
403 case '8':
404 image_zoom_set(imd, -3.0);
405 break;
406 case '9':
407 image_zoom_set(imd, -2.0);
408 break;
409 case 'W': case 'w':
410 image_zoom_set_fill_geometry(imd, FALSE);
411 break;
412 case 'H': case 'h':
413 image_zoom_set_fill_geometry(imd, TRUE);
414 break;
415 case 'R': case 'r':
416 if (!event->state & GDK_SHIFT_MASK)
417 {
418 image_reload(imd);
419 }
420 break;
421 case 'S': case 's':
422 if (vw->ss)
423 view_slideshow_stop(vw);
424 else
425 view_slideshow_start(vw);
426 stop_signal = TRUE;
427 break;
428 case 'P': case 'p':
429 slideshow_pause_toggle(vw->ss);
430 break;
431 case 'F': case 'f':
432 case 'V': case 'v':
433 view_fullscreen_toggle(vw, FALSE);
434 stop_signal = TRUE;
435 break;
436 case 'I': case 'i':
437 view_overlay_toggle(vw);
438 break;
439 case ']':
440 image_alter(imd, ALTER_ROTATE_90);
441 stop_signal = TRUE;
442 break;
443 case '[':
444 image_alter(imd, ALTER_ROTATE_90_CC);
445 stop_signal = TRUE;
446 break;
447 case GDK_Delete: case GDK_KP_Delete:
448 if (enable_delete_key)
449 {
450 file_util_delete(image_get_path(imd), NULL, imd->widget);
451 stop_signal = TRUE;
452 }
453 break;
454 case GDK_Escape:
455 if (vw->fs)
456 {
457 view_fullscreen_toggle(vw, TRUE);
458 }
459 else
460 {
461 gtk_widget_destroy(vw->window);
462 }
463 stop_signal = TRUE;
464 break;
465 case GDK_Menu:
466 case GDK_F10:
467 menu = view_popup_menu(vw);
468 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, view_window_menu_pos_cb, vw, 0, GDK_CURRENT_TIME);
469 stop_signal = TRUE;
470 break;
471 }
472 369
473 if (event->state & GDK_CONTROL_MASK) 370 if (event->state & GDK_CONTROL_MASK)
474 { 371 {
475 gint n = -1; 372 gint n = -1;
373
374 stop_signal = TRUE;
476 switch (event->keyval) 375 switch (event->keyval)
477 { 376 {
478 case '1': 377 case '1':
479 n = 0; 378 n = 0;
480 break; 379 break;
505 case '0': 404 case '0':
506 n = 9; 405 n = 9;
507 break; 406 break;
508 case 'C': case 'c': 407 case 'C': case 'c':
509 file_util_copy(image_get_path(imd), NULL, NULL, imd->widget); 408 file_util_copy(image_get_path(imd), NULL, NULL, imd->widget);
510 stop_signal = TRUE;
511 break; 409 break;
512 case 'M': case 'm': 410 case 'M': case 'm':
513 file_util_move(image_get_path(imd), NULL, NULL, imd->widget); 411 file_util_move(image_get_path(imd), NULL, NULL, imd->widget);
514 stop_signal = TRUE;
515 break; 412 break;
516 case 'R': case 'r': 413 case 'R': case 'r':
517 file_util_rename(image_get_path(imd), NULL, imd->widget); 414 file_util_rename(image_get_path(imd), NULL, imd->widget);
518 stop_signal = TRUE;
519 break; 415 break;
520 case 'D': case 'd': 416 case 'D': case 'd':
521 file_util_delete(image_get_path(imd), NULL, imd->widget); 417 file_util_delete(image_get_path(imd), NULL, imd->widget);
522 stop_signal = TRUE;
523 break; 418 break;
524 case 'P': case 'p': 419 case 'P': case 'p':
525 info_window_new(image_get_path(imd), NULL); 420 info_window_new(image_get_path(imd), NULL);
526 stop_signal = TRUE;
527 break; 421 break;
528 case 'W': case 'w': 422 case 'W': case 'w':
529 view_window_close(vw); 423 view_window_close(vw);
424 break;
425 default:
426 stop_signal = FALSE;
530 break; 427 break;
531 } 428 }
532 if (n != -1) 429 if (n != -1)
533 { 430 {
534 if (!editor_window_flag_set(n)) 431 if (!editor_window_flag_set(n))
539 start_editor_from_file(n, image_get_path(imd)); 436 start_editor_from_file(n, image_get_path(imd));
540 } 437 }
541 } 438 }
542 else if (event->state & GDK_SHIFT_MASK) 439 else if (event->state & GDK_SHIFT_MASK)
543 { 440 {
441 stop_signal = TRUE;
544 switch (event->keyval) 442 switch (event->keyval)
545 { 443 {
546 case 'R': case 'r': 444 case 'R': case 'r':
547 image_alter(imd, ALTER_ROTATE_180); 445 image_alter(imd, ALTER_ROTATE_180);
548 stop_signal = TRUE;
549 break; 446 break;
550 case 'M': case 'm': 447 case 'M': case 'm':
551 image_alter(imd, ALTER_MIRROR); 448 image_alter(imd, ALTER_MIRROR);
552 stop_signal = TRUE;
553 break; 449 break;
554 case 'F': case 'f': 450 case 'F': case 'f':
555 image_alter(imd, ALTER_FLIP); 451 image_alter(imd, ALTER_FLIP);
556 stop_signal = TRUE;
557 break; 452 break;
558 case 'G': case 'g': 453 case 'G': case 'g':
559 image_alter(imd, ALTER_DESATURATE); 454 image_alter(imd, ALTER_DESATURATE);
560 stop_signal = TRUE;
561 break; 455 break;
562 default: 456 default:
563 break; 457 stop_signal = FALSE;
564 } 458 break;
565 x *= 3; 459 }
566 y *= 3; 460 }
567 } 461 else
568 462 {
569 if (x != 0 || y!= 0) 463 stop_signal = TRUE;
570 { 464 switch (event->keyval)
571 keyboard_scroll_calc(&x, &y, event); 465 {
572 image_scroll(imd, x, y); 466 case GDK_Page_Up: case GDK_KP_Page_Up:
467 case GDK_BackSpace:
468 case 'B': case 'b':
469 view_step_prev(vw);
470 break;
471 case GDK_Page_Down: case GDK_KP_Page_Down:
472 case GDK_space:
473 case 'N': case 'n':
474 view_step_next(vw);
475 break;
476 case GDK_Home: case GDK_KP_Home:
477 view_step_to_end(vw, FALSE);
478 break;
479 case GDK_End: case GDK_KP_End:
480 view_step_to_end(vw, TRUE);
481 break;
482 case '+': case '=': case GDK_KP_Add:
483 image_zoom_adjust(imd, get_zoom_increment());
484 break;
485 case '-': case GDK_KP_Subtract:
486 image_zoom_adjust(imd, -get_zoom_increment());
487 break;
488 case 'X': case 'x': case GDK_KP_Multiply:
489 image_zoom_set(imd, 0.0);
490 break;
491 case 'Z': case 'z': case GDK_KP_Divide: case '1':
492 image_zoom_set(imd, 1.0);
493 break;
494 case '2':
495 image_zoom_set(imd, 2.0);
496 break;
497 case '3':
498 image_zoom_set(imd, 3.0);
499 break;
500 case '4':
501 image_zoom_set(imd, 4.0);
502 break;
503 case '7':
504 image_zoom_set(imd, -4.0);
505 break;
506 case '8':
507 image_zoom_set(imd, -3.0);
508 break;
509 case '9':
510 image_zoom_set(imd, -2.0);
511 break;
512 case 'W': case 'w':
513 image_zoom_set_fill_geometry(imd, FALSE);
514 break;
515 case 'H': case 'h':
516 image_zoom_set_fill_geometry(imd, TRUE);
517 break;
518 case 'R': case 'r':
519 image_reload(imd);
520 break;
521 case 'S': case 's':
522 if (vw->ss)
523 {
524 view_slideshow_stop(vw);
525 }
526 else
527 {
528 view_slideshow_start(vw);
529 }
530 break;
531 case 'P': case 'p':
532 slideshow_pause_toggle(vw->ss);
533 break;
534 case 'F': case 'f':
535 case 'V': case 'v':
536 view_fullscreen_toggle(vw, FALSE);
537 break;
538 case 'I': case 'i':
539 view_overlay_toggle(vw);
540 break;
541 case ']':
542 image_alter(imd, ALTER_ROTATE_90);
543 break;
544 case '[':
545 image_alter(imd, ALTER_ROTATE_90_CC);
546 break;
547 case GDK_Delete: case GDK_KP_Delete:
548 if (enable_delete_key)
549 {
550 file_util_delete(image_get_path(imd), NULL, imd->widget);
551 }
552 break;
553 case GDK_Escape:
554 if (vw->fs)
555 {
556 view_fullscreen_toggle(vw, TRUE);
557 }
558 else
559 {
560 gtk_widget_destroy(vw->window);
561 }
562 break;
563 case GDK_Menu:
564 case GDK_F10:
565 menu = view_popup_menu(vw);
566 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
567 view_window_menu_pos_cb, vw, 0, GDK_CURRENT_TIME);
568 break;
569 default:
570 stop_signal = FALSE;
571 break;
572 }
573 } 573 }
574 574
575 return stop_signal; 575 return stop_signal;
576 } 576 }
577 577