Commit 72aa76d2 authored by Claes Sjofors's avatar Claes Sjofors

Wow error message dialog, double UTF-8 coversion avoided

parent f613b27d
...@@ -323,7 +323,7 @@ static gboolean displayerror_remove_cb( void *data) ...@@ -323,7 +323,7 @@ static gboolean displayerror_remove_cb( void *data)
return FALSE; return FALSE;
} }
void CoWowGtk::DisplayError( const char *title, const char *text) void CoWowGtk::DisplayError( const char *title, const char *text, lng_eCoding coding)
{ {
GtkWidget *parent = m_parent; GtkWidget *parent = m_parent;
if ( parent) { if ( parent) {
...@@ -331,15 +331,21 @@ void CoWowGtk::DisplayError( const char *title, const char *text) ...@@ -331,15 +331,21 @@ void CoWowGtk::DisplayError( const char *title, const char *text)
parent = gtk_widget_get_parent( parent); parent = gtk_widget_get_parent( parent);
} }
char *textutf8 = g_convert( text, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL); char *ctext;
if ( textutf8[0] == '%') if ( coding != lng_eCoding_UTF_8) {
textutf8[0] = ' '; ctext = g_convert( text, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
if ( ctext[0] == '%')
ctext[0] = ' ';
}
else
ctext = (char *)text;
GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(parent), GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(parent),
GTK_DIALOG_MODAL, GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK, textutf8); GTK_BUTTONS_OK, ctext);
g_free( textutf8); if ( coding != lng_eCoding_UTF_8)
g_free( ctext);
g_signal_connect( dialog, "response", g_signal_connect( dialog, "response",
G_CALLBACK(displayerror_ok_cb), NULL); G_CALLBACK(displayerror_ok_cb), NULL);
gtk_window_set_title( GTK_WINDOW(dialog), title); gtk_window_set_title( GTK_WINDOW(dialog), title);
......
...@@ -126,7 +126,7 @@ class CoWowGtk : public CoWow { ...@@ -126,7 +126,7 @@ class CoWowGtk : public CoWow {
void (* questionbox_ok) ( void *, void *), void (* questionbox_ok) ( void *, void *),
void (* questionbox_cancel) ( void *, void *), void (* questionbox_cancel) ( void *, void *),
void *data); void *data);
void DisplayError( const char *title, const char *text); void DisplayError( const char *title, const char *text, lng_eCoding coding = lng_eCoding_ISO8859_1);
void DisplayText( const char *title, const char *text, int width = 0, int height = 0); void DisplayText( const char *title, const char *text, int width = 0, int height = 0);
void CreateInputDialog( void *ctx, const char *title, const char *text, void CreateInputDialog( void *ctx, const char *title, const char *text,
void (* inputdialogbox_ok) ( void *, void *, char *), void (* inputdialogbox_ok) ( void *, void *, char *),
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <string.h> #include <string.h>
#include "co_wow_msg.h" #include "co_wow_msg.h"
#include "co_lng.h"
typedef enum { typedef enum {
wow_eFileSelType_, wow_eFileSelType_,
...@@ -117,7 +118,7 @@ class CoWow { ...@@ -117,7 +118,7 @@ class CoWow {
void (* questionbox_ok) ( void *, void *), void (* questionbox_ok) ( void *, void *),
void (* questionbox_cancel) ( void *, void *), void (* questionbox_cancel) ( void *, void *),
void *data) {} void *data) {}
virtual void DisplayError( const char *title, const char *text) {} virtual void DisplayError( const char *title, const char *text, lng_eCoding coding = lng_eCoding_ISO8859_1) {}
virtual void DisplayText( const char *title, const char *text, int width = 0, int height = 0) {} virtual void DisplayText( const char *title, const char *text, int width = 0, int height = 0) {}
virtual void CreateInputDialog( void *ctx, const char *title, const char *text, virtual void CreateInputDialog( void *ctx, const char *title, const char *text,
void (* inputdialogbox_ok) ( void *, void *, char *), void (* inputdialogbox_ok) ( void *, void *, char *),
......
...@@ -152,7 +152,7 @@ void XttGeGtk::message_dialog_cb( void *ge_ctx, const char *text) ...@@ -152,7 +152,7 @@ void XttGeGtk::message_dialog_cb( void *ge_ctx, const char *text)
char title[80]; char title[80];
strcpy( title, Lng::translate("Message")); strcpy( title, Lng::translate("Message"));
wow.DisplayError( title, Lng::translate(text)); wow.DisplayError( title, Lng::translate(text), Lng::translatefile_coding());
// g_object_set( ((XttGeGtk *)ge)->message_dia_widget, "visible", TRUE, NULL); // g_object_set( ((XttGeGtk *)ge)->message_dia_widget, "visible", TRUE, NULL);
// gtk_label_set_text( GTK_LABEL(((XttGeGtk *)ge)->message_dia_label), text); // gtk_label_set_text( GTK_LABEL(((XttGeGtk *)ge)->message_dia_label), text);
......
...@@ -52,7 +52,6 @@ using namespace std; ...@@ -52,7 +52,6 @@ using namespace std;
#include <string> #include <string>
#include <vector> #include <vector>
extern "C" {
#include "co_cdh.h" #include "co_cdh.h"
#include "co_time.h" #include "co_time.h"
#include "cow_wow.h" #include "cow_wow.h"
...@@ -64,7 +63,6 @@ extern "C" { ...@@ -64,7 +63,6 @@ extern "C" {
#include "rt_elog.h" #include "rt_elog.h"
#include "co_dcli.h" #include "co_dcli.h"
#include <db.h> #include <db.h>
}
#include <deque> #include <deque>
#include <algorithm> #include <algorithm>
......
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