gboolean cc_wacom_page_update_tools (CcWacomPage *page, CsdWacomDevice *stylus, CsdWacomDevice *eraser, CsdWacomDevice *pad) { CcWacomPagePrivate *priv; int layout; gboolean changed; /* Type of layout */ layout = get_layout_type (stylus); priv = page->priv; changed = (priv->stylus != stylus || priv->eraser != eraser || priv->pad != pad); if (!changed) return FALSE; priv->stylus = stylus; priv->eraser = eraser; priv->pad = pad; update_tablet_ui (CC_WACOM_PAGE (page), layout); return TRUE; }
static void cc_wacom_page_dispose (GObject *object) { CcWacomPagePrivate *priv = CC_WACOM_PAGE (object)->priv; if (priv->area) { calib_area_free (priv->area); priv->area = NULL; } if (priv->button_map) { gtk_widget_destroy (priv->button_map); priv->button_map = NULL; } if (priv->dialog) { gtk_widget_destroy (priv->dialog); priv->dialog = NULL; } if (priv->builder) { g_object_unref (priv->builder); priv->builder = NULL; } priv->panel = NULL; G_OBJECT_CLASS (cc_wacom_page_parent_class)->dispose (object); }
static void add_page (GList *devices, GtkWidget *notebook) { GtkWidget *widget; GsdWacomDevice *stylus, *eraser, *pad; GList *l; if (devices == NULL) return; stylus = eraser = pad = NULL; for (l = devices; l ; l = l->next) { switch (gsd_wacom_device_get_device_type (l->data)) { case WACOM_TYPE_ERASER: eraser = l->data; break; case WACOM_TYPE_STYLUS: stylus = l->data; break; case WACOM_TYPE_PAD: pad = l->data; break; default: /* Nothing */ ; } } g_list_free (devices); widget = cc_wacom_page_new (NULL, stylus, eraser, pad); cc_wacom_page_set_navigation (CC_WACOM_PAGE (widget), GTK_NOTEBOOK (notebook), FALSE); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, NULL); gtk_widget_show (widget); }
static void set_left_handed_from_gsettings (CcWacomPage *page) { CcWacomPagePrivate *priv = CC_WACOM_PAGE(page)->priv; CsdWacomDevice *device = priv->stylus; CsdWacomRotation display_rotation; const gchar* rotation; display_rotation = csd_wacom_device_get_display_rotation (device); rotation = g_settings_get_string (priv->wacom_settings, "rotation"); if (strcmp (rotation, csd_wacom_device_rotation_type_to_name (display_rotation)) != 0) gtk_switch_set_active (GTK_SWITCH (WID ("switch-left-handed")), TRUE); }
static void left_handed_toggled_cb (GtkSwitch *sw, GParamSpec *pspec, gpointer *user_data) { CcWacomPagePrivate *priv = CC_WACOM_PAGE(user_data)->priv; CsdWacomDevice *device = priv->stylus; CsdWacomRotation display_rotation; const gchar* rotation; display_rotation = csd_wacom_device_get_display_rotation (device); rotation = csd_wacom_device_rotation_type_to_name (display_rotation); if (gtk_switch_get_active (sw)) rotation = opposite_rotation (rotation); g_settings_set_string (priv->wacom_settings, "rotation", rotation); }
static void tabletmode_changed_cb (GtkComboBox *combo, gpointer user_data) { CcWacomPagePrivate *priv = CC_WACOM_PAGE(user_data)->priv; GtkListStore *liststore; GtkTreeIter iter; gint mode; gboolean is_absolute; if (!gtk_combo_box_get_active_iter (combo, &iter)) return; liststore = GTK_LIST_STORE (WID ("liststore-tabletmode")); gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter, MODENUMBER_COLUMN, &mode, -1); is_absolute = (mode == MODE_ABSOLUTE); g_settings_set_boolean (priv->wacom_settings, "is-absolute", is_absolute); }
static void add_page (GList *devices, GtkWidget *notebook) { GtkWidget *widget; CcWacomDevice *stylus, *eraser, *pad; GList *l; if (devices == NULL) return; stylus = eraser = pad = NULL; for (l = devices; l ; l = l->next) { stylus = l->data; } g_list_free (devices); widget = cc_wacom_page_new (NULL, stylus, pad); cc_wacom_page_set_navigation (CC_WACOM_PAGE (widget), GTK_NOTEBOOK (notebook), FALSE); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, NULL); gtk_widget_show (widget); }
static void update_current_page (CcWacomPanel *self) { GHashTable *ht; GList *devices, *tablets, *l; gboolean changed; CcWacomPanelPrivate *priv; priv = self->priv; changed = FALSE; ht = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); devices = g_hash_table_get_values (priv->devices); for (l = devices; l; l = l->next) { Tablet *tablet; GsdWacomDevice *device; device = l->data; tablet = g_hash_table_lookup (ht, gsd_wacom_device_get_name (device)); if (tablet == NULL) { tablet = g_new0 (Tablet, 1); tablet->name = gsd_wacom_device_get_name (device); g_hash_table_insert (ht, (gpointer) tablet->name, tablet); } switch (gsd_wacom_device_get_device_type (device)) { case WACOM_TYPE_STYLUS: tablet->stylus = device; break; case WACOM_TYPE_ERASER: tablet->eraser = device; break; case WACOM_TYPE_PAD: tablet->pad = device; break; default: /* Nothing */ ; } } g_list_free (devices); /* We now have a list of Tablet structs, * see which ones are full tablets */ tablets = g_hash_table_get_values (ht); for (l = tablets; l; l = l->next) { Tablet *tablet; GtkWidget *page; tablet = l->data; if (tablet->stylus == NULL || tablet->eraser == NULL) { page = g_hash_table_lookup (priv->pages, tablet->name); if (page != NULL) { remove_page (GTK_NOTEBOOK (priv->notebook), page); g_hash_table_remove (priv->pages, tablet->name); changed = TRUE; } continue; } /* this code is called once the stylus + eraser were set up, but the pad does not exist yet */ page = g_hash_table_lookup (priv->pages, tablet->name); if (page == NULL) { page = cc_wacom_page_new (self, tablet->stylus, tablet->eraser, tablet->pad); cc_wacom_page_set_navigation (CC_WACOM_PAGE (page), GTK_NOTEBOOK (priv->notebook), TRUE); gtk_widget_show (page); gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page, NULL); g_hash_table_insert (priv->pages, g_strdup (tablet->name), page); changed = TRUE; } else { cc_wacom_page_update_tools (CC_WACOM_PAGE (page), tablet->stylus, tablet->eraser, tablet->pad); } } g_list_free (tablets); g_hash_table_destroy (ht); if (changed == TRUE) { int num_pages; num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook)); if (num_pages > 1) gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), WACOM_PAGE); } }