[gnome-control-center] wacom: Remove custom boolean type
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] wacom: Remove custom boolean type
- Date: Tue, 10 Jan 2012 19:25:18 +0000 (UTC)
commit 8516b6a1f9bff4ac673ce91af6578fdf6373fea2
Author: Bastien Nocera <hadess hadess net>
Date: Tue Jan 10 18:33:26 2012 +0000
wacom: Remove custom boolean type
panels/wacom/calibrator/calibrator.c | 28 ++++++++++++++--------------
panels/wacom/calibrator/calibrator.h | 16 ++++++----------
panels/wacom/calibrator/gui_gtk.c | 34 +++++++++++++++++-----------------
panels/wacom/calibrator/gui_gtk.h | 12 ++++++------
panels/wacom/calibrator/main.c | 34 +++++++++++++++++-----------------
panels/wacom/calibrator/main.h | 8 ++++----
panels/wacom/cc-wacom-page.c | 2 +-
7 files changed, 65 insertions(+), 69 deletions(-)
---
diff --git a/panels/wacom/calibrator/calibrator.c b/panels/wacom/calibrator/calibrator.c
index 213d098..2d9f73f 100644
--- a/panels/wacom/calibrator/calibrator.c
+++ b/panels/wacom/calibrator/calibrator.c
@@ -35,7 +35,7 @@ reset (struct Calib *c)
}
/* add a click with the given coordinates */
-bool
+gboolean
add_click (struct Calib *c,
int x,
int y)
@@ -49,7 +49,7 @@ add_click (struct Calib *c,
if (abs(x - c->clicked_x[i]) <= c->threshold_doubleclick &&
abs(y - c->clicked_y[i]) <= c->threshold_doubleclick)
{
- return false;
+ return FALSE;
}
i--;
}
@@ -58,7 +58,7 @@ add_click (struct Calib *c,
/* Mis-click detection */
if (c->threshold_misclick > 0 && c->num_clicks > 0)
{
- bool misclick = true;
+ gboolean misclick = TRUE;
if (c->num_clicks == 1)
{
@@ -66,7 +66,7 @@ add_click (struct Calib *c,
if (along_axis(c, x,c->clicked_x[0],c->clicked_y[0]) ||
along_axis(c, y,c->clicked_x[0],c->clicked_y[0]))
{
- misclick = false;
+ misclick = FALSE;
}
}
else if (c->num_clicks == 2)
@@ -77,7 +77,7 @@ add_click (struct Calib *c,
(along_axis(c, x,c->clicked_x[0],c->clicked_y[0]) &&
along_axis(c, c->clicked_y[1],c->clicked_x[0],c->clicked_y[0])))
{
- misclick = false;
+ misclick = FALSE;
}
}
else if (c->num_clicks == 3)
@@ -88,14 +88,14 @@ add_click (struct Calib *c,
(along_axis(c, y,c->clicked_x[1],c->clicked_y[1]) &&
along_axis(c, x,c->clicked_x[2],c->clicked_y[2])))
{
- misclick = false;
+ misclick = FALSE;
}
}
if (misclick)
{
reset(c);
- return false;
+ return FALSE;
}
}
@@ -103,11 +103,11 @@ add_click (struct Calib *c,
c->clicked_y[c->num_clicks] = y;
c->num_clicks++;
- return true;
+ return TRUE;
}
/* check whether the coordinates are along the respective axis */
-bool
+gboolean
along_axis (struct Calib *c,
int xy,
int x0,
@@ -118,14 +118,14 @@ along_axis (struct Calib *c,
}
/* calculate and apply the calibration */
-bool
+gboolean
finish (struct Calib *c,
int width,
int height,
XYinfo *new_axys,
- bool *swap)
+ gboolean *swap)
{
- bool swap_xy;
+ gboolean swap_xy;
float scale_x;
float scale_y;
int delta_x;
@@ -133,7 +133,7 @@ finish (struct Calib *c,
XYinfo axys = {-1, -1, -1, -1};
if (c->num_clicks != 4)
- return false;
+ return FALSE;
/* Should x and y be swapped? */
swap_xy = (abs (c->clicked_x [UL] - c->clicked_x [UR]) < abs (c->clicked_y [UL] - c->clicked_y [UR]));
@@ -172,6 +172,6 @@ finish (struct Calib *c,
*new_axys = axys;
*swap = swap_xy;
- return true;
+ return TRUE;
}
diff --git a/panels/wacom/calibrator/calibrator.h b/panels/wacom/calibrator/calibrator.h
index 98bc71e..4924547 100644
--- a/panels/wacom/calibrator/calibrator.h
+++ b/panels/wacom/calibrator/calibrator.h
@@ -24,6 +24,8 @@
#ifndef _calibrator_h
#define _calibrator_h
+#include <glib.h>
+
/*
* Number of blocks. We partition the screen into 'num_blocks' x 'num_blocks'
* rectangles of equal size. We then ask the user to press points that are
@@ -70,12 +72,6 @@ typedef struct
int y_max;
} XYinfo;
-typedef enum
-{
- false = 0,
- true = 1
-} bool;
-
struct Calib
{
/* original axys values */
@@ -103,17 +99,17 @@ struct Calib
};
void reset (struct Calib *c);
-bool add_click (struct Calib *c,
+gboolean add_click (struct Calib *c,
int x,
int y);
-bool along_axis (struct Calib *c,
+gboolean along_axis (struct Calib *c,
int xy,
int x0,
int y0);
-bool finish (struct Calib *c,
+gboolean finish (struct Calib *c,
int width,
int height,
XYinfo *new_axys,
- bool *swap);
+ gboolean *swap);
#endif /* _calibrator_h */
diff --git a/panels/wacom/calibrator/gui_gtk.c b/panels/wacom/calibrator/gui_gtk.c
index dddf12a..b2b5aba 100644
--- a/panels/wacom/calibrator/gui_gtk.c
+++ b/panels/wacom/calibrator/gui_gtk.c
@@ -143,7 +143,7 @@ resize_display(struct CalibArea *calib_area)
}
}
-bool
+gboolean
on_expose_event(GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
@@ -160,7 +160,7 @@ on_expose_event(GtkWidget *widget,
draw(widget, cr, data);
cairo_restore(cr);
}
- return true;
+ return TRUE;
}
void
@@ -271,11 +271,11 @@ redraw(struct CalibArea *calib_area)
rect.y = 0;
rect.width = calib_area->display_width;
rect.height = calib_area->display_height;
- gdk_window_invalidate_rect(win, &rect, false);
+ gdk_window_invalidate_rect(win, &rect, FALSE);
}
}
-bool
+gboolean
on_timer_signal(struct CalibArea *calib_area)
{
GdkWindow *win;
@@ -286,7 +286,7 @@ on_timer_signal(struct CalibArea *calib_area)
{
if (parent)
gtk_widget_destroy(parent);
- return false;
+ return FALSE;
}
/* Update clock */
@@ -298,19 +298,19 @@ on_timer_signal(struct CalibArea *calib_area)
rect.y = calib_area->display_height/2 - clock_radius - clock_line_width;
rect.width = 2 * clock_radius + 1 + 2 * clock_line_width;
rect.height = 2 * clock_radius + 1 + 2 * clock_line_width;
- gdk_window_invalidate_rect(win, &rect, false);
+ gdk_window_invalidate_rect(win, &rect, FALSE);
}
- return true;
+ return TRUE;
}
-bool
+gboolean
on_button_press_event(GtkWidget *widget,
GdkEventButton *event,
gpointer data)
{
struct CalibArea *calib_area = (struct CalibArea*)data;
- bool success;
+ gboolean success;
/* Handle click */
calib_area->time_elapsed = 0;
@@ -327,13 +327,13 @@ on_button_press_event(GtkWidget *widget,
GtkWidget *parent = gtk_widget_get_parent(calib_area->drawing_area);
if (parent)
gtk_widget_destroy(parent);
- return true;
+ return TRUE;
}
/* Force a redraw */
redraw(calib_area);
- return true;
+ return TRUE;
}
void
@@ -343,7 +343,7 @@ draw_message(struct CalibArea *calib_area,
calib_area->message = msg;
}
-bool
+gboolean
on_key_press_event(GtkWidget *widget,
GdkEventKey *event,
gpointer data)
@@ -352,21 +352,21 @@ on_key_press_event(GtkWidget *widget,
GtkWidget *parent = gtk_widget_get_parent(calib_area->drawing_area);
if (parent)
gtk_widget_destroy(parent);
- return true;
+ return TRUE;
}
/**
* Creates the windows and other objects required to do calibration
* under GTK and then starts the main loop. When the main loop exits,
* the calibration will be calculated (if possible) and this function
- * will then return ('true' if successful, 'false' otherwise).
+ * will then return ('TRUE' if successful, 'FALSE' otherwise).
*/
-bool
+gboolean
run_gui(struct Calib *c,
XYinfo *new_axys,
- bool *swap)
+ gboolean *swap)
{
- bool success;
+ gboolean success;
struct CalibArea *calib_area = CalibrationArea_(c);
printf("Current calibration: %d, %d, %d, %d\n",
diff --git a/panels/wacom/calibrator/gui_gtk.h b/panels/wacom/calibrator/gui_gtk.h
index b376ff1..2547c88 100644
--- a/panels/wacom/calibrator/gui_gtk.h
+++ b/panels/wacom/calibrator/gui_gtk.h
@@ -45,24 +45,24 @@ void set_display_size (struct CalibArea *calib_area,
int width,
int height);
void resize_display (struct CalibArea *calib_area);
-bool on_expose_event (GtkWidget *widget,
+gboolean on_expose_event (GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
void draw (GtkWidget *widget,
cairo_t *cr,
gpointer data);
void redraw (struct CalibArea *calib_area);
-bool on_timer_signal (struct CalibArea *calib_area);
-bool on_button_press_event (GtkWidget *widget,
+gboolean on_timer_signal (struct CalibArea *calib_area);
+gboolean on_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer data);
void draw_message (struct CalibArea *calib_area,
const char *msg);
-bool on_key_press_event (GtkWidget *widget,
+gboolean on_key_press_event (GtkWidget *widget,
GdkEventKey *event,
gpointer data);
-bool run_gui (struct Calib *c,
+gboolean run_gui (struct Calib *c,
XYinfo *new_axys,
- bool *swap);
+ gboolean *swap);
#endif /* _gui_gtk_h */
diff --git a/panels/wacom/calibrator/main.c b/panels/wacom/calibrator/main.c
index 96d970e..69baa99 100644
--- a/panels/wacom/calibrator/main.c
+++ b/panels/wacom/calibrator/main.c
@@ -38,10 +38,10 @@
* retuns number of devices found,
* the data of the device is returned in the last 3 function parameters
*/
-int find_device(const char* pre_device, bool verbose, bool list_devices,
+int find_device(const char* pre_device, gboolean verbose, gboolean list_devices,
XID* device_id, const char** device_name, XYinfo* device_axys)
{
- bool pre_device_is_id = true;
+ gboolean pre_device_is_id = TRUE;
int found = 0;
Display* display = XOpenDisplay(NULL);
@@ -73,7 +73,7 @@ int find_device(const char* pre_device, bool verbose, bool list_devices,
int loop;
for (loop=0; loop<len; loop++) {
if (!isdigit(pre_device[loop])) {
- pre_device_is_id = false;
+ pre_device_is_id = FALSE;
break;
}
}
@@ -169,10 +169,10 @@ static void usage(char* cmd, unsigned thr_misclick)
struct Calib* main_common(int argc, char** argv)
{
- bool verbose = false;
- bool list_devices = false;
- bool fake = false;
- bool precalib = false;
+ gboolean verbose = FALSE;
+ gboolean list_devices = FALSE;
+ gboolean fake = FALSE;
+ gboolean precalib = FALSE;
XYinfo pre_axys = {-1, -1, -1, -1};
const char* pre_device = NULL;
const char* geometry = NULL;
@@ -194,12 +194,12 @@ struct Calib* main_common(int argc, char** argv)
/* Verbose output ? */
if (strcmp("-v", argv[i]) == 0 ||
strcmp("--verbose", argv[i]) == 0) {
- verbose = true;
+ verbose = TRUE;
} else
/* Just list devices ? */
if (strcmp("--list", argv[i]) == 0) {
- list_devices = true;
+ list_devices = TRUE;
} else
/* Select specific device ? */
@@ -215,7 +215,7 @@ struct Calib* main_common(int argc, char** argv)
/* Get pre-calibration ? */
if (strcmp("--precalib", argv[i]) == 0) {
- precalib = true;
+ precalib = TRUE;
if (argc > i+1)
pre_axys.x_min = atoi(argv[++i]);
if (argc > i+1)
@@ -245,7 +245,7 @@ struct Calib* main_common(int argc, char** argv)
/* Fake calibratable device ? */
if (strcmp("--fake", argv[i]) == 0) {
- fake = true;
+ fake = TRUE;
}
/* unknown option */
@@ -323,7 +323,7 @@ struct Calib* main_common(int argc, char** argv)
verbose, thr_misclick, thr_doubleclick, geometry);
}
-struct Calib* CalibratorXorgPrint(const char* const device_name0, const XYinfo *axys0, const bool verbose0, const int thr_misclick, const int thr_doubleclick, const char* geometry)
+struct Calib* CalibratorXorgPrint(const char* const device_name0, const XYinfo *axys0, const gboolean verbose0, const int thr_misclick, const int thr_doubleclick, const char* geometry)
{
struct Calib* c = (struct Calib*)calloc(1, sizeof(struct Calib));
c->old_axys = *axys0;
@@ -339,9 +339,9 @@ struct Calib* CalibratorXorgPrint(const char* const device_name0, const XYinfo *
return c;
}
-bool finish_data(struct Calib* c, const XYinfo new_axys, int swap_xy)
+gboolean finish_data(struct Calib* c, const XYinfo new_axys, int swap_xy)
{
- bool success = true;
+ gboolean success = TRUE;
/* we suppose the previous 'swap_xy' value was 0 */
/* (unfortunately there is no way to verify this (yet)) */
@@ -353,7 +353,7 @@ bool finish_data(struct Calib* c, const XYinfo new_axys, int swap_xy)
return success;
}
-bool output_xorgconfd(struct Calib* c, const XYinfo new_axys, int swap_xy, int new_swap_xy)
+gboolean output_xorgconfd(struct Calib* c, const XYinfo new_axys, int swap_xy, int new_swap_xy)
{
const char* sysfs_name = "!!Name_Of_TouchScreen!!";
@@ -370,14 +370,14 @@ bool output_xorgconfd(struct Calib* c, const XYinfo new_axys, int swap_xy, int n
printf(" Option \"SwapXY\" \"%d\" # unless it was already set to 1\n", new_swap_xy);
printf("EndSection\n");
- return true;
+ return TRUE;
}
int main(int argc, char** argv)
{
int success = 0;
XYinfo axys;
- bool swap_xy;
+ gboolean swap_xy;
struct Calib* calibrator = main_common(argc, argv);
diff --git a/panels/wacom/calibrator/main.h b/panels/wacom/calibrator/main.h
index 7819568..805d863 100644
--- a/panels/wacom/calibrator/main.h
+++ b/panels/wacom/calibrator/main.h
@@ -27,18 +27,18 @@
#include "calibrator.h"
-int find_device(const char*, bool, bool, XID*, const char**, XYinfo*);
+int find_device(const char*, gboolean, gboolean, XID*, const char**, XYinfo*);
static void usage(char* cmd, unsigned thr_misclick);
struct Calib* main_common(int argc, char** argv);
struct Calib* CalibratorXorgPrint(const char* const device_name, const XYinfo *axys,
- const bool verbose, const int thr_misclick, const int thr_doubleclick,
+ const gboolean verbose, const int thr_misclick, const int thr_doubleclick,
const char* geometry);
-bool finish_data(struct Calib*, const XYinfo new_axys, int swap_xy);
-bool output_xorgconfd(struct Calib*, const XYinfo new_axys, int swap_xy, int new_swap_xy);
+gboolean finish_data(struct Calib*, const XYinfo new_axys, int swap_xy);
+gboolean output_xorgconfd(struct Calib*, const XYinfo new_axys, int swap_xy, int new_swap_xy);
int main(int argc, char** argv);
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index d22b403..dbda6ea 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -160,7 +160,7 @@ run_calibration (gint *cal,
{
gboolean success = FALSE;
XYinfo axys;
- bool swap_xy;
+ gboolean swap_xy;
struct Calib calibrator;
if (ncal != 4)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]