@@ -146,26 +146,34 @@ void NWindow::sighandle_dblclick_item (const Gtk::TreeModel::Path& path) {
146
146
}
147
147
148
148
/* *
149
- * Handles the user pressing the apply button. Grabs the selected items and
149
+ * Handles the user pressing the apply button.
150
+ */
151
+ void NWindow::sighandle_click_apply (void ) {
152
+ this ->apply_bg ();
153
+ }
154
+
155
+ /* *
156
+ * Performs the apply action
157
+ * Grabs the selected items and
150
158
* calls set_bg on it. It also saves the bg and closes the application if
151
159
* the app is not multiheaded, or the full xin desktop is selected.
152
160
*/
153
- void NWindow::sighandle_click_apply ( void ) {
154
-
155
- // find out which image is currently selected
156
- Gtk::TreeModel::iterator iter = view.get_selected ();
157
- Gtk::TreeModel::Row row = *iter;
161
+ void NWindow::apply_bg ( ) {
162
+
163
+ // find out which image is currently selected
164
+ Gtk::TreeModel::iterator iter = view.get_selected ();
165
+ Gtk::TreeModel::Row row = *iter;
158
166
Glib::ustring file = row[view.record .Filename ];
159
- this ->set_bg (file);
167
+ this ->set_bg (file);
160
168
161
169
// apply - remove dirty flag
162
170
m_dirty = false ;
163
171
164
172
SetBG::SetMode mode = SetBG::string_to_mode ( this ->select_mode .get_active_data () );
165
- Glib::ustring thedisp = this ->select_display .get_active_data ();
166
- Gdk::Color bgcolor = this ->button_bgcolor .get_color ();
173
+ Glib::ustring thedisp = this ->select_display .get_active_data ();
174
+ Gdk::Color bgcolor = this ->button_bgcolor .get_color ();
167
175
168
- // save
176
+ // save
169
177
Config::get_instance ()->set_bg (thedisp, file, mode, bgcolor);
170
178
171
179
// tell the row that he's now on thedisp
@@ -178,7 +186,7 @@ void NWindow::sighandle_click_apply (void) {
178
186
// old background on thedisp, but could be 2 items if xinerama individual bgs
179
187
// are replaced by the fullscreen xinerama.
180
188
for (Gtk::TreeIter i = view.store ->children ().begin (); i != view.store ->children ().end (); i++)
181
- {
189
+ {
182
190
Glib::ustring curbgondisp = (*i)[view.record .CurBGOnDisp ];
183
191
if (curbgondisp == " " )
184
192
continue ;
@@ -199,24 +207,34 @@ void NWindow::sighandle_click_apply (void) {
199
207
else
200
208
(*i)[view.record .Description ] = Util::make_current_set_string (this , filename, (*mapiter).first );
201
209
}
202
-
203
210
}
204
211
205
212
bool NWindow::on_delete_event (GdkEventAny *event)
206
213
{
207
214
if (m_dirty)
208
215
{
209
- Gtk::MessageDialog dialog (*this , _ (" You previewed an image without applying it, exit anyway?" ), false , Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true );
216
+ int result;
217
+ Gtk::MessageDialog dialog (*this ,
218
+ _ (" You previewed an image without applying it, apply?" ), false ,
219
+ Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true );
220
+
221
+ dialog.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
222
+ dialog.add_button (Gtk::Stock::NO, Gtk::RESPONSE_NO);
223
+ dialog.add_button (Gtk::Stock::YES, Gtk::RESPONSE_YES);
224
+
225
+ dialog.set_default_response (Gtk::RESPONSE_YES);
226
+ result = dialog.run ();
210
227
211
- int result = dialog.run ();
212
228
switch (result)
213
229
{
214
230
case Gtk::RESPONSE_YES:
215
-
231
+ this -> apply_bg ();
216
232
break ;
217
233
case Gtk::RESPONSE_NO:
218
- return true ;
219
234
break ;
235
+ case Gtk::RESPONSE_CANCEL:
236
+ case Gtk::RESPONSE_DELETE_EVENT:
237
+ return true ;
220
238
};
221
239
}
222
240
0 commit comments