[gtkmm] Avoid unnecessary conversions between std::string and Glib::ustring



commit 24b078a005bc07fa480b87e0a5138c5fbcdf2357
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Nov 18 09:58:21 2019 +0100

    Avoid unnecessary conversions between std::string and Glib::ustring
    
    and make necessary conversions explicit.

 demos/gtk-demo/demowindow.cc                      | 2 +-
 demos/gtk-demo/example_shortcuts.cc               | 2 +-
 demos/gtk-demo/example_treeview_editable_cells.cc | 2 +-
 tools/m4/convert_gdk.m4                           | 8 ++++----
 4 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/demos/gtk-demo/demowindow.cc b/demos/gtk-demo/demowindow.cc
index abf28221..cfb5cbdf 100644
--- a/demos/gtk-demo/demowindow.cc
+++ b/demos/gtk-demo/demowindow.cc
@@ -457,7 +457,7 @@ void DemoWindow::add_data_tabs(const std::string& filename)
         continue;
       }
     }
-    m_Notebook.append_page(*Gtk::manage(widget), resources[i]);
+    m_Notebook.append_page(*Gtk::manage(widget), Glib::ustring(resources[i]));
     m_Notebook.get_page(*widget)->property_tab_expand() = true;
   }
 }
diff --git a/demos/gtk-demo/example_shortcuts.cc b/demos/gtk-demo/example_shortcuts.cc
index 3920359b..b0af4f73 100644
--- a/demos/gtk-demo/example_shortcuts.cc
+++ b/demos/gtk-demo/example_shortcuts.cc
@@ -97,7 +97,7 @@ void Example_Shortcuts::on_button_clicked(const Glib::ustring& id, const Glib::u
   auto builder = Gtk::Builder::create();
   try
   {
-    builder->add_from_resource("/shortcuts/example_" + id + ".ui");
+    builder->add_from_resource("/shortcuts/example_" + id.raw() + ".ui");
   }
   catch (const Glib::Error& error)
   {
diff --git a/demos/gtk-demo/example_treeview_editable_cells.cc 
b/demos/gtk-demo/example_treeview_editable_cells.cc
index 1b6c093a..4a75e4ed 100644
--- a/demos/gtk-demo/example_treeview_editable_cells.cc
+++ b/demos/gtk-demo/example_treeview_editable_cells.cc
@@ -208,7 +208,7 @@ void Example_TreeView_EditableCells::on_column_number_edited(const Glib::ustring
       int new_value = 0;
       try
       {
-        new_value = std::stoi(new_text);
+        new_value = std::stoi(new_text.raw());
       }
       catch (const std::exception& err)
       {
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index 2aafa8ae..7cf1de6f 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -277,10 +277,10 @@ _CONVERSION(`GdkTimeCoord**&',`GdkTimeCoord***',`&($3)')
 
 dnl _CONVERSION(GdkBitmap*,Gdk::Bitmap&,`Glib::unwrap_boxed($3)',`$3')
 
-dnl Atom -> string and vice versa
-_CONVERSION(`GdkAtom',`Glib::ustring',`Gdk::AtomString::to_cpp_type($3)')
-_CONVERSION(`const Glib::ustring&', `GdkAtom', `Gdk::AtomString::to_c_type($3)')
-_CONVERSION(`Glib::ustring&',`GdkAtom',`Gdk::AtomString::to_c_type($3)')
+dnl GdkAtom -> Glib::ustring and vice versa
+_CONVERSION(`GdkAtom',`Glib::ustring',`Gdk::AtomUstring::to_cpp_type($3)')
+_CONVERSION(`const Glib::ustring&', `GdkAtom', `Gdk::AtomUstring::to_c_type($3)')
+_CONVERSION(`Glib::ustring&',`GdkAtom',`Gdk::AtomUstring::to_c_type($3)')
 
 dnl GdkEvent and GdkEventSequence
 _CONVERSION(`GdkEvent*',`Glib::RefPtr<Event>',`Glib::wrap($3)')


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