]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/colordlg.cpp
don't forward Enter presses to the default button if any of the ancestor windows...
[wxWidgets.git] / src / gtk / colordlg.cpp
index 448f347a386c1bfe7cf79e433b65b7644c6ff590..ccb80aadc14b43dca1f26ed07f82dfa3e3011982 100644 (file)
@@ -16,7 +16,7 @@
     #pragma hdrstop
 #endif
 
-#if wxUSE_COLOURDLG && defined(__WXGTK20__)
+#if wxUSE_COLOURDLG
 
 #include "wx/colordlg.h"
 
@@ -41,9 +41,13 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
     wxString title(_("Choose colour"));
     m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
 
-    if (parent)
+    m_parent = GetParentForModalDialog(parent);
+    if ( m_parent )
+    {
+        GtkWindow* gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(m_parent->m_widget) );
         gtk_window_set_transient_for(GTK_WINDOW(m_widget),
-                                     GTK_WINDOW(parent->m_widget));
+                                     gtk_parent);
+    }
 
     GtkColorSelection *sel =
         GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
@@ -101,12 +105,10 @@ void wxColourDialog::ColourDataToDialog()
         }
     }
 
-    gchar *pal = gtk_color_selection_palette_to_string(colors, n_colors);
+    wxGtkString pal(gtk_color_selection_palette_to_string(colors, n_colors));
 
     GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel));
-    g_object_set(settings, "gtk-color-palette", pal, NULL);
-
-    g_free(pal);
+    g_object_set(settings, "gtk-color-palette", pal.c_str(), NULL);
 }
 
 void wxColourDialog::DialogToColourData()
@@ -116,7 +118,7 @@ void wxColourDialog::DialogToColourData()
 
     GdkColor clr;
     gtk_color_selection_get_current_color(sel, &clr);
-    m_data.SetColour(wxColour(clr.red >> 8, clr.green >> 8, clr.blue >> 8));
+    m_data.SetColour(wxColour(clr));
 
     // Extract custom palette:
 
@@ -130,9 +132,7 @@ void wxColourDialog::DialogToColourData()
     {
         for (int i = 0; i < wxMin(n_colors, 16); i++)
         {
-            m_data.SetCustomColour(i, wxColour(colors[i].red >> 8,
-                                               colors[i].green >> 8,
-                                               colors[i].blue >> 8));
+            m_data.SetCustomColour(i, wxColour(colors[i]));
         }
         g_free(colors);
     }
@@ -140,5 +140,5 @@ void wxColourDialog::DialogToColourData()
     g_free(pal);
 }
 
-#endif // wxUSE_COLOURDLG && defined(__WXGTK20__)
+#endif // wxUSE_COLOURDLG