~canonical-dx-team/ubuntu/maverick/gtk+2.0/menuproxy

« back to all changes in this revision

Viewing changes to gtk/gen-paper-names.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-05-04 12:24:25 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20070504122425-0m8midgzrp40y8w2
Tags: 2.10.12-1ubuntu1
* Sync with Debian
* New upstream version:
  Fixed bugs:
  - 379414 file chooser warnings when changing path in the entry
  - 418585 GtkFileChooserDefault sizing code is not DPI independent
  - 419568 Crash in search if start with special letter
  - 435062 build dies with icon cache validation
  - 379399 Segfault to call gtk_print_operation_run twice.
  - 387889 cups backend has problems when there are too many printers
  - 418531 invalid read to gtkicontheme.c gtk_icon_theme_lookup_icon...
  - 423916 crash in color scheme code
  - 424042 Segmentation fault while quickly pressing Alt+arrows
  - 415260 Protect against negative indices when setting values in G...
  - 419171 XGetVisualInfo() may not set nxvisuals
  - 128852 Gdk cursors don't look good on win32
  - 344657 Ctrl-H doesn't toggle "Show Hidden Files" setting
  - 345345 PrintOperation::paginate is not emitted for class handler
  - 347567 GtkPrintOperation::end-print is not emitted if it's cance...
  - 369112 gtk_ui_manager_add_ui should accept unnamed separator
  - 392015 Selected menu item invisible on Windows Vista
  - 399253 MS-Windows Theme Bottom Tab placement rendering glitches
  - 399425 gtk_input_dialog_fill_axes() adds child to gtkscrolledwin...
  - 403251 [patch] little memory leak in GtkPrintJob
  - 403267 [patch] memory leak in GtkPageSetupUnixDialog
  - 403470 MS-Windows Theme tab placement other than on top leaks a ...
  - 404506 Windows system fonts that have multi-byte font names cann...
  - 405089 Incorrect window placement for GtkEventBox private window
  - 405515 Minor leak in gtkfilesystemmodel.c
  - 405539 gdk_pixbuf_save() for PNG saver can return FALSE without ...
  - 415681 gdk_window_clear_area includes an extra line and column o...
  - 418219 GtkRecentChooser should apply filter before sorting and c...
  - 418403 Scroll to printer after selecting it from settings
  - 421985 _gtk_print_operation_platform_backend_launch_preview
  - 421990 gtk_print_job_get_surface
  - 421993 gtk_print_operation_init
  - 423064 Conditional jump or move depends on uninitialised value(s...
  - 423722 Fix printing header in gtk-demo
  - 424168 gtk_print_operation_run on async preview
  - 425655 Don't install gtk+-unix-print-2.0.pc on non-UNIX platforms
  - 425786 GDK segfaults if XineramaQueryScreens fails
  - 428665 Lpr Backend gets stuck in infinite loop during gtk_enumer...
  - 429902 GtkPrintOperation leaks cairo contextes
  - 431997 First delay of GdkPixbufAnimationIter is wrong
  - 433242 Inconsistent scroll arrow position calculations
  - 433972 Placing gtk.Expander inside a gtk.TextView() changes gtk....
  - 434261 _gtk_toolbar_elide_underscores incorrectly handles some s...
  - 383354 ctrl-L should make 'Location' entry disappear
  - 418673 gtk_recent_manager_add_item
  - 429732 gtk_accel_group_finalize accesses invalid memory
  - 435028 WM_CLIENT_LEADER is wrong on the leader_window
  - 431067 Background of the header window is not updated
  - 338843 add recent files support inside the ui manager
  - 148535 add drop shadow to menus, tooltips, etc. under Windows XP
* debian/control.in:
  - Conflicts on ubuntulooks (<= 0.9.11-1)
* debian/patches/15_default-fallback-icon-theme.patch:
  - patch from Debian, fallback on gnome icon theme

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GTK - The GIMP Toolkit
 
2
 * Copyright (C) 2006 Matthias Clasen
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
#include <stdlib.h>
 
21
#include <stdio.h>
 
22
#include <string.h>
 
23
 
 
24
#include <glib.h>
 
25
 
 
26
#include "paper_names.c"
 
27
 
 
28
static const gint n_infos = G_N_ELEMENTS (standard_names);
 
29
static const gint n_extra = G_N_ELEMENTS (extra_ppd_names);
 
30
 
 
31
typedef struct {
 
32
  const gchar *s;
 
33
  gint         len;
 
34
  gint         suffix;
 
35
  gint         offset;
 
36
} NameInfo;
 
37
 
 
38
static NameInfo *names = NULL;
 
39
static gint n_names = 0;
 
40
 
 
41
static void
 
42
add_name (const gchar *name)
 
43
{
 
44
  names[n_names].s = name;
 
45
  names[n_names].len = strlen (name);
 
46
  names[n_names].suffix = -1;
 
47
  names[n_names].offset = 0;
 
48
 
 
49
  n_names++;
 
50
}
 
51
 
 
52
static gint
 
53
find_name (const gchar *name)
 
54
{
 
55
  gint i;
 
56
 
 
57
  if (!name)
 
58
    return -1;
 
59
 
 
60
  for (i = 0; i < n_names; i++)
 
61
    {
 
62
      if (strcmp (names[i].s, name) == 0)
 
63
        return names[i].offset;
 
64
    }
 
65
 
 
66
  fprintf (stderr, "BOO! %s not found\n", name);
 
67
 
 
68
  return -2;
 
69
}
 
70
 
 
71
#define MM_PER_INCH 25.4
 
72
#define POINTS_PER_INCH 72
 
73
 
 
74
static gboolean
 
75
parse_media_size (const gchar *size,
 
76
                  gdouble     *width_mm, 
 
77
                  gdouble     *height_mm)
 
78
{
 
79
  const gchar *p;
 
80
  gchar *e;
 
81
  gdouble short_dim, long_dim;
 
82
 
 
83
  p = size;
 
84
  
 
85
  short_dim = g_ascii_strtod (p, &e);
 
86
 
 
87
  if (p == e || *e != 'x')
 
88
    return FALSE;
 
89
 
 
90
  p = e + 1; /* Skip x */
 
91
 
 
92
  long_dim = g_ascii_strtod (p, &e);
 
93
 
 
94
  if (p == e)
 
95
    return TRUE;
 
96
 
 
97
  p = e;
 
98
 
 
99
  if (strcmp (p, "in") == 0)
 
100
    {
 
101
      short_dim = short_dim * MM_PER_INCH;
 
102
      long_dim = long_dim * MM_PER_INCH;
 
103
    }
 
104
  else if (strcmp (p, "mm") != 0)
 
105
    return FALSE;
 
106
 
 
107
  if (width_mm)
 
108
    *width_mm = short_dim;
 
109
  if (height_mm)
 
110
    *height_mm = long_dim;
 
111
  
 
112
  return TRUE;  
 
113
}
 
114
 
 
115
int 
 
116
main (int argc, char *argv[])
 
117
{
 
118
  gint i, j, offset;
 
119
  gdouble width, height;
 
120
 
 
121
  names = (NameInfo *) malloc (sizeof (NameInfo) * (4 + n_infos + 2 * n_extra));
 
122
  n_names = 0;
 
123
 
 
124
  /* collect names */
 
125
  for (i = 0; i < n_infos; i++)
 
126
    {
 
127
      add_name (standard_names[i].name);
 
128
      add_name (standard_names[i].display_name);
 
129
      if (standard_names[i].ppd_name)
 
130
        add_name (standard_names[i].ppd_name);
 
131
    }
 
132
 
 
133
  for (i = 0; i < n_extra; i++)
 
134
    {
 
135
      add_name (extra_ppd_names[i].ppd_name);
 
136
      add_name (extra_ppd_names[i].standard_name);
 
137
    }
 
138
 
 
139
  /* find suffixes and dupes */
 
140
  for (i = 0; i < n_names; i++)
 
141
    for (j = 0; j < n_names; j++)
 
142
      {
 
143
        if (i == j) continue;
 
144
        
 
145
        if (names[i].len < names[j].len ||
 
146
            (names[i].len == names[j].len && j < i))
 
147
          {
 
148
            if (strcmp (names[i].s, names[j].s + names[j].len - names[i].len) == 0)
 
149
              {
 
150
                names[i].suffix = j;
 
151
                break;
 
152
              }
 
153
          }
 
154
      }
 
155
  
 
156
  /* calculate offsets for regular entries */
 
157
  offset = 0;
 
158
  for (i = 0; i < n_names; i++)
 
159
    {
 
160
      if (names[i].suffix == -1)
 
161
        {
 
162
          names[i].offset = offset;
 
163
          offset += names[i].len + 1;
 
164
        }
 
165
    }
 
166
  
 
167
  /* calculate offsets for suffixes */
 
168
  for (i = 0; i < n_names; i++)
 
169
    {
 
170
      if (names[i].suffix != -1)
 
171
        {
 
172
          j = i;
 
173
          do {
 
174
            j = names[j].suffix;
 
175
          } while (names[j].suffix != -1);
 
176
          names[i].offset = names[j].offset + names[j].len - names[i].len;
 
177
        }
 
178
    }
 
179
    
 
180
  printf ("/* Generated by gen-paper-names */\n\n");
 
181
 
 
182
  /* write N_ marked names */
 
183
 
 
184
  printf ("#if 0\n");
 
185
  for (i = 0; i < n_infos; i++)
 
186
    printf ("/* translators, strip everything up to the first | */\n"
 
187
            "N_(\"paper size|%s\")\n", standard_names[i].display_name);
 
188
  printf ("#endif\n\n");
 
189
 
 
190
  /* write strings */
 
191
  printf ("const char _gtk_paper_names[] =");
 
192
  for (i = 0; i < n_names; i++)
 
193
    {
 
194
      if (names[i].suffix == -1)
 
195
        printf ("\n  \"%s\\0\"", names[i].s);
 
196
    }
 
197
  printf (";\n\n");
 
198
 
 
199
  /* dump PaperInfo array */
 
200
  printf ("typedef struct {\n"
 
201
          "  int name;\n"
 
202
          "  float width;\n"
 
203
          "  float height;\n"
 
204
          "  int display_name;\n"
 
205
          "  int ppd_name;\n"
 
206
          "} PaperInfo;\n\n"
 
207
          "const PaperInfo _gtk_standard_names_offsets[] = {\n");
 
208
 
 
209
  for (i = 0; i < n_infos; i++)
 
210
    {
 
211
      width = height = 0.0;
 
212
      if (!parse_media_size (standard_names[i].size, &width, &height))
 
213
        printf ("failed to parse size %s\n", standard_names[i].size);
 
214
 
 
215
      printf ("  { %4d, %g, %g, %4d, %4d },\n", 
 
216
              find_name (standard_names[i].name),
 
217
              width, height,
 
218
              find_name (standard_names[i].display_name),
 
219
              find_name (standard_names[i].ppd_name));
 
220
    }
 
221
  
 
222
  printf ("};\n\n");
 
223
 
 
224
 
 
225
  /* dump extras */
 
226
 
 
227
  printf ("const struct {\n"
 
228
          "  int ppd_name;\n"
 
229
          "  int standard_name;\n"
 
230
          "} _gtk_extra_ppd_names_offsets[] = {\n");
 
231
 
 
232
  for (i = 0; i < n_extra; i++)
 
233
    {
 
234
      printf ("  { %4d, %4d },\n", 
 
235
              find_name (extra_ppd_names[i].ppd_name),
 
236
              find_name (extra_ppd_names[i].standard_name));
 
237
    }
 
238
  
 
239
  printf ("};\n\n");
 
240
 
 
241
  return 0;
 
242
}