X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b6dd7ed8d761b48e506762b7e4a4c9b9bf2d79b5..7f19ef40eb05ef30e63ce12d40071d35b1d5aaaf:/src/gtk/colordlg.cpp diff --git a/src/gtk/colordlg.cpp b/src/gtk/colordlg.cpp index 07623444a3..893311f989 100644 --- a/src/gtk/colordlg.cpp +++ b/src/gtk/colordlg.cpp @@ -30,6 +30,12 @@ #include #endif // wxUSE_LIBHILDON +#if wxUSE_LIBHILDON2 +extern "C" { + #include +} +#endif // wxUSE_LIBHILDON2 + IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data) @@ -48,19 +54,25 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) #if wxUSE_LIBHILDON m_widget = hildon_color_selector_new(parentGTK); -#else // !wxUSE_LIBHILDON +#elif wxUSE_LIBHILDON2 // !wxUSE_LIBHILDON + m_widget = hildon_color_chooser_dialog_new(); +#else // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 wxString title(_("Choose colour")); 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); } +#if !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 GtkColorSelection *sel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel); gtk_color_selection_set_has_palette(sel, true); +#endif // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 return true; } @@ -75,7 +87,7 @@ int wxColourDialog::ShowModal() switch (result) { default: - wxFAIL_MSG(_T("unexpected GtkColorSelectionDialog return code")); + wxFAIL_MSG(wxT("unexpected GtkColorSelectionDialog return code")); // fall through case GTK_RESPONSE_CANCEL: @@ -97,8 +109,20 @@ void wxColourDialog::ColourDataToDialog() #if wxUSE_LIBHILDON HildonColorSelector * const sel = HILDON_COLOR_SELECTOR(m_widget); - hildon_color_selector_set_color(sel, wx_const_cast(GdkColor *, col)); -#else // !wxUSE_LIBHILDON + hildon_color_selector_set_color(sel, const_cast(col)); +#elif wxUSE_LIBHILDON2 + GdkColor clr; + if (col) + clr = *col; + else { + clr.pixel = 0; + clr.red = 32768; + clr.green = 32768; + clr.blue = 32768; + } + + hildon_color_chooser_dialog_set_color((HildonColorChooserDialog *)m_widget, &clr); +#else // !wxUSE_LIBHILDON2/!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 GtkColorSelection *sel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel); @@ -123,7 +147,7 @@ void wxColourDialog::ColourDataToDialog() GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel)); g_object_set(settings, "gtk-color-palette", pal.c_str(), NULL); -#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON +#endif // wxUSE_LIBHILDON / wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 } void wxColourDialog::DialogToColourData() @@ -133,7 +157,25 @@ void wxColourDialog::DialogToColourData() const GdkColor * const clr = hildon_color_selector_get_color(sel); if ( clr ) m_data.SetColour(*clr); -#else // !wxUSE_LIBHILDON +#elif wxUSE_LIBHILDON2 // !wxUSE_LIBHILDON + const GdkColor * const + col = m_data.GetColour().Ok() ? m_data.GetColour().GetColor() : NULL; + + GdkColor clr; + if (col) + clr = *col; + else { + clr.pixel = 0; + clr.red = 32768; + clr.green = 32768; + clr.blue = 32768; + } + GdkColor new_color = clr; + hildon_color_chooser_dialog_get_color((HildonColorChooserDialog *)m_widget, &new_color); + + m_data.SetColour(new_color); +#else // !wxUSE_LIBHILDON2 + GtkColorSelection *sel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel); @@ -159,7 +201,7 @@ void wxColourDialog::DialogToColourData() } g_free(pal); -#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON +#endif // wxUSE_LIBHILDON / wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 } #endif // wxUSE_COLOURDLG