aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-tab.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-04-18 03:39:00 +0800
committerChristian Persch <chpe@src.gnome.org>2005-04-18 03:39:00 +0800
commitffdcb7ffd0191129ccee3d377cae306c81b10594 (patch)
tree239f51f3a48167e9278a8b810a2f2054d9694723 /src/ephy-tab.c
parent7b8fb927ca8c223ba51294bf52ab865b067bd774 (diff)
downloadgsoc2013-epiphany-ffdcb7ffd0191129ccee3d377cae306c81b10594.tar
gsoc2013-epiphany-ffdcb7ffd0191129ccee3d377cae306c81b10594.tar.gz
gsoc2013-epiphany-ffdcb7ffd0191129ccee3d377cae306c81b10594.tar.bz2
gsoc2013-epiphany-ffdcb7ffd0191129ccee3d377cae306c81b10594.tar.lz
gsoc2013-epiphany-ffdcb7ffd0191129ccee3d377cae306c81b10594.tar.xz
gsoc2013-epiphany-ffdcb7ffd0191129ccee3d377cae306c81b10594.tar.zst
gsoc2013-epiphany-ffdcb7ffd0191129ccee3d377cae306c81b10594.zip
Rework popup windows. Introduce "is-popup" property on EphyWindow to
2005-04-17 Christian Persch <chpe@cvs.gnome.org> * src/ephy-automation.c: (impl_ephy_automation_loadUrlWithStartupId): * src/ephy-notebook.c: (ephy_notebook_set_dnd_enabled), (ephy_notebook_get_property), (ephy_notebook_set_property), (ephy_notebook_class_init), (move_tab_to_another_notebook), (button_press_cb), (ephy_notebook_init): * src/ephy-notebook.h: * src/ephy-session.c: (ephy_session_get_active_window): * src/ephy-shell.c: (ephy_shell_new_window_cb), (ephy_shell_new_tab_full), (ephy_shell_new_tab): * src/ephy-shell.h: * src/ephy-tab.c: (ephy_tab_class_init), (popups_manager_new_window_info), (ephy_tab_dispose), (ephy_tab_finalize), (let_me_resize_hack), (ephy_tab_set_size), (ephy_tab_init): * src/ephy-tab.h: * src/ephy-window.c: (get_chromes_visibility), (sync_chromes_visibility), (update_chromes_actions), (update_actions_sensitivity), (sync_tab_visibility), (show_embed_popup), (let_me_resize_hack), (tab_size_to_cb), (ephy_window_set_active_tab), (ephy_window_set_chrome), (ephy_window_set_is_popup), (ephy_window_dispose), (ephy_window_set_property), (ephy_window_get_property), (ephy_window_class_init), (ephy_window_init), (ephy_window_constructor), (ephy_window_new_with_chrome), (ephy_window_set_print_preview), (ephy_window_add_tab), (ephy_window_show), (ephy_window_view_popup_windows_cb), (ephy_window_get_is_popup): * src/ephy-window.h: Rework popup windows. Introduce "is-popup" property on EphyWindow to indicate a window who will only have one tab, and can be resized by javascript calls. Fixes bug #136288 and #155395.
Diffstat (limited to 'src/ephy-tab.c')
-rw-r--r--src/ephy-tab.c153
1 files changed, 93 insertions, 60 deletions
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 09debb6f1..db7a005c2 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -87,10 +87,12 @@ struct _EphyTabPrivate
GSList *shown_popups;
EphyTabNavigationFlags nav_flags;
EphyEmbedDocumentType document_type;
+ guint idle_resize_handler;
};
static void ephy_tab_class_init (EphyTabClass *klass);
static void ephy_tab_init (EphyTab *tab);
+static void ephy_tab_dispose (GObject *object);
static void ephy_tab_finalize (GObject *object);
enum
@@ -343,7 +345,8 @@ ephy_tab_class_init (EphyTabClass *class)
parent_class = g_type_class_peek_parent (class);
- object_class->finalize = ephy_tab_finalize;
+ object_class->dispose = ephy_tab_dispose;
+ object_class->finalize = ephy_tab_finalize;
object_class->get_property = ephy_tab_get_property;
object_class->set_property = ephy_tab_set_property;
@@ -632,16 +635,20 @@ popups_manager_show_all (EphyTab *tab)
static char *
popups_manager_new_window_info (EphyWindow *window)
{
+ EphyTab *tab;
EphyEmbedChrome chrome;
+ gboolean is_popup;
char *features;
- int w, h;
- g_object_get (window, "chrome", &chrome, NULL);
- gtk_window_get_size (GTK_WINDOW (window), &w, &h);
+ g_object_get (window, "chrome", &chrome, "is-popup", &is_popup, NULL);
+ g_return_val_if_fail (is_popup, g_strdup (""));
+
+ tab = ephy_window_get_active_tab (window);
+ g_return_val_if_fail (tab != NULL, g_strdup (""));
features = g_strdup_printf
("width=%d,height=%d,menubar=%d,status=%d,toolbar=%d",
- w, h,
+ tab->priv->width, tab->priv->height,
(chrome & EPHY_EMBED_CHROME_MENUBAR) > 0,
(chrome & EPHY_EMBED_CHROME_STATUSBAR) > 0,
(chrome & EPHY_EMBED_CHROME_TOOLBAR) > 0);
@@ -746,17 +753,31 @@ popups_manager_reset (EphyTab *tab)
}
static void
-ephy_tab_finalize (GObject *object)
+ephy_tab_dispose (GObject *object)
{
- EphyTab *tab = EPHY_TAB (object);
+ EphyTab *tab = EPHY_TAB (object);
+ EphyTabPrivate *priv = tab->priv;
- g_idle_remove_by_data (tab);
+ if (priv->idle_resize_handler != 0)
+ {
+ g_source_remove (priv->idle_resize_handler);
+ priv->idle_resize_handler = 0;
+ }
- g_free (tab->priv->title);
- g_free (tab->priv->address);
- g_free (tab->priv->icon_address);
- g_free (tab->priv->link_message);
- g_free (tab->priv->status_message);
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+ephy_tab_finalize (GObject *object)
+{
+ EphyTab *tab = EPHY_TAB (object);
+ EphyTabPrivate *priv = tab->priv;
+
+ g_free (priv->title);
+ g_free (priv->address);
+ g_free (priv->icon_address);
+ g_free (priv->link_message);
+ g_free (priv->status_message);
popups_manager_reset (tab);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -782,6 +803,17 @@ address_has_web_scheme (const char *address)
return has_web_scheme;
}
+static gboolean
+let_me_resize_hack (EphyTab *tab)
+{
+ EphyTabPrivate *priv = tab->priv;
+
+ gtk_widget_set_size_request (GTK_WIDGET (tab), -1, -1);
+
+ priv->idle_resize_handler = 0;
+ return FALSE;
+}
+
/* Public functions */
/**
@@ -938,6 +970,54 @@ ephy_tab_get_size (EphyTab *tab, int *width, int *height)
}
/**
+ * ephy_tab_set_size:
+ * @tab: an #EphyTab
+ * @width:
+ * @height:
+ *
+ * Sets the size of @tab. This is not guaranteed to actually resize the tab.
+ **/
+void
+ephy_tab_set_size (EphyTab *tab,
+ int width,
+ int height)
+{
+ EphyTabPrivate *priv = tab->priv;
+ GtkWidget *widget = GTK_WIDGET (tab);
+ GtkAllocation allocation;
+
+ priv->width = width;
+ priv->height = height;
+
+ gtk_widget_set_size_request (widget, width, height);
+
+ /* HACK: When the web site changes both width and height,
+ * we will first get a width change, then a height change,
+ * without actually resizing the window in between (since
+ * that happens only on idle).
+ * If we don't set the allocation, GtkMozEmbed doesn't tell
+ * mozilla the new width, so the height change sets the width
+ * back to the old value!
+ */
+ allocation.x = widget->allocation.x;
+ allocation.y = widget->allocation.y;
+ allocation.width = width;
+ allocation.height = height;
+ gtk_widget_size_allocate (widget, &allocation);
+
+ /* HACK: reset widget requisition after the container
+ * has been resized. It appears to be the only way
+ * to have the window sized according to embed
+ * size correctly.
+ */
+ if (priv->idle_resize_handler == 0)
+ {
+ priv->idle_resize_handler =
+ g_idle_add ((GSourceFunc) let_me_resize_hack, tab);
+ }
+}
+
+/**
* ephy_tab_get_visibility:
* @tab: an #EphyTab
*
@@ -1330,14 +1410,6 @@ ephy_tab_popup_blocked_cb (EphyEmbed *embed, const char *url,
popups_manager_add (tab, url, features);
}
-static gboolean
-let_me_resize_hack (GtkWidget *tab)
-{
- gtk_widget_set_size_request (tab, -1, -1);
-
- return FALSE;
-}
-
static void
ephy_tab_visibility_cb (EphyEmbed *embed, gboolean visibility,
EphyTab *tab)
@@ -1379,42 +1451,6 @@ ephy_tab_destroy_brsr_cb (EphyEmbed *embed, EphyTab *tab)
ephy_notebook_remove_tab (EPHY_NOTEBOOK (notebook), tab);
}
-static void
-ephy_tab_size_to_cb (EphyEmbed *embed, gint width, gint height,
- EphyTab *tab)
-{
- GtkWidget *notebook;
- EphyWindow *window;
-
- LOG ("ephy_tab_size_to_cb tab %p width %d height %d", tab, width, height);
-
- tab->priv->width = width;
- tab->priv->height = height;
-
- window = ephy_tab_get_window (tab);
- notebook = ephy_window_get_notebook (window);
-
- /* Do not resize window with multiple tabs.
- * Do not resize window already showed because
- * it's not possible to calculate a sensible window
- * size based on the embed size */
- if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) == 1 &&
- !tab->priv->visibility)
- {
- gtk_widget_set_size_request
- (GTK_WIDGET (tab), width, height);
-
- /* HACK reset widget requisition after the container
- * has been resized. It appears to be the only way
- * to have the window sized according to embed
- * size correctly.
- */
-
- g_idle_add ((GSourceFunc) let_me_resize_hack, tab);
- }
-}
-
-
static gboolean
open_link_in_new_tab (EphyTab *tab,
const char *link_address)
@@ -1637,9 +1673,6 @@ ephy_tab_init (EphyTab *tab)
g_signal_connect_object (embed, "destroy_browser",
G_CALLBACK (ephy_tab_destroy_brsr_cb),
tab, 0);
- g_signal_connect_object (embed, "size_to",
- G_CALLBACK (ephy_tab_size_to_cb),
- tab, 0);
g_signal_connect_object (embed, "ge_dom_mouse_click",
G_CALLBACK (ephy_tab_dom_mouse_click_cb),
tab, 0);