static void stylus_changed (CsdWacomDevice *device, GParamSpec *pspec, CcWacomPage *page) { CsdWacomStylus *stylus; CcWacomPagePrivate *priv; int num_pages; guint i; priv = page->priv; g_object_get (G_OBJECT (device), "last-stylus", &stylus, NULL); if (stylus == NULL) return; num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook)); for (i = 0; i < num_pages; i++) { CsdWacomStylus *s; CcWacomStylusPage *spage; spage = CC_WACOM_STYLUS_PAGE (gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), i)); s = cc_wacom_stylus_page_get_stylus (spage); if (s == stylus) { gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i); return; } } g_warning ("Failed to find the page for stylus '%s'", csd_wacom_stylus_get_name (stylus)); }
static void print_stylus (CsdWacomStylus *stylus, gboolean is_current) { CsdWacomDevice *device; char *loc; device = csd_wacom_stylus_get_device (stylus); g_print ("\t%sStylus: '%s' (Type: %s, ID: 0x%x)\n", is_current ? "*** " : "", csd_wacom_stylus_get_name (stylus), stylus_type_to_string (csd_wacom_stylus_get_stylus_type (stylus)), csd_wacom_stylus_get_id (stylus)); loc = get_loc (csd_wacom_stylus_get_settings (stylus)); g_print ("\t\tSettings: %s\n", loc); g_free (loc); g_print ("\t\tIcon name: %s\n", csd_wacom_stylus_get_icon_name (stylus)); if (csd_wacom_device_get_device_type (device) == WACOM_TYPE_STYLUS) { int num_buttons; char *buttons; g_print ("\t\tHas Eraser: %s\n", BOOL_AS_STR(csd_wacom_stylus_get_has_eraser (stylus))); num_buttons = csd_wacom_stylus_get_num_buttons (stylus); if (num_buttons < 0) num_buttons = 2; if (num_buttons > 0) buttons = g_strdup_printf ("%d buttons", num_buttons); else buttons = g_strdup ("no button"); g_print ("\t\tButtons: %s\n", buttons); g_free (buttons); } }