Remove panel pages implicitly as viewables are destroyed
For this to work smoothly, from now on the browser destroys the panel eary, as it does with the tabs, and the panel in turn destroys its pages early.
This commit is contained in:
parent
a81405dcf0
commit
92fd37ad61
3 changed files with 62 additions and 10 deletions
|
@ -64,6 +64,13 @@ page_holder_button_add_clicked_cb (GtkWidget* button,
|
|||
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
||||
}
|
||||
|
||||
static void
|
||||
page_holder_deactivate_cb (MidoriExtension* extension,
|
||||
GtkWidget* notebook)
|
||||
{
|
||||
gtk_widget_destroy (notebook);
|
||||
}
|
||||
|
||||
static void
|
||||
page_holder_app_add_browser_cb (MidoriApp* app,
|
||||
MidoriBrowser* browser,
|
||||
|
@ -107,6 +114,8 @@ page_holder_app_add_browser_cb (MidoriApp* app,
|
|||
midori_panel_append_widget (MIDORI_PANEL (panel), notebook,
|
||||
/* i18n: A panel showing a user specified web page */
|
||||
STOCK_PAGE_HOLDER, _("Pageholder"), toolbar);
|
||||
g_signal_connect (extension, "deactivate",
|
||||
G_CALLBACK (page_holder_deactivate_cb), notebook);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -3477,7 +3477,9 @@ midori_browser_size_allocate_cb (MidoriBrowser* browser,
|
|||
static void
|
||||
midori_browser_destroy_cb (MidoriBrowser* browser)
|
||||
{
|
||||
/* Destroy tabs first, so child widgets don't need special care */
|
||||
/* Destroy panel first, so panels don't need special care */
|
||||
gtk_widget_destroy (browser->panel);
|
||||
/* Destroy tabs second, so child widgets don't need special care */
|
||||
gtk_container_foreach (GTK_CONTAINER (browser->notebook),
|
||||
(GtkCallback) gtk_widget_destroy, NULL);
|
||||
}
|
||||
|
|
|
@ -157,6 +157,14 @@ midori_panel_button_close_clicked_cb (GtkWidget* toolitem,
|
|||
g_signal_emit (panel, signals[CLOSE], 0, &return_value);
|
||||
}
|
||||
|
||||
static void
|
||||
midori_panel_destroy_cb (MidoriPanel* panel)
|
||||
{
|
||||
/* Destroy pages first, so they don't need special care */
|
||||
gtk_container_foreach (GTK_CONTAINER (panel->notebook),
|
||||
(GtkCallback) gtk_widget_destroy, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
midori_panel_init (MidoriPanel* panel)
|
||||
{
|
||||
|
@ -215,18 +223,14 @@ midori_panel_init (MidoriPanel* panel)
|
|||
gtk_container_add (GTK_CONTAINER (panel->frame), panel->notebook);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), panel->frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show_all (panel->frame);
|
||||
|
||||
g_signal_connect (panel, "destroy",
|
||||
G_CALLBACK (midori_panel_destroy_cb), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
midori_panel_finalize (GObject* object)
|
||||
{
|
||||
MidoriPanel* panel = MIDORI_PANEL (object);
|
||||
|
||||
if (panel->menu)
|
||||
{
|
||||
/* FIXME: Remove all menu items */
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (midori_panel_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
@ -342,6 +346,26 @@ midori_panel_menu_item_activate_cb (GtkWidget* widget,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
midori_panel_viewable_destroy_cb (GtkWidget* viewable,
|
||||
MidoriPanel* panel)
|
||||
{
|
||||
gint i = gtk_notebook_page_num (GTK_NOTEBOOK (panel->notebook), viewable);
|
||||
if (i > -1)
|
||||
gtk_notebook_remove_page (GTK_NOTEBOOK (panel->notebook), i);
|
||||
g_signal_handlers_disconnect_by_func (
|
||||
viewable, midori_panel_viewable_destroy_cb, panel);
|
||||
}
|
||||
|
||||
static void
|
||||
midori_panel_widget_destroy_cb (GtkWidget* viewable,
|
||||
GtkWidget* widget)
|
||||
{
|
||||
gtk_widget_destroy (widget);
|
||||
g_signal_handlers_disconnect_by_func (
|
||||
viewable, midori_panel_widget_destroy_cb, widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* midori_panel_append_page:
|
||||
* @panel: a #MidoriPanel
|
||||
|
@ -353,6 +377,9 @@ midori_panel_menu_item_activate_cb (GtkWidget* widget,
|
|||
* Appends a new page to the panel. If @toolbar is specified it will
|
||||
* be packed above @viewable.
|
||||
*
|
||||
* Since 0.1.3 destroying the @viewable implicitly removes
|
||||
* the page including the menu and eventual toolbar.
|
||||
*
|
||||
* In the case of an error, -1 is returned.
|
||||
*
|
||||
* Return value: the index of the new page, or -1
|
||||
|
@ -401,6 +428,8 @@ midori_panel_append_page (MidoriPanel* panel,
|
|||
toolbar = midori_viewable_get_toolbar (viewable);
|
||||
gtk_widget_show (toolbar);
|
||||
gtk_container_add (GTK_CONTAINER (panel->toolbook), toolbar);
|
||||
g_signal_connect (viewable, "destroy",
|
||||
G_CALLBACK (midori_panel_widget_destroy_cb), toolbar);
|
||||
|
||||
n = midori_panel_page_num (panel, scrolled);
|
||||
label = midori_viewable_get_label (viewable);
|
||||
|
@ -421,6 +450,8 @@ midori_panel_append_page (MidoriPanel* panel,
|
|||
G_CALLBACK (midori_panel_menu_item_activate_cb), panel);
|
||||
gtk_widget_show_all (GTK_WIDGET (toolitem));
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (panel->toolbar), toolitem, -1);
|
||||
g_signal_connect (viewable, "destroy",
|
||||
G_CALLBACK (midori_panel_widget_destroy_cb), toolitem);
|
||||
|
||||
if (panel->menu)
|
||||
{
|
||||
|
@ -432,8 +463,13 @@ midori_panel_append_page (MidoriPanel* panel,
|
|||
G_CALLBACK (midori_panel_menu_item_activate_cb),
|
||||
panel);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (panel->menu), menuitem);
|
||||
g_signal_connect (viewable, "destroy",
|
||||
G_CALLBACK (midori_panel_widget_destroy_cb), menuitem);
|
||||
}
|
||||
|
||||
g_signal_connect (viewable, "destroy",
|
||||
G_CALLBACK (midori_panel_viewable_destroy_cb), panel);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -695,6 +731,9 @@ midori_dummy_viewable_new (const gchar* stock_id,
|
|||
* Actually implementing #MidoriViewable instead of using
|
||||
* this convenience is recommended.
|
||||
*
|
||||
* Since 0.1.3 destroying the @widget implicitly removes
|
||||
* the page including the menu and eventual toolbar.
|
||||
*
|
||||
* In the case of an error, -1 is returned.
|
||||
*
|
||||
* Return value: the index of the new page, or -1
|
||||
|
@ -717,5 +756,7 @@ midori_panel_append_widget (MidoriPanel* panel,
|
|||
viewable = midori_dummy_viewable_new (stock_id, label, toolbar);
|
||||
gtk_widget_show (viewable);
|
||||
gtk_container_add (GTK_CONTAINER (viewable), widget);
|
||||
g_signal_connect (widget, "destroy",
|
||||
G_CALLBACK (midori_panel_widget_destroy_cb), viewable);
|
||||
return midori_panel_append_page (panel, MIDORI_VIEWABLE (viewable));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue