Sophie

Sophie

distrib > Mandriva > 2006.0 > i586 > media > main-src > by-pkgid > a6bc312ce50b5c8d0c51736e58ac32bc > files > 258

kdebase-3.4.2-55mdk.src.rpm

--- kdebase-3.2/kcontrol/locale/kcmlocale.cpp--	2004-03-03 11:55:45.000000000 +0100
+++ kdebase-3.2/kcontrol/locale/kcmlocale.cpp	2004-03-03 12:14:20.000000000 +0100
@@ -38,6 +38,12 @@
 #include <kiconloader.h>
 
 #include <qlistbox.h>
+#include <kprocess.h>
+#include <kstandarddirs.h>
+
+#include <stdlib.h>
+#include <kdebug.h>
+
 
 #include "klanguagebutton.h"
 #include "kcmlocale.h"
@@ -59,6 +65,8 @@ KLocaleConfig::KLocaleConfig(KLocale *lo
   m_labCountry->setBuddy(m_comboCountry);
   connect( m_comboCountry, SIGNAL(activated(const QString &)),
            this, SLOT(changedCountry(const QString &)) );
+  connect(m_comboCountry, SIGNAL(activated(const QString &)),
+          SLOT(slotLangChanged()));
 
   m_labLang = new QLabel(this, I18N_NOOP("Languages:"));
   m_labLang->setAlignment( AlignTop );
@@ -74,6 +82,8 @@ KLocaleConfig::KLocaleConfig(KLocale *lo
   boxlay->add(m_addLanguage);
   connect(m_addLanguage, SIGNAL(activated(const QString &)),
           SLOT(slotAddLanguage(const QString &)));
+  connect(m_addLanguage, SIGNAL(activated(const QString &)),
+          SLOT(slotLangChanged()));
   m_removeLanguage = new QPushButton(vb, I18N_NOOP("Remove Language"));
   m_upButton = new QPushButton(vb, I18N_NOOP("Move Up"));
   m_downButton = new QPushButton(vb, I18N_NOOP("Move Down"));
@@ -124,6 +134,7 @@ void KLocaleConfig::slotAddLanguage(cons
 
   m_locale->setLanguage( languageList );
 
+  updateLocaleDrake(true);
   emit localeChanged();
   if ( pos == 0 )
     emit languageChanged();
@@ -470,3 +481,50 @@ void KLocaleConfig::changedCountry(const
   emit localeChanged();
   emit languageChanged();
 }
+
+
+void KLocaleConfig::updateLocaleDrake(bool apply)
+{
+   // /usr/sbin on Mandrake, $PATH allows flexibility for other distributions
+   QString path = QString::fromLocal8Bit(getenv("PATH")) + QString::fromLatin1(":/usr/sbin");
+   QString exeName=QString::fromLatin1("localedrake");
+   QString exe = KStandardDirs::findExe( exeName, path );
+   if (exe.isEmpty())
+     {
+       kdError() << exeName << " not found in " << path << endl;
+       return;
+     }
+  if (!exe.isEmpty())
+    {
+      KProcess *proc=new KProcess;
+      *proc << exe;
+      *proc << QString::fromLatin1(" --kde_lang=")+ m_addLanguage->current();
+      *proc << QString::fromLatin1(" --kde_country=")+m_comboCountry->current();
+      if( apply)
+   *proc << QString::fromLatin1(" --apply");
+      connect(proc, SIGNAL(processExited(KProcess *)),
+                      this, SLOT(slotLocaleUpdated()));
+      connect( proc, SIGNAL(receivedStdout(KProcess*, char*, int)),
+      this, SLOT(slotReceivedTOC(KProcess*, char*, int)));
+      proc->start( KProcess::NotifyOnExit,KProcess::AllOutput );
+    }
+}
+
+void KLocaleConfig::slotReceivedTOC(KProcess*, char*_data, int _length)
+{
+  result=QString::null;
+  //-1 remove \n
+  for(int i=0;i<_length-1;i++)
+    result+=_data[i];
+}
+
+void KLocaleConfig::slotLocaleUpdated()
+{
+  //comboChset->setCurrentItem(result);
+}
+
+void KLocaleConfig::slotLangChanged()
+{
+  //don't update system locale
+  updateLocaleDrake(false);
+}
--- kdebase-3.2/kcontrol/locale/kcmlocale.h--	2004-03-03 11:55:59.000000000 +0100
+++ kdebase-3.2/kcontrol/locale/kcmlocale.h	2004-03-03 12:13:50.000000000 +0100
@@ -36,6 +36,7 @@ class KAddButton;
 class QLabel;
 class QListBox;
 class QPushButton;
+class KProcess;
 
 #include <qstringlist.h>
 
@@ -49,6 +50,7 @@ public:
   virtual ~KLocaleConfig( );
 
   void save();
+  void updateLocaleDrake(bool apply);
 
 public slots:
   /**
@@ -59,6 +61,9 @@ public slots:
    * Retranslate all objects owned by this object using the current locale.
    */
   void slotTranslate();
+  void slotLocaleUpdated();
+  void slotReceivedTOC(KProcess*, char*, int);
+  void slotLangChanged();
 
 signals:
   void localeChanged();
@@ -93,6 +98,7 @@ private:
   QPushButton * m_removeLanguage;
   QPushButton * m_upButton;
   QPushButton * m_downButton;
+  QString result;
 };
 
 #endif