Attempt to fix handling of background and foreground tabs.

This commit is contained in:
Christian Dywan 2008-04-25 00:20:43 +02:00
parent a2aa737677
commit 62cbafe12a
4 changed files with 65 additions and 23 deletions

7
TODO
View file

@ -1,18 +1,13 @@
TODO:
. Import and export of the bookmarks file, or using one from a specific path
. Save files on change as opposed to on quit
. Position context menus properly
. New tabs from a TabNew action should always open in the foreground
. Middle click toolbuttons or menuitems should open new tabs
. Implement support for (multiple) userscripts/ userstyles
. Actual multiple window support, some things just ignore this currently
. Custom context menu actions
. Create proper submenus in the window's menu instead of popups
. Custom context menu actions, like in Thunar or Epiphany
. Custom tab names
. Identify and fix Gtk2.6 compatibility problems
. Open an auto-vanishing findbox with '.'
. Support gettext
. Implement custom actions, like in Thunar or Epiphany
. Custom panels, loaded from (x)htm(l) files or websites
. Drag tabs onto the panel to add them to the sidebar
. Save completion stores

View file

@ -13,6 +13,8 @@
#include <glib/gi18n.h>
#include <string.h>
static void
proxy_toggle_button_toggled_cb (GtkToggleButton* button, GObject* object)
{
@ -186,6 +188,8 @@ katze_property_proxy (gpointer object,
int n_families;
pango_context_list_families (context, &families, &n_families);
g_object_get (object, property, &string, NULL);
if (!string)
string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
gint i = 0;
while (i < n_families)
{

View file

@ -231,6 +231,19 @@ _midori_browser_set_statusbar_text (MidoriBrowser* browser,
priv->statusbar_text ? priv->statusbar_text : "");
}
static void
_midori_browser_set_current_page_smartly (MidoriBrowser* browser,
gint n)
{
MidoriBrowserPrivate* priv = browser->priv;
gboolean open_tabs_in_the_background;
g_object_get (priv->settings, "open-tabs-in-the-background",
&open_tabs_in_the_background, NULL);
if (!open_tabs_in_the_background)
midori_browser_set_current_page (browser, n);
}
static void
_midori_browser_update_progress (MidoriBrowser* browser,
gint progress)
@ -420,8 +433,8 @@ midori_web_view_new_tab_cb (GtkWidget* web_view,
const gchar* uri,
MidoriBrowser* browser)
{
midori_browser_append_uri (browser, uri);
gtk_widget_grab_focus (web_view);
gint n = midori_browser_append_uri (browser, uri);
_midori_browser_set_current_page_smartly (browser, n);
}
static void
@ -565,7 +578,11 @@ static void
_action_tab_new_activate (GtkAction* action,
MidoriBrowser* browser)
{
midori_browser_append_uri (browser, "");
MidoriBrowserPrivate* priv = browser->priv;
gint n = midori_browser_append_uri (browser, "");
midori_browser_set_current_page (browser, n);
gtk_widget_grab_focus (priv->location);
}
static void
@ -817,7 +834,8 @@ midori_browser_menu_trash_item_activate_cb (GtkWidget* menuitem,
KatzeXbelItem* item = g_object_get_data (G_OBJECT (menuitem),
"KatzeXbelItem");
const gchar* uri = katze_xbel_bookmark_get_href (item);
midori_browser_append_uri (browser, uri);
gint n = midori_browser_append_uri (browser, uri);
midori_browser_set_current_page (browser, n);
katze_xbel_item_unref (item);
}
@ -1322,7 +1340,8 @@ midori_panel_bookmarks_button_release_event_cb (GtkWidget* widget,
if (event->button == 2 && katze_xbel_item_is_bookmark (item))
{
const gchar* uri = katze_xbel_bookmark_get_href (item);
midori_browser_append_uri (browser, uri);
gint n = midori_browser_append_uri (browser, uri);
midori_browser_set_current_page (browser, n);
}
else
_midori_panel_bookmarks_popup (widget, event, item, browser);
@ -1741,7 +1760,10 @@ _action_bookmark_open_tab_activate (GtkAction* action,
KatzeXbelItem* item;
gtk_tree_model_get (model, &iter, 0, &item, -1);
if (katze_xbel_item_is_bookmark (item))
midori_browser_append_xbel_item (browser, item);
{
gint n = midori_browser_append_xbel_item (browser, item);
_midori_browser_set_current_page_smartly (browser, n);
}
}
}
}
@ -1763,7 +1785,10 @@ _action_bookmark_open_window_activate (GtkAction* action,
KatzeXbelItem* item;
gtk_tree_model_get (model, &iter, 0, &item, -1);
if (katze_xbel_item_is_bookmark (item))
midori_browser_append_xbel_item (browser, item);
{
gint n = midori_browser_append_xbel_item (browser, item);
_midori_browser_set_current_page_smartly (browser, n);
}
}
}
}
@ -1798,7 +1823,8 @@ _action_undo_tab_close_activate (GtkAction* action,
// Reopen the most recent trash item
KatzeXbelItem* item = midori_trash_get_nth_xbel_item (priv->trash, 0);
midori_browser_append_xbel_item (browser, item);
gint n = midori_browser_append_xbel_item (browser, item);
midori_browser_set_current_page (browser, n);
midori_trash_remove_nth_item (priv->trash, 0);
_midori_browser_update_actions (browser);
}
@ -2953,7 +2979,7 @@ midori_browser_append_tab (MidoriBrowser* browser,
{
gtk_widget_show (menuitem);
g_signal_connect (menuitem, "activate",
G_CALLBACK (midori_browser_window_menu_item_activate_cb), browser);
G_CALLBACK (midori_browser_window_menu_item_activate_cb), scrolled);
gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu_window), menuitem);
}
@ -2969,14 +2995,6 @@ midori_browser_append_tab (MidoriBrowser* browser,
_midori_browser_update_actions (browser);
n = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), scrolled);
gboolean open_tabs_in_the_background;
g_object_get (priv->settings, "open-tabs-in-the-background",
&open_tabs_in_the_background, NULL);
if (!open_tabs_in_the_background)
{
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), n);
gtk_widget_grab_focus (priv->location);
}
return n;
}
@ -3052,6 +3070,27 @@ midori_browser_append_uri (MidoriBrowser* browser,
return midori_browser_append_tab (browser, web_view);
}
/**
* midori_browser_set_current_page:
* @browser: a #MidoriBrowser
* @n: the index of a page
*
* Switches to the page with the index @n.
*
* The widget will also grab the focus automatically.
**/
void
midori_browser_set_current_page (MidoriBrowser* browser,
gint n)
{
MidoriBrowserPrivate* priv = browser->priv;
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), n);
GtkWidget* widget = midori_browser_get_current_page (browser);
if (widget)
gtk_widget_grab_focus (widget);
}
/**
* midori_browser_get_current_page:
* @browser: a #MidoriBrowser

View file

@ -76,6 +76,10 @@ gint
midori_browser_append_uri (MidoriBrowser* browser,
const gchar* uri);
void
midori_browser_set_current_page (MidoriBrowser* browser,
gint n);
GtkWidget*
midori_browser_get_current_page (MidoriBrowser* browser);