]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GView.C
Get rid of trailing whitespace 'noise' in future patches for the
[lyx.git] / src / frontends / gtk / GView.C
1 /**
2  * \file GView.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Huang Ying
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12 #include <gtkmm.h>
13
14 #include "GView.h"
15 #include "MenuBackend.h"
16 #include "support/filetools.h"
17 #include "GMenubar.h"
18 #include "GToolbar.h"
19 #include "BufferView.h"
20 #include "XWorkArea.h"
21 #include "lyx_cb.h"
22 #include "GMiniBuffer.h"
23 #include "lyxfunc.h"
24 #include <boost/bind.hpp>
25
26 BufferView * current_view;
27
28 GView * GView::view_ = 0;
29
30
31 GView::GView()
32 {
33         view_ = this;
34         vbox_.reset(new Gtk::VBox());
35         add(*vbox_.get());
36         menubar_.reset(new GMenubar(this, menubackend));
37         toolbar_.reset(new GToolbar(this, 0, 0));
38         toolbar_->init();
39         bufferview_.reset(new BufferView(this, 0, 0, 300, 300));
40         ::current_view = bufferview_.get();
41         minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
42         vbox_->show();
43         focus_command_buffer.connect(
44                 boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
45         view_state_changed.connect(boost::bind(&GView::showViewState, this));
46         signal_focus_in_event().connect(SigC::slot(*this, &GView::onFocusIn));
47         set_default_size(500, 550);
48         // Make sure the buttons are disabled if needed.
49         updateToolbar();
50         string const iconName =
51                 lyx::support::LibFileSearch("images", "lyx", "xpm");
52         if (!iconName.empty())
53                 set_icon_from_file(iconName);
54 }
55
56
57 GView::~GView()
58 {
59 }
60
61
62 bool GView::on_delete_event(GdkEventAny * /*event*/)
63 {
64         QuitLyX();
65         return true;
66 }
67
68
69 bool GView::onFocusIn(GdkEventFocus * /*event*/)
70 {
71         workArea_->grab_focus();
72         return true;
73 }
74
75
76 void GView::prohibitInput() const
77 {
78         view()->hideCursor();
79         const_cast<GView*>(this)->set_sensitive(false);
80 }
81
82
83 void GView::allowInput() const
84 {
85         const_cast<GView*>(this)->set_sensitive(true);
86 }
87
88
89 void GView::message(string const & msg)
90 {
91         minibuffer_->message(msg);
92 }
93
94
95 void GView::showViewState()
96 {
97         message(getLyXFunc().view_status_message());
98 }
99
100
101 void GView::setWindowTitle(string const & t, string const & /*it*/)
102 {
103         set_title(Glib::locale_to_utf8(t));
104 }
105
106
107 void GView::busy(bool yes) const
108 {
109         if (yes ) {
110                 view()->hideCursor();
111                 Gdk::Cursor cursor(Gdk::WATCH);
112                 const_cast<GView*>(this)->get_window()->set_cursor(cursor);
113                 const_cast<GView*>(this)->set_sensitive(false);
114         } else {
115                 const_cast<GView*>(this)->get_window()->set_cursor();
116                 const_cast<GView*>(this)->set_sensitive(true);
117         }
118 }
119
120
121 void GView::clearMessage()
122 {
123         message(getLyXFunc().view_status_message());
124 }