X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fgtk%2Flyx_gui.C;h=fef13b1af14eba2e3278b660c60121182f08828c;hb=1396ade8b1c050b73493391469d194e790b2ffe9;hp=5053f92aee5de89bc3bfc124a1ebe8ea13a013a8;hpb=b6ab9d88866d33c67437aec552c739d2740e92f1;p=lyx.git diff --git a/src/frontends/gtk/lyx_gui.C b/src/frontends/gtk/lyx_gui.C index 5053f92aee..fef13b1af1 100644 --- a/src/frontends/gtk/lyx_gui.C +++ b/src/frontends/gtk/lyx_gui.C @@ -26,6 +26,7 @@ #include "funcrequest.h" #include "gettext.h" +#include "Color.h" #include "LColor.h" #include "LyXAction.h" #include "lyx_main.h" @@ -87,10 +88,6 @@ bool lyx_gui::use_gui = true; namespace { -/// quit lyx -bool finished = false; - - /// estimate DPI from X server int getDPI() { @@ -146,11 +143,7 @@ void lyx_gui::start(string const & batch, std::vector const & files) view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch)); } - // enter the event loop - while (!finished) { - while (Gtk::Main::events_pending()) - Gtk::Main::iteration(false); - } + Gtk::Main::run(); // FIXME: breaks emergencyCleanup delete lyxsocket; @@ -160,7 +153,7 @@ void lyx_gui::start(string const & batch, std::vector const & files) void lyx_gui::exit() { - finished = true; + Gtk::Main::quit(); } @@ -183,23 +176,44 @@ FuncStatus lyx_gui::getStatus(FuncRequest const & ev) } -string const lyx_gui::hexname(LColor_color col) +bool lyx_gui::getRGBColor(LColor_color col, lyx::RGBColor & rgbcol) { Gdk::Color gdkColor; Gdk::Color * gclr = colorCache.getColor(col); if (!gclr) { gclr = &gdkColor; - gclr->parse(lcolor.getX11Name(col)); + if(!gclr->parse(lcolor.getX11Name(col))) { + rgbcol.r = 0; + rgbcol.g = 0; + rgbcol.b = 0; + return false; + } } - std::ostringstream os; - // Note that X stores the RGB values in the range 0 - 65535 // whilst we require them in the range 0 - 255. + rgbcol.r = gclr->get_red() / 256; + rgbcol.g = gclr->get_green() / 256; + rgbcol.b = gclr->get_blue() / 256; + return true; +} + + +string const lyx_gui::hexname(LColor_color col) +{ + lyx::RGBColor rgbcol; + if (!getRGBColor(col, rgbcol)) { + lyxerr << "X can't find color for \"" << lcolor.getLyXName(col) + << '"' << std::endl; + return string(); + } + + std::ostringstream os; + os << std::setbase(16) << std::setfill('0') - << std::setw(2) << (gclr->get_red() / 256) - << std::setw(2) << (gclr->get_green() / 256) - << std::setw(2) << (gclr->get_blue() / 256); + << std::setw(2) << rgbcol.r + << std::setw(2) << rgbcol.g + << std::setw(2) << rgbcol.b; return os.str(); }