static void list_devices (GList *devices) { GList *l; for (l = devices; l ; l = l->next) { CsdWacomDevice *device; CsdWacomDeviceType 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", csd_wacom_device_get_name (device), csd_wacom_device_type_to_string (csd_wacom_device_get_device_type (device))); g_print ("\tReversible: %s\n", BOOL_AS_STR (csd_wacom_device_reversible (device))); g_print ("\tScreen Tablet: %s\n", BOOL_AS_STR (csd_wacom_device_is_screen_tablet (device))); g_print ("\tIntegrated Device: %s\n", BOOL_AS_STR (csd_wacom_device_is_isd (device))); g_print ("\tUnknown (fallback) device: %s\n", BOOL_AS_STR(csd_wacom_device_is_fallback (device))); loc = get_loc (csd_wacom_device_get_settings (device)); g_print ("\tGeneric settings: %s\n", loc); g_free (loc); type = csd_wacom_device_get_device_type (device); if (type == WACOM_TYPE_STYLUS || type == WACOM_TYPE_ERASER) { GList *styli, *j; CsdWacomStylus *current_stylus; g_object_get (device, "last-stylus", ¤t_stylus, NULL); styli = csd_wacom_device_list_styli (device); for (j = styli; j; j = j->next) { CsdWacomStylus *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); }
static int get_layout_type (CsdWacomDevice *device) { int layout; if (csd_wacom_device_is_screen_tablet (device)) layout = LAYOUT_SCREEN; else if (csd_wacom_device_reversible (device)) layout = LAYOUT_REVERSIBLE; else layout = LAYOUT_NORMAL; return layout; }
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); }