summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2007-09-26 07:44:18 +0000
committerjoncruz <joncruz@users.sourceforge.net>2007-09-26 07:44:18 +0000
commit05745991b3fd17634af5c2001c381b950be6a99a (patch)
tree9c316452326d7ee7403c6396b6b85dc5a536b5f1 /src
parentfix 1802374, 1736088 (diff)
downloadinkscape-05745991b3fd17634af5c2001c381b950be6a99a.tar.gz
inkscape-05745991b3fd17634af5c2001c381b950be6a99a.zip
Changed preference to use file chooser button
(bzr r3806)
Diffstat (limited to 'src')
-rw-r--r--src/color-profile.cpp2
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp5
-rw-r--r--src/ui/dialog/inkscape-preferences.h2
-rw-r--r--src/ui/widget/preferences-widget.cpp56
-rw-r--r--src/ui/widget/preferences-widget.h22
5 files changed, 58 insertions, 29 deletions
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index 5c5303e08..46bd1b803 100644
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -378,7 +378,7 @@ cmsHPROFILE Inkscape::colorprofile_get_system_profile_handle()
long long int which = prefs_get_int_attribute_limited( "options.displayprofile", "enable", 0, 0, 1 );
gchar const * uri = prefs_get_string_attribute("options.displayprofile", "uri");
- if ( which && uri ) {
+ if ( which && uri && *uri ) {
if ( lastURI != std::string(uri) ) {
if ( theOne ) {
cmsCloseProfile( theOne );
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 7ee381bff..a5c071dc3 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -650,11 +650,14 @@ void InkscapePreferences::initPageMisc()
_misc_cms_display.init( _("Enable display calibration"), "options.displayprofile", "enable", false);
_page_misc.add_line( false, "", _misc_cms_display, "",
_("Enables application of the display using an ICC profile."), true);
- _misc_cms_display_profile.init("options.displayprofile", "uri", true);
+ _misc_cms_display_profile.init("options.displayprofile", "uri");
_page_misc.add_line( false, _("Display profile:"), _misc_cms_display_profile, "",
_("The ICC profile to use to calibrate display output."), true);
#if ENABLE_LCMS
_misc_cms_display.signal_toggled().connect( sigc::ptr_fun(forceUpdates) );
+
+ _misc_cms_display_profile.signal_selection_changed().connect( sigc::ptr_fun(forceUpdates) );
+
#else
// disable it, but leave it visible
_misc_cms_display.set_sensitive( false );
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index 03ed72f63..1f53115ca 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -163,7 +163,7 @@ protected:
PrefCombo _misc_overs_bitmap;
PrefCheckButton _misc_cms_display;
- PrefEntry _misc_cms_display_profile;
+ PrefFileButton _misc_cms_display_profile;
PrefEntryButtonHBox _importexport_ocal_url;
PrefEntry _importexport_ocal_username;
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index 4de42f36f..243fe029d 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -8,7 +8,7 @@
* Copyright (C) 2004, 2006, 2007 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
- */
+ */
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -47,11 +47,11 @@ DialogPage::DialogPage()
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)
- {
+ {
w = &widget;
}
else
@@ -86,7 +86,7 @@ void DialogPage::add_line(bool indent, const Glib::ustring label, Gtk::Widget& w
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);
@@ -100,7 +100,7 @@ void DialogPage::add_line(bool indent, const Glib::ustring label, Gtk::Widget& w
else
((Gtk::HBox*)w)->pack_start(*suffix_widget,false,false);
}
-
+
if (tip != "")
{
_tooltips.set_tip (widget, tip);
@@ -113,11 +113,11 @@ void DialogPage::add_group_header(Glib::ustring 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);
- if (row != 1)
+ if (row != 1)
this->set_row_spacing(row - 1, 18);
}
}
@@ -127,7 +127,7 @@ void DialogPage::set_tip(Gtk::Widget& widget, const Glib::ustring& 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;
@@ -139,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
- {
+ {
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)
{
+ (void)default_value;
_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);
}
@@ -164,7 +165,7 @@ void PrefRadioButton::init(const Glib::ustring& label, const std::string& prefs_
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;
@@ -173,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)
- {
+ {
Gtk::RadioButtonGroup rbg = group_member->get_group();
this->set_group(rbg);
}
@@ -187,16 +188,16 @@ void PrefRadioButton::on_toggled()
{
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 )
- 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 )
- 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,
- 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;
@@ -204,7 +205,7 @@ void PrefSpinButton::init(const std::string& prefs_path, const std::string& attr
_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);
@@ -218,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);
- if (is_int)
+ if (is_int)
this->set_digits(0);
else if (step_increment < 0.1)
this->set_digits(4);
@@ -230,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
- {
+ {
if (_is_int)
if (_is_percent)
prefs_set_double_attribute(_prefs_path.c_str(), _attr.c_str(), this->get_value()/100.0);
@@ -262,7 +263,7 @@ void PrefCombo::init(const std::string& prefs_path, const std::string& attr,
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()]);
}
}
@@ -306,6 +307,19 @@ void PrefEntryButtonHBox::onRelatedButtonClickedCallback()
}
+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)
diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h
index b48672d39..72f010f13 100644
--- a/src/ui/widget/preferences-widget.h
+++ b/src/ui/widget/preferences-widget.h
@@ -23,6 +23,7 @@
#include <gtkmm/radiobutton.h>
#include <gtkmm/box.h>
#include <gtkmm/frame.h>
+#include <gtkmm/filechooserbutton.h>
#include <sigc++/sigc++.h>
//#include <glibmm/i18n.h>
@@ -33,7 +34,7 @@ namespace Widget {
class PrefCheckButton : public Gtk::CheckButton
{
public:
- void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+ void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
bool default_value);
protected:
std::string _prefs_path;
@@ -45,9 +46,9 @@ protected:
class PrefRadioButton : public Gtk::RadioButton
{
public:
- void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+ void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
int int_value, bool default_value, PrefRadioButton* group_member);
- void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+ void 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);
sigc::signal<void, bool> changed_signal;
protected:
@@ -68,7 +69,7 @@ class PrefSpinButton : public Gtk::SpinButton
{
public:
void 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);
protected:
std::string _prefs_path;
@@ -116,6 +117,17 @@ protected:
void onRelatedButtonClickedCallback();
};
+class PrefFileButton : public Gtk::FileChooserButton
+{
+public:
+ void init(const std::string& prefs_path, const std::string& attr);
+
+protected:
+ std::string _prefs_path;
+ std::string _attr;
+ void onFileChanged();
+};
+
class DialogPage : public Gtk::Table
{
public:
@@ -134,7 +146,7 @@ protected:
#endif //INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
-/*
+/*
Local Variables:
mode:c++
c-file-style:"stroustrup"