]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/fontdlg.cpp
Fix crash in wxDC::GetMultiLineTextExtent() after last commit.
[wxWidgets.git] / src / gtk / fontdlg.cpp
index f6059b9e635c42468f3b978f1ac53f3bd4cc3d2d..ce8afcb7ad5dc5ea29868968ff039cd5825d6291 100644 (file)
@@ -32,8 +32,6 @@ extern "C" {
 static
 bool gtk_fontdialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
 {
-    // don't need to install idle handler, its done from "event" signal
-
 /*
     printf( "OnDelete from " );
     if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -55,9 +53,6 @@ extern "C" {
 static
 void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dialog )
 {
-    if (g_isIdle)
-        wxapp_install_idle_handler();
-
     GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget);
 
     wxGtkString fontname(gtk_font_selection_dialog_get_font_name(fontdlg));
@@ -65,7 +60,7 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial
 
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
     event.SetEventObject( dialog );
-    dialog->GetEventHandler()->ProcessEvent( event );
+    dialog->HandleWindowEvent( event );
 }
 }
 
@@ -77,12 +72,9 @@ extern "C" {
 static
 void gtk_fontdialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFontDialog *dialog )
 {
-    if (g_isIdle)
-        wxapp_install_idle_handler();
-
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
     event.SetEventObject( dialog );
-    dialog->GetEventHandler()->ProcessEvent( event );
+    dialog->HandleWindowEvent( event );
 }
 }
 
@@ -94,7 +86,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
 
 bool wxFontDialog::DoCreate(wxWindow *parent)
 {
-    m_needParent = false;
+    parent = GetParentForModalDialog(parent, 0);
 
     if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) ||
         !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE,
@@ -106,6 +98,7 @@ bool wxFontDialog::DoCreate(wxWindow *parent)
 
     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),
@@ -113,17 +106,17 @@ bool wxFontDialog::DoCreate(wxWindow *parent)
 
     GtkFontSelectionDialog *sel = GTK_FONT_SELECTION_DIALOG(m_widget);
 
-    g_signal_connect (sel->ok_button, "clicked",
+    g_signal_connect (gtk_font_selection_dialog_get_ok_button(sel), "clicked",
                       G_CALLBACK (gtk_fontdialog_ok_callback), this);
 
-    g_signal_connect (sel->cancel_button, "clicked",
+    g_signal_connect (gtk_font_selection_dialog_get_cancel_button(sel), "clicked",
                       G_CALLBACK (gtk_fontdialog_cancel_callback), this);
 
     g_signal_connect (m_widget, "delete_event",
                       G_CALLBACK (gtk_fontdialog_delete_callback), this);
 
     wxFont font = m_fontData.GetInitialFont();
-    if( font.Ok() )
+    if( font.IsOk() )
     {
         const wxNativeFontInfo *info = font.GetNativeFontInfo();
 
@@ -136,7 +129,7 @@ bool wxFontDialog::DoCreate(wxWindow *parent)
         else
         {
             // this is not supposed to happen!
-            wxFAIL_MSG(_T("font is ok but no native font info?"));
+            wxFAIL_MSG(wxT("font is ok but no native font info?"));
         }
     }
 
@@ -149,7 +142,7 @@ wxFontDialog::~wxFontDialog()
 
 void wxFontDialog::SetChosenFont(const char *fontname)
 {
-    m_fontData.SetChosenFont(wxFont( wxString::FromAscii(fontname) ));
+    m_fontData.SetChosenFont(wxFont( wxString::FromUTF8(fontname) ));
 }
 
 #endif // wxUSE_FONTDLG && !__WXGPE__