]> git.lyx.org Git - lyx.git/blobdiff - src/intl.C
mathed31.diff
[lyx.git] / src / intl.C
index c25e33b5a0133c759900cec153305736d877c979..89141686266f3e6aaa314be151770350103cd0f8 100644 (file)
 #include "lyx_gui_misc.h" // CancelCloseBoxCB
 #include "debug.h"
 #include "lyxrc.h"
-#include "trans_mgr.h"
+
 #include "support/lstrings.h"
 #include "language.h"
+#include "frontends/Dialogs.h" // redrawGUI
+
+#ifdef SIGC_CXX_NAMESPACES
+using SigC::slot;
+#endif
 
 using std::endl;
 
@@ -38,19 +43,27 @@ extern "C" void C_Intl_DispatchCallback(FL_OBJECT * ob, long code);
 
 Intl::Intl()
        : prim_lang(lyxrc.primary_kbmap), 
-       sec_lang(lyxrc.secondary_kbmap),
-       trans(new TransManager)
+       sec_lang(lyxrc.secondary_kbmap)
 {
        keymapon = lyxrc.use_kbmap;
        chsetcode = 0;
        primarykeymap = false;
        curkeymap = 0;
        otherkeymap = 0;
+       r_ = Dialogs::redrawGUI.connect(slot(this, &Intl::redraw));
 }
 
+
 Intl::~Intl()
 {
-       delete trans;
+       r_.disconnect();
+}
+
+
+void Intl::redraw()
+{
+       if (fd_form_keymap && fd_form_keymap->KeyMap->visible)
+               fl_redraw_form(fd_form_keymap->KeyMap);
 }
 
 
@@ -58,7 +71,7 @@ int Intl::SetPrimary(string const & lang)
 {
        if (lyxerr.debugging(Debug::KBMAP))
                lyxerr << "Primary: `" << lang << "'" << endl;
-       return trans->SetPrimary(lang);
+       return trans.SetPrimary(lang);
 }
 
 
@@ -66,7 +79,7 @@ int Intl::SetSecondary(string const & lang)
 {
        if (lyxerr.debugging(Debug::KBMAP))
                lyxerr << "Secondary: `" << lang << "'" << endl;
-       return trans->SetSecondary(lang);
+       return trans.SetSecondary(lang);
 }
 
 
@@ -93,7 +106,7 @@ void Intl::update()
 
 
 void Intl::KeyMapOn(bool on)
-       /* turn on/off key mappings, status in keymapon */
+       // turn on/off key mappings, status in keymapon
 {
        keymapon = on;
 
@@ -112,7 +125,7 @@ void Intl::KeyMapOn(bool on)
        } else {
                fl_set_button(fd_form_keymap->KeyOffBtn, 1);
                fl_hide_object(fd_form_keymap->KeymapErr);
-               trans->DisableKeymap();
+               trans.DisableKeymap();
        }
 }
 
@@ -145,13 +158,13 @@ void Intl::KeyMapPrim()
 
        curkeymap = i;
 
-       if (p.empty() || trans->SetPrimary(p)) {
+       if (p.empty() || trans.SetPrimary(p)) {
                // error selecting keymap
                fl_show_object(fd_form_keymap->KeymapErr);
                update();
        } else {
                // no error
-               trans->EnablePrimary();
+               trans.EnablePrimary();
                keymapon = true;
                primarykeymap = true;
                fl_hide_object(fd_form_keymap->KeymapErr);
@@ -165,7 +178,7 @@ void Intl::KeyMapSec()
        fl_set_button(fd_form_keymap->KeyOnBtn, 0);
        fl_set_button(fd_form_keymap->KeyOnBtn2, 1);
 
-       /* read text from choice */
+       // read text from choice
        int const i = Language2->get();
 
        string p;
@@ -175,19 +188,20 @@ void Intl::KeyMapSec()
                p = Language2->getline();
        curkeymap = i;
 
-       if (p.empty() || trans->SetSecondary(p)) {
+       if (p.empty() || trans.SetSecondary(p)) {
                // error selecting keymap
                fl_show_object(fd_form_keymap->KeymapErr);
                update();
        } else {
                // no error
-               trans->EnableSecondary();
+               trans.EnableSecondary();
                keymapon = true;
                primarykeymap = false;
                fl_hide_object(fd_form_keymap->KeymapErr);
        }
 }
 
+
 void Intl::LCombo(int, void * v, Combox * combox)
 {
        Intl * itl = static_cast<Intl*>(v);
@@ -198,6 +212,7 @@ void Intl::LCombo(int, void * v, Combox * combox)
        return;
 }
 
+
 void Intl::DispatchCallback(FL_OBJECT * ob, long code)
 {
        if (ob && (code == 0)) {
@@ -209,7 +224,7 @@ void Intl::DispatchCallback(FL_OBJECT * ob, long code)
        
        Intl * itl = static_cast<Intl *>(ob->u_vdata);
 
-       if (itl!= 0) itl->Keymap(code);
+       if (itl != 0) itl->Keymap(code);
 }
 
 
@@ -220,7 +235,7 @@ extern "C" void C_Intl_DispatchCallback(FL_OBJECT * ob, long code)
 
 
 void Intl::InitKeyMapper(bool on)
-       /* initialize key mapper */
+       // initialize key mapper
 {
        lyxerr[Debug::INIT] << "Initializing key mappings..." << endl;
 
@@ -293,22 +308,19 @@ void Intl::InitKeyMapper(bool on)
        if (!Language->select_text(prim_lang)) {
                Language->select(n + 1);
                fl_set_input(fd_form_keymap->OtherKeymap, prim_lang.c_str());
-       }
-       else 
-               trans->SetPrimary(prim_lang);
+       } else
+               trans.SetPrimary(prim_lang);
 
        if (!Language2->select_text(sec_lang)) {
                Language2->select(n + 1);
                fl_set_input(fd_form_keymap->OtherKeymap2, sec_lang.c_str());
-       }
-       else
-               trans->SetSecondary(sec_lang);
+       } else
+               trans.SetSecondary(sec_lang);
 
        KeyMapOn(keymapon);
        if (keymapon)
                Keymap(23); // turn primary on
-
-       trans->setCharset(lyxrc.font_norm);
+       trans.setCharset(lyxrc.font_norm);
 }
 
 
@@ -322,7 +334,7 @@ void Intl::Keymap(long code)
        // spagetti example using a switch... (Lgb)
        switch (code) {
        case 0:
-               /* cancel/hide */
+               // cancel/hide
                fl_hide_form(fd_form_keymap->KeyMap);
                break;
        case 3:
@@ -342,9 +354,9 @@ void Intl::Keymap(long code)
                        KeyMapSec();
                }
                break;
-       case 27:        /* set new font norm */
+       case 27:        // set new font norm
                char const * p = fl_get_input(fd_form_keymap->Charset);
-               if (trans->setCharset(p))
+               if (trans.setCharset(p))
                        fl_show_object(fd_form_keymap->ChsetErr);
                else
                        fl_hide_object(fd_form_keymap->ChsetErr);
@@ -357,6 +369,7 @@ void Intl::MenuKeymap()
 {
        if (fd_form_keymap->KeyMap->visible) {
                fl_raise_form(fd_form_keymap->KeyMap);
-       } else fl_show_form(fd_form_keymap->KeyMap, FL_PLACE_MOUSE,
-                           FL_FULLBORDER, _("Key Mappings"));
+       } else fl_show_form(fd_form_keymap->KeyMap,
+                           FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                           _("Key Mappings"));
 }