static void
print_buttons (CsdWacomDevice *device)
{
	GList *buttons, *l;

	buttons = csd_wacom_device_get_buttons (device);
	if (buttons == NULL)
		return;

	for (l = buttons; l != NULL; l = l->next) {
		CsdWacomTabletButton *button = l->data;

		g_print ("\tButton: %s (%s)\n", button->name, button->id);
		g_print ("\t\tType: %s\n", button_type_to_string (button->type));
		if (button->group_id > 0) {
			g_print ("\t\tGroup: %d", button->group_id);
			if (button->idx >= 0)
				g_print (" Index: %d\n", button->idx);
			else
				g_print ("\n");
		}
		if (button->settings) {
			char *loc;
			loc = get_loc (button->settings);
			g_print ("\t\tSettings: %s\n", loc);
			g_free (loc);
		}
	}
	g_list_free (buttons);
}
static void
setup_mapping_treeview (CcWacomPage *page)
{
	CcWacomPagePrivate *priv;
	GtkTreeView *treeview;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkListStore *model;
	GtkTreeIter iter;
	GList *list, *l;
	gint i;

	priv = page->priv;
	treeview = GTK_TREE_VIEW(MWID ("shortcut_treeview"));

	g_signal_connect (treeview, "button_press_event",
			  G_CALLBACK (start_editing_cb), page);
	g_signal_connect (treeview, "row-activated",
			  G_CALLBACK (start_editing_kb_cb), page);

	renderer = gtk_cell_renderer_text_new ();
	g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);

	column = gtk_tree_view_column_new_with_attributes (_("Button"),
							   renderer,
							   "text", MAPPING_DESCRIPTION_COLUMN,
							   NULL);
	gtk_tree_view_column_set_resizable (column, FALSE);
	gtk_tree_view_column_set_expand (column, TRUE);

	gtk_tree_view_append_column (treeview, column);
	gtk_tree_view_column_set_sort_column_id (column, MAPPING_DESCRIPTION_COLUMN);

	priv->action_store = gtk_list_store_new (ACTION_N_COLUMNS, G_TYPE_STRING, G_TYPE_INT);
	for (i = 0; i < G_N_ELEMENTS (action_table); i++) {
		/* Screen tablets cannot switch monitors (as the monitor is the tablet) */
		if (action_table[i].action_type == CSD_WACOM_ACTION_TYPE_SWITCH_MONITOR &&
		    csd_wacom_device_is_screen_tablet (priv->stylus))
			continue;

		/* Do not list on-screen help if libwacom do no provide a layout */
		if (action_table[i].action_type == CSD_WACOM_ACTION_TYPE_HELP &&
		    csd_wacom_device_get_layout_path (priv->stylus) == NULL)
			continue;

		gtk_list_store_append (priv->action_store, &iter);
		gtk_list_store_set (priv->action_store, &iter,
		                    ACTION_NAME_COLUMN, WACOM_C(action_table[i].action_name),
		                    ACTION_TYPE_COLUMN, action_table[i].action_type, -1);
	}
	renderer = gtk_cell_renderer_combo_new ();
	g_object_set (renderer,
                      "text-column", ACTION_NAME_COLUMN,
                      "has-entry", FALSE,
                      "model", priv->action_store,
                      "editable", TRUE,
                      NULL);
	g_signal_connect (renderer, "changed",
	                  G_CALLBACK (combo_action_cell_changed), page);

	column = gtk_tree_view_column_new_with_attributes (_("Type"),
							   renderer,
							   "text", MAPPING_TYPE_COLUMN,
							   NULL);
	gtk_tree_view_column_set_cell_data_func (column, renderer, action_set_func, NULL, NULL);
	gtk_tree_view_column_set_resizable (column, FALSE);
	gtk_tree_view_column_set_expand (column, FALSE);

	gtk_tree_view_append_column (treeview, column);

	renderer = (GtkCellRenderer *) g_object_new (GTK_TYPE_CELL_RENDERER_ACCEL,
						     "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_OTHER,
						     NULL);

	g_signal_connect (renderer, "accel_edited",
			  G_CALLBACK (accel_edited_callback),
			  page);
	g_signal_connect (renderer, "accel_cleared",
			  G_CALLBACK (accel_cleared_callback),
			  page);

	column = gtk_tree_view_column_new_with_attributes (_("Action"), renderer, NULL);
	gtk_tree_view_column_set_cell_data_func (column, renderer, accel_set_func, NULL, NULL);
	gtk_tree_view_column_set_resizable (column, FALSE);
	gtk_tree_view_column_set_expand (column, FALSE);

	gtk_tree_view_append_column (treeview, column);

	model = gtk_list_store_new (MAPPING_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INT);
	gtk_tree_view_set_model (treeview, GTK_TREE_MODEL (model));

	/* Fill it up! */
	list = csd_wacom_device_get_buttons (priv->pad);
	for (l = list; l != NULL; l = l->next) {
		CsdWacomTabletButton *button = l->data;
		CsdWacomActionType type = CSD_WACOM_ACTION_TYPE_NONE;

		if (button->settings)
			type = g_settings_get_enum (button->settings, ACTION_TYPE_KEY);

		if (button->type == WACOM_TABLET_BUTTON_TYPE_STRIP ||
		    button->type == WACOM_TABLET_BUTTON_TYPE_RING) {
			add_button_to_store (model, button, GTK_DIR_UP, CSD_WACOM_ACTION_TYPE_CUSTOM);
			add_button_to_store (model, button, GTK_DIR_DOWN, CSD_WACOM_ACTION_TYPE_CUSTOM);
		} else {
			add_button_to_store (model, button, 0, type);
		}
	}
	g_list_free (list);
	g_object_unref (model);
}