static void
aspectswitch_toggled_cb (GtkWidget           *widget,
                         GParamSpec          *pspec,
			 CcWacomMappingPanel *self)
{
	GSettings *settings;

	settings = gsd_wacom_device_get_settings (self->priv->device);
	g_settings_set_boolean (settings,
				"keep-aspect",
				gtk_switch_get_active (GTK_SWITCH (widget)));
}
static void
list_devices (GList *devices)
{
	GList *l;

	for (l = devices; l ; l = l->next) {
		GsdWacomDevice *device;
		GsdWacomDeviceType type;
		char *loc;

		device = l->data;

		g_signal_connect (G_OBJECT (device), "notify::last-stylus",
				  G_CALLBACK (last_stylus_changed), NULL);

		g_print ("Device '%s' (type: %s)\n",
			 gsd_wacom_device_get_name (device),
			 gsd_wacom_device_type_to_string (gsd_wacom_device_get_device_type (device)));
		g_print ("\tReversible: %s\n", BOOL_AS_STR (gsd_wacom_device_reversible (device)));
		g_print ("\tScreen Tablet: %s\n", BOOL_AS_STR (gsd_wacom_device_is_screen_tablet (device)));
		g_print ("\tUnknown (fallback) device: %s\n", BOOL_AS_STR(gsd_wacom_device_is_fallback (device)));

		loc = get_loc (gsd_wacom_device_get_settings (device));
		g_print ("\tGeneric settings: %s\n", loc);
		g_free (loc);

		type = gsd_wacom_device_get_device_type (device);
		if (type == WACOM_TYPE_STYLUS ||
		    type == WACOM_TYPE_ERASER) {
			GList *styli, *j;
			GsdWacomStylus *current_stylus;

			g_object_get (device, "last-stylus", &current_stylus, NULL);

			styli = gsd_wacom_device_list_styli (device);
			for (j = styli; j; j = j->next) {
				GsdWacomStylus *stylus;

				stylus = j->data;
				print_stylus (stylus, current_stylus == stylus);
			}
			g_list_free (styli);
		}

		print_buttons (device);

		if (monitor_styli == FALSE)
			g_object_unref (device);
	}
	g_list_free (devices);
}
/* Update the display of available monitors based on the latest
 * information from RandR. At the moment the chooser is just a
 * a combobox crudely listing available outputs. The UI mockup
 * has something more akin to the Display panel, with the ability
 * to do rubber-band selection of multiple outputs (note: the
 * g-s-d backend can only handle a single output at the moment)
 */
static void
update_monitor_chooser (CcWacomMappingPanel *self)
{
	GtkListStore *store;
	GnomeRROutputInfo **outputs;
	GdkRectangle geom;
	GSettings *settings;
	gint monitor;
	gboolean single_mon;
	guint i;

	store = gtk_list_store_new (MONITOR_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_INT);
	gtk_combo_box_set_model (GTK_COMBO_BOX(self->priv->combobox), GTK_TREE_MODEL(store));

	if (self->priv->device == NULL) {
		set_combobox_sensitive (self, FALSE);
		g_object_unref (store);
		return;
	}

	settings = gsd_wacom_device_get_settings (self->priv->device);
	monitor = gsd_wacom_device_get_display_monitor (self->priv->device);
	single_mon = (monitor != GSD_WACOM_SET_ALL_MONITORS);

	g_signal_handlers_block_by_func (G_OBJECT (self->priv->checkbutton), checkbutton_toggled_cb, self);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(self->priv->checkbutton), single_mon);
	g_signal_handlers_unblock_by_func (G_OBJECT (self->priv->checkbutton), checkbutton_toggled_cb, self);

	g_signal_handlers_block_by_func (G_OBJECT (self->priv->aspectswitch), aspectswitch_toggled_cb, self);
	gtk_switch_set_active (GTK_SWITCH(self->priv->aspectswitch), g_settings_get_boolean (settings, "keep-aspect"));
	g_signal_handlers_unblock_by_func (G_OBJECT (self->priv->aspectswitch), aspectswitch_toggled_cb, self);

	/* FIXME: does this break screen tablets? What's the default
	 * for unconfigured tablets? */
	if (monitor < 0)
		monitor = 0;
	gdk_screen_get_monitor_geometry (gdk_screen_get_default (), monitor, &geom);

	outputs = get_rr_outputs ();
	if (outputs == NULL)
		goto bail;

	for (i = 0; outputs[i] != NULL; i++) {
		GnomeRROutputInfo *output = outputs[i];

		if (gnome_rr_output_info_is_active (output)) {
			GtkTreeIter iter;
			gchar *name, *disp_name, *text;
			int x, y, w, h;
			int mon_at_point;

			name = gnome_rr_output_info_get_name (output);
			disp_name = gnome_rr_output_info_get_display_name (output);
			text = g_strdup_printf ("%s (%s)", name, disp_name);

			gnome_rr_output_info_get_geometry (output, &x, &y, &w, &h);
			mon_at_point = gdk_screen_get_monitor_at_point (gdk_screen_get_default (), x, y);
			gtk_list_store_append (store, &iter);
			gtk_list_store_set (store, &iter, MONITOR_NAME_COLUMN, text, MONITOR_NUM_COLUMN, mon_at_point, -1);

			if (x == geom.x && y == geom.y && w == geom.width && h == geom.height) {
				g_signal_handlers_block_by_func (G_OBJECT (self->priv->combobox), combobox_changed_cb, self);
				gtk_combo_box_set_active_iter (GTK_COMBO_BOX(self->priv->combobox), &iter);
				g_signal_handlers_unblock_by_func (G_OBJECT (self->priv->combobox), combobox_changed_cb, self);
			}

			g_free (text);
		}
	}

bail:
	set_combobox_sensitive (self, single_mon);
	g_object_unref (store);
}