diff --git a/pgadmin/dlg/dlgAddFavourite.cpp b/pgadmin/dlg/dlgAddFavourite.cpp
index be7f515..1fb367a 100644
--- a/pgadmin/dlg/dlgAddFavourite.cpp
+++ b/pgadmin/dlg/dlgAddFavourite.cpp
@@ -31,12 +31,14 @@ BEGIN_EVENT_TABLE(dlgAddFavourite, pgDialog)
 	EVT_TREE_SEL_CHANGED(XRCID("trLocation"),	dlgAddFavourite::OnTreeChange)
 	EVT_BUTTON (wxID_OK,               dlgAddFavourite::OnOK)
 	EVT_BUTTON (wxID_CANCEL,           dlgAddFavourite::OnCancel)
+	EVT_BUTTON (XRCID("btnNewFolder"), dlgAddFavourite::OnNewFolder)
 END_EVENT_TABLE()
 
 
 #define btnOK			CTRL_BUTTON("wxID_OK")
 #define txtTitle		CTRL_TEXT("txtTitle")
 #define trLocation		CTRL_TREE("trLocation")
+#define btnNewFolder	CTRL_BUTTON("btnNewFolder")
 
 
 dlgAddFavourite::dlgAddFavourite(wxWindow *parent, queryFavouriteFolder *favourites) :
@@ -46,6 +48,8 @@ dlgAddFavourite::dlgAddFavourite(wxWindow *parent, queryFavouriteFolder *favouri
 	LoadResource(parent, wxT("dlgAddFavourite"));
 	RestorePosition();
 
+	anythingChanged = false;
+
 	this->favourites = favourites;
 
 	wxImageList *imgList = new wxImageList(16, 16, true, 2);
@@ -58,26 +62,51 @@ dlgAddFavourite::dlgAddFavourite(wxWindow *parent, queryFavouriteFolder *favouri
 	trLocation->Expand(trLocation->GetRootItem());
 }
 
-bool dlgAddFavourite::AddFavourite(wxString newtext)
+int dlgAddFavourite::AddFavourite(wxString newtext)
 {
+	int ret = 1;
 	int r = ShowModal();
 	if (r != wxID_OK)
-		return false;
+	{
+		if (anythingChanged)
+			// Need rollback!
+			ret = -1;
+		else
+			ret = 0;
+	}
 
 	wxString title = txtTitle->GetValue().Trim();
 	if (title.IsEmpty())
-		return false;
+	{
+		if (anythingChanged)
+			// Need rollback!
+			ret = -1;
+		else
+			ret = 0;
+	}
 
 	if (!trLocation->GetSelection().IsOk())
-		return false;
+	{
+		if (anythingChanged)
+			// Need rollback!
+			ret = -1;
+		else
+			ret = 0;
+	}
 
 	queryFavouriteFolder *fld = (queryFavouriteFolder *)favourites->FindTreeItem(trLocation->GetSelection());
 
 	if (!fld)
-		return false;
+	{
+		if (anythingChanged)
+			// Need rollback!
+			ret = -1;
+		else
+			ret = 0;
+	}
 
 	fld->AddNewFavourite(title, newtext);
-	return true;
+	return ret;
 }
 
 dlgAddFavourite::~dlgAddFavourite()
@@ -120,3 +149,36 @@ void dlgAddFavourite::OnTreeChange(wxTreeEvent &ev)
 	wxCommandEvent evt;
 	OnChange(evt);
 }
