aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-shell.c
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gns@gnome.org>2012-12-09 22:25:37 +0800
committerGustavo Noronha Silva <gns@gnome.org>2012-12-11 05:15:54 +0800
commitc968c68cabc319896ad4d2096940c9a34d4c13cd (patch)
treed9cde42306f750303d3d35ee701fe58c5040f878 /src/ephy-shell.c
parent3573116d0473da1ca51d1766d412a97185addb9d (diff)
downloadgsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.tar
gsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.tar.gz
gsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.tar.bz2
gsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.tar.lz
gsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.tar.xz
gsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.tar.zst
gsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.zip
Append new tab on the window with most tabs in the current workspace
This change uses a different heuristic to decide on what the best window to add a new tab is from the last window which has been interacted with, which might even be in a different workspace, to the window with the most tabs in the current workspace. If no window exists on the current workspace one will be created. Partial fix for https://bugzilla.gnome.org/show_bug.cgi?id=685976
Diffstat (limited to 'src/ephy-shell.c')
-rw-r--r--src/ephy-shell.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index eb9789166..9800038cb 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -1061,6 +1061,44 @@ ephy_shell_get_n_windows (EphyShell *shell)
return g_list_length (shell->priv->windows);
}
+EphyWindow*
+ephy_shell_get_main_window (EphyShell *shell)
+{
+ EphyWindow *window = NULL;
+ GList *windows;
+ GList *iter;
+
+ g_return_val_if_fail (EPHY_IS_SHELL (shell), NULL);
+
+ /* Select the window with most tabs in the current workspace as the window to
+ * use for opening a new tab on, if that turns out to be the case.
+ */
+ windows = ephy_shell_get_windows (shell);
+
+ for (iter = windows; iter != NULL; iter = iter->next) {
+ EphyWindow *candidate = EPHY_WINDOW (iter->data);
+ GtkWidget *cur_notebook;
+ GtkWidget *cand_notebook;
+
+ if (!ephy_window_is_on_current_workspace (candidate))
+ continue;
+
+ if (!window) {
+ window = candidate;
+ continue;
+ }
+
+ cur_notebook = ephy_window_get_notebook (window);
+ cand_notebook = ephy_window_get_notebook (candidate);
+ if (gtk_notebook_get_n_pages (cand_notebook) > gtk_notebook_get_n_pages (cur_notebook))
+ window = candidate;
+ }
+
+ g_list_free (windows);
+
+ return window;
+}
+
gboolean
ephy_shell_close_all_windows (EphyShell *shell)
{