~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/widgets/sp-color-notebook.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Ted Gould, Kees Cook
  • Date: 2009-06-24 14:00:43 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624140043-07stp20mry48hqup
Tags: 0.47~pre0-0ubuntu1
* New upstream release

[ Ted Gould ]
* debian/control: Adding libgsl0 and removing version specifics on boost

[ Kees Cook ]
* debian/watch: updated to run uupdate and mangle pre-release versions.
* Dropped patches that have been taken upstream:
  - 01_mips
  - 02-poppler-0.8.3
  - 03-chinese-inkscape
  - 05_fix_latex_patch
  - 06_gcc-4.4
  - 07_cdr2svg
  - 08_skip-bad-utf-on-pdf-import
  - 09_gtk-clist
  - 10_belarussian
  - 11_libpng
  - 12_desktop
  - 13_slider
  - 100_svg_import_improvements
  - 102_sp_pattern_painter_free
  - 103_bitmap_type_print

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <glibmm/i18n.h>
27
27
 
28
28
#include "../dialogs/dialog-events.h"
29
 
#include "../prefs-utils.h"
 
29
#include "../preferences.h"
30
30
#include "sp-color-notebook.h"
31
31
#include "spw-utilities.h"
32
32
#include "sp-color-scales.h"
55
55
#define XPAD 4
56
56
#define YPAD 1
57
57
 
58
 
GtkType
59
 
sp_color_notebook_get_type (void)
 
58
GType sp_color_notebook_get_type(void)
60
59
{
61
 
        static GtkType type = 0;
62
 
        if (!type) {
63
 
                GtkTypeInfo info = {
64
 
                        "SPColorNotebook",
65
 
                        sizeof (SPColorNotebook),
66
 
                        sizeof (SPColorNotebookClass),
67
 
                        (GtkClassInitFunc) sp_color_notebook_class_init,
68
 
                        (GtkObjectInitFunc) sp_color_notebook_init,
69
 
                        NULL, NULL, NULL
70
 
                };
71
 
                type = gtk_type_unique (SP_TYPE_COLOR_SELECTOR, &info);
72
 
        }
73
 
        return type;
 
60
    static GtkType type = 0;
 
61
    if (!type) {
 
62
        GTypeInfo info = {
 
63
            sizeof(SPColorNotebookClass),
 
64
            0, // base_init
 
65
            0, // base_finalize
 
66
            (GClassInitFunc)sp_color_notebook_class_init,
 
67
            0, // class_finalize
 
68
            0, // class_data
 
69
            sizeof(SPColorNotebook),
 
70
            0, // n_preallocs
 
71
            (GInstanceInitFunc)sp_color_notebook_init,
 
72
            0 // value_table
 
73
        };
 
74
        type = g_type_register_static(SP_TYPE_COLOR_SELECTOR, "SPColorNotebook", &info, static_cast<GTypeFlags>(0));
 
75
    }
 
76
    return type;
74
77
}
75
78
 
76
79
static void
94
97
 
95
98
static void
96
99
sp_color_notebook_switch_page(GtkNotebook *notebook,
97
 
                                                          GtkNotebookPage *page,
98
 
                                                          guint page_num,
99
 
                                                          SPColorNotebook *colorbook)
 
100
                              GtkNotebookPage *page,
 
101
                              guint page_num,
 
102
                              SPColorNotebook *colorbook)
100
103
{
101
 
        if ( colorbook )
102
 
        {
 
104
    if ( colorbook )
 
105
    {
103
106
        ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
104
107
        nb->switchPage( notebook, page, page_num );
105
108
 
106
 
        // remember the page we seitched to
107
 
        prefs_set_int_attribute ("colorselector", "page", page_num);
108
 
 
109
 
        }
 
109
        // remember the page we seitched to
 
110
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
111
        prefs->setInt("/colorselector/page", page_num);
 
112
    }
110
113
}
111
114
 
112
115
void ColorNotebook::switchPage(GtkNotebook*,
271
274
                      XPAD, YPAD);
272
275
 
273
276
        // restore the last active page
274
 
        gtk_notebook_set_current_page (GTK_NOTEBOOK (_book), prefs_get_int_attribute ("colorselector", "page", 0));
 
277
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
278
        gtk_notebook_set_current_page (GTK_NOTEBOOK (_book), prefs->getInt("/colorselector/page", 0));
275
279
 
276
280
        {
277
281
                gboolean found = FALSE;
444
448
    const gchar *t = gtk_entry_get_text( entry );
445
449
 
446
450
    if (t) {
447
 
        gchar *e = 0;
448
 
        guint rgba = strtoul (t, &e, 16);
449
 
        if ( e != t ) {
450
 
            ptrdiff_t len=e-t;
 
451
        Glib::ustring text = t;
 
452
        bool changed = false;
 
453
        if (!text.empty() && text[0] == '#') {
 
454
            changed = true;
 
455
            text.erase(0,1);
 
456
            if (text.size() == 6) {
 
457
                // it was a standard RGB hex
 
458
                unsigned int alph = SP_COLOR_F_TO_U(_alpha);
 
459
                gchar* tmp = g_strdup_printf("%02x", alph);
 
460
                text += tmp;
 
461
                g_free(tmp);
 
462
            }
 
463
        }
 
464
        gchar* str = g_strdup(text.c_str());
 
465
        gchar* end = 0;
 
466
        guint64 rgba = g_ascii_strtoull( str, &end, 16 );
 
467
        if ( end != str ) {
 
468
            ptrdiff_t len = end - str;
451
469
            if ( len < 8 ) {
452
470
                rgba = rgba << ( 4 * ( 8 - len ) );
453
471
            }
454
472
            _updatingrgba = TRUE;
 
473
            if ( changed ) {
 
474
                gtk_entry_set_text( entry, str );
 
475
            }
455
476
            SPColor color( rgba );
456
477
            setColorAlpha( color, SP_RGBA32_A_F(rgba), true );
457
478
            _updatingrgba = FALSE;
458
479
        }
 
480
        g_free(str);
459
481
    }
460
482
}
461
483