[gnote] Replace std::string by Glib::ustring in PreferencesDialog



commit 722da5b4eee32dcb68adde68937b6832d9a7ab1d
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Feb 5 21:58:41 2017 +0200

    Replace std::string by Glib::ustring in PreferencesDialog

 src/preferencesdialog.cpp |   44 +++++++++++++++++++++-----------------------
 src/preferencesdialog.hpp |   19 +++++++++----------
 2 files changed, 30 insertions(+), 33 deletions(-)
---
diff --git a/src/preferencesdialog.cpp b/src/preferencesdialog.cpp
index 4ac8c39..63d5bd6 100644
--- a/src/preferencesdialog.cpp
+++ b/src/preferencesdialog.cpp
@@ -71,14 +71,14 @@ namespace gnote {
   {
   public:
     AddinInfoDialog(const AddinInfo & module, Gtk::Dialog &parent);
-    void set_addin_id(const std::string & id)
+    void set_addin_id(const Glib::ustring & id)
       { m_id = id; }
-    const std::string & get_addin_id() const
+    const Glib::ustring & get_addin_id() const
       { return m_id; }
   private:
     void fill(Gtk::Label &);
     AddinInfo m_addin_info;
-    std::string m_id;
+    Glib::ustring m_id;
   };
 
 
@@ -172,7 +172,7 @@ namespace gnote {
 
   void PreferencesDialog::enable_addin(bool enable)
   {
-    std::string id = get_selected_addin();
+    Glib::ustring id = get_selected_addin();
     sharp::DynamicModule * const module = m_addin_manager.get_module(id);
     if(!module) {
       return;
@@ -356,7 +356,7 @@ namespace gnote {
     button->add (*font_box);
     button->show ();
 
-    std::string font_desc = Preferences::obj().get_schema_settings(
+    Glib::ustring font_desc = Preferences::obj().get_schema_settings(
         Preferences::SCHEMA_GNOTE)->get_string(Preferences::CUSTOM_FONT_FACE);
     update_font_button (font_desc);
 
@@ -451,7 +451,7 @@ namespace gnote {
 
     // Read from Preferences which service is configured and select it
     // by default.  Otherwise, just select the first one in the list.
-    std::string addin_id = Preferences::obj()
+    Glib::ustring addin_id = Preferences::obj()
       .get_schema_settings(Preferences::SCHEMA_SYNC)->get_string(Preferences::SYNC_SELECTED_SERVICE_ADDIN);
 
     Gtk::TreeIter active_iter;
@@ -472,7 +472,7 @@ namespace gnote {
 
     // Get the preferences GUI for the Sync Addin
     if (active_iter.get_stamp() != 0) {
-      std::string addin_name;
+      Glib::ustring addin_name;
       active_iter->get_value(0, m_selected_sync_addin);
     }
     
@@ -659,12 +659,12 @@ namespace gnote {
   }
 
 
-  std::string PreferencesDialog::get_selected_addin()
+  Glib::ustring PreferencesDialog::get_selected_addin()
   {
     /// TODO really set
     Glib::RefPtr<Gtk::TreeSelection> select = m_addin_tree->get_selection();
     Gtk::TreeIter iter = select->get_selected();
-    std::string module_id;
+    Glib::ustring module_id;
     if(iter) {
       module_id = m_addin_tree_model->get_module_id(iter);
     }
@@ -691,7 +691,7 @@ namespace gnote {
   /// Set the sensitivity of the buttons based on what is selected
   void PreferencesDialog::update_addin_buttons()
   {
-    std::string id = get_selected_addin();
+    Glib::ustring id = get_selected_addin();
     if(id != "") {
       bool loaded = m_addin_manager.is_module_loaded(id);
       bool enabled = false;
@@ -751,7 +751,7 @@ namespace gnote {
 
   void PreferencesDialog::on_addin_prefs_button()
   {
-    std::string id = get_selected_addin();
+    Glib::ustring id = get_selected_addin();
     AddinInfo addin_info = m_addin_manager.get_addin_info(id);
     const sharp::DynamicModule *module = m_addin_manager.get_module(id);
     Gtk::Dialog *dialog;
@@ -760,8 +760,7 @@ namespace gnote {
       return;
     }
 
-    std::map<std::string, Gtk::Dialog* >::iterator iter;
-    iter = addin_prefs_dialogs.find(id);
+    auto iter = addin_prefs_dialogs.find(id);
     if (iter == addin_prefs_dialogs.end()) {
       // A preference dialog isn't open already so create a new one
       Gtk::Image *icon =
@@ -844,12 +843,11 @@ namespace gnote {
 
   void PreferencesDialog::on_addin_info_button()
   {
-    std::string id = get_selected_addin();
+    Glib::ustring id = get_selected_addin();
     AddinInfo addin = m_addin_manager.get_addin_info(id);
 
     Gtk::Dialog* dialog;
-    std::map<std::string, Gtk::Dialog* >::iterator iter;
-    iter = addin_info_dialogs.find(addin.id());
+    auto iter = addin_info_dialogs.find(addin.id());
     if (iter == addin_info_dialogs.end()) {
       dialog = new AddinInfoDialog (addin, *this);
       dialog->signal_delete_event().connect(
@@ -896,7 +894,7 @@ namespace gnote {
 
 
 
-  Gtk::Label *PreferencesDialog::make_label (const std::string & label_text/*, params object[] args*/)
+  Gtk::Label *PreferencesDialog::make_label(const Glib::ustring & label_text/*, params object[] args*/)
   {
 //    if (args.Length > 0)
 //      label_text = String.Format (label_text, args);
@@ -911,7 +909,7 @@ namespace gnote {
     return label;
   }
 
-  Gtk::CheckButton *PreferencesDialog::make_check_button (const std::string & label_text)
+  Gtk::CheckButton *PreferencesDialog::make_check_button(const Glib::ustring & label_text)
   {
     Gtk::Label *label = manage(make_label(label_text));
     
@@ -923,7 +921,7 @@ namespace gnote {
   }
 
 
-  void PreferencesDialog::set_widget_tooltip(Gtk::Widget & widget, std::string label_text)
+  void PreferencesDialog::set_widget_tooltip(Gtk::Widget & widget, Glib::ustring label_text)
   {
     widget.set_tooltip_markup(Glib::ustring::compose("<small>%1</small>", label_text));
   }
@@ -934,7 +932,7 @@ namespace gnote {
       new Gtk::FontSelectionDialog (_("Choose Note Font"));
 
     Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
-    std::string font_name = settings->get_string(Preferences::CUSTOM_FONT_FACE);
+    Glib::ustring font_name = settings->get_string(Preferences::CUSTOM_FONT_FACE);
     font_dialog->set_font_name(font_name);
 
     if (Gtk::RESPONSE_OK == font_dialog->run()) {
@@ -948,7 +946,7 @@ namespace gnote {
     delete font_dialog;
   }
 
-  void PreferencesDialog::update_font_button (const std::string & font_desc)
+  void PreferencesDialog::update_font_button(const Glib::ustring & font_desc)
   {
     PangoFontDescription *desc = pango_font_description_from_string(font_desc.c_str());
 
@@ -1193,7 +1191,7 @@ namespace gnote {
     }
 
     bool saved = false;
-    std::string errorMsg;
+    Glib::ustring errorMsg;
     try {
       get_window()->set_cursor(Gdk::Cursor::create(Gdk::WATCH));
       get_window()->get_display()->flush();
@@ -1323,7 +1321,7 @@ namespace gnote {
     sb += Glib::ustring::compose("<b>%1</b>\n%2\n\n",
               _("Author:"), m_addin_info.authors());
     
-    std::string s = m_addin_info.copyright();
+    Glib::ustring s = m_addin_info.copyright();
     if(s != "") {
       sb += Glib::ustring::compose("<b>%1</b>\n%2\n\n", _("Copyright:"), s);
     }
diff --git a/src/preferencesdialog.hpp b/src/preferencesdialog.hpp
index eeba06a..ac83af7 100644
--- a/src/preferencesdialog.hpp
+++ b/src/preferencesdialog.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2013,2015-2016 Aurimas Cernius
+ * Copyright (C) 2011-2013,2015-2017 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -24,7 +24,6 @@
 #ifndef __PREFERENCES_DIALOG_HPP_
 #define __PREFERENCES_DIALOG_HPP_
 
-#include <string>
 #include <map>
 
 #include <gtkmm/dialog.h>
@@ -55,10 +54,10 @@ public:
   Gtk::Widget *make_addins_pane();
 
 private:
-  void set_widget_tooltip(Gtk::Widget & widget, std::string label_text);
+  void set_widget_tooltip(Gtk::Widget & widget, Glib::ustring label_text);
   Gtk::Button *make_font_button();
-  Gtk::Label *make_label (const std::string & label_text/*, params object[] args*/);
-  Gtk::CheckButton *make_check_button (const std::string & label_text);
+  Gtk::Label *make_label(const Glib::ustring & label_text/*, params object[] args*/);
+  Gtk::CheckButton *make_check_button(const Glib::ustring & label_text);
 
   void enable_addin(bool enable);
   template <typename T>
@@ -66,7 +65,7 @@ private:
 
   void open_template_button_clicked();
   void on_font_button_clicked();
-  void update_font_button(const std::string & font_desc);
+  void update_font_button(const Glib::ustring & font_desc);
   void on_sync_addin_combo_changed();
   void on_advanced_sync_config_button();
   void on_reset_sync_addin_button(bool signal);
@@ -75,7 +74,7 @@ private:
   void on_preferences_setting_changed(const Glib::ustring & key);
   void on_rename_behavior_changed();
 
-  std::string get_selected_addin();
+  Glib::ustring get_selected_addin();
   void set_module_for_selected_addin(sharp::DynamicModule * module);
   void on_addin_tree_selection_changed();
   void update_addin_buttons();
@@ -110,7 +109,7 @@ private:
 
   SyncStoreModel m_sync_addin_store_record;
   Glib::RefPtr<Gtk::ListStore> m_sync_addin_store;
-  std::map<std::string, Gtk::TreeIter> m_sync_addin_iters;
+  std::map<Glib::ustring, Gtk::TreeIter> m_sync_addin_iters;
   Gtk::ComboBox *m_sync_addin_combo;
   sync::SyncServiceAddin *m_selected_sync_addin;
   Gtk::Grid   *m_sync_addin_prefs_container;
@@ -146,11 +145,11 @@ private:
   /// dialogs).
   ///
   /// Key = Mono.Addins.Addin.Id
-  std::map<std::string, Gtk::Dialog* > addin_prefs_dialogs;
+  std::map<Glib::ustring, Gtk::Dialog* > addin_prefs_dialogs;
 
   /// Used to keep track of open AddinInfoDialogs.
   /// Key = Mono.Addins.Addin.Id
-  std::map<std::string, Gtk::Dialog* > addin_info_dialogs;
+  std::map<Glib::ustring, Gtk::Dialog* > addin_info_dialogs;
 
 };
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]