aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjcid <devnull@localhost>2008-09-30 16:19:42 +0200
committerjcid <devnull@localhost>2008-09-30 16:19:42 +0200
commit6deac7761c79417469c515268ba010a5f1fd60fb (patch)
tree026f29085b1eff534367f63bb22a5f639f334561
parentf4e629d279e3c42b73118d7d7e719b3df672d3ed (diff)
- Added a confirmation dialog for closing with Windows/Tabs > 1
-rw-r--r--src/bw.c5
-rw-r--r--src/bw.h1
-rw-r--r--src/uicmd.cc32
3 files changed, 34 insertions, 4 deletions
diff --git a/src/bw.c b/src/bw.c
index da448206..31ecd1a2 100644
--- a/src/bw.c
+++ b/src/bw.c
@@ -258,6 +258,11 @@ void a_Bw_cleanup(BrowserWindow *bw)
/*--------------------------------------------------------------------------*/
+int a_Bw_num()
+{
+ return num_bws;
+}
+
/*
* TODO: remove this Hack.
*/
diff --git a/src/bw.h b/src/bw.h
index cf884d3a..fffbbb57 100644
--- a/src/bw.h
+++ b/src/bw.h
@@ -76,6 +76,7 @@ void a_Bw_init(void);
BrowserWindow *a_Bw_new();
void a_Bw_free(BrowserWindow *bw);
BrowserWindow *a_Bw_get();
+int a_Bw_num();
void a_Bw_add_client(BrowserWindow *bw, int Key, int Root);
int a_Bw_remove_client(BrowserWindow *bw, int ClientKey);
diff --git a/src/uicmd.cc b/src/uicmd.cc
index c9df453c..d91c60a8 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -34,7 +34,7 @@
#include "nav.h"
// Handy macro
-#define BW2UI(bw) ((UI*)(bw->ui))
+#define BW2UI(bw) ((UI*)((bw)->ui))
// Platform idependent part
using namespace dw::core;
@@ -109,6 +109,24 @@ public:
}
};
+static void win_cb (fltk::Widget *w, void *cb_data) {
+ CustTabGroup *tabs;
+ int choice = 0;
+
+ if (cb_data == NULL) {
+ w->hide ();
+ } else {
+ // It is assumed that user_data() of a window contains a pointer
+ // to the current BrowserWindow.
+ tabs = BW2UI((BrowserWindow*) cb_data)->tabs();
+ if (tabs->children () > 1)
+ choice = a_Dialog_choice3 ("Window contains more than one tab.",
+ "Close all tabs", "Cancel", NULL);
+ if (choice == 0)
+ for (int i = tabs->children() - 1; i >= 0; i--)
+ a_UIcmd_close_bw(((UI*)tabs->child(i))->vbw());
+ }
+}
/*
* Create a new UI and its associated BrowserWindow data structure.
@@ -132,6 +150,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, const void *vbw)
CustTabGroup *DilloTabs = new CustTabGroup(0, 0, ww, wh);
DilloTabs->selection_color(156);
win->add(DilloTabs);
+ win->callback(win_cb, (void*) NULL);
// Create and set the UI
UI *new_ui = new UI(0, 0, ww, wh, "Label", old_bw ? BW2UI(old_bw) : NULL);
@@ -254,9 +273,14 @@ void a_UIcmd_close_bw(void *vbw)
void a_UIcmd_close_all_bw()
{
BrowserWindow *bw;
-
- while ((bw = a_Bw_get()))
- a_UIcmd_close_bw((void*)bw);
+ int choice = 0;
+
+ if (a_Bw_num() > 1)
+ choice = a_Dialog_choice3 ("More than one open tab or Window.",
+ "Close all tabs and windows", "Cancel", NULL);
+ if (choice == 0)
+ while ((bw = a_Bw_get()))
+ a_UIcmd_close_bw((void*)bw);
}
/*