+
+void dlgAddFavourite::OnNewFolder(wxCommandEvent &ev)
+{
+	if (!trLocation->GetSelection().IsOk())
+		return;
+
+	queryFavouriteItem *item = favourites->FindTreeItem(trLocation->GetSelection());
+	if (!item)
+		return;
+	if (item->GetId() != -2)
+		return;
+
+	wxTextEntryDialog dlg(this, _("Enter name of new folder"), _("Create new favourites folder"));
+	if (dlg.ShowModal() != wxID_OK)
+		return;
+
+	wxString title = dlg.GetValue().Trim();
+	if (title.IsEmpty())
+		return;
+
+	queryFavouriteFolder *fld = (queryFavouriteFolder *)item;
+	if (fld->ContainsFolder(title))
+	{
+		wxMessageBox(_("A folder with the specified name already exists."));
+		return;
+	}
+
+
+	queryFavouriteFolder *newfld = fld->AddNewFolder(dlg.GetValue());
+	newfld->SetTreeId(trLocation->AppendItem(trLocation->GetSelection(), title, 0));
+	trLocation->Expand(fld->GetTreeId());
+	anythingChanged = true;
+}
diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
index bd4ded2..0403e91 100644
--- a/pgadmin/frm/frmQuery.cpp
+++ b/pgadmin/frm/frmQuery.cpp
@@ -1503,10 +1503,15 @@ void frmQuery::OnAddFavourite(wxCommandEvent &event)
 {
 	if (sqlQuery->GetText().Trim().IsEmpty())
 		return;
-	if (dlgAddFavourite(this, favourites).AddFavourite(sqlQuery->GetText()))
+	int r = dlgAddFavourite(this, favourites).AddFavourite(sqlQuery->GetText());
+	if (r == 1)
 	{
 		// Added a favourite, so save
 		queryFavouriteFileProvider::SaveFavourites(favourites);
+	}
+	if (r == 1 || r == -1)
+	{
+		// Changed something requiring rollback
 		mainForm->UpdateAllFavouritesList();
 	}
 }
diff --git a/pgadmin/include/dlg/dlgAddFavourite.h b/pgadmin/include/dlg/dlgAddFavourite.h
index 0cc96f9..17b72f5 100644
--- a/pgadmin/include/dlg/dlgAddFavourite.h
+++ b/pgadmin/include/dlg/dlgAddFavourite.h
@@ -21,7 +21,7 @@ class dlgAddFavourite : public pgDialog
 public:
 	dlgAddFavourite(wxWindow *parent, queryFavouriteFolder *favourites);
 	~dlgAddFavourite();
-	bool AddFavourite(wxString newtext);
+	int AddFavourite(wxString newtext);
 
 private:
 	queryFavouriteFolder *favourites;
@@ -29,6 +29,10 @@ private:
 	void OnCancel(wxCommandEvent &ev);
 	void OnChange(wxCommandEvent &ev);
 	void OnTreeChange(wxTreeEvent &ev);
+	void OnNewFolder(wxCommandEvent &ev);
+
+	bool anythingChanged;
+
 	DECLARE_EVENT_TABLE()
 };
 
diff --git a/pgadmin/ui/dlgAddFavourite.xrc b/pgadmin/ui/dlgAddFavourite.xrc
index 26c1252..54e2b72 100644
--- a/pgadmin/ui/dlgAddFavourite.xrc
+++ b/pgadmin/ui/dlgAddFavourite.xrc
@@ -7,7 +7,7 @@
     <object class="wxFlexGridSizer">
       <minsize>216,225d</minsize>
       <cols>1</cols>
-      <rows>5</rows>
+      <rows>6</rows>
       <vgap>5</vgap>
       <hgap>5</hgap>
       <growablerows>3</growablerows>
@@ -41,6 +41,23 @@
       </object>
       <object class="sizeritem">
         <object class="wxFlexGridSizer">
+          <cols>2</cols>
+          <rows>1</rows>
+          <growablecols>1</growablecols>
+          <object class="sizeritem">
+            <object class="wxButton" name="btnNewFolder">
+              <label>New Folder</label>
+            </object>
+            <flag>wxLEFT|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag>
+            <border>4</border>
+          </object>
+          <object class="spacer">
+            <size>0,0d</size>
+          </object>
+        </object>
+      </object>
+      <object class="sizeritem">
+        <object class="wxFlexGridSizer">
           <cols>3</cols>
           <growablecols>0</growablecols>
           <object class="spacer">
@@ -51,14 +68,14 @@
               <label>&amp;OK</label>
               <default>1</default>
             </object>
-            <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL</flag>
+            <flag>wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag>
             <border>4</border>
           </object>
           <object class="sizeritem">
             <object class="wxButton" name="wxID_CANCEL">
               <label>&amp;Cancel</label>
             </object>
-            <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL</flag>
+            <flag>wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag>
             <border>4</border>
           </object>
         </object>