コード例 #1
0
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);
}
コード例 #2
0
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);
}
コード例 #3
0
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);
	}
}