From: Jean-Philippe Orsini Date: Sun, 26 May 2013 17:59:26 +0000 (+0000) Subject: Switched to GtkColorChooserDialog instead of the deprecated widget GtkColorSelectionD... X-Git-Tag: v0.8.0.5~53 X-Git-Url: http://git.wpitchoune.net/gitweb/?p=psensor.git;a=commitdiff_plain;h=97831c4b309f58946df2a582b2ab466e65b2684f Switched to GtkColorChooserDialog instead of the deprecated widget GtkColorSelectionDialog. --- diff --git a/NEWS b/NEWS index 6ca1958..6d0a075 100644 --- 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 --- 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 diff --git a/README.html b/README.html index cfcd824..ef7fb23 100644 --- a/README.html +++ b/README.html @@ -503,7 +503,7 @@ library sensors4
  • -library gtk3 +library gtk3 >=3.4

  • @@ -670,7 +670,7 @@ have extracted the ATI ADL SDK. Other steps are indentical.


    diff --git a/po/Makefile.in b/po/Makefile.in index a45906f..4281278 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /usr +prefix = /tmp exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/src/ui_color.c b/src/ui_color.c index f34727e..cae61f0 100644 --- a/src/ui_color.c +++ b/src/ui_color.c @@ -20,31 +20,50 @@ #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)); diff --git a/src/ui_color.h b/src/ui_color.h index dba12d7..c73b2ed 100644 --- a/src/ui_color.h +++ b/src/ui_color.h @@ -22,10 +22,10 @@ #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 diff --git a/src/ui_sensorlist.c b/src/ui_sensorlist.c index f21a82e..1c3ffb1 100644 --- a/src/ui_sensorlist.c +++ b/src/ui_sensorlist.c @@ -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); }