index c45952c839aea9762f5406fbd67cfdd978867790..6c5473caa062ca39e0e64f0e0257cde57170c024 100644 (file)
*
* Authors:
* Marco Scholten
*
* Authors:
* Marco Scholten
+ * Bruno Dilly <bruno.dilly@gmail.com>
*
*
- * Copyright (C) 2004, 2006 Authors
+ * Copyright (C) 2004, 2006, 2007 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
- */
+ */
#ifdef HAVE_CONFIG_H
# include <config.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
void DialogPage::add_line(bool indent, const Glib::ustring label, Gtk::Widget& widget, const Glib::ustring suffix, const Glib::ustring& tip, bool expand_widget)
{
void DialogPage::add_line(bool indent, const Glib::ustring label, Gtk::Widget& widget, const Glib::ustring suffix, const Glib::ustring& tip, bool expand_widget)
{
- int start_col;
+ int start_col;
int row = this->property_n_rows();
Gtk::Widget* w;
if (expand_widget)
int row = this->property_n_rows();
Gtk::Widget* w;
if (expand_widget)
- {
+ {
w = &widget;
}
else
w = &widget;
}
else
alignment->set_padding(0, 0, 12, 0);
alignment->add(*w);
this->attach(*alignment, start_col, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(), 0, 0);
alignment->set_padding(0, 0, 12, 0);
alignment->add(*w);
this->attach(*alignment, start_col, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(), 0, 0);
- }
+ }
else
{
this->attach(*w, start_col, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(), 0, 0);
else
{
this->attach(*w, start_col, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(), 0, 0);
else
((Gtk::HBox*)w)->pack_start(*suffix_widget,false,false);
}
else
((Gtk::HBox*)w)->pack_start(*suffix_widget,false,false);
}
-
+
if (tip != "")
{
_tooltips.set_tip (widget, tip);
if (tip != "")
{
_tooltips.set_tip (widget, tip);
int row = this->property_n_rows();
if (name != "")
{
int row = this->property_n_rows();
if (name != "")
{
- Gtk::Label* label_widget = Gtk::manage(new Gtk::Label(Glib::ustring(/*"<span size='large'>*/"<b>") + name +
+ Gtk::Label* label_widget = Gtk::manage(new Gtk::Label(Glib::ustring(/*"<span size='large'>*/"<b>") + name +
Glib::ustring("</b>"/*</span>"*/) , Gtk::ALIGN_LEFT , Gtk::ALIGN_CENTER, true));
label_widget->set_use_markup(true);
this->attach(*label_widget , 0, 4, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
Glib::ustring("</b>"/*</span>"*/) , Gtk::ALIGN_LEFT , Gtk::ALIGN_CENTER, true));
label_widget->set_use_markup(true);
this->attach(*label_widget , 0, 4, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
- if (row != 1)
+ if (row != 1)
this->set_row_spacing(row - 1, 18);
}
}
this->set_row_spacing(row - 1, 18);
}
}
_tooltips.set_tip (widget, tip);
}
_tooltips.set_tip (widget, tip);
}
-void PrefCheckButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+void PrefCheckButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
bool default_value)
{
_prefs_path = prefs_path;
bool default_value)
{
_prefs_path = prefs_path;
@@ -138,21 +139,22 @@ void PrefCheckButton::init(const Glib::ustring& label, const std::string& prefs_
void PrefCheckButton::on_toggled()
{
if (this->is_visible()) //only take action if the user toggled it
void PrefCheckButton::on_toggled()
{
if (this->is_visible()) //only take action if the user toggled it
- {
+ {
prefs_set_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int) this->get_active());
}
}
prefs_set_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int) this->get_active());
}
}
-void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
const std::string& string_value, bool default_value, PrefRadioButton* group_member)
{
const std::string& string_value, bool default_value, PrefRadioButton* group_member)
{
+ (void)default_value;
_value_type = VAL_STRING;
_prefs_path = prefs_path;
_attr = attr;
_string_value = string_value;
this->set_label(label);
if (group_member)
_value_type = VAL_STRING;
_prefs_path = prefs_path;
_attr = attr;
_string_value = string_value;
this->set_label(label);
if (group_member)
- {
+ {
Gtk::RadioButtonGroup rbg = group_member->get_group();
this->set_group(rbg);
}
Gtk::RadioButtonGroup rbg = group_member->get_group();
this->set_group(rbg);
}
@@ -163,7 +165,7 @@ void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_
this->set_active( false );
}
this->set_active( false );
}
-void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
int int_value, bool default_value, PrefRadioButton* group_member)
{
_value_type = VAL_INT;
int int_value, bool default_value, PrefRadioButton* group_member)
{
_value_type = VAL_INT;
@@ -172,7 +174,7 @@ void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_
_int_value = int_value;
this->set_label(label);
if (group_member)
_int_value = int_value;
this->set_label(label);
if (group_member)
- {
+ {
Gtk::RadioButtonGroup rbg = group_member->get_group();
this->set_group(rbg);
}
Gtk::RadioButtonGroup rbg = group_member->get_group();
this->set_group(rbg);
}
{
this->changed_signal.emit(this->get_active());
if (this->is_visible() && this->get_active() ) //only take action if toggled by user (to active)
{
this->changed_signal.emit(this->get_active());
if (this->is_visible() && this->get_active() ) //only take action if toggled by user (to active)
- {
+ {
if ( _value_type == VAL_STRING )
if ( _value_type == VAL_STRING )
- prefs_set_string_attribute ( _prefs_path.c_str(), _attr.c_str(), _string_value.c_str());
+ prefs_set_string_attribute ( _prefs_path.c_str(), _attr.c_str(), _string_value.c_str());
else if ( _value_type == VAL_INT )
else if ( _value_type == VAL_INT )
- prefs_set_int_attribute ( _prefs_path.c_str(), _attr.c_str(), _int_value);
+ prefs_set_int_attribute ( _prefs_path.c_str(), _attr.c_str(), _int_value);
}
}
void PrefSpinButton::init(const std::string& prefs_path, const std::string& attr,
}
}
void PrefSpinButton::init(const std::string& prefs_path, const std::string& attr,
- double lower, double upper, double step_increment, double page_increment,
+ double lower, double upper, double step_increment, double page_increment,
double default_value, bool is_int, bool is_percent)
{
_prefs_path = prefs_path;
double default_value, bool is_int, bool is_percent)
{
_prefs_path = prefs_path;
@@ -203,7 +205,7 @@ void PrefSpinButton::init(const std::string& prefs_path, const std::string& attr
_is_int = is_int;
_is_percent = is_percent;
_is_int = is_int;
_is_percent = is_percent;
- double value;
+ double value;
if (is_int)
if (is_percent)
value = 100 * prefs_get_double_attribute_limited (prefs_path.c_str(), attr.c_str(), default_value, lower/100.0, upper/100.0);
if (is_int)
if (is_percent)
value = 100 * prefs_get_double_attribute_limited (prefs_path.c_str(), attr.c_str(), default_value, lower/100.0, upper/100.0);
@@ -217,7 +219,7 @@ void PrefSpinButton::init(const std::string& prefs_path, const std::string& attr
this->set_numeric();
this->set_value (value);
this->set_width_chars(6);
this->set_numeric();
this->set_value (value);
this->set_width_chars(6);
- if (is_int)
+ if (is_int)
this->set_digits(0);
else if (step_increment < 0.1)
this->set_digits(4);
this->set_digits(0);
else if (step_increment < 0.1)
this->set_digits(4);
@@ -229,7 +231,7 @@ void PrefSpinButton::init(const std::string& prefs_path, const std::string& attr
void PrefSpinButton::on_value_changed()
{
if (this->is_visible()) //only take action if user changed value
void PrefSpinButton::on_value_changed()
{
if (this->is_visible()) //only take action if user changed value
- {
+ {
if (_is_int)
if (_is_percent)
prefs_set_double_attribute(_prefs_path.c_str(), _attr.c_str(), this->get_value()/100.0);
if (_is_int)
if (_is_percent)
prefs_set_double_attribute(_prefs_path.c_str(), _attr.c_str(), this->get_value()/100.0);
void PrefCombo::on_changed()
{
if (this->is_visible()) //only take action if user changed value
void PrefCombo::on_changed()
{
if (this->is_visible()) //only take action if user changed value
- {
+ {
prefs_set_int_attribute (_prefs_path.c_str(), _attr.c_str(), _values[this->get_active_row_number()]);
prefs_set_int_attribute (_prefs_path.c_str(), _attr.c_str(), _values[this->get_active_row_number()]);
- std::cout << "combo set: " << _prefs_path << " " << _attr << " " << _values[this->get_active_row_number()] << std::endl;
+ }
+}
+
+void PrefEntryButtonHBox::init(const std::string& prefs_path, const std::string& attr,
+ bool visibility, gchar* default_string)
+{
+ _prefs_path = prefs_path;
+ _attr = attr;
+ _default_string = default_string;
+ relatedEntry = new Gtk::Entry();
+ relatedButton = new Gtk::Button(_("Reset"));
+ relatedEntry->set_invisible_char('*');
+ relatedEntry->set_visibility(visibility);
+ relatedEntry->set_text(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str()));
+ this->pack_start(*relatedEntry);
+ this->pack_start(*relatedButton);
+ relatedButton->signal_clicked().connect(
+ sigc::mem_fun(*this, &PrefEntryButtonHBox::onRelatedButtonClickedCallback));
+ relatedEntry->signal_changed().connect(
+ sigc::mem_fun(*this, &PrefEntryButtonHBox::onRelatedEntryChangedCallback));
+}
+
+void PrefEntryButtonHBox::onRelatedEntryChangedCallback()
+{
+ if (this->is_visible()) //only take action if user changed value
+ {
+ prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(),
+ relatedEntry->get_text().c_str());
+ }
+}
+
+void PrefEntryButtonHBox::onRelatedButtonClickedCallback()
+{
+ if (this->is_visible()) //only take action if user changed value
+ {
+ prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(),
+ _default_string);
+ relatedEntry->set_text(_default_string);
+ }
+}
+
+
+void PrefFileButton::init(const std::string& prefs_path, const std::string& attr)
+{
+ _prefs_path = prefs_path;
+ _attr = attr;
+ select_filename(Glib::filename_from_utf8(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str())));
+
+ signal_selection_changed().connect(sigc::mem_fun(*this, &PrefFileButton::onFileChanged));
+}
+
+void PrefFileButton::onFileChanged()
+{
+ prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), Glib::filename_to_utf8(get_filename()).c_str());
+}
+
+void PrefEntry::init(const std::string& prefs_path, const std::string& attr,
+ bool visibility)
+{
+ _prefs_path = prefs_path;
+ _attr = attr;
+ this->set_invisible_char('*');
+ this->set_visibility(visibility);
+ this->set_text(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str()));
+}
+
+void PrefEntry::on_changed()
+{
+ if (this->is_visible()) //only take action if user changed value
+ {
+ prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), this->get_text().c_str());
+ }
+}
+
+void PrefColorPicker::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+ guint32 default_rgba)
+{
+ _prefs_path = prefs_path;
+ _attr = attr;
+ _title = label;
+ this->setRgba32( prefs_get_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int)default_rgba) );
+}
+
+void PrefColorPicker::on_changed (guint32 rgba)
+{
+ if (this->is_visible()) //only take action if the user toggled it
+ {
+ prefs_set_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int) rgba);
+ }
+}
+
+void PrefUnit::init(const std::string& prefs_path, const std::string& attr)
+{
+ _prefs_path = prefs_path;
+ _attr = attr;
+ setUnitType(UNIT_TYPE_LINEAR);
+ gchar const * prefval = prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str());
+ setUnit(prefval);
+}
+
+void PrefUnit::on_changed()
+{
+ if (this->is_visible()) //only take action if user changed value
+ {
+ prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), getUnitAbbr().c_str());
}
}
}
}