~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/core/gimp-templates.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
23
23
#include <glib-object.h>
24
24
 
25
25
#include "libgimpbase/gimpbase.h"
 
26
#include "libgimpconfig/gimpconfig.h"
26
27
 
27
28
#include "core-types.h"
28
29
 
29
 
#include "config/gimpconfig.h"
30
 
#include "config/gimpconfig-error.h"
31
 
 
32
30
#include "gimp.h"
33
31
#include "gimp-templates.h"
34
32
#include "gimplist.h"
48
46
 
49
47
  filename = gimp_personal_rc_file ("templaterc");
50
48
 
51
 
  if (!gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
52
 
                                     filename, NULL, &error))
 
49
  if (gimp->be_verbose)
 
50
    g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
 
51
 
 
52
  if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
 
53
                                      filename, NULL, &error))
53
54
    {
54
55
      if (error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
55
56
        {
59
60
          filename = g_build_filename (gimp_sysconf_directory (),
60
61
                                       "templaterc", NULL);
61
62
 
62
 
          if (!gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
63
 
                                             filename, NULL, &error))
 
63
          if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
 
64
                                              filename, NULL, &error))
64
65
            {
65
 
              g_message (error->message);
 
66
              gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR,
 
67
                            "%s", error->message);
66
68
            }
67
69
        }
68
70
      else
69
71
        {
70
 
          g_message (error->message);
 
72
          gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
71
73
        }
72
74
 
73
75
      g_clear_error (&error);
84
86
  const gchar *header =
85
87
    "GIMP templaterc\n"
86
88
    "\n"
87
 
    "This file will be entirely rewritten every time you quit the gimp.";
 
89
    "This file will be entirely rewritten each time you exit.";
88
90
  const gchar *footer =
89
91
    "end of templaterc";
90
92
 
96
98
 
97
99
  filename = gimp_personal_rc_file ("templaterc");
98
100
 
 
101
  if (gimp->be_verbose)
 
102
    g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
 
103
 
99
104
  if (! gimp_config_serialize_to_file (GIMP_CONFIG (gimp->templates),
100
 
                                       filename,
101
 
                                       header, footer, NULL,
102
 
                                       &error))
 
105
                                       filename,
 
106
                                       header, footer, NULL,
 
107
                                       &error))
103
108
    {
104
 
      g_message (error->message);
 
109
      gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
105
110
      g_error_free (error);
106
111
    }
107
112
 
109
114
}
110
115
 
111
116
 
112
 
/*  just like gimp_list_get_child_by_name() but matches case-insensitive  */
 
117
/*  just like gimp_list_get_child_by_name() but matches case-insensitive
 
118
 *  and dpi/ppi-insensitive
 
119
 */
113
120
static GimpObject *
114
121
gimp_templates_migrate_get_child_by_name (const GimpContainer *container,
115
122
                                          const gchar         *name)
116
123
{
117
 
  GimpList *list = GIMP_LIST (container);
118
 
  GList    *glist;
 
124
  GimpList   *list   = GIMP_LIST (container);
 
125
  GimpObject *retval = NULL;
 
126
  GList      *glist;
119
127
 
120
128
  for (glist = list->list; glist; glist = g_list_next (glist))
121
129
    {
122
130
      GimpObject *object = glist->data;
123
 
 
124
 
      if (! g_ascii_strcasecmp (object->name, name))
125
 
        return object;
 
131
      gchar      *str1   = g_ascii_strdown (object->name, -1);
 
132
      gchar      *str2   = g_ascii_strdown (name, -1);
 
133
 
 
134
      if (! strcmp (str1, str2))
 
135
        {
 
136
          retval = object;
 
137
        }
 
138
      else
 
139
        {
 
140
          gchar *dpi = strstr (str1, "dpi");
 
141
 
 
142
          if (dpi)
 
143
            {
 
144
              strncpy (dpi, "ppi", 3);
 
145
 
 
146
              g_print ("replaced: %s\n", str1);
 
147
 
 
148
              if (! strcmp (str1, str2))
 
149
                retval = object;
 
150
            }
 
151
        }
 
152
 
 
153
      g_free (str1);
 
154
      g_free (str2);
126
155
    }
127
156
 
128
 
  return NULL;
 
157
  return retval;
129
158
}
130
159
 
131
160
/**
149
178
      gchar *tmp = g_build_filename (gimp_sysconf_directory (),
150
179
                                     "templaterc", NULL);
151
180
 
152
 
      if (olddir && strstr (olddir, "2.0"))
 
181
      if (olddir && (strstr (olddir, "2.0") || strstr (olddir, "2.2")))
153
182
        {
154
 
          /* We changed the spelling of a couple of template names
155
 
           * from upper to lower case between 2.0 and 2.2.
 
183
          /* We changed the spelling of a couple of template names:
 
184
           *
 
185
           * - from upper to lower case between 2.0 and 2.2
 
186
           * - from "dpi" to "ppi" between 2.2 and 2.4
156
187
           */
157
188
          GimpContainerClass *class = GIMP_CONTAINER_GET_CLASS (templates);
158
189
          gpointer            func  = class->get_child_by_name;