A Simple X Image Viewer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

139 lines
6.0 KiB

  1. #ifdef _WINDOW_CONFIG
  2. /* default window dimensions (overwritten via -g option): */
  3. enum {
  4. WIN_WIDTH = 800,
  5. WIN_HEIGHT = 600
  6. };
  7. /* default color for window background: */
  8. static const char * const BG_COLOR = "#777777";
  9. /* default color for thumbnail selection: */
  10. static const char * const SEL_COLOR = "#DDDDDD";
  11. /* (see X(7) section "COLOR NAMES" for valid values) */
  12. #endif
  13. #ifdef _IMAGE_CONFIG
  14. /* how should images be scaled when they are loaded?
  15. * (also controllable via -d/-s/-Z/-z options)
  16. * SCALE_DOWN: 100%, but fit large images into window,
  17. * SCALE_FIT: fit all images into window,
  18. * SCALE_ZOOM: use current zoom level, 100% at startup
  19. */
  20. static const scalemode_t SCALE_MODE = SCALE_DOWN;
  21. /* levels (percent) to use when zooming via '-' and '+': */
  22. static const float zoom_levels[] = {
  23. 12.5, 25.0, 50.0, 75.0,
  24. 100.0, 150.0, 200.0, 400.0, 800.0
  25. };
  26. /* default settings for multi-frame gif images: */
  27. enum {
  28. GIF_DELAY = 100, /* delay time (in ms) */
  29. GIF_AUTOPLAY = 1, /* autoplay when loaded [0/1] */
  30. GIF_LOOP = 0 /* endless loop [0/1] */
  31. };
  32. #endif
  33. #ifdef _THUMBS_CONFIG
  34. /* default dimension of thumbnails (width == height): */
  35. enum { THUMB_SIZE = 60 };
  36. #endif
  37. #ifdef _MAPPINGS_CONFIG
  38. /* keyboard mappings for image and thumbnail mode: */
  39. static const keymap_t keys[] = {
  40. /* ctrl key function argument */
  41. { False, XK_q, it_quit, (arg_t) None },
  42. { False, XK_Return, it_switch_mode, (arg_t) None },
  43. { False, XK_f, it_toggle_fullscreen, (arg_t) None },
  44. { False, XK_r, it_reload_image, (arg_t) None },
  45. { False, XK_D, it_remove_image, (arg_t) None },
  46. { False, XK_n, i_navigate, (arg_t) +1 },
  47. { False, XK_space, i_navigate, (arg_t) +1 },
  48. { False, XK_p, i_navigate, (arg_t) -1 },
  49. { False, XK_BackSpace, i_navigate, (arg_t) -1 },
  50. { False, XK_bracketright, i_navigate, (arg_t) +10 },
  51. { False, XK_bracketleft, i_navigate, (arg_t) -10 },
  52. { False, XK_g, it_first, (arg_t) None },
  53. { False, XK_G, it_last, (arg_t) None },
  54. { True, XK_n, i_navigate_frame, (arg_t) +1 },
  55. { True, XK_p, i_navigate_frame, (arg_t) -1 },
  56. { True, XK_space, i_toggle_animation, (arg_t) None },
  57. { False, XK_h, it_move, (arg_t) DIR_LEFT },
  58. { False, XK_Left, it_move, (arg_t) DIR_LEFT },
  59. { False, XK_j, it_move, (arg_t) DIR_DOWN },
  60. { False, XK_Down, it_move, (arg_t) DIR_DOWN },
  61. { False, XK_k, it_move, (arg_t) DIR_UP },
  62. { False, XK_Up, it_move, (arg_t) DIR_UP },
  63. { False, XK_l, it_move, (arg_t) DIR_RIGHT },
  64. { False, XK_Right, it_move, (arg_t) DIR_RIGHT },
  65. { True, XK_h, i_pan_screen, (arg_t) DIR_LEFT },
  66. { True, XK_Left, i_pan_screen, (arg_t) DIR_LEFT },
  67. { True, XK_j, i_pan_screen, (arg_t) DIR_DOWN },
  68. { True, XK_Down, i_pan_screen, (arg_t) DIR_DOWN },
  69. { True, XK_k, i_pan_screen, (arg_t) DIR_UP },
  70. { True, XK_Up, i_pan_screen, (arg_t) DIR_UP },
  71. { True, XK_l, i_pan_screen, (arg_t) DIR_RIGHT },
  72. { True, XK_Right, i_pan_screen, (arg_t) DIR_RIGHT },
  73. { False, XK_H, i_pan_edge, (arg_t) DIR_LEFT },
  74. { False, XK_J, i_pan_edge, (arg_t) DIR_DOWN },
  75. { False, XK_K, i_pan_edge, (arg_t) DIR_UP },
  76. { False, XK_L, i_pan_edge, (arg_t) DIR_RIGHT },
  77. { False, XK_plus, i_zoom, (arg_t) +1 },
  78. { False, XK_equal, i_zoom, (arg_t) +1 },
  79. { False, XK_KP_Add, i_zoom, (arg_t) +1 },
  80. { False, XK_minus, i_zoom, (arg_t) -1 },
  81. { False, XK_KP_Subtract, i_zoom, (arg_t) -1 },
  82. { False, XK_0, i_zoom, (arg_t) None },
  83. { False, XK_KP_0, i_zoom, (arg_t) None },
  84. { False, XK_w, i_fit_to_win, (arg_t) None },
  85. { False, XK_W, i_fit_to_img, (arg_t) None },
  86. { False, XK_less, i_rotate, (arg_t) DIR_LEFT },
  87. { False, XK_greater, i_rotate, (arg_t) DIR_RIGHT },
  88. { False, XK_a, i_toggle_antialias, (arg_t) None },
  89. { False, XK_A, it_toggle_alpha, (arg_t) None },
  90. /* open current image with given program: */
  91. { True, XK_g, it_open_with, (arg_t) "gimp" },
  92. /* run shell command line on current file ("$SXIV_IMG"): */
  93. { True, XK_less, it_shell_cmd, (arg_t) \
  94. "mogrify -rotate -90 \"$SXIV_IMG\"" },
  95. { True, XK_greater, it_shell_cmd, (arg_t) \
  96. "mogrify -rotate +90 \"$SXIV_IMG\"" },
  97. { True, XK_comma, it_shell_cmd, (arg_t) \
  98. "jpegtran -rotate 270 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" },
  99. { True, XK_period, it_shell_cmd, (arg_t) \
  100. "jpegtran -rotate 90 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" },
  101. };
  102. /* mouse button mappings for image mode: */
  103. static const button_t buttons[] = {
  104. /* ctrl shift button function argument */
  105. { False, False, Button1, i_navigate, (arg_t) +1 },
  106. { False, False, Button3, i_navigate, (arg_t) -1 },
  107. { False, False, Button2, i_drag, (arg_t) None },
  108. { False, False, Button4, it_move, (arg_t) DIR_UP },
  109. { False, False, Button5, it_move, (arg_t) DIR_DOWN },
  110. { False, True, Button4, it_move, (arg_t) DIR_LEFT },
  111. { False, True, Button5, it_move, (arg_t) DIR_RIGHT },
  112. { True, False, Button4, i_zoom, (arg_t) +1 },
  113. { True, False, Button5, i_zoom, (arg_t) -1 },
  114. };
  115. #endif