~ubuntu-branches/ubuntu/karmic/tuxpaint-config/karmic

« back to all changes in this revision

Viewing changes to src/tuxpaint-config.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Ben Armstrong
  • Date: 2007-07-03 22:12:27 UTC
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20070703221227-rirc97czjvb417aj
Tags: upstream-0.0.8
ImportĀ upstreamĀ versionĀ 0.0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
  Tux Paint Configuration Tool - A GUI configuration editor for Tux Paint,
5
5
                                 a simpel drawing program for children.
6
6
 
7
 
  Copyright (c) 2004
 
7
  Copyright (c) 2002-2007
8
8
  
9
9
  Torsten Giebl <wizard@turricane.org>
10
10
  Jan Wynholds
11
11
  Bill Kendrick <bill@newbreedsoftware.com>
12
12
 
13
 
  http://www.newbreedsoftware.com/tuxpaint/
 
13
  http://www.tuxpaint.org/
14
14
  
15
 
  November 12, 2002 - October 2, 2004
 
15
  November 12, 2002 - June 25, 2007
16
16
*/
17
17
 
18
18
 
27
27
#define gettext_noop(String) String
28
28
#endif
29
29
 
 
30
#if !defined (__WIN32__) && !defined(__APPLE__) && !defined(__BEOS__)
 
31
#include <paper.h>
 
32
#endif
 
33
 
30
34
#include "version.h"
31
35
#include "about.h"
32
36
 
33
37
 
34
38
#ifdef WIN32
35
 
 
36
 
extern char * g_win32_getlocale(void);
37
 
 
38
 
#define DOC_PREFIX "docs/"
39
 
#define DATA_PREFIX "data/"
40
39
#define LOCALEDIR "locale"
41
 
 
42
 
#define strcasecmp    stricmp
43
 
#define strncasecmp   strnicmp
44
 
#define snprintf      _snprintf
45
 
 
46
40
#endif
47
41
 
48
42
#include <errno.h>
61
55
 
62
56
#include "tuxpaint-config2.h"
63
57
 
64
 
#ifdef WIN32
65
 
/*
66
 
 *   The SDL stderr redirection trick doesn't seem to work for perror().
67
 
 *     This does pretty much the same thing.
68
 
 *     */
69
 
void win32_perror(const char *str)
70
 
{
71
 
  if ( str && *str )
72
 
      fprintf(stderr,"%s : ",str);
73
 
 
74
 
  fprintf(stderr, "%s [%d]\n",
75
 
          (errno<_sys_nerr)?_sys_errlist[errno]:"unknown",errno );
76
 
}
77
 
 
78
 
#define perror         win32_perror
79
 
#endif
80
 
 
81
 
 
82
 
 
83
 
 
84
58
/* Local function prototypes: */
85
59
 
86
60
void setup(int argc, char * argv[]);
89
63
 
90
64
int main(int argc, char * argv[])
91
65
{
 
66
  int res;
 
67
 
92
68
  setup(argc, argv);
93
69
 
94
 
  return ( mainloop(argc, argv) );
 
70
  res = mainloop(argc, argv);
 
71
 
 
72
#if !defined (__WIN32__) && !defined(__APPLE__) && !defined(__BEOS__)
 
73
  paperdone();
 
74
#endif
 
75
 
 
76
  return res;
95
77
}
96
78
 
97
79
 
109
91
  int i;
110
92
  int show_usage;
111
93
  int exit_val;
 
94
  const struct paper * ppr;
 
95
  int max_papersizes;
112
96
 
113
97
  show_usage = 0;
114
98
  exit_val = 0;
117
101
  {
118
102
    if (strcmp(argv[i], "--help") == 0)
119
103
    {
120
 
      printf("%s\n", about_text);
 
104
      unsigned int x, j, len;
 
105
      char buf[80];
 
106
 
 
107
      buf[0] = '\0';
 
108
      len = 0;
 
109
      x = 0;
 
110
 
 
111
      for (j = 0; j <= strlen(about_text); j++)
 
112
      {
 
113
        buf[len++] = about_text[j];
 
114
 
 
115
        if (about_text[j] == ' ' || about_text[j] == '\0')
 
116
        {
 
117
          if (x + len > 78)
 
118
          {
 
119
            printf("\n");
 
120
            x = 0;
 
121
          }
 
122
 
 
123
          buf[len] = '\0';
 
124
          printf("%s", buf);
 
125
          x += len;
 
126
 
 
127
          len = 0;
 
128
        }
 
129
      }
 
130
 
 
131
      printf("\n\n");
 
132
 
121
133
      exit(0);
122
134
    }
123
135
    else if (strcmp(argv[i], "--usage") == 0)
179
191
  textdomain("tuxpaint-config");
180
192
 
181
193
#endif
 
194
 
 
195
 
 
196
  /* Get available paper sizes: */
 
197
 
 
198
#if !defined (__WIN32__) && !defined(__APPLE__) && !defined(__BEOS__)
 
199
  paperinit();
 
200
 
 
201
  max_papersizes = 5;
 
202
  papersizes = (char * *) malloc(sizeof (char * *) * max_papersizes);
 
203
 
 
204
  papersizes[0] = strdup("(Use system's default)");
 
205
  num_papersizes = 1;
 
206
  ppr = paperfirst();
 
207
  
 
208
  do
 
209
  {
 
210
    if (ppr != NULL)
 
211
    {
 
212
      if (num_papersizes >= max_papersizes)
 
213
      {
 
214
        max_papersizes += 5;
 
215
        papersizes = (char * *) realloc(papersizes, sizeof(char * *) * max_papersizes);
 
216
      }
 
217
 
 
218
      papersizes[num_papersizes++] = strdup(papername(ppr));
 
219
    }
 
220
 
 
221
    ppr = papernext(ppr);
 
222
  }
 
223
  while (ppr != NULL);
 
224
 
 
225
#endif
182
226
}