X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/205177b0b448a26ca4ee4baa29f1f340c5ea066c..e6ba38871f6cc5c02391c04e37e481d0428cef3f:/src/gtk/tbargtk.cpp?ds=inline diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index 63d7dae975..7deab1ffa5 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -51,12 +51,6 @@ public: : wxToolBarToolBase(tbar, control, label) { m_item = NULL; - // Hold a reference to keep control alive until DoInsertTool() is - // called, or if RemoveTool() is called (see DoDeleteTool) - g_object_ref(control->m_widget); - // release reference when gtk_widget_destroy() is called on control - g_signal_connect( - control->m_widget, "destroy", G_CALLBACK(g_object_unref), NULL); } void SetImage(); @@ -248,20 +242,15 @@ arrow_button_press_event(GtkToggleButton* button, GdkEventButton* event, wxToolB } } -//----------------------------------------------------------------------------- -// InsertChild callback for wxToolBar -//----------------------------------------------------------------------------- - -static void wxInsertChildInToolBar(wxWindow* parent, wxWindow* child) +void wxToolBar::AddChildGTK(wxWindowGTK* child) { GtkWidget* align = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(align); gtk_container_add(GTK_CONTAINER(align), child->m_widget); GtkToolItem* item = gtk_tool_item_new(); gtk_container_add(GTK_CONTAINER(item), align); - wxToolBar* tbar = static_cast(parent); // position will be corrected in DoInsertTool if necessary - gtk_toolbar_insert(GTK_TOOLBAR(GTK_BIN(tbar->m_widget)->child), item, -1); + gtk_toolbar_insert(GTK_TOOLBAR(GTK_BIN(m_widget)->child), item, -1); } // ---------------------------------------------------------------------------- @@ -376,8 +365,6 @@ bool wxToolBar::Create( wxWindow *parent, long style, const wxString& name ) { - m_insertCallback = wxInsertChildInToolBar; - if ( !PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { @@ -411,6 +398,7 @@ bool wxToolBar::Create( wxWindow *parent, m_widget = gtk_event_box_new(); ConnectWidget( m_widget ); } + g_object_ref(m_widget); gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar)); gtk_widget_show(GTK_WIDGET(m_toolbar)); @@ -537,7 +525,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) case wxTOOL_STYLE_CONTROL: wxWindow* control = tool->GetControl(); if (control->m_widget->parent == NULL) - wxInsertChildInToolBar(this, control); + AddChildGTK(control); tool->m_item = GTK_TOOL_ITEM(control->m_widget->parent->parent); if (gtk_toolbar_get_item_index(m_toolbar, tool->m_item) != int(pos)) {