From 34e0654bec1ac85887655c237146dfd9a1aa0c9f Mon Sep 17 00:00:00 2001
From: Daniel Kotschate <epyx@epyx-online.de>
Date: Tue, 5 Apr 2011 15:45:34 +0200
Subject: [PATCH] Quit button and linking XLib

---
 src/Makefile.am |    2 +-
 src/NWindow.cc  |  416 ++++++++++++++++++++++++++++---------------------------
 src/NWindow.h   |   75 +++++-----
 3 files changed, 252 insertions(+), 241 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index ae5ecfa..98597c9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,6 @@
 bin_PROGRAMS = nitrogen
 nitrogen_SOURCES = Config.h NWindow.h main.cc md5.h SetBG.cc main.h Thumbview.cc Config.cc NWindow.cc SetBG.h md5.c ArgParser.h ArgParser.cc Thumbview.h ImageCombo.cc ImageCombo.h Inotify.cc Inotify.h Util.h Util.cc NPrefsWindow.cc
-LIBS=@NITROGEN_LIBS@
+LIBS=@NITROGEN_LIBS@ -lX11
 INCLUDES = @NITROGEN_CFLAGS@ \
 	-DNITROGEN_DATA_DIR=\"$(pkgdatadir)\"
 man_MANS = nitrogen.1
diff --git a/src/NWindow.cc b/src/NWindow.cc
index 8409a33..e9148f2 100644
--- a/src/NWindow.cc
+++ b/src/NWindow.cc
@@ -1,21 +1,21 @@
 /*
 
-This file is from Nitrogen, an X11 background setter.  
-Copyright (C) 2006  Dave Foster & Javeed Shaikh
+   This file is from Nitrogen, an X11 background setter.  
+   Copyright (C) 2006  Dave Foster & Javeed Shaikh
 
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2
+   of the License, or (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 */
 
@@ -29,72 +29,77 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "NPrefsWindow.h"
 
 #ifdef USE_XINERAMA
-#include <X11/extensions/Xinerama.h>
+    #include <X11/extensions/Xinerama.h>
 #endif
 
 // leethax constructor
 
