~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/ui/widget/imagetoggler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Authors:
 
3
 *   Jon A. Cruz
 
4
 *   Johan B. C. Engelen
 
5
 *
 
6
 * Copyright (C) 2006-2008 Authors
 
7
 *
 
8
 * Released under GNU GPL, read the file 'COPYING' for more information
 
9
 */
 
10
 
 
11
 
 
12
#include "ui/widget/imagetoggler.h"
 
13
 
 
14
#include <gtkmm/icontheme.h>
 
15
 
 
16
#include "widgets/icon.h"
 
17
 
 
18
namespace Inkscape {
 
19
namespace UI {
 
20
namespace Widget {
 
21
 
 
22
ImageToggler::ImageToggler( char const* on, char const* off) :
 
23
    Glib::ObjectBase(typeid(ImageToggler)),
 
24
    Gtk::CellRendererPixbuf(),
 
25
    _pixOnName(on),
 
26
    _pixOffName(off),
 
27
    _property_active(*this, "active", false),
 
28
    _property_activatable(*this, "activatable", true),
 
29
    _property_pixbuf_on(*this, "pixbuf_on", Glib::RefPtr<Gdk::Pixbuf>(0)),
 
30
    _property_pixbuf_off(*this, "pixbuf_off", Glib::RefPtr<Gdk::Pixbuf>(0))
 
31
{
 
32
    property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
 
33
    int phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION);
 
34
    Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
 
35
 
 
36
    if (icon_theme->has_icon(_pixOnName)) {
 
37
        _property_pixbuf_on = icon_theme->load_icon(_pixOnName, phys, (Gtk::IconLookupFlags)0);
 
38
    }
 
39
 
 
40
    if (icon_theme->has_icon(_pixOffName)) {
 
41
        _property_pixbuf_off = icon_theme->load_icon(_pixOffName, phys, (Gtk::IconLookupFlags)0);
 
42
    }
 
43
 
 
44
    property_pixbuf() = _property_pixbuf_off.get_value();
 
45
}
 
46
 
 
47
void
 
48
ImageToggler::get_size_vfunc( Gtk::Widget& widget,
 
49
                             const Gdk::Rectangle* cell_area,
 
50
                             int* x_offset,
 
51
                             int* y_offset,
 
52
                             int* width,
 
53
                             int* height ) const
 
54
{
 
55
    Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
 
56
 
 
57
    if ( width ) {
 
58
        *width += (*width) >> 1;
 
59
    }
 
60
    if ( height ) {
 
61
        *height += (*height) >> 1;
 
62
    }
 
63
}
 
64
 
 
65
 
 
66
void
 
67
ImageToggler::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
 
68
                           Gtk::Widget& widget,
 
69
                           const Gdk::Rectangle& background_area,
 
70
                           const Gdk::Rectangle& cell_area,
 
71
                           const Gdk::Rectangle& expose_area,
 
72
                           Gtk::CellRendererState flags )
 
73
{
 
74
    property_pixbuf() = _property_active.get_value() ? _property_pixbuf_on : _property_pixbuf_off;
 
75
    Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
 
76
}
 
77
 
 
78
bool
 
79
ImageToggler::activate_vfunc(GdkEvent* event,
 
80
                            Gtk::Widget& /*widget*/,
 
81
                            const Glib::ustring& path,
 
82
                            const Gdk::Rectangle& /*background_area*/,
 
83
                            const Gdk::Rectangle& /*cell_area*/,
 
84
                            Gtk::CellRendererState /*flags*/)
 
85
{
 
86
    _signal_pre_toggle.emit(event);
 
87
    _signal_toggled.emit(path);
 
88
 
 
89
    return false;
 
90
}
 
91
 
 
92
 
 
93
} // namespace Widget
 
94
} // namespace UI
 
95
} // namespace Inkscape
 
96
 
 
97
/*
 
98
  Local Variables:
 
99
  mode:c++
 
100
  c-file-style:"stroustrup"
 
101
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
102
  indent-tabs-mode:nil
 
103
  fill-column:99
 
104
  End:
 
105
*/
 
106
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 
107
 
 
108