2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2003-2012 Hiroyuki Yamamoto & The Claws Mail Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include <gdk/gdkkeysyms.h>
25 #include "manage_window.h"
27 static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
33 static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
39 static gboolean quote_colors_set_dialog_key_pressed(GtkWidget *widget,
43 if (event && event->keyval == GDK_KEY_Escape) {
47 } else if (event && event->keyval == GDK_KEY_Return) {
55 gint colorsel_select_color_rgb(gchar *title, gint rgbvalue)
58 GtkColorSelectionDialog *color_dialog;
59 GtkWidget *ok_button, *cancel_button;
62 color_dialog = GTK_COLOR_SELECTION_DIALOG(gtk_color_selection_dialog_new(title));
63 gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
64 gtk_window_set_resizable(GTK_WINDOW(color_dialog), FALSE);
65 manage_window_set_transient(GTK_WINDOW(color_dialog));
67 g_object_get(color_dialog,
68 "ok-button", &ok_button,
69 "cancel-button", &cancel_button,
72 g_signal_connect(G_OBJECT(ok_button),
74 G_CALLBACK(quote_colors_set_dialog_ok), &result);
75 g_signal_connect(G_OBJECT(cancel_button),
77 G_CALLBACK(quote_colors_set_dialog_cancel), &result);
78 g_signal_connect(G_OBJECT(color_dialog), "key_press_event",
79 G_CALLBACK(quote_colors_set_dialog_key_pressed), &result);
81 /* preselect the previous color in the color selection dialog */
82 gtkut_convert_int_to_gdk_color(rgbvalue, &color);
83 gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(
84 gtk_color_selection_dialog_get_color_selection(color_dialog)), &color);
86 gtk_widget_show(GTK_WIDGET(color_dialog));
90 gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(
91 gtk_color_selection_dialog_get_color_selection(color_dialog)), &color);
92 rgbvalue = gtkut_convert_gdk_color_to_int(&color);
95 gtk_widget_destroy(GTK_WIDGET(color_dialog));