src/color.c: Port to GtkColorChooserDialog

This commit is contained in:
Javier Jardón 2015-03-22 06:30:57 +00:00
parent fba4f05582
commit e54c5db6aa

View File

@ -34,27 +34,21 @@ static void zenity_colorselection_dialog_response (GtkWidget *widget, int respon
void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
{ {
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *colorsel;
GtkWidget *button; GtkWidget *button;
GdkColor color; GdkRGBA color;
zen_data = data; zen_data = data;
dialog = gtk_color_selection_dialog_new (NULL); dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL);
g_signal_connect (G_OBJECT (dialog), "response", g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_colorselection_dialog_response), G_CALLBACK (zenity_colorselection_dialog_response),
color_data); color_data);
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog));
if (color_data->color) { if (color_data->color) {
if (gdk_color_parse (color_data->color, &color)) if (gdk_rgba_parse (&color, color_data->color)) {
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (colorsel), gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color);
&color); }
} }
if (data->ok_label) { if (data->ok_label) {
@ -72,8 +66,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
if (data->modal) if (data->modal)
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), g_object_set (dialog, "show-editor", !color_data->show_palette, NULL);
color_data->show_palette);
zenity_util_show_dialog (dialog, data->attach); zenity_util_show_dialog (dialog, data->attach);
@ -89,15 +82,13 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
static void static void
zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data) zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data)
{ {
GtkWidget *colorsel; GdkRGBA color;
GdkColor color;
switch (response) { switch (response) {
case GTK_RESPONSE_OK: case GTK_RESPONSE_OK:
zenity_util_exit_code_with_data(ZENITY_OK, zen_data); zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (widget)); gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color);
gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color); g_print ("%s\n", gdk_rgba_to_string (&color));
g_print ("%s\n", gdk_color_to_string (&color));
break; break;
case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_CANCEL: