Changeset a2a811e2605275a015a5c8d402ea98b2947afb86
- Timestamp:
- 09/19/08 00:01:22 (5 years ago)
- Parents:
- 04fe422de37ab2581560c02d9fbb84e47b49f86e
- Children:
- 823255b93401a002c0156230dbcbd5a508dd0baf
- git-committer:
- Armin Burgmeier <armin@arbur.net> / 2008-09-19T00:01:22Z+0200
- Files:
-
- 5 modified
-
ChangeLog (modified) (1 diff)
-
inc/core/browser.hpp (modified) (3 diffs)
-
inc/dialogs/preferencesdialog.hpp (modified) (3 diffs)
-
src/core/browser.cpp (modified) (5 diffs)
-
src/dialogs/preferencesdialog.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r04fe422 ra2a811e 1 2008-09-18 Armin Burgmeier <armin@arbur.net> 2 3 * inc/dialogs/preferencesdialogs.hpp: 4 * src/dialogs/preferencesdialogs.cpp: Added a security page. 5 6 * inc/core/browser.hpp: 7 * src/core/browser.cpp: Set discovery's security policy and 8 certificate manager's trust file from preferences. 9 1 10 2008-09-18 Armin Burgmeier <armin@arbur.net> 2 11 -
inc/core/browser.hpp
r8667620 ra2a811e 29 29 #include <libinfgtk/inf-gtk-certificate-manager.h> 30 30 #include <libinfinity/client/infc-browser.h> 31 #include <libinfinity/common/inf-discovery-avahi.h> 31 32 #include <libinfinity/common/inf-xmpp-manager.h> 33 #include <libinfinity/inf-config.h> 32 34 33 35 #include <gtkmm/window.h> … … 106 108 const std::runtime_error& error); 107 109 110 void on_security_policy_changed(); 111 void on_trust_file_changed(); 112 108 113 Gtk::Window& m_parent; 109 114 const InfcNotePlugin* m_text_plugin; … … 112 117 113 118 InfXmppManager* m_xmpp_manager; 119 #ifdef INFINOTE_HAVE_AVAHI 120 InfDiscoveryAvahi* m_discovery; 121 #endif 114 122 InfGtkIo* m_io; 115 123 InfGtkCertificateManager* m_cert_manager; -
inc/dialogs/preferencesdialog.hpp
r04fe422 ra2a811e 29 29 #include <gtkmm/spinbutton.h> 30 30 #include <gtkmm/checkbutton.h> 31 #include <gtkmm/combobox text.h>31 #include <gtkmm/combobox.h> 32 32 #include <gtkmm/notebook.h> 33 33 #include <gtkmm/alignment.h> 34 34 #include <gtkmm/filechooserbutton.h> 35 35 #include <gtkmm/fontbutton.h> 36 //#include <gtkmm/colorbutton.h>37 36 #include <gtkmm/sizegroup.h> 37 #include <gtkmm/liststore.h> 38 38 39 39 namespace Gobby 40 40 { 41 42 template<typename OptionType> 43 class PreferencesComboBox: public Gtk::ComboBox 44 { 45 public: 46 PreferencesComboBox(Preferences::Option<OptionType>& option): 47 m_option(option), m_store(Gtk::ListStore::create(m_columns)) 48 { 49 set_model(m_store); 50 51 Gtk::CellRendererText* renderer = 52 Gtk::manage(new Gtk::CellRendererText); 53 pack_start(*renderer, true); 54 add_attribute(renderer->property_text(), m_columns.text); 55 } 56 57 void add(const Glib::ustring& text, const OptionType& value) 58 { 59 Gtk::TreeIter iter = m_store->append(); 60 (*iter)[m_columns.text] = text; 61 (*iter)[m_columns.value] = value; 62 63 if(m_option == value) 64 set_active(iter); 65 } 66 67 private: 68 class Columns: public Gtk::TreeModelColumnRecord 69 { 70 public: 71 Gtk::TreeModelColumn<Glib::ustring> text; 72 Gtk::TreeModelColumn<OptionType> value; 73 74 Columns() { add(text); add(value); } 75 }; 76 77 virtual void on_changed() 78 { 79 Gtk::ComboBox::on_changed(); 80 m_option = (*get_active())[m_columns.value]; 81 } 82 83 Preferences::Option<OptionType>& m_option; 84 85 Columns m_columns; 86 Glib::RefPtr<Gtk::ListStore> m_store; 87 }; 41 88 42 89 class PreferencesDialog : public Gtk::Dialog 43 90 { 44 91 public: 92 template<typename OptionType> 93 class ComboColumns: public Gtk::TreeModelColumnRecord 94 { 95 }; 96 45 97 class Group: public Gtk::Frame 46 98 { … … 148 200 Group m_group_font; 149 201 150 Gtk::ComboBoxText m_cmb_toolbar_style; 151 202 PreferencesComboBox<Gtk::ToolbarStyle> m_cmb_toolbar_style; 152 203 Gtk::FontButton m_btn_font; 204 }; 205 206 class Security: public Page 207 { 208 public: 209 Security(Preferences& preferences); 210 211 protected: 212 Group m_group_trust_file; 213 Group m_group_connection_policy; 214 215 Gtk::FileChooserButton m_btn_path_trust_file; 216 PreferencesComboBox<InfXmppConnectionSecurityPolicy> 217 m_cmb_connection_policy; 153 218 }; 154 219 … … 167 232 View m_page_view; 168 233 Appearance m_page_appearance; 234 Security m_page_security; 169 235 }; 170 236 -
src/core/browser.cpp
rcd0ff9f ra2a811e 21 21 22 22 #include <libinfinity/inf-config.h> 23 #include <libinfinity/common/inf-discovery-avahi.h>24 23 25 24 #include <gtkmm/stock.h> … … 63 62 m_xmpp_manager = inf_xmpp_manager_new(); 64 63 #ifdef INFINOTE_HAVE_AVAHI 65 InfDiscoveryAvahi* discovery = 66 inf_discovery_avahi_new(INF_IO(m_io), m_xmpp_manager, 67 NULL, NULL); 64 m_discovery = inf_discovery_avahi_new(INF_IO(m_io), m_xmpp_manager, 65 NULL, NULL); 66 inf_discovery_avahi_set_security_policy( 67 m_discovery, m_preferences.security.policy); 68 68 inf_gtk_browser_store_add_discovery(m_browser_store, 69 INF_DISCOVERY(discovery)); 70 g_object_unref(discovery); 69 INF_DISCOVERY(m_discovery)); 71 70 #endif 72 71 73 72 Glib::ustring known_hosts_file = Glib::build_filename( 74 73 Glib::get_home_dir(), GOBBY_CONFIGDIR"/known_hosts"); 74 75 const std::string trust_file = m_preferences.security.trust_file; 75 76 m_cert_manager = inf_gtk_certificate_manager_new( 76 77 parent.gobj(), m_xmpp_manager, 77 NULL, known_hosts_file.c_str()); 78 trust_file.empty() ? NULL : trust_file.c_str(), 79 known_hosts_file.c_str()); 78 80 79 81 m_browser_view = … … 103 105 ); 104 106 107 m_preferences.security.policy.signal_changed().connect( 108 sigc::mem_fun(*this, &Browser::on_security_policy_changed)); 109 m_preferences.security.trust_file.signal_changed().connect( 110 sigc::mem_fun(*this, &Browser::on_trust_file_changed)); 111 105 112 set_spacing(6); 106 113 pack_start(m_scroll, Gtk::PACK_EXPAND_WIDGET); … … 120 127 g_object_unref(m_cert_manager); 121 128 g_object_unref(m_xmpp_manager); 129 #ifdef INFINOTE_HAVE_AVAHI 130 g_object_unref(m_discovery); 131 #endif 122 132 g_object_unref(m_io); 123 133 } … … 319 329 inf_gtk_browser_view_set_selected(m_browser_view, &tree_iter); 320 330 } 331 332 void Gobby::Browser::on_security_policy_changed() 333 { 334 #ifdef INFINOTE_HAVE_AVAHI 335 inf_discovery_avahi_set_security_policy( 336 m_discovery, m_preferences.security.policy); 337 #endif 338 } 339 340 void Gobby::Browser::on_trust_file_changed() 341 { 342 const std::string trust_file = m_preferences.security.trust_file; 343 344 g_object_set(G_OBJECT(m_cert_manager), "trust-file", 345 trust_file.empty() ? NULL : trust_file.c_str(), NULL); 346 } -
src/dialogs/preferencesdialog.cpp
r04fe422 ra2a811e 29 29 using namespace Gobby; 30 30 31 Gtk::ToolbarStyle rownum_to_toolstyle(int rownum)32 {33 switch(rownum)34 {35 case 0: return Gtk::TOOLBAR_TEXT;36 case 1: return Gtk::TOOLBAR_ICONS;37 case 3: return Gtk::TOOLBAR_BOTH_HORIZ;38 case 2: default: return Gtk::TOOLBAR_BOTH;39 }40 }41 42 31 Gtk::WrapMode 43 32 wrap_mode_from_check_buttons(Gtk::CheckButton& char_button, … … 106 95 entry, 107 96 &Gtk::Entry::get_text 108 )109 )110 );111 }112 113 void114 connect_toolbar_style_option(Gtk::ComboBox& box,115 Preferences::Option<Gtk::ToolbarStyle>&116 option)117 {118 box.signal_changed().connect(119 sigc::compose(120 sigc::mem_fun(121 option,122 &Preferences::Option<123 Gtk::ToolbarStyle>::set124 ),125 sigc::compose(126 sigc::ptr_fun(rownum_to_toolstyle),127 sigc::mem_fun(128 box,129 &Gtk::ComboBox::130 get_active_row_number131 )132 97 ) 133 98 ) … … 482 447 } 483 448 484 Gobby::PreferencesDialog::Appearance:: 485 Appearance(Gobby::Preferences& preferences): 449 Gobby::PreferencesDialog::Appearance::Appearance(Preferences& preferences): 486 450 m_group_toolbar(_("Toolbar") ), 487 m_group_font(_("Font") ) 488 { 489 Gtk::ToolbarStyle style = preferences.appearance.toolbar_style; 451 m_group_font(_("Font") ), 452 m_cmb_toolbar_style(preferences.appearance.toolbar_style) 453 { 490 454 const Pango::FontDescription& font = preferences.appearance.font; 491 455 492 m_cmb_toolbar_style.append_text(_("Show text only") ); 493 m_cmb_toolbar_style.append_text(_("Show icons only") ); 494 m_cmb_toolbar_style.append_text(_("Show both icons and text") ); 495 m_cmb_toolbar_style.append_text(_("Show text besides icons") ); 456 m_cmb_toolbar_style.add(_("Show text only"), 457 Gtk::TOOLBAR_TEXT); 458 m_cmb_toolbar_style.add(_("Show icons only"), 459 Gtk::TOOLBAR_ICONS); 460 m_cmb_toolbar_style.add(_("Show both icons and text"), 461 Gtk::TOOLBAR_BOTH ); 462 m_cmb_toolbar_style.add(_("Show text besides icons"), 463 Gtk::TOOLBAR_BOTH_HORIZ ); 496 464 m_cmb_toolbar_style.show(); 497 connect_toolbar_style_option(m_cmb_toolbar_style,498 preferences.appearance.toolbar_style);499 500 switch(style)501 {502 case Gtk::TOOLBAR_TEXT: m_cmb_toolbar_style.set_active(0); break;503 case Gtk::TOOLBAR_ICONS: m_cmb_toolbar_style.set_active(1); break;504 case Gtk::TOOLBAR_BOTH: m_cmb_toolbar_style.set_active(2); break;505 case Gtk::TOOLBAR_BOTH_HORIZ: m_cmb_toolbar_style.set_active(3); break;506 default: break; // Avoids compiler warnings507 }508 465 509 466 m_btn_font.set_font_name(font.to_string()); … … 519 476 add(m_group_toolbar); 520 477 add(m_group_font); 478 } 479 480 Gobby::PreferencesDialog::Security::Security(Preferences& preferences): 481 m_group_trust_file(_("Trusted CAs")), 482 m_group_connection_policy(_("Secure Connection")), 483 m_btn_path_trust_file(_("Select a file containing trusted CAs")), 484 m_cmb_connection_policy(preferences.security.policy) 485 { 486 const std::string& trust_file = preferences.security.trust_file; 487 if(!trust_file.empty()) 488 m_btn_path_trust_file.set_filename(trust_file); 489 490 connect_path_option(m_btn_path_trust_file, 491 preferences.security.trust_file); 492 m_btn_path_trust_file.show(); 493 m_group_trust_file.add(m_btn_path_trust_file); 494 m_group_trust_file.show(); 495 496 /* m_cmb_connection_policy.add( 497 _("Never use a secure connection"), 498 INF_XMPP_CONNECTION_SECURITY_ONLY_UNSECURED);*/ 499 m_cmb_connection_policy.add( 500 _("Use TLS if possible"), 501 INF_XMPP_CONNECTION_SECURITY_BOTH_PREFER_TLS); 502 m_cmb_connection_policy.add( 503 _("Always use TLS"), 504 INF_XMPP_CONNECTION_SECURITY_ONLY_TLS); 505 m_cmb_connection_policy.show(); 506 m_group_connection_policy.add(m_cmb_connection_policy); 507 m_group_connection_policy.show(); 508 509 add(m_group_trust_file); 510 add(m_group_connection_policy); 521 511 } 522 512 … … 525 515 Gtk::Dialog(_("Preferences"), parent), m_preferences(preferences), 526 516 m_page_user(*this, preferences), m_page_editor(preferences), 527 m_page_view(preferences), m_page_appearance(preferences) 517 m_page_view(preferences), m_page_appearance(preferences), 518 m_page_security(preferences) 528 519 { 529 520 m_notebook.append_page(m_page_user, _("User")); … … 531 522 m_notebook.append_page(m_page_view, _("View")); 532 523 m_notebook.append_page(m_page_appearance, _("Appearance")); 524 m_notebook.append_page(m_page_security, _("Security")); 533 525 534 526 m_page_user.show(); … … 536 528 m_page_view.show(); 537 529 m_page_appearance.show(); 530 m_page_security.show(); 538 531 539 532 get_vbox()->set_spacing(6); … … 544 537 545 538 set_border_width(12); 539 set_resizable(false); 546 540 } 547 541
