[pan2/new_master: 265/266] more iconv fixes, but iconv isn't dynamic, only converts for the current group



commit 3741c7790de2cf5307327fdadc300351059964d4
Author: Heinrich MÃller <henmull src gnome org>
Date:   Mon Jan 2 13:58:08 2012 +0100

    more iconv fixes, but iconv isn't dynamic, only converts for the current group

 pan/gui/actions.cc             |    6 +++---
 pan/gui/gui.cc                 |   12 +++++++++++-
 pan/gui/pan.ui.h               |    4 ++--
 pan/gui/progress-view.cc       |    9 ++++++++-
 pan/gui/task-pane.cc           |    8 ++++++--
 pan/usenet-utils/mime-utils.cc |   11 ++++++++++-
 pan/usenet-utils/mime-utils.h  |    6 +++---
 7 files changed, 43 insertions(+), 13 deletions(-)
---
diff --git a/pan/gui/actions.cc b/pan/gui/actions.cc
index 0a61680..7470f75 100644
--- a/pan/gui/actions.cc
+++ b/pan/gui/actions.cc
@@ -561,9 +561,9 @@ namespace
       N_("_Turn Flag off for Thread"),
       G_CALLBACK(do_flag_off) },
 
-    { "mark-all-flagged", NULL,
-      N_("_Mark all flagged Threads"), "<control>X",
-      N_("_Mark all flagged Threads"),
+    { "select-all-flagged", NULL,
+      N_("_Select all flagged Threads"), "<control>X",
+      N_("_Select all flagged Threads"),
       G_CALLBACK(do_mark_all_flagged) },
 
     { "next-flagged", NULL,
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 0b12152..958104b 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -1809,6 +1809,10 @@ void GUI :: do_show_selected_article_info ()
     foreach_const (std::set<number_t>, missing_parts, it)
       s << ' ' << *it;
 
+
+    const char* author = iconv_inited ? __g_mime_iconv_strdup(conv, a->author.c_str()) : a->author.c_str();
+    const char* subject = iconv_inited ? __g_mime_iconv_strdup(conv, a->subject.c_str()) : a->subject.c_str();
+
     GtkWidget * w = gtk_message_dialog_new_with_markup (
       get_window(_root),
       GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -1819,7 +1823,7 @@ void GUI :: do_show_selected_article_info ()
         "<b>%s</b>: %lu\n" "<b>%s</b>: %s (%lu %s)\n"
         "\n"
         "%s" "%s",
-        _("Subject"), a->subject.c_str(), _("From"), a->author.c_str(),
+        _("Subject"), subject, _("From"), author,
         _("Date"), date, _("Message-ID"), a->message_id.c_str(),
         _("Lines"), a->get_line_count(), _("Size"), bytes_to_size(a->get_byte_count()).c_str(),
         a->get_byte_count(),_("Bytes"),
@@ -1829,6 +1833,12 @@ void GUI :: do_show_selected_article_info ()
 
     // cleanup
     g_free (date);
+    if (iconv_inited)
+    {
+      g_free ((char*)author);
+      g_free ((char*)subject);
+    }
+
   }
 }
 
diff --git a/pan/gui/pan.ui.h b/pan/gui/pan.ui.h
index abecb3e..ad6bc23 100644
--- a/pan/gui/pan.ui.h
+++ b/pan/gui/pan.ui.h
@@ -136,7 +136,7 @@ const char * fallback_ui_file =
 "        <menuitem action='unflag-thread' />\n"
 "        <menuitem action='next-flagged' />\n"
 "        <menuitem action='last-flagged' />\n"
-"        <menuitem action='mark-all-flagged' />\n"
+"        <menuitem action='select-all-flagged' />\n"
 "        <separator />\n"
 "        <menuitem action='plonk' />\n"
 "        <menuitem action='view-article-score' />\n"
@@ -212,7 +212,7 @@ const char * fallback_ui_file =
 "    <menuitem action='unflag-thread' />\n"
 "    <menuitem action='next-flagged' />\n"
 "    <menuitem action='last-flagged' />\n"
-"    <menuitem action='mark-all-flagged' />\n"
+"    <menuitem action='select-all-flagged' />\n"
 "    <separator />\n"
 "    <menuitem action='plonk' />\n"
 "    <menuitem action='view-article-score' />\n"
diff --git a/pan/gui/progress-view.cc b/pan/gui/progress-view.cc
index 7134bfc..9bf2daf 100644
--- a/pan/gui/progress-view.cc
+++ b/pan/gui/progress-view.cc
@@ -22,6 +22,7 @@ extern "C" {
   #include <pan/gui/gtk-compat.h>
 }
 #include <pan/general/string-view.h>
+#include <pan/usenet-utils/mime-utils.h>
 #include "progress-view.h"
 
 using namespace pan;
@@ -94,8 +95,14 @@ ProgressView :: on_progress_status_idle (gpointer self_gpointer)
   std::string status;
   if (self->_progress)
     status = self->_progress->get_status();
-  gtk_progress_bar_set_text (GTK_PROGRESS_BAR(self->_progressbar), status.c_str());
+
+  const char* _status = iconv_inited ? __g_mime_iconv_strdup(conv,status.c_str()) : status.c_str();
+
+  gtk_progress_bar_set_text (GTK_PROGRESS_BAR(self->_progressbar), _status);
   self->_progress_status_idle_tag = 0;
+
+  if (iconv_inited) g_free((char*)_status);
+
   return false;
 }
 
