]> git.lyx.org Git - lyx.git/blobdiff - src/intl.C
More fixes to insettabular/text (and some missing features added).
[lyx.git] / src / intl.C
index 28bcae1716054c9dda55d0ad6ef86e0dbb8ad0a8..0a4ee015e56e5cedbd94e4dcc78f8e623aab4fbd 100644 (file)
 #include "lyx_gui_misc.h" // CancelCloseBoxCB
 #include "debug.h"
 #include "lyxrc.h"
+
+#if 0
 #include "trans_mgr.h"
+#endif
+
 #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 +47,33 @@ 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)
+#if 0
+       , trans(new TransManager)
+#endif
 {
        keymapon = lyxrc.use_kbmap;
        chsetcode = 0;
        primarykeymap = false;
        curkeymap = 0;
        otherkeymap = 0;
+       r_ = Dialogs::redrawGUI.connect(slot(this, &Intl::redraw));
 }
 
+
 Intl::~Intl()
 {
+       r_.disconnect();
+#if 0
        delete trans;
+#endif
+}
+
+
+void Intl::redraw()
+{
+       if (fd_form_keymap && fd_form_keymap->KeyMap->visible)
+               fl_redraw_form(fd_form_keymap->KeyMap);
 }
 
 
@@ -58,7 +81,11 @@ int Intl::SetPrimary(string const & lang)
 {
        if (lyxerr.debugging(Debug::KBMAP))
                lyxerr << "Primary: `" << lang << "'" << endl;
+#if 0
        return trans->SetPrimary(lang);
+#else
+       return trans.SetPrimary(lang);
+#endif
 }
 
 
@@ -66,7 +93,11 @@ int Intl::SetSecondary(string const & lang)
 {
        if (lyxerr.debugging(Debug::KBMAP))
                lyxerr << "Secondary: `" << lang << "'" << endl;
+#if 0
        return trans->SetSecondary(lang);
+#else
+       return trans.SetSecondary(lang);
+#endif
 }
 
 
@@ -93,7 +124,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 +143,11 @@ void Intl::KeyMapOn(bool on)
        } else {
                fl_set_button(fd_form_keymap->KeyOffBtn, 1);
                fl_hide_object(fd_form_keymap->KeymapErr);
+#if 0
                trans->DisableKeymap();
+#else
+               trans.DisableKeymap();
+#endif
        }
 }
 
@@ -135,7 +170,7 @@ void Intl::KeyMapPrim()
        fl_set_button(fd_form_keymap->KeyOnBtn2, 0);
 
        /* read text from choice */
-       int i = Language->get();
+       int const i = Language->get();
 
        string p;
        if (i == otherkeymap)
@@ -145,13 +180,21 @@ void Intl::KeyMapPrim()
 
        curkeymap = i;
 
+#if 0
        if (p.empty() || trans->SetPrimary(p)) {
+#else
+       if (p.empty() || trans.SetPrimary(p)) {
+#endif
                // error selecting keymap
                fl_show_object(fd_form_keymap->KeymapErr);
                update();
        } else {
                // no error
+#if 0
                trans->EnablePrimary();
+#else
+               trans.EnablePrimary();
+#endif
                keymapon = true;
                primarykeymap = true;
                fl_hide_object(fd_form_keymap->KeymapErr);
@@ -165,8 +208,8 @@ void Intl::KeyMapSec()
        fl_set_button(fd_form_keymap->KeyOnBtn, 0);
        fl_set_button(fd_form_keymap->KeyOnBtn2, 1);
 
-       /* read text from choice */
-       int i = Language2->get();
+       // read text from choice
+       int const i = Language2->get();
 
        string p;
        if (i == otherkeymap)
@@ -175,6 +218,7 @@ void Intl::KeyMapSec()
                p = Language2->getline();
        curkeymap = i;
 
+#if 0
        if (p.empty() || trans->SetSecondary(p)) {
                // error selecting keymap
                fl_show_object(fd_form_keymap->KeymapErr);
@@ -186,8 +230,22 @@ void Intl::KeyMapSec()
                primarykeymap = false;
                fl_hide_object(fd_form_keymap->KeymapErr);
        }
+#else
+       if (p.empty() || trans.SetSecondary(p)) {
+               // error selecting keymap
+               fl_show_object(fd_form_keymap->KeymapErr);
+               update();
+       } else {
+               // no error
+               trans.EnableSecondary();
+               keymapon = true;
+               primarykeymap = false;
+               fl_hide_object(fd_form_keymap->KeymapErr);
+       }
+#endif
 }
 
+
 void Intl::LCombo(int, void * v, Combox * combox)
 {
        Intl * itl = static_cast<Intl*>(v);
@@ -198,6 +256,7 @@ void Intl::LCombo(int, void * v, Combox * combox)
        return;
 }
 
+
 void Intl::DispatchCallback(FL_OBJECT * ob, long code)
 {
        if (ob && (code == 0)) {
@@ -209,7 +268,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 +279,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;
 
@@ -273,11 +332,12 @@ void Intl::InitKeyMapper(bool on)
        Language2->add(120, 110, 160, 30, 300); // Secondary
        fl_end_form();
 
-       int n = 1;
+       int n = 0;
        // Default is not in the language map
 #ifdef DO_USE_DEFAULT_LANGUAGE
        Language->addto("default");
        Language2->addto("default");
+       ++n;
 #endif
        for (Languages::const_iterator cit = languages.begin();
             cit != languages.end(); ++cit) {
@@ -290,24 +350,34 @@ void Intl::InitKeyMapper(bool on)
        Language2->addto(_("other..."));
        otherkeymap = n + 1;
        if (!Language->select_text(prim_lang)) {
-               Language->select(n+1);
+               Language->select(n + 1);
                fl_set_input(fd_form_keymap->OtherKeymap, prim_lang.c_str());
        }
-       else 
+       else
+#if 0
                trans->SetPrimary(prim_lang);
-
+#else
+               trans.SetPrimary(prim_lang);
+#endif
        if (!Language2->select_text(sec_lang)) {
                Language2->select(n + 1);
                fl_set_input(fd_form_keymap->OtherKeymap2, sec_lang.c_str());
        }
        else
+#if 0
                trans->SetSecondary(sec_lang);
+#else
+               trans.SetSecondary(sec_lang);
+#endif
 
        KeyMapOn(keymapon);
        if (keymapon)
                Keymap(23); // turn primary on
-
+#if 0
        trans->setCharset(lyxrc.font_norm);
+#else
+       trans.setCharset(lyxrc.font_norm);
+#endif
 }
 
 
@@ -321,7 +391,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:
@@ -341,9 +411,13 @@ 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 0
                if (trans->setCharset(p))
+#else
+               if (trans.setCharset(p))
+#endif
                        fl_show_object(fd_form_keymap->ChsetErr);
                else
                        fl_hide_object(fd_form_keymap->ChsetErr);
@@ -356,6 +430,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"));
 }