Switched to GtkColorChooserDialog instead of the deprecated widget GtkColorSelectionD...
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sun, 26 May 2013 17:59:26 +0000 (17:59 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sun, 26 May 2013 17:59:26 +0000 (17:59 +0000)
NEWS
README
README.html
po/Makefile.in
src/ui_color.c
src/ui_color.h
src/ui_sensorlist.c

diff --git a/NEWS b/NEWS
index 6ca1958..6d0a075 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+* v0.8.0.3
+
+** Switched to GtkColorChooserDialog instead of the
+   deprecated widget GtkColorSelectionDialog.
+
 * v0.8.0.2
 
 ** GConf2/GTK/XEXT/X11 lib optional to allow psensor-server
diff --git a/README b/README
index 38c92dd..43123c8 100644 (file)
--- a/README
+++ b/README
@@ -113,7 +113,7 @@ The compilation of +psensor+ requires:
  * gcc (or llvm)
  * lm-sensors
  * library sensors4
- * library gtk3
+ * library gtk3 >=3.4
  * library gconf2
  * help2man 
  * asciidoc (optional, required to produce the html version of the
index cfcd824..ef7fb23 100644 (file)
@@ -503,7 +503,7 @@ library sensors4
 </li>\r
 <li>\r
 <p>\r
-library gtk3\r
+library gtk3 &gt;=3.4\r
 </p>\r
 </li>\r
 <li>\r
@@ -670,7 +670,7 @@ have extracted the ATI ADL SDK. Other steps are indentical.</p></div>
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Last updated 2013-05-19 10:52:03 CEST\r
+Last updated 2013-05-26 19:23:21 CEST\r
 </div>\r
 </div>\r
 </body>\r
index a45906f..4281278 100644 (file)
@@ -21,7 +21,7 @@ srcdir = .
 top_srcdir = ..
 
 
-prefix = /usr
+prefix = /tmp
 exec_prefix = ${prefix}
 datarootdir = ${prefix}/share
 datadir = ${datarootdir}
index f34727e..cae61f0 100644 (file)
 
 #include "ui_color.h"
 
-int ui_change_color(const char *title, struct color *col)
+int ui_change_color(const char *title, struct color *col, GtkWindow *win)
 {
-       GdkColor color;
-       GtkColorSelection *colorsel;
+       GdkRGBA color;
        int res;
-       GtkColorSelectionDialog *colordlg;
+       GtkColorChooserDialog *colordlg;
+       double r, g, b;
 
        color.red = col->red;
        color.green = col->green;
        color.blue = col->blue;
+       color.alpha = 1;
 
-       colordlg = GTK_COLOR_SELECTION_DIALOG
-               (gtk_color_selection_dialog_new(title));
+       colordlg = GTK_COLOR_CHOOSER_DIALOG
+               (gtk_color_chooser_dialog_new(title, win));
 
-       colorsel = GTK_COLOR_SELECTION
-               (gtk_color_selection_dialog_get_color_selection(colordlg));
+       gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(colordlg), 0);
 
-       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);
+               gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(colordlg), &color);
 
-               color_set(col, color.red, color.green, color.blue);
+               /* GdkRGBA defines rgb as double 0..1 but chooser returns
+                * values > 1 when selecting a custom undefined color.
+                * Not sure whether that's a gtk/gdk bug. */
+
+               if (color.red > 1)
+                       r = 1;
+               else
+                       r = color.red;
+
+               if (color.green > 1)
+                       g = 1;
+               else
+                       g = color.green;
+
+               if (color.blue > 1)
+                       b = 1;
+               else
+                       b = color.blue;
+
+               color_set(col, 65535*r, 65535*g, 65535*b);
        }
 
        gtk_widget_destroy(GTK_WIDGET(colordlg));
index dba12d7..c73b2ed 100644 (file)
 #include "color.h"
 
 /*
-  UI to change a given color.
-
-  Returns 1 if the color has been modified.
* UI to change a given color.
+ *
* Returns 1 if the color has been modified.
  */
-int ui_change_color(const char *title, struct color *col);
+int ui_change_color(const char *title, struct color *col, GtkWindow *win);
 
 #endif
index f21a82e..1c3ffb1 100644 (file)
@@ -243,7 +243,8 @@ static int clicked_cbk(GtkWidget *widget, GdkEventButton *event, gpointer data)
 
                if (coli == COL_COLOR) {
                        if (ui_change_color(_("Select foreground color"),
-                                           s->color)) {
+                                           s->color,
+                                           GTK_WINDOW(ui->main_window))) {
                                ui_sensorlist_update(ui, 1);
                                config_set_sensor_color(s->id, s->color);
                        }