]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GFloat.C
fix tooltips in toolbar
[lyx.git] / src / frontends / gnome / GFloat.C
1 /**
2  * \file GFloat.C
3  * Copyright 2001 The LyX Team.
4  * See the file COPYING.
5  *
6  * \author Michael Koziarski <michael@koziarski.org>
7  */
8
9 #ifdef __GNUG__
10 #pragma implementation
11 #endif
12
13 #include <config.h>
14
15 #include "gnomeBC.h"
16 #include "GFloat.h"
17 #include "support/lstrings.h"
18
19 #include <gtkmm/button.h>
20 #include <gtkmm/checkbutton.h>
21 #include <gtkmm/radiobutton.h>
22 #include <gtkmm/box.h>
23
24 GFloat::GFloat(ControlFloat & c)
25         : FormCB<ControlFloat>(c, "GFloat")
26 {}
27
28
29 GFloat::~GFloat()
30 {}
31
32
33 void GFloat::build()
34 {
35         // Connect the buttons.
36         close_btn()->signal_clicked().connect(SigC::slot(*this, &GFloat::OKClicked));
37         // Manage the buttons state
38         bc().setCancel(close_btn());
39         bc().refresh();
40         connect_signals();
41 }
42
43 void GFloat::apply()
44 {
45         string placement;
46         if (here_definitely()->get_active()) {
47                 placement += "H";
48         } else {
49                 if (top_of_page()->get_active()) {
50                         placement += "t";
51                 }
52                 if (bottom_of_page()->get_active()) {
53                         placement += "b";
54                 }
55                 if (page_of_floats()->get_active()) {
56                         placement += "p";
57                 }
58                 if (here_if_possible()->get_active()) {
59                         placement += "h";
60                 }
61         }
62         controller().params().placement = placement;
63 }
64
65
66 void GFloat::update()
67 {
68         disconnect_signals();
69         bool top = false;
70         bool bottom = false;
71         bool page = false;
72         bool here = false;
73         bool forcehere = false;
74
75         string placement(controller().params().placement);
76
77         if (contains(placement, "H")) {
78                 forcehere = true;
79         } else {
80                 if (contains(placement, "t")) {
81                         top = true;
82                 }
83                 if (contains(placement, "b")) {
84                         bottom = true;
85                 }
86                 if (contains(placement, "p")) {
87                         page = true;
88                 }
89                 if (contains(placement, "h")) {
90                         here = true;
91                 }
92         }
93         
94         top_of_page()->set_active(top);
95         page_of_floats()->set_active(page);
96         bottom_of_page()->set_active(bottom);
97         here_if_possible()->set_active(here);
98         here_definitely()->set_active(forcehere);
99         connect_signals();
100 }
101
102 void GFloat::connect_signals()
103 {
104         conn_top_        = top_of_page()->signal_toggled().connect(
105                 SigC::slot(*this, &GFloat::ApplyClicked)
106                 );
107         conn_bottom_     = bottom_of_page()->signal_toggled().connect(
108                 SigC::slot(*this, &GFloat::ApplyClicked)
109                 );
110         conn_page_       = page_of_floats()->signal_toggled().connect(
111                 SigC::slot(*this, &GFloat::ApplyClicked)
112                 );
113         conn_ifposs_     = here_if_possible()->signal_toggled().connect(
114                 SigC::slot(*this, &GFloat::ApplyClicked)
115                 );
116         conn_definitely_ = here_definitely()->signal_toggled().connect(
117                 SigC::slot(*this, &GFloat::ApplyClicked)
118                 );
119         conn_disable_    = here_definitely()->signal_toggled().connect(
120                 SigC::slot(*this, &GFloat::update_sensitive)
121                 );
122 }
123
124 void GFloat::disconnect_signals() 
125 {
126         conn_top_.disconnect();
127         conn_bottom_.disconnect();
128         conn_page_.disconnect();
129         conn_ifposs_.disconnect();
130         conn_definitely_.disconnect();
131         conn_disable_.disconnect();
132 }
133
134 void GFloat::update_sensitive() 
135 {
136         if (here_definitely()->get_active()) 
137                 other_options()->set_sensitive(false);
138         else 
139                 other_options()->set_sensitive(true);
140
141 }
142
143 Gtk::HBox * GFloat::other_options() const 
144 {
145         return getWidget<Gtk::HBox>("r_other_options");
146 }
147 Gtk::CheckButton * GFloat::page_of_floats() const 
148 {
149         return getWidget<Gtk::CheckButton>("r_page_of_floats");
150 }
151 Gtk::CheckButton * GFloat::top_of_page() const 
152 {
153         return getWidget<Gtk::CheckButton>("r_top_of_page");
154 }
155 Gtk::CheckButton * GFloat::bottom_of_page() const 
156 {
157         return getWidget<Gtk::CheckButton>("r_bottom_of_page");
158 }
159 Gtk::CheckButton * GFloat::here_if_possible() const 
160 {
161         return getWidget<Gtk::CheckButton>("r_here_if_possible");
162 }
163 Gtk::RadioButton * GFloat::here_definitely() const 
164 {
165         return getWidget<Gtk::RadioButton>("r_here_definitely");
166 }
167
168 Gtk::Button * GFloat::close_btn() const 
169 {
170         return getWidget<Gtk::Button>("r_close_btn");
171 }