git.iko.soy/typeable/nixpkgs
on master help sign in
xsensors: init at 0.70
commit44594e851cc64e0e85c7d1d04042c00ba583d342 authorCharles Strahan <charles.c.strahan@gmail.com> dateFri 3 Jul 2015, 22:54 (11 years ago) parent4726690
4 files changed+231
pkgs/os-specific/linux/xsensors/default.nix+22 pkgs/os-specific/linux/xsensors/remove-unused-variables.patch+39 pkgs/os-specific/linux/xsensors/replace-deprecated-gtk.patch+168 pkgs/top-level/all-packages.nix+2
pkgs/os-specific/linux/xsensors/default.nixnew file+22
@@ -0,0 +1,22 @@
1+{ stdenv, lib, fetchurl, gtk2, pkgconfig, lm_sensors }:
2+
3+stdenv.mkDerivation rec {
4+ name = "xsensors-${version}";
5+ version = "0.70";
6+ src = fetchurl {
7+ url = "http://www.linuxhardware.org/xsensors/xsensors-${version}.tar.gz";
8+ sha256 = "1siplsfgvcxamyqf44h71jx6jdfmvhfm7mh0y1q8ps4zs6pj2zwh";
9+ };
10+ buildInputs = [
11+ gtk2 pkgconfig lm_sensors
12+ ];
13+ patches = [
14+ ./remove-unused-variables.patch
15+ ./replace-deprecated-gtk.patch
16+ ];
17+ meta = with lib; {
18+ license = licenses.gpl2;
19+ platforms = platforms.linux;
20+ maintainers = with maintainers; [ cstrahan ];
21+ };
22+}
pkgs/os-specific/linux/xsensors/remove-unused-variables.patchnew file+39
@@ -0,0 +1,39 @@
1+Author: Nanley Chery <nanleychery@gmail.com>
2+From: Jean Delvare <khali@linux-fr.org>
3+Subject: Remove declared, but unused variables
4+Bug-Debian: http://bugs.debian.org/625435
5+---
6+--- a/src/gui.c
7++++ b/src/gui.c
8+@@ -257,10 +257,9 @@
9+
10+ /* Start the sensor info update timer. */
11+ gint start_timer( GtkWidget *widget, gpointer data ) {
12+- gint timer;
13+
14+ /* Setup timer for updates. */
15+- timer = g_timeout_add( update_time * 1000,
16++ g_timeout_add( update_time * 1000,
17+ (GtkFunction) update_sensor_data,
18+ (gpointer) data );
19+
20+@@ -287,7 +286,7 @@
21+
22+ /* feature data */
23+ updates *head = NULL;
24+- updates *current = NULL, *prev = NULL;
25++ updates *current = NULL;
26+
27+ const sensors_feature *feature;
28+
29+@@ -347,10 +346,8 @@
30+ new_node->pbar = featpbar;
31+
32+ if ( head == NULL ) {
33+- prev = head;
34+ head = current = new_node;
35+ } else {
36+- prev = current;
37+ current = current->next = new_node;
38+ }
39+
pkgs/os-specific/linux/xsensors/replace-deprecated-gtk.patchnew file+168
@@ -0,0 +1,168 @@
1+Author: Nanley Chery <nanleychery@gmail.com>
2+Subject: Update deprecated gtk casts and replace deprecated function calls with their analogous cairo counterparts.
3+Bug-Debian: http://bugs.debian.org/622005
4+Bug-Debian: http://bugs.debian.org/610321
5+---
6+--- a/src/gui.c
7++++ b/src/gui.c
8+@@ -27,10 +27,10 @@
9+ GtkWidget *mainwindow = NULL;
10+
11+ GdkColor colorWhite = { 0, 0xFFFF, 0xFFFF, 0xFFFF };
12+-
13+-GdkColormap *cmap = NULL;
14+
15+-GdkPixmap *theme = NULL;
16++GdkPixbuf *theme = NULL;
17++
18++cairo_surface_t *surface = NULL;
19+
20+ /* Destroy the main window. */
21+ gint destroy_gui( GtkWidget *widget, gpointer data ) {
22+@@ -76,17 +76,16 @@
23+ }
24+ }
25+
26+-static void draw_digits( GtkWidget *widget, const gchar *digits, int highLow )
27++static void draw_digits( GtkWidget *widget, cairo_t *cr, const gchar *digits, int highLow )
28+ {
29+ const gchar *digit = digits;
30+ int pos = 0, x = 0, y = 0, w = 0;
31+
32+ while ( *digit ) {
33+ get_pm_location( *digit, &x, &y, &w );
34+- gdk_draw_drawable( widget->window,
35+- widget->style->fg_gc[ GTK_WIDGET_STATE
36+- (widget) ], theme, x, y + highLow,
37+- pos, 0, w, 30 );
38++ cairo_set_source_surface (cr, surface, pos-x, 0-(y + highLow));
39++ cairo_rectangle(cr, pos, 0, w, 30);
40++ cairo_fill(cr);
41+ pos += w;
42+ digit++;
43+ }
44+@@ -102,6 +101,8 @@
45+
46+ gchar result[7];
47+
48++ cairo_t *cr = gdk_cairo_create(widget->window);
49++
50+ #ifdef DEBUG_XSENSORS
51+ printf( "area.width = %d, area.height = %d\n", event->area.width,
52+ event->area.height );
53+@@ -117,13 +118,11 @@
54+
55+ /* Display the digits */
56+ if ( g_snprintf( result, 6, "%5.0f", current->curvalue ) >= 0 )
57+- draw_digits( widget, result, highLow );
58++ draw_digits( widget, cr, result, highLow );
59+
60+ /* Display RPM */
61+- gdk_draw_drawable( widget->window,
62+- widget->style->fg_gc[ GTK_WIDGET_STATE
63+- (widget) ], theme, 0, 120 + highLow,
64+- 90, 0, 57, 30 );
65++ cairo_set_source_surface (cr, surface, 90-0, 0-(120 + highLow));
66++ cairo_rectangle(cr, 90, 0, 57, 30);
67+ break;
68+ case TEMP:
69+ if ( current->curvalue > current->curmax )
70+@@ -134,17 +133,15 @@
71+
72+ /* Display the digits */
73+ if ( g_snprintf( result, 7, "%6.1f", current->curvalue ) >= 0 )
74+- draw_digits( widget, result, highLow );
75++ draw_digits( widget, cr, result, highLow );
76+
77+ /* Display degree symbol */
78+ if ( tf == FALSE )
79+ x = 0;
80+ else
81+ x = 57;
82+- gdk_draw_drawable( widget->window,
83+- widget->style->fg_gc[ GTK_WIDGET_STATE
84+- (widget) ], theme, x, 60 + highLow,
85+- 96, 0, 57, 30 );
86++ cairo_set_source_surface (cr, surface, 96-x, 0-(60 + highLow));
87++ cairo_rectangle(cr, 96, 0, 57, 30);
88+
89+ break;
90+ case VOLT:
91+@@ -154,20 +151,17 @@
92+
93+ /* Display the digits */
94+ if ( g_snprintf( result, 7, "%6.2f", current->curvalue ) >= 0 )
95+- draw_digits( widget, result, highLow );
96++ draw_digits( widget, cr, result, highLow );
97+
98+ /* Display V */
99+- gdk_draw_drawable( widget->window,
100+- widget->style->fg_gc[ GTK_WIDGET_STATE
101+- (widget) ], theme, 114, 60 + highLow,
102+- 96, 0, 57, 30 );
103+-
104+-
105++ cairo_set_source_surface (cr, surface, 96-114, 0-(60 + highLow));
106++ cairo_rectangle(cr, 96, 0, 57, 30);
107+ break;
108+ default:
109+ break;
110+ }
111+-
112++ cairo_fill(cr);
113++ cairo_destroy(cr);
114+ return TRUE;
115+ }
116+
117+@@ -260,7 +254,7 @@
118+
119+ /* Setup timer for updates. */
120+ g_timeout_add( update_time * 1000,
121+- (GtkFunction) update_sensor_data,
122++ (GSourceFunc) update_sensor_data,
123+ (gpointer) data );
124+
125+ return SUCCESS;
126+@@ -460,8 +454,6 @@
127+ g_signal_connect( G_OBJECT (mainwindow), "delete_event",
128+ G_CALLBACK (destroy_gui), NULL );
129+
130+- /* Graphics needed for drawing info. */
131+- cmap = gtk_widget_get_colormap( mainwindow );
132+
133+ /* Set up the image file used for displaying characters. */
134+ if ( imagefile == NULL ) {
135+@@ -481,12 +473,10 @@
136+ "Image file not found in either location! Exiting!\n" );
137+ exit( 1 );
138+ } else {
139+- theme = gdk_pixmap_colormap_create_from_xpm( NULL, cmap,
140+- NULL, NULL, "./images/default.xpm" );
141++ theme = gdk_pixbuf_new_from_file("./images/default.xpm", NULL );
142+ }
143+ } else {
144+- theme = gdk_pixmap_colormap_create_from_xpm( NULL, cmap,
145+- NULL, NULL, imagefile );
146++ theme = gdk_pixbuf_new_from_file(imagefile, NULL );
147+ }
148+ } else {
149+ if ( stat( imagefile, &sbuf ) != 0 ) {
150+@@ -495,11 +485,15 @@
151+ "Image file not found in specified location! Exiting!\n" );
152+ exit( 1 );
153+ } else {
154+- theme = gdk_pixmap_colormap_create_from_xpm( NULL, cmap,
155+- NULL, NULL, imagefile );
156++ theme = gdk_pixbuf_new_from_file(imagefile, NULL );
157+ }
158+ }
159+-
160++ surface = cairo_image_surface_create_for_data(gdk_pixbuf_get_pixels(theme),
161++ CAIRO_FORMAT_RGB24,
162++ gdk_pixbuf_get_width(theme),
163++ gdk_pixbuf_get_height(theme),
164++ gdk_pixbuf_get_rowstride(theme));
165++
166+ /* Create notebook for sensors. */
167+ notebook = gtk_notebook_new( );
168+ gtk_widget_modify_bg( notebook, GTK_STATE_NORMAL, &colorWhite );
pkgs/top-level/all-packages.nix+2
@@ -3319,6 +3319,8 @@ let
33193319
33203320 xsettingsd = callPackage ../tools/X11/xsettingsd { };
33213321
3322+ xsensors = callPackage ../os-specific/linux/xsensors { };
3323+
33223324 xcruiser = callPackage ../applications/misc/xcruiser { };
33233325
33243326 unarj = callPackage ../tools/archivers/unarj { };