diff --git a/pan/gui/task-pane.cc b/pan/gui/task-pane.cc
index a31a9d4..b046557 100644
--- a/pan/gui/task-pane.cc
+++ b/pan/gui/task-pane.cc
@@ -28,6 +28,7 @@ extern "C" {
 #include <pan/general/file-util.h>
 #include <pan/general/macros.h>
 #include <pan/general/utf8-utils.h>
+#include <pan/usenet-utils/mime-utils.h>
 #include <pan/tasks/queue.h>
 #include <pan/icons/pan-pixbufs.h>
 #include "pad.h"
@@ -532,6 +533,8 @@ namespace
     // get the description
     const std::string description (task->describe ());
 
+    const char * descr = iconv_inited ? __g_mime_iconv_strdup(conv, description.c_str()) : description.c_str();
+
     std::string status (state_str);
 
     if (percent) {
@@ -566,12 +569,13 @@ namespace
     char * str (0);
     if (state == Queue::RUNNING || state == Queue::DECODING
         || state == Queue::ENCODING)
-      str = g_markup_printf_escaped ("<b>%s</b>\n<small>%s</small>", description.c_str(), status.c_str());
+      str = g_markup_printf_escaped ("<b>%s</b>\n<small>%s</small>", descr, status.c_str());
     else
-      str = g_markup_printf_escaped ("%s\n<small>%s</small>", description.c_str(), status.c_str());
+      str = g_markup_printf_escaped ("%s\n<small>%s</small>", descr, status.c_str());
     const std::string str_utf8 = clean_utf8 (str);
     g_object_set(rend, "markup", str_utf8.c_str(), "xpad", 10, "ypad", 5, NULL);
     g_free (str);
+    if (iconv_inited) g_free ((char*)descr);
   }
 }
 
diff --git a/pan/usenet-utils/mime-utils.cc b/pan/usenet-utils/mime-utils.cc
index 3525b04..886cbe4 100644
--- a/pan/usenet-utils/mime-utils.cc
+++ b/pan/usenet-utils/mime-utils.cc
@@ -47,8 +47,15 @@ namespace pan
   bool iconv_inited(false);
 
   char *
-  __g_mime_iconv_strndup (iconv_t cd, const char *str, size_t n)
+  __g_mime_iconv_strndup (iconv_t cd, const char *str, size_t n, const char* charset)
   {
+    iconv_t ic(0), backup(0);
+    if (charset)
+    {
+      ic = iconv_open ("UTF-8", charset);
+      backup = conv;
+      conv = ic;
+    }
 
     size_t inleft, outleft, converted = 0;
     char *out, *outbuf;
@@ -131,6 +138,8 @@ namespace pan
     /* reset the cd */
     iconv (cd, NULL, NULL, NULL, NULL);
 
+    if (backup) conv = backup;
+
     return out;
   }
 }
diff --git a/pan/usenet-utils/mime-utils.h b/pan/usenet-utils/mime-utils.h
index fa89512..66822ab 100644
--- a/pan/usenet-utils/mime-utils.h
+++ b/pan/usenet-utils/mime-utils.h
@@ -115,11 +115,11 @@ namespace pan
   extern iconv_t conv;
   extern bool iconv_inited;
 
-  char * __g_mime_iconv_strndup (iconv_t cd, const char *str, size_t n);
+  char * __g_mime_iconv_strndup (iconv_t cd, const char *str, size_t n, const char* charset=0);
 
-  static char * __g_mime_iconv_strdup (iconv_t cd, const char *str)
+  static char * __g_mime_iconv_strdup (iconv_t cd, const char *str, const char* charset=0)
   {
-    return __g_mime_iconv_strndup(cd, str, strlen(str));
+    return __g_mime_iconv_strndup(cd, str, strlen(str), charset);
   }
 
 }



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