const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
const wxString& name = wxFileDialogNameStr);
- virtual ~wxFileDialog() { delete m_extraControl; }
+ virtual ~wxFileDialog();
virtual wxString GetPath() const;
virtual void GetPaths(wxArrayString& paths) const;
SetWindowStyle(style);
m_widget = gtk_image_new();
+ g_object_ref(m_widget);
gtk_widget_show(m_widget);
m_parent->DoAddChild( this );
m_bmpNormal = bitmap;
m_widget = gtk_button_new();
+ g_object_ref(m_widget);
if (style & wxNO_BORDER)
gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
#include "wx/gtk/private.h"
-#ifdef __WXGTK24__
- #include "wx/gtk/win_gtk.h"
-
- #include <gobject/gvaluecollector.h>
- #include <gtk/gtktreemodel.h>
-#endif
-
-
// ============================================================================
// implementation
// ============================================================================
m_entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
gtk_entry_set_editable( m_entry, TRUE );
}
+ g_object_ref(m_widget);
// This must be called as gtk_combo_box_entry_new_with_model adds
// automatically adds one text column.
}
m_widget = gtk_button_new_with_mnemonic("");
+ g_object_ref(m_widget);
float x_alignment = 0.5;
if (HasFlag(wxBU_LEFT))
}
m_widget = gtk_calendar_new();
+ g_object_ref(m_widget);
SetDate(date.IsValid() ? date : wxDateTime::Today());
if (style & wxCAL_NO_MONTH_CHANGE)
m_widgetLabel = GTK_BIN(m_widgetCheckbox)->child;
m_widget = m_widgetCheckbox;
}
+ g_object_ref(m_widget);
SetLabel( label );
g_signal_connect (m_widgetCheckbox, "toggled",
}
m_widget = gtk_combo_box_new_text();
+ g_object_ref(m_widget);
Append(n, choices);
m_colour = col;
m_widget = gtk_color_button_new_with_color( m_colour.GetColor() );
+ g_object_ref(m_widget);
gtk_widget_show(m_widget);
// GtkColourButton signals
m_widget =
gtk_expander_new_with_mnemonic(wxGTK_CONV(GTKConvertMnemonics(label)));
+ g_object_ref(m_widget);
// see the gtk_collapsiblepane_expanded_callback comments to understand why
// we connect to the "notify::expanded" signal instead of the more common
m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
+ g_object_ref(m_widget);
+
if ( parentGTK )
{
gtk_window_set_transient_for(GTK_WINDOW(m_widget), parentGTK);
void wxComboBox::GTKCreateComboBoxWidget()
{
m_widget = gtk_combo_box_entry_new_text();
+ g_object_ref(m_widget);
m_entry = GTK_ENTRY(GTK_BIN(m_widget)->child);
}
m_insertCallback = wxInsertChildInDataViewCtrl;
m_widget = gtk_scrolled_window_new (NULL, NULL);
+ g_object_ref(m_widget);
GtkScrolledWindowSetBorder(m_widget, style);
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
+ g_object_ref(m_widget);
gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT);
gtkAction = GTK_FILE_CHOOSER_ACTION_SAVE;
m_widget = gtk_alignment_new ( 0, 0, 1, 1 );
+ g_object_ref(m_widget);
m_fcWidget = GTK_FILE_CHOOSER( gtk_file_chooser_widget_new(gtkAction) );
gtk_widget_show ( GTK_WIDGET( m_fcWidget ) );
gtk_container_add ( GTK_CONTAINER ( m_widget ), GTK_WIDGET( m_fcWidget ) );
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
ok_btn_stock, GTK_RESPONSE_ACCEPT,
NULL);
+ g_object_ref(m_widget);
GtkFileChooser* file_chooser = GTK_FILE_CHOOSER(m_widget);
m_fc.SetWidget(file_chooser);
}
}
+wxFileDialog::~wxFileDialog()
+{
+ if (m_extraControl)
+ {
+ // get chooser to drop its reference right now, allowing wxWindow dtor
+ // to verify that ref count drops to zero
+ gtk_file_chooser_set_extra_widget(
+ GTK_FILE_CHOOSER(m_widget), NULL);
+ }
+}
+
void wxFileDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event))
{
EndDialog(wxID_OK);
// NOTE: we deliberately ignore the given label as GtkFileChooserButton
// use as label the currently selected file
m_widget = gtk_file_chooser_button_new_with_dialog( m_dialog->m_widget );
+ g_object_ref(m_widget);
gtk_widget_show(m_widget);
// we need to know when the dialog has been dismissed clicking OK...
wxFileButton::~wxFileButton()
{
- // GtkFileChooserButton will automatically destroy the
- // GtkFileChooserDialog associated with m_dialog.
- // Thus we have to set its m_widget to NULL to avoid
- // double destruction on same widget
- if (m_dialog)
- m_dialog->m_widget = NULL;
}
void wxFileButton::OnDialogOK(wxCommandEvent& ev)
// NOTE: we deliberately ignore the given label as GtkFileChooserButton
// use as label the currently selected file
m_widget = gtk_file_chooser_button_new_with_dialog( m_dialog->m_widget );
+ g_object_ref(m_widget);
gtk_widget_show(m_widget);
wxDirButton::~wxDirButton()
{
- // GtkFileChooserButton will automatically destroy the
- // GtkFileChooserDialog associated with m_dialog.
- // Thus we have to set its m_widget to NULL to avoid
- // double destruction on same widget
- if (m_dialog)
- m_dialog->m_widget = NULL;
}
void wxDirButton::SetPath(const wxString& str)
wxString m_message( _("Choose font") );
m_widget = gtk_font_selection_dialog_new( wxGTK_CONV( m_message ) );
+ g_object_ref(m_widget);
if (parent)
gtk_window_set_transient_for(GTK_WINDOW(m_widget),
}
m_widget = gtk_font_button_new();
+ g_object_ref(m_widget);
// set initial font
m_selectedFont = initial.IsOk() ? initial : *wxNORMAL_FONT;
m_rangeMax = range;
m_widget = gtk_progress_bar_new();
+ g_object_ref(m_widget);
if ( style & wxGA_VERTICAL )
{
gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget),
}
m_widget = gtk_link_button_new("asdfsaf asdfdsaf asdfdsa");
+ g_object_ref(m_widget);
gtk_widget_show(m_widget);
// alignment
//-----------------------------------------------------------------------------
extern "C" {
-static gint
+static gboolean
gtk_listbox_key_press_callback( GtkWidget *WXUNUSED(widget),
GdkEventKey *gdk_event,
wxListBox *listbox )
}
m_widget = gtk_scrolled_window_new( (GtkAdjustment*) NULL, (GtkAdjustment*) NULL );
+ g_object_ref(m_widget);
if (style & wxLB_ALWAYS_SB)
{
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
}
m_widget = gtk_notebook_new();
+ g_object_ref(m_widget);
g_signal_connect (m_widget, "switch_page",
G_CALLBACK (gtk_mdi_page_change_callback), parent);
ApplyWidgetStyle();
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
+ g_object_ref(m_widget);
+
for (size_t i = 0; i < n; ++i )
Append(menus[i], titles[i]);
}
#endif // GTK+ 2.6+
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
+ g_object_ref(m_widget);
+
if (m_caption != wxMessageBoxCaptionStr)
gtk_window_set_title(GTK_WINDOW(m_widget), wxGTK_CONV(m_caption));
gint result = gtk_dialog_run(GTK_DIALOG(m_widget));
gtk_widget_destroy(m_widget);
+ g_object_unref(m_widget);
m_widget = NULL;
switch (result)
m_widget = gtk_notebook_new();
+ g_object_ref(m_widget);
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
if ( !client )
return NULL;
- gtk_widget_ref( client->m_widget );
gtk_widget_unrealize( client->m_widget );
// we don't need to unparent the client->m_widget; GTK+ will do
_T("invalid page index in wxNotebookPage::InsertPage()") );
// Hack Alert! (Part II): See above in wxInsertChildInNotebook callback
- // why this has to be done. NOTE: using gtk_widget_unparent here does not
- // work as it seems to undo too much and will cause errors in the
- // gtk_notebook_insert_page below, so instead just clear the parent by
- // hand here.
- win->m_widget->parent = NULL;
+ // why this has to be done.
+ gtk_widget_unparent(win->m_widget);
if (m_themeEnabled)
win->SetThemeEnabled(true);
m_insertCallback = wxInsertChildInPopupWin;
m_widget = gtk_window_new( GTK_WINDOW_POPUP );
+ g_object_ref(m_widget);
if ((m_parent) && (GTK_IS_WINDOW(m_parent->m_widget)))
gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
}
m_widget = GTKCreateFrame(title);
+ g_object_ref(m_widget);
wxControl::SetLabel(title);
if ( HasFlag(wxNO_BORDER) )
{
}
m_widget = gtk_radio_button_new_with_label( radioButtonGroup, wxGTK_CONV( label ) );
+ g_object_ref(m_widget);
SetLabel(label);
m_widget = gtk_vscrollbar_new( (GtkAdjustment *) NULL );
else
m_widget = gtk_hscrollbar_new( (GtkAdjustment *) NULL );
+ g_object_ref(m_widget);
m_scrollBar[0] = (GtkRange*)m_widget;
m_widget = gtk_vscale_new( (GtkAdjustment *) NULL );
else
m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );
+ g_object_ref(m_widget);
gtk_scale_set_draw_value(GTK_SCALE (m_widget), (style & wxSL_LABELS) != 0);
// Keep full precision in position value
m_pos = 0;
m_widget = gtk_spin_button_new_with_range(0, 100, 1);
+ g_object_ref(m_widget);
gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
(int)(m_windowStyle & wxSP_WRAP) );
}
m_widget = gtk_spin_button_new_with_range(min, max, inc);
+ g_object_ref(m_widget);
gtk_spin_button_set_value( GTK_SPIN_BUTTON(m_widget), initial);
m_value = gtk_spin_button_get_value( GTK_SPIN_BUTTON(m_widget));
m_bitmap = bitmap;
m_widget = gtk_image_new();
+ g_object_ref(m_widget);
if (bitmap.Ok())
SetBitmap(bitmap);
}
m_widget = GTKCreateFrame(label);
+ g_object_ref(m_widget);
// only base SetLabel needs to be called after GTKCreateFrame
wxControl::SetLabel(label);
SetSize( new_size );
}
}
+ g_object_ref(m_widget);
m_parent->DoAddChild( this );
}
m_widget = gtk_label_new(NULL);
+ g_object_ref(m_widget);
GtkJustification justify;
if ( style & wxALIGN_CENTER_HORIZONTAL )
if (IsProtocolSupported())
{
m_widget = GTK_WIDGET(egg_tray_icon_new("systray icon"));
+ g_object_ref(m_widget);
gtk_window_set_resizable(GTK_WINDOW(m_widget), false);
wxLogTrace(_T("systray"), _T("using freedesktop.org systray spec"));
: 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();
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));
g_object_set (m_text, "has-frame", FALSE, NULL);
}
+ g_object_ref(m_widget);
m_parent->DoAddChild( this );
// Create the gtk widget.
m_widget = gtk_toggle_button_new();
+ g_object_ref(m_widget);
if (style & wxNO_BORDER)
gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
// Create the gtk widget.
m_widget = gtk_toggle_button_new_with_mnemonic("");
+ g_object_ref(m_widget);
SetLabel(label);
}
}
#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
+
+ g_object_ref(m_widget);
}
wxWindow *topParent = wxGetTopLevelParent(m_parent);
gtk_widget_show( m_wxwindow );
}
+ g_object_ref(m_widget);
if (m_parent)
m_parent->DoAddChild( this );
// delete before the widgets to avoid a crash on solaris
delete m_imData;
- if (m_wxwindow && (m_wxwindow != m_widget))
- {
- gtk_widget_destroy( m_wxwindow );
- m_wxwindow = (GtkWidget*) NULL;
- }
-
if (m_widget)
{
- gtk_widget_destroy( m_widget );
- m_widget = (GtkWidget*) NULL;
+ // Note that gtk_widget_destroy() does not destroy the widget, it just
+ // emits the "destroy" signal. The widget is not actually destroyed
+ // until its reference count drops to zero.
+ gtk_widget_destroy(m_widget);
+ // Release our reference, should be the last one
+ g_object_unref(m_widget);
+ m_widget = NULL;
}
+ m_wxwindow = NULL;
}
bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size )