Пример #1
0
UIVR::UIVR(VMDApp *vmdapp) : UIObject(vmdapp) {
  command_wanted(Command::TOOL_OFFSET);
  command_wanted(Command::TOOL_REP);
  command_wanted(Command::TOOL_ADD_DEVICE);
  command_wanted(Command::TOOL_DELETE_DEVICE);
  command_wanted(Command::TOOL_CALLBACK);

  tool_serialno = 0;

  tool_types.add_name("grab",     0); // grabbing/rotating molecule
  tool_types.add_name("rotate",   1); // rotating, constrained to sphere
  tool_types.add_name("joystick", 2); // relative positioning 
  tool_types.add_name("tug",      3); // apply IMD forces to molecule
  tool_types.add_name("pinch",    4); // apply IMD forces, but only tracker dir
  tool_types.add_name("spring",   5); // attach IMD springs
  tool_types.add_name("print",    6); // print tracker data

  update_device_lists();
  reset();
}
Пример #2
0
static FormatVolume*
write_partition_table(FormatDialog* dialog, FormatVolume* vol, const char* fs)
{
	FormatVolume* ret = NULL;
	char* drive_udi = g_strdup(libhal_drive_get_udi(vol->drive));

	/* Write out a new table */
	GError* err = NULL;

	/* FIXME: Somehow, we need to decide what kind of table to write */
	if(!write_partition_table_for_device(vol->drive, PART_TYPE_MSDOS, &err)) {
		show_error_dialog(dialog->toplevel, _("Error formatting disk"), err->message);
		g_error_free(err);
		goto out;
	}

	/* Set the partition type */
	int msdos_type = get_part_type_from_fs(fs);
	if( !set_partition_type(vol->drive, 0 /* Always first partition */, msdos_type) ) {
		show_error_dialog(dialog->toplevel, _("Error formatting disk"), _("Couldn't set partition type on drive"));
		goto out;
	}

	/* Find the partition attached to our drive */
	if(!update_device_lists(dialog))	goto out;
	GSList* iter; 
	for(iter = dialog->hal_volume_list; iter != NULL; iter = g_slist_next(iter)) {
		FormatVolume* vol = iter->data;
		if(!strcmp(vol->drive_udi, drive_udi))	break;
	}
	if(iter == NULL) {
		show_error_dialog(dialog->toplevel, _("Error formatting disk"), 
				_("Can't find new partition after formatting. Try again"));
		goto out;
	}

	ret = iter->data;

out:
	return ret;
}
Пример #3
0
static void
rebuild_volume_combo(FormatDialog* dialog)
{
	g_assert(dialog && dialog->volume_model);
	gboolean show_partitions = gtk_toggle_button_get_active(dialog->show_partitions);
	if( !update_device_lists(dialog) )
		return;

	/* Iterate through the volume list and build the tree model. If we're
	 * listing partitions, it's a bit trickier: first we add all the drives,
	 * and make a udi=>GtkTreeIter table. Then we use that table to add
	 * the partitions to the correct drives */
	GSList* treeiter_list = NULL, *device_list = dialog->hal_drive_list;
	GSList* iter;	gboolean not_empty = FALSE, can_format, listed_drives = FALSE;
	GHashTable* udi_table = g_hash_table_new(g_str_hash, g_str_equal);
	FormatVolume* current;
	GtkTreeIter* parent_treeiter, *current_treeiter;

	gtk_tree_store_clear(dialog->volume_model);
	while(device_list != NULL) {
		for(iter = device_list; iter != NULL; iter=iter->next) {
			current = iter->data;
			can_format = (current->volume || 
					!libhal_drive_uses_removable_media(current->drive) ||
					libhal_drive_is_media_detected(current->drive));

			if(!current->friendly_name || strlen(current->friendly_name) == 0)
				continue;

			/* Look up the correct parent in the table */
			parent_treeiter = NULL;
			if(current->drive_udi)
				parent_treeiter = g_hash_table_lookup(udi_table, current->drive_udi);
			
			/*
			if(parent_treeiter && !gtk_tree_store_iter_is_valid(dialog->volume_model, parent_treeiter)) {
				g_warning("Iter wasn't valid! 0x%p", parent_treeiter);
				parent_treeiter = NULL;
			} */

			treeiter_list = g_slist_prepend(treeiter_list, (current_treeiter = g_new0(GtkTreeIter, 1)) );

			gtk_tree_store_insert_with_values(dialog->volume_model, current_treeiter, parent_treeiter, 1000,
				DEV_COLUMN_UDI, current->udi, 
				DEV_COLUMN_NAME_MARKUP, current->friendly_name, 
				DEV_COLUMN_ICON, current->icon, 
				DEV_COLUMN_SENSITIVE, can_format, -1);

			g_hash_table_insert(udi_table, current->udi, current_treeiter);

			not_empty = TRUE;
		}

		device_list = NULL;
		if(!listed_drives && show_partitions) {
			listed_drives = TRUE;
			device_list = dialog->hal_volume_list;
		}
	}

	for(iter = treeiter_list; iter != NULL; iter = iter->next)
		g_free((GtkTreeIter*)iter->data);
	g_slist_free(treeiter_list);
	g_hash_table_destroy(udi_table);

	if(!not_empty) {
		gtk_tree_store_insert_with_values(dialog->volume_model, NULL, NULL, 0, 
				DEV_COLUMN_NAME_MARKUP, _("<i>No devices found</i>"), 
				DEV_COLUMN_SENSITIVE, FALSE, -1);
	}
}