[gtkmm/gtkmm-3-24] Avoid unnecessary conversions between std::string and Glib::ustring



commit 58df45def1bcf142253f3342f56649b200b72756
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Nov 18 15:47:30 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 +-
 gtk/src/actiongroup.ccg                           | 2 +-
 gtk/src/clipboard.ccg                             | 4 ++--
 gtk/src/menuitem.ccg                              | 2 +-
 gtk/src/statusicon.ccg                            | 2 +-
 gtk/src/treeview.hg                               | 2 +-
 gtk/src/widget.ccg                                | 2 +-
 tools/m4/convert_gdk.m4                           | 8 ++++----
 10 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/demos/gtk-demo/demowindow.cc b/demos/gtk-demo/demowindow.cc
index d6c41133..2c81a1ff 100644
--- a/demos/gtk-demo/demowindow.cc
+++ b/demos/gtk-demo/demowindow.cc
@@ -428,7 +428,7 @@ void DemoWindow::add_data_tabs(const std::string& filename)
       }
     }
     widget->show_all();
-    m_Notebook.append_page(*Gtk::manage(widget), resources[i]);
+    m_Notebook.append_page(*Gtk::manage(widget), Glib::ustring(resources[i]));
     m_Notebook.child_property_tab_expand(*widget) = true;
   }
 }
diff --git a/demos/gtk-demo/example_shortcuts.cc b/demos/gtk-demo/example_shortcuts.cc
index ca12a1c4..a248ddd1 100644
--- a/demos/gtk-demo/example_shortcuts.cc
+++ b/demos/gtk-demo/example_shortcuts.cc
@@ -107,7 +107,7 @@ void Example_Shortcuts::on_button_clicked(const Glib::ustring& id, const Glib::u
   Glib::RefPtr<Gtk::Builder> 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 c80b1714..0b526268 100644
--- a/demos/gtk-demo/example_treeview_editable_cells.cc
+++ b/demos/gtk-demo/example_treeview_editable_cells.cc
@@ -206,7 +206,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/gtk/src/actiongroup.ccg b/gtk/src/actiongroup.ccg
index 72e39787..0ef01c01 100644
--- a/gtk/src/actiongroup.ccg
+++ b/gtk/src/actiongroup.ccg
@@ -58,7 +58,7 @@ void ActionGroup::add(const Glib::RefPtr<Action>& action, const AccelKey& accel_
       }
     }
 
-    AccelMap::add_entry(accel_path, key, mod);
+    AccelMap::add_entry(accel_path.raw(), key, mod);
 
     action->set_accel_path(accel_path);
   }
diff --git a/gtk/src/clipboard.ccg b/gtk/src/clipboard.ccg
index b45dc869..0d0e9c61 100644
--- a/gtk/src/clipboard.ccg
+++ b/gtk/src/clipboard.ccg
@@ -115,7 +115,7 @@ static void SignalProxy_TargetsReceived_gtk_callback(GtkClipboard*, GdkAtom* ato
   try
   {
     // TODO: check if the ownership is good.
-    (*slot) (Glib::ArrayHandler<Glib::ustring, Gdk::AtomStringTraits>::array_to_vector(atoms, n_atoms > 0 ? 
n_atoms : 0, Glib::OWNERSHIP_NONE));
+    (*slot) (Glib::ArrayHandler<Glib::ustring, Gdk::AtomUstringTraits>::array_to_vector(atoms, n_atoms > 0 ? 
n_atoms : 0, Glib::OWNERSHIP_NONE));
   }
   catch (...)
   {
@@ -287,7 +287,7 @@ std::vector<Glib::ustring> Clipboard::wait_for_targets() const
     n_targets = 0;
   }
 
-  return Glib::ArrayHandler<Glib::ustring, Gdk::AtomStringTraits>::array_to_vector(atoms, n_targets, 
Glib::OWNERSHIP_SHALLOW);
+  return Glib::ArrayHandler<Glib::ustring, Gdk::AtomUstringTraits>::array_to_vector(atoms, n_targets, 
Glib::OWNERSHIP_SHALLOW);
 }
 
 void Clipboard::set_can_store(const std::vector<TargetEntry>& targets)
diff --git a/gtk/src/menuitem.ccg b/gtk/src/menuitem.ccg
index 10dcba63..bedad7c5 100644
--- a/gtk/src/menuitem.ccg
+++ b/gtk/src/menuitem.ccg
@@ -91,7 +91,7 @@ _DEPRECATE_IFDEF_END
     }
     else
     {
-      AccelMap::add_entry(accel_key_.get_path(),
+      AccelMap::add_entry(accel_key_.get_path().raw(),
                           accel_key_.get_key(),
                           accel_key_.get_mod());
 
diff --git a/gtk/src/statusicon.ccg b/gtk/src/statusicon.ccg
index d1bf068e..4625d358 100644
--- a/gtk/src/statusicon.ccg
+++ b/gtk/src/statusicon.ccg
@@ -40,7 +40,7 @@ Glib::RefPtr<StatusIcon> StatusIcon::create(const StockID& stock_id)
 Glib::RefPtr<StatusIcon> StatusIcon::create_from_file(const std::string& filename)
 {
   Glib::RefPtr<StatusIcon> status_icon( new StatusIcon() );
-  status_icon->set_from_file(filename);
+  status_icon->set_from_file(Glib::ustring(filename));
   return status_icon;
 }
 
diff --git a/gtk/src/treeview.hg b/gtk/src/treeview.hg
index 67793e4c..3428b0cd 100644
--- a/gtk/src/treeview.hg
+++ b/gtk/src/treeview.hg
@@ -1188,7 +1188,7 @@ void _auto_store_on_cellrenderer_text_edited_numerical(const Glib::ustring& path
       ColumnType new_value = ColumnType();
       try
       {
-        new_value =  static_cast<ColumnType>( std::stod(new_text) );
+        new_value =  static_cast<ColumnType>( std::stod(new_text.raw()) );
       }
       catch(const std::invalid_argument&)
       {
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index d7c2ce5d..964aa460 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -692,7 +692,7 @@ void Widget_Class::dispose_vfunc_callback(GObject* self)
 
 Glib::ustring Widget::drag_dest_find_target(const Glib::RefPtr<Gdk::DragContext>& context) const
 {
-  return Gdk::AtomString::to_cpp_type(gtk_drag_dest_find_target(const_cast<GtkWidget*>(gobj()), 
Glib::unwrap(context), nullptr /* See GTK+ docs */));
+  return Gdk::AtomUstring::to_cpp_type(gtk_drag_dest_find_target(const_cast<GtkWidget*>(gobj()), 
Glib::unwrap(context), nullptr /* See GTK+ docs */));
 }
 
 #ifndef GTKMM_DISABLE_DEPRECATED
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index 7dc6768a..9b4b647a 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -289,10 +289,10 @@ _CONVERSION(`GdkTimeCoord**&',`GdkTimeCoord***',`&($3)')
 dnl _CONVERSION(GdkPixmap*,Gdk::Pixmap&,`Glib::unwrap_boxed($3)',`$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 NativeWindow
 _CONVERSION(`GdkNativeWindow',`Gdk::NativeWindow',`($2)($3)')


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