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