Commit 30c9adbf authored by Claes Sjofors's avatar Claes Sjofors

Wb and xtt bugfix for non ISO8859-1 chars

parent 487a4b4e
......@@ -310,15 +310,17 @@ void WAttGtk::change_value_close()
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
// Replace ctrl characters with space
for ( s = (unsigned char *) text; *s; s++) {
if ( *s < ' ' && *s != 10 && *s != 13)
*s = ' ';
if ( text) {
// Replace ctrl characters with space
for ( s = (unsigned char *) text; *s; s++) {
if ( *s < ' ' && *s != 10 && *s != 13)
*s = ' ';
}
sts = wattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
}
sts = wattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
g_object_set( cmd_scrolledinput, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
......@@ -329,6 +331,8 @@ void WAttGtk::change_value_close()
wattnav->redraw();
wattnav->set_inputfocus();
if ( !text)
message( 'E', "Input error, invalid character");
}
else {
char *text, *textutf8;
......@@ -336,9 +340,11 @@ void WAttGtk::change_value_close()
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
sts = wattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
if ( text) {
sts = wattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
}
g_object_set( cmd_input, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
......@@ -346,6 +352,9 @@ void WAttGtk::change_value_close()
(redraw_cb)( this);
wattnav->set_inputfocus();
if ( !text)
message( 'E', "Input error, invalid character");
}
if ( pending_close) {
if ( close_cb)
......@@ -367,20 +376,27 @@ void WAttGtk::activate_cmd_input( GtkWidget *w, gpointer data)
textutf8 = gtk_editable_get_chars( GTK_EDITABLE(w), 0, -1);
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
if ( watt->input_open) {
sts = ((WAttNav *)watt->wattnav)->set_attr_value( watt->input_node,
watt->input_name, text);
if ( text)
sts = ((WAttNav *)watt->wattnav)->set_attr_value( watt->input_node,
watt->input_name, text);
g_object_set( w, "visible", FALSE, NULL);
watt->set_prompt( "");
watt->input_open = 0;
if ( watt->redraw_cb)
(watt->redraw_cb)( watt);
}
g_free( text);
if ( text)
g_free( text);
g_object_set( watt->cmd_prompt, "visible", FALSE, NULL);
g_object_set( watt->cmd_input, "visible", FALSE, NULL);
if ( !text)
watt->message( 'E', "Input error, invalid character");
if ( watt->pending_close) {
if ( watt->close_cb)
(watt->close_cb)( watt);
......@@ -406,14 +422,16 @@ void WAttGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
// Replace ctrl characters with space
for ( s = (unsigned char *) text; *s; s++) {
if ( *s < ' ' && *s != 10 && *s != 13)
*s = ' ';
}
if ( text) {
// Replace ctrl characters with space
for ( s = (unsigned char *) text; *s; s++) {
if ( *s < ' ' && *s != 10 && *s != 13)
*s = ' ';
}
sts = ((WAttNav *)watt->wattnav)->set_attr_value( watt->input_node,
watt->input_name, text);
sts = ((WAttNav *)watt->wattnav)->set_attr_value( watt->input_node,
watt->input_name, text);
}
g_object_set( watt->cmd_scrolledinput, "visible", FALSE, NULL);
watt->set_prompt( "");
watt->input_open = 0;
......@@ -424,7 +442,11 @@ void WAttGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
((WAttNav *)watt->wattnav)->redraw();
((WAttNav *)watt->wattnav)->set_inputfocus();
g_free( text);
if ( text)
g_free( text);
else
watt->message( 'E', "Input error, invalid character");
if ( watt->pending_close) {
if ( watt->close_cb)
......
......@@ -215,15 +215,19 @@ void WAttTextGtk::set_attr_value()
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
if ( text) {
// Replace ctrl characters with space
for ( s = (unsigned char *) text; *s; s++) {
if ( *s < ' ' && *s != 10 && *s != 13)
*s = ' ';
for ( s = (unsigned char *) text; *s; s++) {
if ( *s < ' ' && *s != 10 && *s != 13)
*s = ' ';
}
sts = ldh_SetObjectPar( ldhses, aref.Objid, "DevBody",
aname, text, size);
g_free( text);
}
sts = ldh_SetObjectPar( ldhses, aref.Objid, "DevBody",
aname, text, size);
g_free( text);
else
wow->DisplayError( "Input error", "Invalid character");
}
}
......
......@@ -407,9 +407,11 @@ void WdaGtk::change_value_close()
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
sts = wdanav->set_attr_value( input_node,
input_name, text);
g_free( text);
if ( text) {
sts = wdanav->set_attr_value( input_node,
input_name, text);
g_free( text);
}
g_object_set( cmd_input, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
......@@ -417,6 +419,9 @@ void WdaGtk::change_value_close()
(redraw_cb)( this);
wdanav->set_inputfocus();
if ( !text)
message( 'E', "Input error, invalid character");
}
}
}
......@@ -437,15 +442,20 @@ void WdaGtk::activate_cmd_input( GtkWidget *w, gpointer data)
g_free( textutf8);
if ( wda->input_open) {
sts = wda->wdanav->set_attr_value( wda->input_node,
wda->input_name, text);
if ( text)
sts = wda->wdanav->set_attr_value( wda->input_node,
wda->input_name, text);
g_object_set( w, "visible", FALSE, NULL);
wda->set_prompt( "");
wda->input_open = 0;
if ( wda->redraw_cb)
(wda->redraw_cb)( wda);
if ( !text)
wda->message( 'E', "Input error, invalid character");
}
g_free( text);
if ( text)
g_free( text);
}
void WdaGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
......@@ -465,14 +475,16 @@ void WdaGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
// Replace ctrl characters with space
for ( s = (unsigned char *) text; *s; s++) {
if ( *s < ' ' && *s != 10 && *s != 13)
*s = ' ';
}
if ( text) {
// Replace ctrl characters with space
for ( s = (unsigned char *) text; *s; s++) {
if ( *s < ' ' && *s != 10 && *s != 13)
*s = ' ';
}
sts = wda->wdanav->set_attr_value( wda->input_node,
wda->input_name, text);
sts = wda->wdanav->set_attr_value( wda->input_node,
wda->input_name, text);
}
g_object_set( wda->cmd_scrolledinput, "visible", FALSE, NULL);
wda->set_prompt( "");
wda->input_open = 0;
......@@ -483,7 +495,10 @@ void WdaGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
wda->wdanav->redraw();
wda->wdanav->set_inputfocus();
g_free( text);
if ( text)
g_free( text);
else
wda->message( 'E', "Input error, invalid character");
}
}
......
......@@ -318,9 +318,12 @@ void XAttGtk::change_value_close()
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
sts = xattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
if ( text) {
sts = xattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
}
g_object_set( cmd_scrolledinput, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
......@@ -331,6 +334,8 @@ void XAttGtk::change_value_close()
xattnav->redraw();
xattnav->set_inputfocus();
if ( !text)
message( 'E', "Input error, invalid character");
}
else {
char *text, *textutf8;
......@@ -339,9 +344,11 @@ void XAttGtk::change_value_close()
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
sts = xattnav->set_attr_value( input_node,
if ( text) {
sts = xattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
g_free( text);
}
g_object_set( cmd_input, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
......@@ -349,6 +356,8 @@ void XAttGtk::change_value_close()
(redraw_cb)( this);
xattnav->set_inputfocus();
if ( !text)
message( 'E', "Input error, invalid character");
}
}
}
......@@ -369,15 +378,19 @@ void XAttGtk::activate_cmd_input( GtkWidget *w, gpointer data)
g_free( textutf8);
if ( xatt->input_open) {
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
if ( text)
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
g_object_set( w, "visible", FALSE, NULL);
xatt->set_prompt( "");
xatt->input_open = 0;
if ( xatt->redraw_cb)
(xatt->redraw_cb)( xatt);
if ( !text)
xatt->message( 'E', "Input error, invalid character");
}
g_free( text);
if ( text)
g_free( text);
}
void XAttGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
......@@ -396,8 +409,12 @@ void XAttGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
if ( text)
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
else
xatt->message( 'E', "Input error, invalid character");
g_object_set( xatt->cmd_scrolledinput, "visible", FALSE, NULL);
xatt->set_prompt( "");
xatt->input_open = 0;
......@@ -408,7 +425,8 @@ void XAttGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
xatt->xattnav->redraw();
xatt->xattnav->set_inputfocus();
g_free( text);
if ( text)
g_free( text);
}
}
......
......@@ -89,6 +89,7 @@ int XAttOneGtk::set_value()
char *text;
int sts;
char buff[1024];
char *textutf8;
if ( input_open) {
if ( input_multiline) {
......@@ -96,13 +97,21 @@ int XAttOneGtk::set_value()
gtk_text_buffer_get_start_iter( cmd_scrolled_buffer, &start_iter);
gtk_text_buffer_get_end_iter( cmd_scrolled_buffer, &end_iter);
text = gtk_text_buffer_get_text( cmd_scrolled_buffer, &start_iter, &end_iter,
textutf8 = gtk_text_buffer_get_text( cmd_scrolled_buffer, &start_iter, &end_iter,
FALSE);
}
else {
text = gtk_editable_get_chars( GTK_EDITABLE(cmd_input), 0, -1);
textutf8 = gtk_editable_get_chars( GTK_EDITABLE(cmd_input), 0, -1);
}
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
if ( !text) {
message( 'E', "Input error, invalid character");
return 0;
}
sts = XNav::attr_string_to_value( atype, text, buff, sizeof(buff),
asize);
g_free( text);
......
......@@ -425,6 +425,21 @@ void XColWindGtk::change_value_close()
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
if ( !text) {
g_object_set( cmd_scrolledinput, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
int w, h;
gdk_drawable_get_size( pane->window, &w, &h);
gtk_paned_set_position( GTK_PANED(pane), h - 50);
xattnav->redraw();
xattnav->set_inputfocus();
message( 'E', "Input error, invalid character");
return;
}
sts = xattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
......@@ -446,6 +461,18 @@ void XColWindGtk::change_value_close()
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
if ( !text) {
g_free( text);
g_object_set( cmd_input, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
if ( redraw_cb)
(redraw_cb)( this);
xattnav->set_inputfocus();
message( 'E', "Input error, invalid character");
return;
}
sts = xattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
......@@ -475,6 +502,16 @@ void XColWindGtk::activate_cmd_input( GtkWidget *w, gpointer data)
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
if ( !text) {
g_object_set( w, "visible", FALSE, NULL);
xcolwind->set_prompt( "");
xcolwind->input_open = 0;
if ( xcolwind->redraw_cb)
(xcolwind->redraw_cb)( xcolwind);
xcolwind->message( 'E', "Input error, invalid character");
return;
}
if ( xcolwind->input_open) {
sts = xcolwind->xattnav->set_attr_value( xcolwind->input_node,
xcolwind->input_name, text);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment