~ubuntu-branches/ubuntu/karmic/moon/karmic

« back to all changes in this revision

Viewing changes to src/cornerradius.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-14 12:01:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090214120108-06539vb25vhbd8bn
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * cornerradius.cpp: CornerRadius parsing
 
3
 *
 
4
 * Contact:
 
5
 *   Moonlight List (moonlight-list@lists.ximian.com)
 
6
 *
 
7
 * Copyright 2007 Novell, Inc. (http://www.novell.com)
 
8
 *
 
9
 * See the LICENSE file included with the distribution for details.
 
10
 * 
 
11
 */
 
12
 
 
13
#include <config.h>
 
14
#include <string.h>
 
15
#include <stdlib.h>
 
16
#include <math.h>
 
17
 
 
18
#include "utils.h"
 
19
#include "cornerradius.h"
 
20
 
 
21
bool
 
22
CornerRadius::FromStr (const char *str, CornerRadius *corner)
 
23
{
 
24
        GArray *values = double_garray_from_str (str, 4);
 
25
        bool rv = true;
 
26
 
 
27
        *corner = NULL;
 
28
 
 
29
        switch (values->len) {
 
30
        case 1:
 
31
                *corner = CornerRadius (g_array_index (values, double, 0));
 
32
                break;
 
33
        case 2:
 
34
                g_warning ("CornerRadius specified with 2 values, '%s'.", str);
 
35
                rv = false;
 
36
                break;
 
37
        case 3:
 
38
                g_warning ("CornerRadius specified with 3 values, '%s'.", str);
 
39
                rv = false;
 
40
                break;
 
41
        case 4:
 
42
                *corner = CornerRadius (g_array_index (values, double, 0),
 
43
                                        g_array_index (values, double, 1),
 
44
                                        g_array_index (values, double, 2),
 
45
                                        g_array_index (values, double, 3));
 
46
                break;
 
47
        }
 
48
 
 
49
        if (values)
 
50
                g_array_free (values, TRUE);
 
51
 
 
52
        return rv;
 
53
}