aboutsummaryrefslogtreecommitdiff
path: root/src/uicmd.cc
diff options
context:
space:
mode:
authorjcid <devnull@localhost>2008-09-26 00:53:13 +0200
committerjcid <devnull@localhost>2008-09-26 00:53:13 +0200
commitf0eaf18f7bf51913b8e10c98ee92c69e6fff6a30 (patch)
tree214b09c3ceebfe19e56093b49ec1953974b695d3 /src/uicmd.cc
parent061a12750c5fafcb0c582d182975022c3aa8b7ff (diff)
- Added the "middle_click_opens_new_tab" option to dillo2rc.
- Added the "focus_new_tab" option to dillo2rc. - Added "New Tab", "Open Link in new Tab" and "Open Image in new Tab". - Fixed the resizable when removed by tabs
Diffstat (limited to 'src/uicmd.cc')
-rw-r--r--src/uicmd.cc104
1 files changed, 87 insertions, 17 deletions
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 2cc26b8e..ef1d19ff 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -79,6 +79,25 @@ public:
return TabGroup::handle(e);
}
+ void remove (Widget *w) {
+ TabGroup::remove (w);
+ /* fixup resizable in case we just removed it */
+ if (resizable () == w)
+ if (children () > 0)
+ resizable (child (children () - 1));
+ else
+ resizable (NULL);
+
+ if (children () < 2)
+ hideLabels ();
+ }
+
+ void add (Widget *w) {
+ TabGroup::add (w);
+ if (children () > 1)
+ showLabels ();
+ }
+
void hideLabels() {
for (int i = children () - 1; i >= 0; i--)
child(i)->resize(x(), y(), w(), h());
@@ -90,7 +109,6 @@ public:
}
};
-static CustTabGroup *DilloTabs = NULL;
/*
* Create a new UI and its associated BrowserWindow data structure.
@@ -107,28 +125,20 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, const void *vbw)
wh = prefs.height;
}
- if (!DilloTabs) {
- {Window *o = new Window(ww, wh);
- o->shortcut(0); // Ignore Escape
- o->clear_double_buffer();
- DilloTabs = new CustTabGroup(0, 0, ww, wh);
- DilloTabs->selection_color(156);
- //DilloTabs->clear_tab_to_focus();
- o->add(DilloTabs);
- }
- }
+ Window *win = new Window(ww, wh);
+ win->shortcut(0); // Ignore Escape
+ win->clear_double_buffer();
+ CustTabGroup *DilloTabs = new CustTabGroup(0, 0, ww, wh);
+ DilloTabs->selection_color(156);
+ win->add(DilloTabs);
// Create and set the UI
UI *new_ui = new UI(0, 0, ww, wh, "Label", old_bw ? BW2UI(old_bw) : NULL);
new_ui->set_status("http://www.dillo.org/");
new_ui->tabs(DilloTabs);
- //new_ui->set_location("http://dillo.org/");
- //new_ui->customize(12);
DilloTabs->add(new_ui);
DilloTabs->resizable(new_ui);
- if (DilloTabs->children () > 1)
- DilloTabs->showLabels ();
DilloTabs->window()->resizable(new_ui);
DilloTabs->window()->show();
@@ -166,6 +176,54 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, const void *vbw)
}
/*
+ * Create a new Tab.
+ * i.e the new UI and its associated BrowserWindow data structure.
+ */
+BrowserWindow *UIcmd_tab_new(const void *vbw)
+{
+ _MSG(" UIcmd_tab_new vbw=%p\n", vbw);
+
+ dReturn_val_if_fail (vbw != NULL, NULL);
+
+ BrowserWindow *new_bw = NULL;
+ BrowserWindow *old_bw = (BrowserWindow*)vbw;
+ UI *ui = BW2UI(old_bw);
+
+ // Create and set the UI
+ UI *new_ui = new UI(0, 0, ui->w(), ui->h(), "Label", ui);
+ new_ui->tabs(ui->tabs());
+
+ new_ui->tabs()->add(new_ui);
+ new_ui->tabs()->resizable(new_ui);
+ new_ui->tabs()->window()->resizable(new_ui);
+ new_ui->tabs()->window()->show();
+
+ // Now create the Dw render layout and viewport
+ FltkPlatform *platform = new FltkPlatform ();
+ Layout *layout = new Layout (platform);
+
+ FltkViewport *viewport = new FltkViewport (0, 0, 1, 1);
+
+ layout->attachView (viewport);
+ new_ui->set_render_layout(*viewport);
+
+ viewport->setScrollStep((int) rint(14.0 * prefs.font_factor));
+
+ // Now, create a new browser window structure
+ new_bw = a_Bw_new();
+
+ // Store new_bw for callback data inside UI
+ new_ui->vbw(new_bw);
+
+ // Reference the UI from the bw
+ new_bw->ui = (void *)new_ui;
+ // Copy the layout pointer into the bw data
+ new_bw->render_layout = (void*)layout;
+
+ return new_bw;
+}
+
+/*
* Close one browser window
*/
void a_UIcmd_close_bw(void *vbw)
@@ -186,8 +244,6 @@ void a_UIcmd_close_bw(void *vbw)
}
delete(ui);
- if (DilloTabs->children() <= 1)
- DilloTabs->hideLabels();
a_Bw_free(bw);
}
@@ -262,6 +318,20 @@ void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
}
/*
+ * Open a new URL in a new tab in the same browser window
+ */
+void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus)
+{
+ BrowserWindow *new_bw = UIcmd_tab_new(vbw);
+ if (url)
+ a_Nav_push(new_bw, url);
+ if (focus) {
+ BW2UI(new_bw)->tabs()->selected_child(BW2UI(new_bw));
+ BW2UI(new_bw)->tabs()->selected_child()->take_focus();
+ }
+}
+
+/*
* Send the browser back to previous page
*/
void a_UIcmd_back(void *vbw)