source: tuxpaint-config/trunk/fuentes/src/tuxpaint-config.cxx @ 220

Last change on this file since 220 was 220, checked in by mabarracus, 3 years ago

added tuxpaint-config sources from trusty

File size: 4.9 KB
Line 
1/*
2  tuxpaint-config.c
3
4  Tux Paint Configuration Tool - A GUI configuration editor for Tux Paint,
5                                 a simpel drawing program for children.
6
7  Copyright (c) 2002-2008
8 
9  Torsten Giebl <wizard@turricane.org>
10  Jan Wynholds
11  Bill Kendrick <bill@newbreedsoftware.com>
12
13  http://www.tuxpaint.org/
14 
15  November 12, 2002 - July 14, 2008
16*/
17
18
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23#include <locale.h>
24
25#include <libintl.h>
26#ifndef gettext_noop
27#define gettext_noop(String) String
28#endif
29
30#if !defined (__WIN32__) && !defined(__APPLE__) && !defined(__BEOS__)
31#include <paper.h>
32#endif
33
34#include "version.h"
35#include "about.h"
36
37
38#ifdef WIN32
39#define LOCALEDIR "locale"
40#endif
41
42#include <errno.h>
43
44#include <FL/Fl.H>
45#include <FL/Fl_Window.H>
46#include <FL/Fl_Box.H>
47
48#if !defined(Fl_H)
49#error "---------------------------------------------------"
50#error "If you installed FLTK from a package, be sure to get"
51#error "the development package, as well!"
52#error "(e.g., 'libfltk1-dev.rpm')"
53#error "---------------------------------------------------"
54#endif
55
56#include "tuxpaint-config2.h"
57
58/* Local function prototypes: */
59
60void setup(int argc, char * argv[]);
61int mainloop(int argc, char * argv[]);
62
63
64int main(int argc, char * argv[])
65{
66  int res;
67
68  setup(argc, argv);
69
70  res = mainloop(argc, argv);
71
72#if !defined (__WIN32__) && !defined(__APPLE__) && !defined(__BEOS__)
73  paperdone();
74#endif
75
76  return res;
77}
78
79
80int mainloop(int argc, char * argv[])
81{
82    Fl::scheme ("none");       
83    Show_TPC_Window ();
84
85    return Fl::run ();
86}
87
88
89void setup(int argc, char * argv[])
90{
91  int i;
92  int show_usage;
93  int exit_val;
94   
95#if !defined (__WIN32__) && !defined(__APPLE__) && !defined(__BEOS__)
96  const struct paper * ppr;
97  int max_papersizes;
98#endif
99   
100  show_usage = 0;
101  exit_val = 0;
102
103  for (i = 1; i < argc; i++)
104  {
105    if (strcmp(argv[i], "--help") == 0)
106    {
107      unsigned int x, j, len;
108      char buf[80];
109
110      buf[0] = '\0';
111      len = 0;
112      x = 0;
113
114      for (j = 0; j <= strlen(about_text); j++)
115      {
116        buf[len++] = about_text[j];
117
118        if (about_text[j] == ' ' || about_text[j] == '\0')
119        {
120          if (x + len > 78)
121          {
122            printf("\n");
123            x = 0;
124          }
125
126          buf[len] = '\0';
127          printf("%s", buf);
128          x += len;
129
130          len = 0;
131        }
132      }
133
134      printf("\n\n");
135
136      exit(0);
137    }
138    else if (strcmp(argv[i], "--usage") == 0)
139    {
140      show_usage = 1;
141      exit_val = 0;
142    }
143    else if (strcmp(argv[i], "--copying") == 0)
144    {
145      /* FIXME: Copying! */
146      printf("\nTux Paint Config. version " VER_VERSION ", " VER_DATE "\n\n");
147
148      printf("This program is free software; you can redistribute it\n"
149             "and/or modify it under the terms of the GNU General Public\n"
150             "License as published by the Free Software Foundation;\n"
151             "either version 2 of the License, or (at your option) any\n"
152             "later version.\n"
153             "\n"
154             "This program is distributed in the hope that it will be\n"
155             "useful and entertaining, but WITHOUT ANY WARRANTY; without\n"
156             "even the implied warranty of MERCHANTABILITY or FITNESS\n"
157             "FOR A PARTICULAR PURPOSE.  See the GNU General Public\n"
158             "License for more details.\n"
159             "\n"
160             "You should have received a copy of the GNU General Public\n"
161             "License along with this program; if not, write to the Free\n"
162             "Software Foundation, Inc., 59 Temple Place, Suite 330,\n"
163             "Boston, MA  02111-1307  USA\n\n");
164        exit(0); 
165    }
166    else if (strcmp(argv[i], "--version") == 0)
167    {
168      printf("Tux Paint Config. version " VER_VERSION ", " VER_DATE "\n");
169      exit(0);
170    }
171    else
172    {
173      show_usage = 1;
174      exit_val = 1;
175    }
176  }
177
178  if (show_usage)
179  {
180    printf("Usage: %s [--version | --copying | --usage | --help]\n",
181           argv[0]);
182
183    /* Kluge to get around OS X sending arguments to apps; jdrake 2004-10-02 */
184#ifndef __APPLE__
185    exit(exit_val);
186#endif
187  }
188
189
190  setlocale(LC_ALL,"");
191
192  bindtextdomain("tuxpaint-config", LOCALEDIR);
193  /* Old version of glibc does not have bind_textdomain_codeset() */
194#if defined __WIN32 || __GLIBC__ && __GLIBC__ == 2 && __GLIBC_MINOR__ >=2 || __GLIBC__ > 2 || __APPLE__
195  bind_textdomain_codeset("tuxpaint-config", "UTF-8");
196#endif
197  textdomain("tuxpaint-config");
198
199
200  /* Get available paper sizes: */
201
202#if !defined (__WIN32__) && !defined(__APPLE__) && !defined(__BEOS__)
203  paperinit();
204
205  max_papersizes = 5;
206  papersizes = (char * *) malloc(sizeof (char * *) * max_papersizes);
207
208  papersizes[0] = strdup(gettext("(Use system's default)"));
209  num_papersizes = 1;
210  ppr = paperfirst();
211 
212  do
213  {
214    if (ppr != NULL)
215    {
216      if (num_papersizes >= max_papersizes)
217      {
218        max_papersizes += 5;
219        papersizes = (char * *) realloc(papersizes, sizeof(char * *) * max_papersizes);
220      }
221
222      papersizes[num_papersizes++] = strdup(papername(ppr));
223    }
224
225    ppr = papernext(ppr);
226  }
227  while (ppr != NULL);
228
229#endif
230}
Note: See TracBrowser for help on using the repository browser.