diff options
Diffstat (limited to 'src/color.c')
-rw-r--r-- | src/color.c | 75 |
1 files changed, 31 insertions, 44 deletions
diff --git a/src/color.c b/src/color.c index 9ef233e..d1f7c8e 100644 --- a/src/color.c +++ b/src/color.c @@ -1,19 +1,22 @@ +/* vim: colorcolumn=80 ts=4 sw=4 + */ /* * color.c * - * Copyright (C) 2010 Berislav Kovacki + * Copyright © 2010 Berislav Kovacki + * Copyright © 2021-2023 Logan Rathbone * * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public + * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Library General Public + * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. @@ -27,51 +30,34 @@ #include "zenity.h" #include <string.h> +/* TODO: port to GtkColorDialog */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + static ZenityData *zen_data; -static void zenity_colorselection_dialog_response ( - GtkWidget *widget, int response, gpointer data); +static void zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data); void -zenity_colorselection (ZenityData *data, ZenityColorData *color_data) { +zenity_colorselection (ZenityData *data, ZenityColorData *color_data) +{ GtkWidget *dialog; - GtkWidget *button; GdkRGBA color; zen_data = data; dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL); - g_signal_connect (G_OBJECT (dialog), - "response", - G_CALLBACK (zenity_colorselection_dialog_response), - color_data); + g_signal_connect (dialog, "response", G_CALLBACK (zenity_colorselection_dialog_response), color_data); - if (color_data->color) { - if (gdk_rgba_parse (&color, color_data->color)) { - gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color); - } + if (color_data->color && + gdk_rgba_parse (&color, color_data->color)) + { + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(dialog), &color); } - if (data->extra_label) { - gint i = 0; - while (data->extra_label[i] != NULL) { - gtk_dialog_add_button ( - GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - g_object_unref (G_OBJECT (button)); - } - - if (data->cancel_label) { - g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - g_object_unref (G_OBJECT (button)); + if (data->extra_label) + { + ZENITY_UTIL_ADD_EXTRA_LABELS (dialog) } if (data->modal) @@ -79,23 +65,23 @@ zenity_colorselection (ZenityData *data, ZenityColorData *color_data) { g_object_set (dialog, "show-editor", !color_data->show_palette, NULL); - zenity_util_show_dialog (dialog, data->attach); + zenity_util_show_dialog (dialog); if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } - - gtk_main (); + zenity_util_gapp_main (GTK_WINDOW(dialog)); } static void -zenity_colorselection_dialog_response ( - GtkWidget *widget, int response, gpointer data) { +zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data) +{ GdkRGBA color; - switch (response) { + switch (response) + { case GTK_RESPONSE_OK: zenity_util_exit_code_with_data (ZENITY_OK, zen_data); gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); @@ -108,11 +94,12 @@ zenity_colorselection_dialog_response ( default: if (zen_data->extra_label && - response < g_strv_length (zen_data->extra_label)) + response < (int)g_strv_length (zen_data->extra_label)) printf ("%s\n", zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } - - gtk_main_quit (); + zenity_util_gapp_quit (GTK_WINDOW(widget), zen_data); } + +G_GNUC_END_IGNORE_DEPRECATIONS |