File: about.c

package info (click to toggle)
fuse-emulator 1.3.2%2Bdfsg1-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 10,456 kB
  • ctags: 9,261
  • sloc: ansic: 83,215; sh: 11,503; perl: 3,806; makefile: 1,000; yacc: 254; lex: 143
file content (92 lines) | stat: -rw-r--r-- 2,589 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* about.c: about dialog box
   Copyright (c) 2016 Sergio BaldovĂ­

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this program; if not, write to the Free Software Foundation, Inc.,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

   Author contact information:

   E-mail: serbalgi@gmail.com

*/

#include <config.h>

#include <stdio.h>

#include "widget.h"
#include "widget_internals.h"

int
widget_about_draw( void *data GCC_UNUSED )
{
  char buffer[80];
  int dialog_cols, string_width, margin, x, line;

  dialog_cols = 30;
  margin = 17;
  line = 0;

  widget_dialog_with_border( 1, 2, dialog_cols, 7+2 );
  widget_printstring( 10, 16, WIDGET_COLOUR_TITLE, "About Fuse" );

  string_width = widget_stringwidth( "the Free Unix Spectrum Emulator (Fuse)" );
  x = margin - 8 + ( dialog_cols * 8 - string_width ) / 2;
  widget_printstring( x, ++line * 8 + 24, WIDGET_COLOUR_FOREGROUND,
                      "the Free Unix Spectrum Emulator (Fuse)" );

  snprintf( buffer, 80, "Version %s", VERSION );
  string_width = widget_stringwidth( buffer );
  x = margin - 8 + ( dialog_cols * 8 - string_width ) / 2;
  widget_printstring( x, ++line * 8 + 24, WIDGET_COLOUR_FOREGROUND, buffer );

  ++line;

  string_width = widget_stringwidth( FUSE_COPYRIGHT );
  x = margin - 8 + ( dialog_cols * 8 - string_width ) / 2;
  widget_printstring( x, ++line * 8 + 24, WIDGET_COLOUR_FOREGROUND,
                      FUSE_COPYRIGHT );

  ++line;

  string_width = widget_stringwidth( PACKAGE_URL );
  x = margin - 8 + ( dialog_cols * 8 - string_width ) / 2;
  widget_printstring( x, ++line * 8 + 24, 0x09, PACKAGE_URL );

  widget_display_lines( 2, line + 3 );

  return 0;
}

void
widget_about_keyhandler( input_key key )
{
  switch( key ) {

  case INPUT_KEY_Escape:
  case INPUT_JOYSTICK_FIRE_2:
    widget_end_widget( WIDGET_FINISHED_CANCEL );
    return;

  case INPUT_KEY_Return:
  case INPUT_KEY_KP_Enter:
  case INPUT_JOYSTICK_FIRE_1:
    widget_end_widget( WIDGET_FINISHED_OK );
    return;

  default:	/* Keep gcc happy */
    break;

  }
}