~ubuntu-branches/debian/sid/gnome-color-chooser/sid

« back to all changes in this revision

Viewing changes to src/checkbutton.cc

  • Committer: Bazaar Package Importer
  • Author(s): Werner Pantke
  • Date: 2008-01-11 14:09:32 UTC
  • Revision ID: james.westby@ubuntu.com-20080111140932-sdtlwa781q52bclm
Tags: upstream-0.2.3
ImportĀ upstreamĀ versionĀ 0.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2006-2007 W. Pantke <gnome-color-chooser@punk-ass-bitch.org>
 
2
//  
 
3
// This program is free software; you can redistribute it and/or modify
 
4
// it under the terms of the GNU General Public License as published by
 
5
// the Free Software Foundation; either version 2 of the License, or
 
6
// (at your option) any later version.
 
7
// 
 
8
// This program is distributed in the hope that it will be useful,
 
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
// GNU General Public License for more details.
 
12
// 
 
13
// You should have received a copy of the GNU General Public License
 
14
// along with this program; if not, write to the Free Software 
 
15
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
16
 
 
17
#include "checkbutton.h"
 
18
 
 
19
 
 
20
CheckButton::CheckButton(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade)
 
21
: Gtk::CheckButton(cobject)
 
22
{
 
23
  this->m_refGlade = refGlade;
 
24
}
 
25
 
 
26
CheckButton::CheckButton()
 
27
{
 
28
 
 
29
}
 
30
 
 
31
CheckButton::~CheckButton()
 
32
{
 
33
  
 
34
}
 
35
 
 
36
void CheckButton::init(int id, TreeHandler* config, string name) // for association with another widget
 
37
{
 
38
  this->isParamWidget = false;
 
39
  this->isEngineWidget = false;
 
40
  this->id = id;
 
41
  this->name = name;
 
42
  this->setConfig(config);
 
43
  ModWidget::register_widget(this);
 
44
  this->reload();
 
45
}
 
46
 
 
47
void CheckButton::init(int id, TreeHandler* config) // as a standalone widget
 
48
{
 
49
  this->isParamWidget = false;
 
50
  this->isEngineWidget = false;
 
51
  this->id = id;
 
52
  this->setConfig(config);
 
53
  ModWidget::register_widget(this);
 
54
  this->reload();
 
55
}
 
56
 
 
57
void CheckButton::init(string category, TreeHandler* config) // as engine widget
 
58
{
 
59
  this->isParamWidget = false;
 
60
  this->isEngineWidget = true;
 
61
  this->category = category;
 
62
  this->setConfig(config);
 
63
  ModWidget::register_widget(this);
 
64
  this->reload();
 
65
}
 
66
 
 
67
void CheckButton::init(string category, string id, TreeHandler* config, bool alone) // as param widget
 
68
{
 
69
  this->isEngineWidget = false;
 
70
  this->isParamWidget = true;
 
71
  this->isParamAloneWidget = alone;
 
72
  this->category = category;
 
73
  this->id_string = id;
 
74
  this->setConfig(config);
 
75
  this->reload();
 
76
}
 
77
 
 
78
void CheckButton::reload()
 
79
{
 
80
  if(isEngineWidget)
 
81
    this->set_active(m_pConfig->getEngineOverride(this->category));
 
82
  else if(isParamWidget)
 
83
  {
 
84
    if(isParamAloneWidget)
 
85
    {
 
86
      string value = "";
 
87
      string checked = "";
 
88
 
 
89
      if((value = m_pConfig->getValue(this->category, this->id_string)) != "" && 
 
90
            (checked = m_pConfig->getChecked(this->category, this->id_string)) != ""  &&
 
91
             value == checked)
 
92
        this->set_active(true);
 
93
      else
 
94
        this->set_active(false);
 
95
 
 
96
      this->set_sensitive(m_pConfig->getOverride(this->category, this->id_string));
 
97
 
 
98
    }
 
99
    else
 
100
      this->set_active(m_pConfig->getOverride(this->category, this->id_string));
 
101
    
 
102
  }
 
103
  else
 
104
    this->set_active(m_pConfig->getOverride(this->id));
 
105
}
 
106
 
 
107
char* CheckButton::getName()
 
108
{
 
109
  if(name == "")
 
110
    return NULL;
 
111
  else
 
112
    return (char*)(this->name.c_str());
 
113
}
 
114
 
 
115