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.
23 #include "manage_window.h"
25 static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
31 static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
37 static gboolean quote_colors_set_dialog_key_pressed(GtkWidget *widget,
45 gint colorsel_select_color_rgb(gchar *title, gint rgbvalue)
47 gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
48 GtkColorSelectionDialog *color_dialog;
51 color_dialog = GTK_COLOR_SELECTION_DIALOG(gtk_color_selection_dialog_new(title));
52 gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
53 gtk_window_set_resizable(GTK_WINDOW(color_dialog), FALSE);
54 manage_window_set_transient(GTK_WINDOW(color_dialog));
56 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
58 G_CALLBACK(quote_colors_set_dialog_ok), &result);
59 g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
61 G_CALLBACK(quote_colors_set_dialog_cancel), &result);
62 g_signal_connect(G_OBJECT(color_dialog), "key_press_event",
63 G_CALLBACK(quote_colors_set_dialog_key_pressed), &result);
65 /* preselect the previous color in the color selection dialog */
66 color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
67 color[1] = (gdouble) ((rgbvalue & 0x00ff00) >> 8) / 255.0;
68 color[2] = (gdouble) (rgbvalue & 0x0000ff) / 255.0;
69 gtk_color_selection_set_color
70 (GTK_COLOR_SELECTION(color_dialog->colorsel), color);
72 gtk_widget_show(GTK_WIDGET(color_dialog));
76 gint red, green, blue, rgbvalue_new;
78 gtk_color_selection_get_color(GTK_COLOR_SELECTION(color_dialog->colorsel), color);
80 red = (gint) (color[0] * 255.0);
81 green = (gint) (color[1] * 255.0);
82 blue = (gint) (color[2] * 255.0);
83 rgbvalue_new = (gint) ((red * 0x10000) | (green * 0x100) | blue);
86 fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
87 fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
88 fprintf(stderr, "Color is %x\n", rgbvalue);
91 rgbvalue = rgbvalue_new;
94 gtk_widget_destroy(GTK_WIDGET(color_dialog));