-NWindow::NWindow (void) : apply (Gtk::Stock::APPLY), is_multihead(false), is_xinerama(false), btn_prefs(Gtk::Stock::PREFERENCES) {
-	
-	set_border_width (5);
-	set_default_size (450, 500);
+NWindow::NWindow (void) : apply (Gtk::Stock::APPLY), is_multihead(false), is_xinerama(false), btn_prefs(Gtk::Stock::PREFERENCES), quitbtn(Gtk::Stock::QUIT) {
 
-	main_vbox.set_spacing (5);
-	add (main_vbox);
+    set_border_width (5);
+    set_default_size (450, 500);
 
-	// setup imagecombos
-	this->setup_select_boxes();
 
-	// bottom hbox
-	bot_hbox.set_spacing (5);
-	bot_hbox.pack_start (select_mode, FALSE, FALSE, 0);
-	bot_hbox.pack_start (select_display, FALSE, FALSE, 0);
-	bot_hbox.pack_start(button_bgcolor, FALSE, FALSE, 0);
-	
-	bot_hbox.pack_end(apply, FALSE, FALSE, 0);
+    main_vbox.set_spacing (5);
+    add (main_vbox);
+
+    // setup imagecombos
+    this->setup_select_boxes();
+    
+    // bottom hbox
+    bot_hbox.set_spacing (5);
+    bot_hbox.pack_start (select_mode, FALSE, FALSE, 0);
+    bot_hbox.pack_start (select_display, FALSE, FALSE, 0);
+    bot_hbox.pack_start(button_bgcolor, FALSE, FALSE, 0);
+
+    bot_hbox.pack_end(apply, FALSE, FALSE, 0);
+    bot_hbox.pack_end(quitbtn, FALSE, FALSE, 0);
     bot_hbox.pack_end(btn_prefs, FALSE, FALSE, 0);
 
-	// add to main box
-	main_vbox.pack_start (view, TRUE, TRUE, 0);
-	main_vbox.pack_start (bot_hbox, FALSE, FALSE, 0);
+    // add to main box
+    main_vbox.pack_start (view, TRUE, TRUE, 0);
+    main_vbox.pack_start (bot_hbox, FALSE, FALSE, 0);
 
-	// signals
+    // signals
     view.signal_selected.connect(sigc::mem_fun(*this, &NWindow::sighandle_dblclick_item));
-	apply.signal_clicked ().connect (sigc::mem_fun(*this, &NWindow::sighandle_click_apply));
+    //--- Signalhandler
+    apply.signal_clicked ().connect (sigc::mem_fun(*this, &NWindow::sighandle_click_apply));
+    quitbtn.signal_clicked ().connect (sigc::mem_fun(*this, &NWindow::sighandle_click_quitbtn));
     btn_prefs.signal_clicked().connect(sigc::mem_fun(*this, &NWindow::sighandle_btn_prefs));
-	
+
     // set icon
-	try {
-		Glib::RefPtr<Gtk::IconTheme> icontheme = Gtk::IconTheme::get_default();
-		std::vector<Glib::RefPtr<Gdk::Pixbuf> > vec;
-		vec.push_back(icontheme->load_icon("nitrogen", 16, Gtk::ICON_LOOKUP_NO_SVG));
-		vec.push_back(icontheme->load_icon("nitrogen", 22, Gtk::ICON_LOOKUP_NO_SVG));
-		vec.push_back(icontheme->load_icon("nitrogen", 32, Gtk::ICON_LOOKUP_NO_SVG));
-		vec.push_back(icontheme->load_icon("nitrogen", 48, Gtk::ICON_LOOKUP_NO_SVG));
-		vec.push_back(icontheme->load_icon("nitrogen", 128, Gtk::ICON_LOOKUP_NO_SVG));
-		Glib::ListHandle<Glib::RefPtr<Gdk::Pixbuf> > lister(vec);
-
-		this->set_icon_list(lister);
-	} catch  (Gtk::IconThemeError e) {
-		// don't even worry about it!
-	}
-	
+    try {
+        Glib::RefPtr<Gtk::IconTheme> icontheme = Gtk::IconTheme::get_default();
+        std::vector<Glib::RefPtr<Gdk::Pixbuf> > vec;
+        vec.push_back(icontheme->load_icon("nitrogen", 16, Gtk::ICON_LOOKUP_NO_SVG));
+        vec.push_back(icontheme->load_icon("nitrogen", 22, Gtk::ICON_LOOKUP_NO_SVG));
+        vec.push_back(icontheme->load_icon("nitrogen", 32, Gtk::ICON_LOOKUP_NO_SVG));
+        vec.push_back(icontheme->load_icon("nitrogen", 48, Gtk::ICON_LOOKUP_NO_SVG));
+        vec.push_back(icontheme->load_icon("nitrogen", 128, Gtk::ICON_LOOKUP_NO_SVG));
+        Glib::ListHandle<Glib::RefPtr<Gdk::Pixbuf> > lister(vec);
+
+        this->set_icon_list(lister);
+    } catch  (Gtk::IconThemeError e) {
+        // don't even worry about it!
+    }
+
     m_dirty = false;
 }
 
 // shows all of our widgets
 
 void NWindow::show (void) {
-	view.show ();
-	select_mode.show ();
-	if ( this->is_multihead ) select_display.show();
-	apply.show ();
-	bot_hbox.show ();
-	main_vbox.show ();
-	button_bgcolor.show();
+    view.show ();
+    select_mode.show ();
+    if ( this->is_multihead ) select_display.show();
+    apply.show ();
+    quitbtn.show( );
+    bot_hbox.show ();
+    main_vbox.show ();
+    button_bgcolor.show();
     btn_prefs.show();
 
-	this->set_title("Nitrogen");
+    this->set_title("Nitrogen");
 }
 
 /**
@@ -102,36 +107,41 @@ void NWindow::show (void) {
  */
 void NWindow::sighandle_dblclick_item (const Gtk::TreeModel::Path& path) {
 
-	// find out which image was double clicked
-	Gtk::TreeModel::iterator iter = (view.store)->get_iter(path);
-	Gtk::TreeModel::Row row = *iter;
-	this->set_bg(row[view.record.Filename]);
+    // find out which image was double clicked
+    Gtk::TreeModel::iterator iter = (view.store)->get_iter(path);
+    Gtk::TreeModel::Row row = *iter;
+    this->set_bg(row[view.record.Filename]);
 
     // preview - set dirty flag
     m_dirty = true;
 }
 
+void NWindow::sighandle_click_quitbtn(void)
+{
+    Gtk::Main::quit( );
+}
+
 /**
  * Handles the user pressing the apply button.  Grabs the selected items and
  * calls set_bg on it. It also saves the bg and closes the application if 
  * the app is not multiheaded, or the full xin desktop is selected.
  */
 void NWindow::sighandle_click_apply (void) {
-	
-	// find out which image is currently selected
-	Gtk::TreeModel::iterator iter = view.get_selected ();
-	Gtk::TreeModel::Row row = *iter;
+
+    // find out which image is currently selected
+    Gtk::TreeModel::iterator iter = view.get_selected ();
+    Gtk::TreeModel::Row row = *iter;
     Glib::ustring file = row[view.record.Filename];
-	this->set_bg(file);
+    this->set_bg(file);
 
     // apply - remove dirty flag
     m_dirty = false;
 
     SetBG::SetMode mode = SetBG::string_to_mode( this->select_mode.get_active_data() );
-	Glib::ustring thedisp = this->select_display.get_active_data(); 
-	Gdk::Color bgcolor = this->button_bgcolor.get_color();
+    Glib::ustring thedisp = this->select_display.get_active_data(); 
+    Gdk::Color bgcolor = this->button_bgcolor.get_color();
 
-	// save	
+    // save	
     Config::get_instance()->set_bg(thedisp, file, mode, bgcolor);
 
     // tell the row that he's now on thedisp
@@ -144,7 +154,7 @@ void NWindow::sighandle_click_apply (void) {
     // old background on thedisp, but could be 2 items if xinerama individual bgs
     // are replaced by the fullscreen xinerama.
     for (Gtk::TreeIter i = view.store->children().begin(); i != view.store->children().end(); i++)
-	{
+    {
         Glib::ustring curbgondisp = (*i)[view.record.CurBGOnDisp];
         if (curbgondisp == "")
             continue;
@@ -195,19 +205,19 @@ bool NWindow::on_delete_event(GdkEventAny *event)
  */
 void NWindow::set_bg(const Glib::ustring file) {
 
-	// get the data from the active items
-	SetBG::SetMode mode = SetBG::string_to_mode( this->select_mode.get_active_data() );
-	Glib::ustring thedisp = this->select_display.get_active_data(); 
-	Gdk::Color bgcolor = this->button_bgcolor.get_color();
+    // get the data from the active items
+    SetBG::SetMode mode = SetBG::string_to_mode( this->select_mode.get_active_data() );
+    Glib::ustring thedisp = this->select_display.get_active_data(); 
+    Gdk::Color bgcolor = this->button_bgcolor.get_color();
 
-	// set it
+    // set it
 #ifdef USE_XINERAMA
-	if (this->is_xinerama)
-		SetBG::set_bg_xinerama(xinerama_info, xinerama_num_screens, thedisp, file, mode, bgcolor);
-	else
+    if (this->is_xinerama)
+        SetBG::set_bg_xinerama(xinerama_info, xinerama_num_screens, thedisp, file, mode, bgcolor);
+    else
 #endif
-		SetBG::set_bg(thedisp, file, mode, bgcolor);
-	
+        SetBG::set_bg(thedisp, file, mode, bgcolor);
+
 }
 
 // leethax destructor
@@ -217,121 +227,121 @@ NWindow::~NWindow () {}
  * Creates our ImageCombo boxes
  */
 void NWindow::setup_select_boxes() {
-		
-	Glib::RefPtr<Gtk::IconTheme> icontheme = Gtk::IconTheme::get_default();
-	Glib::RefPtr<Gdk::Pixbuf> icon, genericicon, video_display_icon;
-
-	try {
-		genericicon = icontheme->load_icon("image-x-generic", 16, Gtk::ICON_LOOKUP_NO_SVG);
-	} catch (Gtk::IconThemeError e) {
-		genericicon = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, false, 8, 16, 16);
-	}
-
-	try {
-		video_display_icon = icontheme->load_icon("video-display", 16, Gtk::ICON_LOOKUP_NO_SVG);
-	} catch (Gtk::IconThemeError e) {
-		video_display_icon = genericicon;
-	}
-
-	// modes
+
+    Glib::RefPtr<Gtk::IconTheme> icontheme = Gtk::IconTheme::get_default();
+    Glib::RefPtr<Gdk::Pixbuf> icon, genericicon, video_display_icon;
+
+    try {
+        genericicon = icontheme->load_icon("image-x-generic", 16, Gtk::ICON_LOOKUP_NO_SVG);
+    } catch (Gtk::IconThemeError e) {
+        genericicon = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, false, 8, 16, 16);
+    }
+
+    try {
+        video_display_icon = icontheme->load_icon("video-display", 16, Gtk::ICON_LOOKUP_NO_SVG);
+    } catch (Gtk::IconThemeError e) {
+        video_display_icon = genericicon;
+    }
+
+    // modes
     icon = genericicon;
     this->select_mode.add_image_row( icon, _("Automatic"), SetBG::mode_to_string(SetBG::SET_AUTO), true );
-	try {
-		icon = icontheme->load_icon("wallpaper-scaled", 16, Gtk::ICON_LOOKUP_NO_SVG);
-		if (!icon) icon = genericicon;
-	} catch (Gtk::IconThemeError e) {
-		icon = genericicon;
-	}
-	this->select_mode.add_image_row( icon, _("Scaled"), SetBG::mode_to_string(SetBG::SET_SCALE), false );
-
-	try {
-		icon = icontheme->load_icon("wallpaper-centered", 16, Gtk::ICON_LOOKUP_NO_SVG);
-		if (!icon) icon = genericicon;
-	} catch (Gtk::IconThemeError e) {
-		icon = genericicon;
-	}
-	this->select_mode.add_image_row( icon, _("Centered"), SetBG::mode_to_string(SetBG::SET_CENTER), false );
-
-	try {
-		icon = icontheme->load_icon("wallpaper-tiled", 16, Gtk::ICON_LOOKUP_NO_SVG);
-		if (!icon) icon = genericicon;
-	} catch (Gtk::IconThemeError e) {
-		icon = genericicon;
-	}
-	this->select_mode.add_image_row( icon, _("Tiled"), SetBG::mode_to_string(SetBG::SET_TILE), false );
-
-	try {
-		icon = icontheme->load_icon("wallpaper-zoomed", 16, Gtk::ICON_LOOKUP_NO_SVG);
-		if (!icon) icon = genericicon;
-	} catch (Gtk::IconThemeError e) {
-		icon = genericicon;
-	}
-
-	this->select_mode.add_image_row( icon, _("Zoomed"), SetBG::mode_to_string(SetBG::SET_ZOOM), false );
-	this->select_mode.add_image_row( icon, _("Zoomed Fill"), SetBG::mode_to_string(SetBG::SET_ZOOM_FILL), false );
-
-	// displays
-	Glib::RefPtr<Gdk::DisplayManager> manager = Gdk::DisplayManager::get();
-	Glib::RefPtr<Gdk::Display> disp	= manager->get_default_display();
-
-	if ( disp->get_n_screens() > 1 ) 
-	{
-		this->is_multihead = true;	
-
-		for (int i=0; i<disp->get_n_screens(); i++) {
-			Glib::RefPtr<Gdk::Screen> screen = disp->get_screen(i);
-			std::ostringstream ostr;
-			ostr << _("Screen") << " " << i;
-			bool on = (screen == disp->get_default_screen());
-				
-			this->select_display.add_image_row( video_display_icon, ostr.str(), screen->make_display_name(), on );
+    try {
+        icon = icontheme->load_icon("wallpaper-scaled", 16, Gtk::ICON_LOOKUP_NO_SVG);
+        if (!icon) icon = genericicon;
+    } catch (Gtk::IconThemeError e) {
+        icon = genericicon;
+    }
+    this->select_mode.add_image_row( icon, _("Scaled"), SetBG::mode_to_string(SetBG::SET_SCALE), false );
+
+    try {
+        icon = icontheme->load_icon("wallpaper-centered", 16, Gtk::ICON_LOOKUP_NO_SVG);
+        if (!icon) icon = genericicon;
+    } catch (Gtk::IconThemeError e) {
+        icon = genericicon;
+    }
+    this->select_mode.add_image_row( icon, _("Centered"), SetBG::mode_to_string(SetBG::SET_CENTER), false );
+
+    try {
+        icon = icontheme->load_icon("wallpaper-tiled", 16, Gtk::ICON_LOOKUP_NO_SVG);
+        if (!icon) icon = genericicon;
+    } catch (Gtk::IconThemeError e) {
+        icon = genericicon;
+    }
+    this->select_mode.add_image_row( icon, _("Tiled"), SetBG::mode_to_string(SetBG::SET_TILE), false );
+
+    try {
+        icon = icontheme->load_icon("wallpaper-zoomed", 16, Gtk::ICON_LOOKUP_NO_SVG);
+        if (!icon) icon = genericicon;
+    } catch (Gtk::IconThemeError e) {
+        icon = genericicon;
+    }
+
+    this->select_mode.add_image_row( icon, _("Zoomed"), SetBG::mode_to_string(SetBG::SET_ZOOM), false );
+    this->select_mode.add_image_row( icon, _("Zoomed Fill"), SetBG::mode_to_string(SetBG::SET_ZOOM_FILL), false );
+
+    // displays
+    Glib::RefPtr<Gdk::DisplayManager> manager = Gdk::DisplayManager::get();
+    Glib::RefPtr<Gdk::Display> disp	= manager->get_default_display();
+
+    if ( disp->get_n_screens() > 1 ) 
+    {
+        this->is_multihead = true;	
+
+        for (int i=0; i<disp->get_n_screens(); i++) {
+            Glib::RefPtr<Gdk::Screen> screen = disp->get_screen(i);
+            std::ostringstream ostr;
+            ostr << _("Screen") << " " << i;
+            bool on = (screen == disp->get_default_screen());
+
+            this->select_display.add_image_row( video_display_icon, ostr.str(), screen->make_display_name(), on );
 
             map_displays[screen->make_display_name()] = ostr.str();
-		}
+        }
 
-		return;
-	}
+        return;
+    }
 
 #ifdef USE_XINERAMA
-	// xinerama
-	int event_base, error_base;
-	int xinerama = XineramaQueryExtension(GDK_DISPLAY_XDISPLAY(disp->gobj()), &event_base, &error_base);
-	if (xinerama) {
-		xinerama = XineramaIsActive(GDK_DISPLAY_XDISPLAY(disp->gobj()));
-		if (xinerama) {
-			xinerama_info = XineramaQueryScreens(GDK_DISPLAY_XDISPLAY(disp->gobj()), &xinerama_num_screens);
+    // xinerama
+    int event_base, error_base;
+    int xinerama = XineramaQueryExtension(GDK_DISPLAY_XDISPLAY(disp->gobj()), &event_base, &error_base);
+    if (xinerama) {
+        xinerama = XineramaIsActive(GDK_DISPLAY_XDISPLAY(disp->gobj()));
+        if (xinerama) {
+            xinerama_info = XineramaQueryScreens(GDK_DISPLAY_XDISPLAY(disp->gobj()), &xinerama_num_screens);
 
-			if (xinerama_num_screens > 1) {
-				this->is_multihead = true;
-				this->is_xinerama = true;
+            if (xinerama_num_screens > 1) {
+                this->is_multihead = true;
+                this->is_xinerama = true;
 
-				// add the big one
-				this->select_display.add_image_row(video_display_icon, _("Full Screen"), "xin_-1", true);
+                // add the big one
+                this->select_display.add_image_row(video_display_icon, _("Full Screen"), "xin_-1", true);
 
                 map_displays["xin_-1"] = _("Full Screen");
 
-				for (int i=0; i<xinerama_num_screens; i++) {
-					std::ostringstream ostr, valstr;
-					ostr << _("Screen") << " " << xinerama_info[i].screen_number+1;
-					valstr << "xin_" << xinerama_info[i].screen_number;
-							
-					this->select_display.add_image_row(video_display_icon, ostr.str(), valstr.str(), false);
+                for (int i=0; i<xinerama_num_screens; i++) {
+                    std::ostringstream ostr, valstr;
+                    ostr << _("Screen") << " " << xinerama_info[i].screen_number+1;
+                    valstr << "xin_" << xinerama_info[i].screen_number;
+
+                    this->select_display.add_image_row(video_display_icon, ostr.str(), valstr.str(), false);
 
                     map_displays[valstr.str()] = ostr.str();
-				}
-							
-							return;
-			}
-		}
-	}
+                }
+
+                return;
+            }
+        }
+    }
 #endif
 
-	// if we made it here, we do not have any kind of multihead
-	// we still need to insert an entry to the display selector or we will die harshly
-	
-	this->select_display.add_image_row( video_display_icon, _("Default"), disp->get_default_screen()->make_display_name(), true);
+    // if we made it here, we do not have any kind of multihead
+    // we still need to insert an entry to the display selector or we will die harshly
+
+    this->select_display.add_image_row( video_display_icon, _("Default"), disp->get_default_screen()->make_display_name(), true);
 
-	return;
+    return;
 }
 
 /**
@@ -340,17 +350,17 @@ void NWindow::setup_select_boxes() {
  */
 void NWindow::set_default_selections()
 {
-	// grab the current config (if there is one)
-	Config *cfg = Config::get_instance();
-	std::vector<Glib::ustring> cfg_displays;
-	if( cfg->get_bg_groups(cfg_displays) ) 
+    // grab the current config (if there is one)
+    Config *cfg = Config::get_instance();
+    std::vector<Glib::ustring> cfg_displays;
+    if( cfg->get_bg_groups(cfg_displays) ) 
     {	
         SetBG::SetMode m;
         Gdk::Color c;
-		Glib::ustring default_selection;
+        Glib::ustring default_selection;
         Glib::ustring file;
 
-		// get default display
+        // get default display
         if (this->is_xinerama)
         {
             // we want the lowest numbered xinerama display (slightly hacky)
@@ -378,24 +388,24 @@ void NWindow::set_default_selections()
         if (find(cfg_displays.begin(), cfg_displays.end(), default_selection) == cfg_displays.end())
             return;
 
-		if (!cfg->get_bg(default_selection, file, m, c)) {
-			// failed. return?
-			return;
-		}
-
-		// set em!
-		button_bgcolor.set_color(c);
-		select_mode.select_value( SetBG::mode_to_string(m) );
-		
-		// iterate through filename list
-		for (Gtk::TreeIter iter = view.store->children().begin(); iter != view.store->children().end(); iter++)
-		{
-			if ( (*iter)[view.record.CurBGOnDisp] == default_selection) {
+        if (!cfg->get_bg(default_selection, file, m, c)) {
+            // failed. return?
+            return;
+        }
+
+        // set em!
+        button_bgcolor.set_color(c);
+        select_mode.select_value( SetBG::mode_to_string(m) );
+
+        // iterate through filename list
+        for (Gtk::TreeIter iter = view.store->children().begin(); iter != view.store->children().end(); iter++)
+        {
+            if ( (*iter)[view.record.CurBGOnDisp] == default_selection) {
                 Glib::signal_timeout().connect(sigc::bind(sigc::mem_fun(view, &Thumbview::select), new Gtk::TreeIter(iter)), 100);
-				break;
-			}
-		}
-	}
+                break;
+            }
+        }
+    }
 
 }
 
@@ -432,7 +442,7 @@ void NWindow::sighandle_btn_prefs()
                 vec_load.push_back(*i);
 
         cfg->load_cfg();        // tells the global instance to reload itself from disk, which the prefs dialog
-                                // told our clone to save to
+        // told our clone to save to
         view.set_current_display_mode(cfg->get_display_mode());
 
         for (VecStrs::iterator i = vec_unload.begin(); i != vec_unload.end(); i++)
diff --git a/src/NWindow.h b/src/NWindow.h
index 663242f..06a2306 100644
--- a/src/NWindow.h
+++ b/src/NWindow.h
@@ -1,21 +1,21 @@
 /*
 
-This file is from Nitrogen, an X11 background setter.  
-Copyright (C) 2006  Dave Foster & Javeed Shaikh
+   This file is from Nitrogen, an X11 background setter.  
+   Copyright (C) 2006  Dave Foster & Javeed Shaikh
 
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2
+   of the License, or (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 */
 
@@ -28,50 +28,51 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "SetBG.h"
 
 class NWindow : public Gtk::Window {
-	public:
-		NWindow ();
-		void show (void);
-		virtual ~NWindow ();
+    public:
+        NWindow ();
+        void show (void);
+        virtual ~NWindow ();
 
-		Thumbview view;
-		void sighandle_dblclick_item(const Gtk::TreeModel::Path& path);
-		void sighandle_click_apply(void);
-		void sighandle_mode_change(void);
+        Thumbview view;
+        void sighandle_dblclick_item(const Gtk::TreeModel::Path& path);
+        void sighandle_click_apply(void);
+        void sighandle_mode_change(void);
 
-		void set_default_selections();
+        void set_default_selections();
 
         std::map<Glib::ustring, Glib::ustring> map_displays;        // a map of current displays on the running instance to their display names
-		
-		bool is_multihead;
-		bool is_xinerama;
+
+        bool is_multihead;
+        bool is_xinerama;
 
         void set_bg(Glib::ustring file);
 
-	protected:        
-		
-		Gtk::VBox main_vbox;
-		Gtk::HBox bot_hbox;
+    protected:        
+
+        Gtk::VBox main_vbox;
+        Gtk::HBox bot_hbox;
 
-		ImageCombo select_mode, select_display;
+        ImageCombo select_mode, select_display;
 
-		Gtk::Button apply;
+        Gtk::Button apply;
+        Gtk::Button quitbtn;
         Gtk::Button btn_prefs;
-		Gtk::ColorButton button_bgcolor;
+        Gtk::ColorButton button_bgcolor;
 
         bool m_dirty;       // set if the user double clicks to preview but forgets to press apply
 
-		void setup_select_boxes();
+        void setup_select_boxes();
 
         void sighandle_togb_list_toggled();
         void sighandle_togb_icon_toggled();
         void sighandle_btn_prefs();
-
+        void sighandle_click_quitbtn( );
         virtual bool on_delete_event(GdkEventAny *event);
 
 #ifdef USE_XINERAMA
-		// xinerama stuff
-		XineramaScreenInfo* xinerama_info;
-		gint xinerama_num_screens;
+        // xinerama stuff
+        XineramaScreenInfo* xinerama_info;
+        gint xinerama_num_screens;
 #endif
 };
 
-- 
1.7.4

