updated copyright end date to 2016
[psensor.git] / src / ui_color.c
index 9010d59..3c77827 100644 (file)
@@ -1,52 +1,46 @@
 /*
-    Copyright (C) 2010-2011 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
-*/
-
+ * Copyright (C) 2010-2016 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 <gtk/gtk.h>
 
-#include "ui_color.h"
+#include <ui_color.h>
 
-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));