2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2003 Hiroyuki Yamamoto & The Sylpheed Claws 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 2 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include <gdk/gdkkeysyms.h>
24 #include "manage_window.h"
26 static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
32 static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
38 static gboolean quote_colors_set_dialog_key_pressed(GtkWidget *widget,
42 if (event && event->keyval == GDK_Escape) {
46 } else if (event && event->keyval == GDK_Return) {
54 gint colorsel_select_color_rgb(gchar *title, gint rgbvalue)
56 gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
57 GtkColorSelectionDialog *color_dialog;
60 color_dialog = GTK_COLOR_SELECTION_DIALOG(gtk_color_selection_dialog_new(title));
61 gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
62 gtk_window_set_resizable(GTK_WINDOW(color_dialog), FALSE);
63 manage_window_set_transient(GTK_WINDOW(color_dialog));
65 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
67 G_CALLBACK(quote_colors_set_dialog_ok), &result);
68 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
70 G_CALLBACK(quote_colors_set_dialog_cancel), &result);
71 g_signal_connect(G_OBJECT(color_dialog), "key_press_event",
72 G_CALLBACK(quote_colors_set_dialog_key_pressed), &result);
74 /* preselect the previous color in the color selection dialog */
75 color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
76 color[1] = (gdouble) ((rgbvalue & 0x00ff00) >> 8) / 255.0;
77 color[2] = (gdouble) (rgbvalue & 0x0000ff) / 255.0;
78 gtk_color_selection_set_color
79 (GTK_COLOR_SELECTION(color_dialog->colorsel), color);
81 gtk_widget_show(GTK_WIDGET(color_dialog));
85 gint red, green, blue, rgbvalue_new;
87 gtk_color_selection_get_color(GTK_COLOR_SELECTION(color_dialog->colorsel), color);
89 red = (gint) (color[0] * 255.0);
90 green = (gint) (color[1] * 255.0);
91 blue = (gint) (color[2] * 255.0);
92 rgbvalue_new = (gint) ((red * 0x10000) | (green * 0x100) | blue);
95 fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
96 fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
97 fprintf(stderr, "Color is %x\n", rgbvalue);
100 rgbvalue = rgbvalue_new;
103 gtk_widget_destroy(GTK_WIDGET(color_dialog));