summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-02-09 13:07:39 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2014-02-09 13:07:39 +0000
commitea79e85fcd109a5bf5f222cece8435305fc8626a (patch)
treeb8d846b7e6a82c0dc88360ba0118187d712f160f /desktop
parent987218e144f95e1917f1eb8956fed8a712ec3a70 (diff)
downloadnetsurf-ea79e85fcd109a5bf5f222cece8435305fc8626a.tar.gz
netsurf-ea79e85fcd109a5bf5f222cece8435305fc8626a.tar.bz2
Clean up gui_window creation API.
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c19
-rw-r--r--desktop/browser.h10
-rw-r--r--desktop/gui.h25
3 files changed, 49 insertions, 5 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 4fdfce52d..5a6cfc727 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -699,7 +699,6 @@ browser_window_create(enum browser_window_nav_flags flags,
struct browser_window **ret_bw)
{
struct browser_window *bw;
- struct browser_window *top;
/* caller must provide window to clone or be adding to history */
assert(clone ||
@@ -730,9 +729,14 @@ browser_window_create(enum browser_window_nav_flags flags,
/* gui window */
/* from the front end's pov, it clones the top level browser window,
* so find that. */
- top = browser_window_get_root(clone);
+ clone = browser_window_get_root(clone);
- bw->window = guit->window->create(bw, top, ((flags & BROWSER_WINDOW_TAB) != 0));
+ bw->window = guit->window->create(bw,
+ (clone != NULL) ? clone->window : NULL,
+ ((flags & BROWSER_WINDOW_TAB) ?
+ GW_CREATE_TAB : GW_CREATE_NONE) |
+ ((clone != NULL) ?
+ GW_CREATE_CLONE : GW_CREATE_NONE));
if (bw->window == NULL) {
browser_window_destroy(bw);
@@ -1945,6 +1949,15 @@ nsurl * browser_window_get_url(struct browser_window *bw)
/* Exported interface, documented in browser.h */
+struct history * browser_window_get_history(struct browser_window *bw)
+{
+ assert(bw != NULL);
+
+ return bw->history;
+}
+
+
+/* Exported interface, documented in browser.h */
bool browser_window_has_content(struct browser_window *bw)
{
assert(bw != NULL);
diff --git a/desktop/browser.h b/desktop/browser.h
index b0a5c506c..095360e5e 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -130,6 +130,16 @@ nserror browser_window_navigate(struct browser_window *bw,
nsurl * browser_window_get_url(struct browser_window *bw);
/**
+ * Get a browser window's history object.
+ *
+ * \param bw browser window
+ * \return pointer browser window's history object
+ *
+ * Clients need history object to make use of the history_* functions.
+ */
+struct history * browser_window_get_history(struct browser_window *bw);
+
+/**
* Get a browser window's content extents.
*
* \param bw browser window
diff --git a/desktop/gui.h b/desktop/gui.h
index 162b51cd3..85f1265bb 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -54,6 +54,12 @@ typedef enum {
GDRAGGING_OTHER
} gui_drag_type;
+typedef enum {
+ GW_CREATE_NONE = 0, /* New window */
+ GW_CREATE_CLONE = (1 << 0), /* Clone existing window */
+ GW_CREATE_TAB = (1 << 1) /* In same window as existing */
+} gui_window_create_flags;
+
struct gui_window;
struct gui_download_window;
struct browser_window;
@@ -77,8 +83,23 @@ struct gui_window_table {
/* Mandantory entries */
- /** create a gui window for a browsing context */
- struct gui_window *(*create)(struct browser_window *bw, struct browser_window *clone, bool new_tab);
+ /**
+ * Create and open a gui window for a browsing context.
+ *
+ * \param bw bw to create gui_window for
+ * \param existing an existing gui_window, may be NULL
+ * \param flags flags for gui window creation
+ * \return gui window, or NULL on error
+ *
+ * If GW_CREATE_CLONE or GW_CREATE_TAB flags are set, existing is
+ * non-NULL.
+ *
+ * Front end's gui_window must include a reference to the
+ * browser window passed in the bw param.
+ */
+ struct gui_window *(*create)(struct browser_window *bw,
+ struct gui_window *existing,
+ gui_window_create_flags flags);
/** destroy previously created gui window */
void (*destroy)(struct gui_window *g);