Changeset cd0ff9f24329c7de221bd7a72ae605afae4f759e
- Timestamp:
- 18/09/08 22:16:27 (5 years ago)
- Author:
- Armin Burgmeier <armin@…>
- Parents:
- ebd3ac7923390c60435abec25998db679fc50781
- Children:
- 04fe422de37ab2581560c02d9fbb84e47b49f86e
- git-committer:
- Armin Burgmeier <armin@arbur.net> / 2008-09-18T22:16:27Z+0200
- Message:
-
Added GOBBY_CONFIGDIR define, honor for config files
2008-09-18 Armin Burgmeier <armin@…>
- configure.ac: Added a new define, GOBBY_CONFIGDIR, that specifies
where Gobby shall store it's configuration files (preferences, known
documents, known hosts)
- inc/core/preferences.hpp:
- src/core/preferences.cpp: Added a security section with trust
file and security-policy entries, changed serialise to serialize for
consistency.
- src/window.cpp: Call preferences.serialize instead of serialise.
- src/core/browser.cpp: Use the security policy to create new XMPP
connections. Honor GOBBY_CONFIGDIR for known hosts file.
- src/core/documentinfostorage: Honor GOBBY_CONFIGDIR for known
documents file.
- src/main.cpp: Honor GOBBY_CONFIGDIR for config file.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rebd3ac7
|
rcd0ff9f
|
|
| | 1 | 2008-09-18 Armin Burgmeier <armin@arbur.net> |
| | 2 | |
| | 3 | * configure.ac: Added a new define, GOBBY_CONFIGDIR, that specifies |
| | 4 | where Gobby shall store it's configuration files (preferences, known |
| | 5 | documents, known hosts) |
| | 6 | |
| | 7 | * inc/core/preferences.hpp: |
| | 8 | * src/core/preferences.cpp: Added a security section with trust |
| | 9 | file and security-policy entries, changed serialise to serialize for |
| | 10 | consistency. |
| | 11 | |
| | 12 | * src/window.cpp: Call preferences.serialize instead of serialise. |
| | 13 | |
| | 14 | * src/core/browser.cpp: Use the security policy to create new XMPP |
| | 15 | connections. Honor GOBBY_CONFIGDIR for known hosts file. |
| | 16 | |
| | 17 | * src/core/documentinfostorage: Honor GOBBY_CONFIGDIR for known |
| | 18 | documents file. |
| | 19 | |
| | 20 | * src/main.cpp: Honor GOBBY_CONFIGDIR for config file. |
| | 21 | |
| 1 | 22 | 2008-09-17 Armin Burgmeier <armin@arbur.net> |
| 2 | 23 | |
-
|
rebd3ac7
|
rcd0ff9f
|
|
| 77 | 77 | AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["${GETTEXT_PACKAGE}"], [gettext domain]) |
| 78 | 78 | |
| | 79 | AC_DEFINE(GOBBY_CONFIGDIR, [".gobby-0.5"], |
| | 80 | [where to store Gobby's config files, |
| | 81 | relative to the user's home directory]) |
| | 82 | |
| 79 | 83 | AC_OUTPUT([ |
| 80 | 84 | Makefile |
-
|
rfb634fc
|
rcd0ff9f
|
|
| 25 | 25 | |
| 26 | 26 | #include <gtkmm/toolbar.h> |
| | 27 | |
| | 28 | #include <libinfinity/common/inf-xmpp-connection.h> |
| 27 | 29 | |
| 28 | 30 | namespace Gobby |
| … |
… |
|
| 90 | 92 | /** Serialises preferences back to config. |
| 91 | 93 | */ |
| 92 | | void serialise(Config& config) const; |
| | 94 | void serialize(Config& config) const; |
| 93 | 95 | |
| 94 | 96 | class User |
| … |
… |
|
| 96 | 98 | public: |
| 97 | 99 | User(Config::ParentEntry& entry); |
| 98 | | void serialise(Config::ParentEntry& entry) const; |
| | 100 | void serialize(Config::ParentEntry& entry) const; |
| 99 | 101 | |
| 100 | 102 | Option<Glib::ustring> name; |
| … |
… |
|
| 107 | 109 | public: |
| 108 | 110 | Editor(Config::ParentEntry& entry); |
| 109 | | void serialise(Config::ParentEntry& entry) const; |
| | 111 | void serialize(Config::ParentEntry& entry) const; |
| 110 | 112 | |
| 111 | 113 | Option<unsigned int> tab_width; |
| … |
… |
|
| 119 | 121 | public: |
| 120 | 122 | View(Config::ParentEntry& entry); |
| 121 | | void serialise(Config::ParentEntry& entry) const; |
| | 123 | void serialize(Config::ParentEntry& entry) const; |
| 122 | 124 | |
| 123 | 125 | Option<Gtk::WrapMode> wrap_mode; |
| … |
… |
|
| 133 | 135 | public: |
| 134 | 136 | Appearance(Config::ParentEntry& entry); |
| 135 | | void serialise(Config::ParentEntry& entry) const; |
| | 137 | void serialize(Config::ParentEntry& entry) const; |
| 136 | 138 | |
| | 139 | // TODO: Option<bool> use_system_default_toolbar_style |
| | 140 | // (sets toolbar_style by gconf). At least WITH_GNOME. |
| 137 | 141 | Option<Gtk::ToolbarStyle> toolbar_style; |
| 138 | 142 | Option<Pango::FontDescription> font; |
| … |
… |
|
| 146 | 150 | }; |
| 147 | 151 | |
| | 152 | class Security |
| | 153 | { |
| | 154 | public: |
| | 155 | Security(Config::ParentEntry& entry); |
| | 156 | void serialize(Config::ParentEntry& entry) const; |
| | 157 | |
| | 158 | Option<std::string> trust_file; |
| | 159 | Option<InfXmppConnectionSecurityPolicy> policy; |
| | 160 | }; |
| | 161 | |
| 148 | 162 | User user; |
| 149 | 163 | Editor editor; |
| 150 | 164 | View view; |
| 151 | 165 | Appearance appearance; |
| | 166 | Security security; |
| 152 | 167 | }; |
| 153 | 168 | |
-
|
r8667620
|
rcd0ff9f
|
|
| 72 | 72 | |
| 73 | 73 | Glib::ustring known_hosts_file = Glib::build_filename( |
| 74 | | Glib::get_home_dir(), ".gobby/known_hosts"); |
| | 74 | Glib::get_home_dir(), GOBBY_CONFIGDIR"/known_hosts"); |
| 75 | 75 | m_cert_manager = inf_gtk_certificate_manager_new( |
| 76 | 76 | parent.gobj(), m_xmpp_manager, |
| … |
… |
|
| 242 | 242 | xmpp = inf_xmpp_connection_new( |
| 243 | 243 | connection, INF_XMPP_CONNECTION_CLIENT, |
| 244 | | NULL, hostname.c_str(), NULL, NULL); |
| | 244 | NULL, hostname.c_str(), |
| | 245 | m_preferences.security.policy, NULL, NULL); |
| 245 | 246 | |
| 246 | 247 | inf_xmpp_manager_add_connection(m_xmpp_manager, xmpp); |
-
|
r092ccc3
|
rcd0ff9f
|
|
| 20 | 20 | #include "util/file.hpp" |
| 21 | 21 | |
| | 22 | #include "features.hpp" |
| | 23 | |
| 22 | 24 | #include <libxml++/nodes/textnode.h> |
| 23 | 25 | #include <libxml++/parsers/domparser.h> |
| … |
… |
|
| 88 | 90 | return Glib::build_filename( |
| 89 | 91 | Glib::get_home_dir(), |
| 90 | | Glib::build_filename(".gobby", "documents.xml")); |
| | 92 | Glib::build_filename( |
| | 93 | GOBBY_CONFIGDIR, |
| | 94 | "documents.xml")); |
| 91 | 95 | } |
| 92 | 96 | } |
-
|
rfb634fc
|
rcd0ff9f
|
|
| 23 | 23 | name(entry.get_value<Glib::ustring>("name", Glib::get_user_name())), |
| 24 | 24 | hue(entry.get_value<double>("hue", Glib::Rand().get_double())), |
| 25 | | host_directory(entry.get_value<std::string>("host-directory", Glib::build_filename(Glib::get_home_dir(), ".infinote"))) |
| | 25 | host_directory(entry.get_value<std::string>("host-directory", |
| | 26 | Glib::build_filename(Glib::get_home_dir(), ".infinote"))) |
| 26 | 27 | { |
| 27 | 28 | } |
| 28 | 29 | |
| 29 | | void Gobby::Preferences::User::serialise(Config::ParentEntry& entry) const |
| | 30 | void Gobby::Preferences::User::serialize(Config::ParentEntry& entry) const |
| 30 | 31 | { |
| 31 | 32 | entry.set_value("name", name); |
| … |
… |
|
| 35 | 36 | |
| 36 | 37 | Gobby::Preferences::Editor::Editor(Config::ParentEntry& entry): |
| 37 | | tab_width(entry.get_value<unsigned int>("tab_width", 8)), |
| 38 | | tab_spaces(entry.get_value<bool>("tab_insert_spaces", false)), |
| 39 | | indentation_auto(entry.get_value<bool>("auto_indentation", true)), |
| 40 | | homeend_smart(entry.get_value<bool>("smart_homeend", false) ) |
| | 38 | tab_width(entry.get_value<unsigned int>("tab-width", 8)), |
| | 39 | tab_spaces(entry.get_value<bool>("tab-insert-spaces", false)), |
| | 40 | indentation_auto(entry.get_value<bool>("auto-indentation", true)), |
| | 41 | homeend_smart(entry.get_value<bool>("smart-homeend", false) ) |
| 41 | 42 | { |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | | void Gobby::Preferences::Editor::serialise(Config::ParentEntry& entry) const |
| | 45 | void Gobby::Preferences::Editor::serialize(Config::ParentEntry& entry) const |
| 45 | 46 | { |
| 46 | | entry.set_value("tab_width", tab_width); |
| 47 | | entry.set_value("tab_insert_spaces", tab_spaces); |
| 48 | | entry.set_value("auto_indentation", indentation_auto); |
| 49 | | entry.set_value("smart_homeend", homeend_smart); |
| | 47 | entry.set_value("tab-width", tab_width); |
| | 48 | entry.set_value("tab-insert_spaces", tab_spaces); |
| | 49 | entry.set_value("auto-indentation", indentation_auto); |
| | 50 | entry.set_value("smart-homeend", homeend_smart); |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | 53 | Gobby::Preferences::View::View(Config::ParentEntry& entry): |
| 53 | | wrap_mode( |
| 54 | | static_cast<Gtk::WrapMode>( |
| 55 | | entry.get_value<int>( |
| 56 | | "wrap_mode", |
| 57 | | static_cast<int>(Gtk::WRAP_WORD_CHAR) |
| 58 | | ) |
| 59 | | ) |
| 60 | | ), |
| 61 | | linenum_display(entry.get_value<bool>("display_line_numbers", true)), |
| 62 | | curline_highlight( |
| 63 | | entry.get_value<bool>("highlight_current_line", true) |
| 64 | | ), |
| 65 | | margin_display(entry.get_value<bool>("margin_display", true) ), |
| 66 | | margin_pos(entry.get_value<unsigned int>("margin_position", 80) ), |
| 67 | | bracket_highlight( |
| 68 | | entry.get_value<bool>("highlight_matching_brackets", true) |
| 69 | | ) |
| | 54 | wrap_mode(static_cast<Gtk::WrapMode>(entry.get_value<int>( |
| | 55 | "wrap-mode", static_cast<int>(Gtk::WRAP_WORD_CHAR)))), |
| | 56 | linenum_display(entry.get_value<bool>("display-line-numbers", true)), |
| | 57 | curline_highlight(entry.get_value<bool>( |
| | 58 | "highlight-current-line", true)), |
| | 59 | margin_display(entry.get_value<bool>("margin-display", true) ), |
| | 60 | margin_pos(entry.get_value<unsigned int>("margin-position", 80) ), |
| | 61 | bracket_highlight(entry.get_value<bool>( |
| | 62 | "highlight-matching-brackets", true)) |
| 70 | 63 | { |
| 71 | 64 | } |
| 72 | 65 | |
| 73 | | void Gobby::Preferences::View::serialise(Config::ParentEntry& entry) const |
| | 66 | void Gobby::Preferences::View::serialize(Config::ParentEntry& entry) const |
| 74 | 67 | { |
| 75 | | entry.set_value("wrap_mode", static_cast<int>(wrap_mode)); |
| 76 | | entry.set_value("display_line_numbers", linenum_display); |
| 77 | | entry.set_value("highlight_current_line", curline_highlight); |
| 78 | | entry.set_value("margin_display", margin_display); |
| 79 | | entry.set_value("margin_position", margin_pos); |
| 80 | | entry.set_value("highlight_matching_brackets", bracket_highlight); |
| | 68 | entry.set_value("wrap-mode", static_cast<int>(wrap_mode)); |
| | 69 | entry.set_value("display-line-numbers", linenum_display); |
| | 70 | entry.set_value("highlight-current-line", curline_highlight); |
| | 71 | entry.set_value("margin-display", margin_display); |
| | 72 | entry.set_value("margin-position", margin_pos); |
| | 73 | entry.set_value("highlight-matching-brackets", bracket_highlight); |
| 81 | 74 | } |
| 82 | 75 | |
| 83 | 76 | Gobby::Preferences::Appearance::Appearance(Config::ParentEntry& entry): |
| 84 | | toolbar_style( |
| 85 | | static_cast<Gtk::ToolbarStyle>( |
| 86 | | entry.get_value<int>( |
| 87 | | "toolbar_style", |
| 88 | | // TODO: Get default value from gconf |
| 89 | | static_cast<int>(Gtk::TOOLBAR_BOTH) |
| 90 | | ) |
| 91 | | ) |
| 92 | | ), |
| | 77 | toolbar_style(static_cast<Gtk::ToolbarStyle>(entry.get_value<int>( |
| | 78 | "toolbar-style", static_cast<int>(Gtk::TOOLBAR_BOTH)))), |
| 93 | 79 | font(Pango::FontDescription(entry.get_value<Glib::ustring>( |
| 94 | 80 | "font", "Monospace 10"))), |
| 95 | | userlist_width(entry.get_value<unsigned int>("userlist_width", 150)), |
| 96 | | show_toolbar(entry.get_value<bool>("show_toolbar", true)), |
| 97 | | show_statusbar(entry.get_value<bool>("show_statusbar", true)), |
| 98 | | show_browser(entry.get_value<bool>("show_browser", true)), |
| 99 | | show_userlist(entry.get_value<bool>("show_userlist", true)) |
| | 81 | userlist_width(entry.get_value<unsigned int>("userlist-width", 150)), |
| | 82 | show_toolbar(entry.get_value<bool>("show-toolbar", true)), |
| | 83 | show_statusbar(entry.get_value<bool>("show-statusbar", true)), |
| | 84 | show_browser(entry.get_value<bool>("show-browser", true)), |
| | 85 | show_userlist(entry.get_value<bool>("show-userlist", true)) |
| 100 | 86 | { |
| 101 | 87 | } |
| 102 | 88 | |
| 103 | 89 | void Gobby::Preferences::Appearance:: |
| 104 | | serialise(Config::ParentEntry& entry) const |
| | 90 | serialize(Config::ParentEntry& entry) const |
| 105 | 91 | { |
| 106 | | entry.set_value("toolbar_style", static_cast<int>(toolbar_style) ); |
| | 92 | entry.set_value("toolbar-style", static_cast<int>(toolbar_style) ); |
| 107 | 93 | |
| 108 | 94 | entry.set_value( |
| 109 | 95 | "font", |
| 110 | | static_cast<const Pango::FontDescription&>(font).to_string() |
| 111 | | ); |
| | 96 | static_cast<const Pango::FontDescription&>(font).to_string()); |
| 112 | 97 | |
| 113 | | entry.set_value("userlist_width", userlist_width); |
| | 98 | entry.set_value("userlist-width", userlist_width); |
| 114 | 99 | |
| 115 | | entry.set_value("show_toolbar", show_toolbar); |
| 116 | | entry.set_value("show_statusbar", show_statusbar); |
| 117 | | entry.set_value("show_browser", show_browser); |
| 118 | | entry.set_value("show_userlist", show_userlist); |
| | 100 | entry.set_value("show-toolbar", show_toolbar); |
| | 101 | entry.set_value("show-statusbar", show_statusbar); |
| | 102 | entry.set_value("show-browser", show_browser); |
| | 103 | entry.set_value("show-userlist", show_userlist); |
| | 104 | } |
| | 105 | |
| | 106 | Gobby::Preferences::Security::Security(Config::ParentEntry& entry): |
| | 107 | trust_file(entry.get_value<std::string>("trust-file", "")), |
| | 108 | policy(static_cast<InfXmppConnectionSecurityPolicy>( |
| | 109 | entry.get_value<int>("policy", static_cast<int>( |
| | 110 | INF_XMPP_CONNECTION_SECURITY_BOTH_PREFER_TLS)))) |
| | 111 | { |
| | 112 | } |
| | 113 | |
| | 114 | void Gobby::Preferences::Security::serialize(Config::ParentEntry& entry) const |
| | 115 | { |
| | 116 | entry.set_value("trust-file", trust_file); |
| | 117 | entry.set_value("policy", static_cast<int>(policy)); |
| 119 | 118 | } |
| 120 | 119 | |
| … |
… |
|
| 123 | 122 | editor(config.get_root()["editor"]), |
| 124 | 123 | view(config.get_root()["view"]), |
| 125 | | appearance(config.get_root()["appearance"]) |
| | 124 | appearance(config.get_root()["appearance"]), |
| | 125 | security(config.get_root()["security"]) |
| 126 | 126 | { |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | | void Gobby::Preferences::serialise(Config& config) const |
| | 129 | void Gobby::Preferences::serialize(Config& config) const |
| 130 | 130 | { |
| 131 | 131 | // Serialise into config |
| 132 | | user.serialise(config.get_root()["user"]); |
| 133 | | editor.serialise(config.get_root()["editor"]); |
| 134 | | view.serialise(config.get_root()["view"]); |
| 135 | | appearance.serialise(config.get_root()["appearance"]); |
| | 132 | user.serialize(config.get_root()["user"]); |
| | 133 | editor.serialize(config.get_root()["editor"]); |
| | 134 | view.serialize(config.get_root()["view"]); |
| | 135 | appearance.serialize(config.get_root()["appearance"]); |
| | 136 | security.serialize(config.get_root()["security"]); |
| 136 | 137 | } |
| 137 | 138 | |
-
|
r1ad50d8
|
rcd0ff9f
|
|
| 325 | 325 | m_group_tab(_("Tab Stops") ), |
| 326 | 326 | m_group_indentation(_("Indentation") ), |
| 327 | | m_group_homeend(_("Home/End behaviour") ), |
| | 327 | m_group_homeend(_("Home/End Behaviour") ), |
| 328 | 328 | m_lbl_tab_width(_("Tab width:"), Gtk::ALIGN_RIGHT), |
| 329 | 329 | m_btn_tab_spaces(_("Insert spaces instead of tabs") ), |
| … |
… |
|
| 381 | 381 | |
| 382 | 382 | Gobby::PreferencesDialog::View::View(Preferences& preferences): |
| 383 | | m_group_wrap(_("Text wrapping") ), |
| 384 | | m_group_linenum(_("Line numbers") ), |
| 385 | | m_group_curline(_("Current line") ), |
| 386 | | m_group_margin(_("Right margin") ), |
| 387 | | m_group_bracket(_("Bracket matching") ), |
| | 383 | m_group_wrap(_("Text Wrapping") ), |
| | 384 | m_group_linenum(_("Line Numbers") ), |
| | 385 | m_group_curline(_("Current Line") ), |
| | 386 | m_group_margin(_("Right Margin") ), |
| | 387 | m_group_bracket(_("Bracket Matching") ), |
| 388 | 388 | m_btn_wrap_text(_("Enable text wrapping") ), |
| 389 | 389 | m_btn_wrap_words(_("Do not split words over two lines") ), |
-
|
rebd3ac7
|
rcd0ff9f
|
|
| 86 | 86 | |
| 87 | 87 | // Read the configuration |
| 88 | | Gobby::Config config(Glib::get_home_dir() + "/.gobby/config.xml"); |
| | 88 | Gobby::Config config(Glib::build_filename( |
| | 89 | Glib::get_home_dir(), |
| | 90 | GOBBY_CONFIGDIR"/config.xml")); |
| 89 | 91 | |
| 90 | 92 | // Create window |
-
|
r5b59013
|
rcd0ff9f
|
|
| 88 | 88 | { |
| 89 | 89 | // Serialise preferences into config |
| 90 | | m_preferences.serialise(m_config); |
| | 90 | m_preferences.serialize(m_config); |
| 91 | 91 | } |
| 92 | 92 | |