]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/FormCredits.C
fix problem with nroff detection, remove dead code with old floats, bogus message...
[lyx.git] / src / frontends / gnome / FormCredits.C
1 /* This file is part of
2  * =================================================
3  * 
4  *          LyX, The Document Processor
5  *          Copyright 1995-2000 The LyX Team.
6  *
7  * ================================================= 
8  *
9  * \author Michael Koziarski <michael@koziarski.org>
10  */
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include <config.h>
17
18 #include "debug.h"
19
20 #include "gnomeBC.h"
21 #include "FormCredits.h"
22 #include "gnome_helpers.h"
23
24 #include <gtk--/button.h>
25 #include <gtk--/text.h>
26 #include <gtk--/style.h>
27
28 FormCredits::FormCredits(ControlCredits & c)
29         : FormCB<ControlCredits>(c, "diahelpcredits.glade", "DiaHelpCredits")
30 {
31 }
32
33
34 void FormCredits::build()
35 {
36         // It is better to show an OK button, but the policy require that we
37         // get a click on "Cancel"
38         ok()->clicked.connect(SigC::slot(this, &FormCredits::CancelClicked));
39
40         // Do not update the dialog when we insert the text
41         text()->freeze();
42         
43         // Get the credits into the string stream
44         stringstream ss;
45         string credits = controller().getCredits(ss).str();
46
47         // Create the strings that we need to detect.
48         string const bold("@b");
49         string const italic("@i");
50
51         // Create the drawing contexts.
52         Gtk::Text_Helpers::Context c_italic;
53         Gtk::Text_Helpers::Context c_bold;
54
55         {
56                 string bold = get_font_name(text()->get_style()->get_font());
57                 //lyxerr << "Font name: " << bold << std::endl;
58                 string italic(bold);
59
60                 string const medium("Medium-");
61                 std::string::size_type index = bold.find(medium);
62                 bold.replace(index, medium.size()-1, "bold");
63
64                 string const r("R-");
65                 index = italic.find(r);
66                 italic.replace(index, r.size()-1, "i");
67                 
68                 //lyxerr << "Bold: " << bold << "\nItalic: " << italic << std::endl;
69                 c_bold.set_font(Gdk_Font(bold));
70                 c_italic.set_font(Gdk_Font(italic));
71         }
72
73         // Insert it into the text and parse the attributes.
74         while (!credits.empty()) {
75                 std::string::size_type end = credits.find('\n');
76                 string const line = credits.substr(0, ++end);
77                 credits = credits.substr(end);
78                 
79 //              lyxerr << "Line got: '" << line << "'\nend = " << end << std::endl;
80                 
81                 string const prefix = line.substr(0, 2);
82                 if (prefix == bold) {
83                         text()->insert(c_bold, line.substr(2));
84                 } else if (prefix == italic) {
85                         text()->insert(c_italic, line.substr(2));
86                 } else {
87                         text()->insert(line);
88                 }
89         }
90         
91         // Allow the text area to be drawn.
92         text()->thaw();
93 }
94
95
96 Gtk::Text * FormCredits::text()
97 {
98         return getWidget<Gtk::Text>("credits_text");
99 }
100
101 Gtk::Button * FormCredits::ok()
102 {
103         return getWidget<Gtk::Button>("credits_button_ok");
104 }