@@ -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 );