Ejemplo n.º 1
0
 void edited()
 {
   std::string data = _text.get_string_value();
   gchar *converted;
   gsize bread, bwritten;
   GError *error = 0;
   
   if (_encoding != "utf8" && _encoding != "UTF8" && _encoding != "utf-8" && _encoding != "UTF-8")
   {
     converted = g_convert(data.data(), (gssize)data.length(), _encoding.c_str(), "UTF-8", &bread,
       &bwritten, &error);
     if (converted == NULL || data.length() != bread)
     {
       std::string message = base::strfmt("Data could not be converted back to %s", _encoding.c_str());
       if (error)
       {
         message.append(": ").append(error->message);
         g_error_free(error);
       }
       _message.set_text(message);
       if (converted != NULL)
         g_free(converted);
       return;
     }
     
     _owner->assign_data(converted, bwritten);
     g_free(converted);
     _message.set_text("");
   }
   else
   {
     _owner->assign_data(data.data(), data.length());
     _message.set_text("");
   }
 }
 void set_text(const std::string &text)
 {
   _label.set_text(text);
   set_size(_label.get_preferred_width(), _label.get_preferred_height());
 }