X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_color.c;h=3f91aa99c0bbe8e59887bc112c2c57a9f785d1a2;hb=de58b641143d1fb9622fa4021c2dd1ab50149dee;hp=fa715a5a0e5ee1e7f1d1da41aaa87ecbecd8b724;hpb=609664bb77874990e10f8073e54bb7f1645c8d72;p=psensor.git diff --git a/src/ui_color.c b/src/ui_color.c index fa715a5..3f91aa9 100644 --- a/src/ui_color.c +++ b/src/ui_color.c @@ -1,52 +1,46 @@ /* - Copyright (C) 2010-2011 wpitchoune@gmail.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA -*/ - + * Copyright (C) 2010-2014 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ #include -#include "ui_color.h" +#include -int ui_change_color(const char *title, struct color *col) +/* + * UI to change a given color. + * + * Returns 1 if the color has been modified. + */ +bool ui_change_color(const char *title, GdkRGBA *color, GtkWindow *win) { - GdkColor color; - GtkColorSelection *colorsel; int res; - GtkColorSelectionDialog *colordlg; - - color.red = col->red; - color.green = col->green; - color.blue = col->blue; + GtkColorChooserDialog *colordlg; - colordlg = (GtkColorSelectionDialog *) - gtk_color_selection_dialog_new(title); + colordlg = GTK_COLOR_CHOOSER_DIALOG + (gtk_color_chooser_dialog_new(title, win)); - colorsel = GTK_COLOR_SELECTION(colordlg->colorsel); + gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(colordlg), 0); - gtk_color_selection_set_previous_color(colorsel, &color); - gtk_color_selection_set_current_color(colorsel, &color); + gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(colordlg), color); res = gtk_dialog_run(GTK_DIALOG(colordlg)); - if (res == GTK_RESPONSE_OK) { - gtk_color_selection_get_current_color(colorsel, &color); - - color_set(col, color.red, color.green, color.blue); - } + if (res == GTK_RESPONSE_OK) + gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(colordlg), color); gtk_widget_destroy(GTK_WIDGET(colordlg));