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)
{
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);
}
}
}
+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
* 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
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);
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)
{
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;
}
static GtkWidget*
midori_dummy_viewable_new (const gchar* stock_id,
- const gchar* label,
- GtkWidget* toolbar)
+ const gchar* label,
+ GtkWidget* toolbar)
{
GtkWidget* viewable = g_object_new (MIDORI_TYPE_DUMMY_VIEWABLE, NULL);
* 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
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));
}